Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(SourceStrings): API updates #88

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/crowdin-api/api_resources/source_strings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
18 changes: 13 additions & 5 deletions spec/api_resources/source_strings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
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)
end
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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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