Skip to content

Commit

Permalink
Implement project target language add end-point
Browse files Browse the repository at this point in the history
  • Loading branch information
İsmail Akbudak committed Mar 12, 2018
1 parent f5170e2 commit d952903
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
4 changes: 4 additions & 0 deletions examples/example.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,7 @@

# Post project statistics build
puts project.statistics_build(PROJECT_ID)

# Post add target language to project
puts project.add_language(PROJECT_ID, 'de')
puts project.add_language(PROJECT_ID, 'it')
4 changes: 3 additions & 1 deletion lib/smartcat_sdk/rest/base_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,10 @@ def connect_and_send(request, type: :json)

class Builder
# rubocop:disable Metrics/MethodLength
# rubocop:disable Metrics/AbcSize
def self.handle(type, response)
if response.is_a?(Net::HTTPClientError)
raise SmartcatSDK::REST::RequestError.new(response, response['code'])
raise SmartcatSDK::REST::RequestError.new(response.body, response.code)
end
if response.body && !response.body.empty?
builder_class = Builder.const_get(type.to_s.capitalize)
Expand All @@ -97,6 +98,7 @@ def self.handle(type, response)
end
end
# rubocop:enable Metrics/MethodLength
# rubocop:enable Metrics/AbcSize

class Body
def self.result(body)
Expand Down
7 changes: 7 additions & 0 deletions lib/smartcat_sdk/rest/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ def statistics(project_id)
def statistics_build(project_id)
prepare_request(:post, "#{@resource}/#{project_id}/statistics/build")
end

def add_language(project_id, target_language)
prepare_request(
:post,
"#{@resource}/language?projectId=#{project_id}&targetLanguage=#{target_language}"
)
end
end
end
end

0 comments on commit d952903

Please sign in to comment.