Skip to content
Closed
21 changes: 21 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "rdbg",
"name": "Debug current file with rdbg",
"request": "launch",
"script": "${file}",
"args": [],
"askParameters": true
},
{
"type": "rdbg",
"name": "Attach with rdbg",
"request": "attach"
}
]
Comment thread
andrii-bodnar marked this conversation as resolved.
Outdated
}
2 changes: 1 addition & 1 deletion lib/crowdin-api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Crowdin
StringTranslations StringComments Screenshots Glossaries TranslationMemory
MachineTranslationEngines Reports Tasks Users Teams Vendors Webhooks
Dictionaries Distributions Labels TranslationStatus Bundles Notifications
Applications StringCorrections].freeze
Applications StringCorrections AI].freeze

# Error Raisers modules
ERROR_RAISERS_MODULES = %i[ApiErrorsRaiser ClientErrorsRaiser].freeze
Expand Down
20 changes: 20 additions & 0 deletions lib/crowdin-api/api_resources/ai.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# frozen_string_literal: true

module Crowdin
module ApiResources
module AI
# https://support.crowdin.com/developer/api/v2/#tag/AI/operation/api.users.ai.translate.strings.post
def ai_translate_strings(user_id = nil, query = {})
user_id || raise_parameter_is_required_error(:user_id)

request = Web::Request.new(
connection,
:post,
Comment thread
andrii-bodnar marked this conversation as resolved.
"#{config.target_api_url}/users/#{user_id}/ai/translations/translate-strings",
{ params: query }
)
Web::SendRequest.new(request).perform
end
end
end
end
15 changes: 15 additions & 0 deletions spec/api_resources/ai_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

describe Crowdin::ApiResources::AI do
describe 'Default endpoints' do
describe '#ai_translate_strings' do
let(:user_id) { 1 }

it 'when request are valid', :default do
stub_request(:post, "https://api.crowdin.com/#{target_api_url}/users/#{user_id}/ai/translations/translate-strings")
Comment thread
andrii-bodnar marked this conversation as resolved.
Outdated
ai_translate_strings = @crowdin.ai_translate_strings(user_id)
expect(ai_translate_strings).to eq(200)
end
end
end
end
Loading