From e7db72edff371cff01c8d8e546221aad23233b4f Mon Sep 17 00:00:00 2001 From: Kirill Korbut Date: Tue, 30 Apr 2024 10:47:25 +0300 Subject: [PATCH] feat(SourceStrings): API updates --- .../api_resources/source_strings.rb | 12 ++++++++++++ spec/api_resources/source_strings_spec.rb | 18 +++++++++++++----- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/lib/crowdin-api/api_resources/source_strings.rb b/lib/crowdin-api/api_resources/source_strings.rb index 736132d..fc660cc 100644 --- a/lib/crowdin-api/api_resources/source_strings.rb +++ b/lib/crowdin-api/api_resources/source_strings.rb @@ -64,6 +64,18 @@ def edit_string(string_id = nil, query = {}, project_id = config.project_id) ) Web::SendRequest.new(request).perform end + + def string_batch_operations(query = {}, project_id = config.project_id) + project_id || raise_project_id_is_required_error + + request = Web::Request.new( + connection, + :patch, + "#{config.target_api_url}/projects/#{project_id}/strings", + { params: query } + ) + Web::SendRequest.new(request).perform + end end end end diff --git a/spec/api_resources/source_strings_spec.rb b/spec/api_resources/source_strings_spec.rb index 818ea1a..65b4985 100644 --- a/spec/api_resources/source_strings_spec.rb +++ b/spec/api_resources/source_strings_spec.rb @@ -3,7 +3,7 @@ describe Crowdin::ApiResources::SourceStrings do describe 'Default endpoints' do describe '#list_strings' do - it 'when request are valid', :default do + it 'returns 200 when request is valid', :default do stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/strings") list_strings = @crowdin.list_strings({}, project_id) expect(list_strings).to eq(200) @@ -11,7 +11,7 @@ end describe '#add_string' do - it 'when request are valid', :default do + it 'returns 200 when request is valid', :default do stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/strings") add_string = @crowdin.add_string({}, project_id) expect(add_string).to eq(200) @@ -21,7 +21,7 @@ describe '#get_string' do let(:string_id) { 1 } - it 'when request are valid', :default do + it 'returns 200 when request is valid', :default do stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/strings/#{string_id}") get_string = @crowdin.get_string(string_id, {}, project_id) expect(get_string).to eq(200) @@ -31,7 +31,7 @@ describe '#delete_string' do let(:string_id) { 1 } - it 'when request are valid', :default do + it 'returns 200 when request is valid', :default do stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/strings/#{string_id}") delete_string = @crowdin.delete_string(string_id, project_id) expect(delete_string).to eq(200) @@ -41,11 +41,19 @@ describe '#edit_string' do let(:string_id) { 1 } - it 'when request are valid', :default do + it 'returns 200 when request is valid', :default do stub_request(:patch, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/strings/#{string_id}") edit_string = @crowdin.edit_string(string_id, {}, project_id) expect(edit_string).to eq(200) end end + + describe '#string_batch_operations' do + it 'returns 200 when request is valid', :default do + stub_request(:patch, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/strings") + string_batch_operations = @crowdin.string_batch_operations({}, project_id) + expect(string_batch_operations).to eq(200) + end + end end end