crowdin-api 1.10.0 → 1.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d44d26d0f12ba278e3199deda37ad21b26e1d977f36bb050e0b42bc98ded84bc
4
- data.tar.gz: e86837279bc7aa8a6cfdd7a87c0e09c7764c63a0b6ac072bb1ba72c820ab5970
3
+ metadata.gz: 22ed7c31fb89ca5299a07d1fe3c828f7686e36d74ad710dc5e1b115598f90fe7
4
+ data.tar.gz: fd8069c348ff758595bbc18a3f8684f6d220b1a53d00fac2fc0af0751b213087
5
5
  SHA512:
6
- metadata.gz: 6798c53e8405fbc05faa84d21aaac11a780e8d945b2ebde85872b18b706c320d83ec797ba762cca02f96b568fdc460361f469cdb00440bb8aa6db7a3768cbeb4
7
- data.tar.gz: 8c211132ea5389f49cb800d78a7cc5405663ee0cd1c12dda5a0bb687f7feb18fd34c29937f5de289c17d3f2cf5a72e86c2197c2b06c69c7fc1c7c0f1fc65279a
6
+ metadata.gz: 6014441ccc9d7c0a1e6a11e20611ee686cff396da2d596c12a1293d701f0395d5ff4adc730098301b4563f3167e5d7af54d15579e401578f822dadeb65066101
7
+ data.tar.gz: afa63e70a5616430e750429bb5b99e4d30e89ae92bbec440eb3fa2e5b7fbeb1319ff4c4947812ae8878597cd7850725f58018c094aa6d0ea2a02230b0ed8e799
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- crowdin-api (1.10.0)
4
+ crowdin-api (1.11.0)
5
5
  open-uri (>= 0.1.0, < 0.2.0)
6
6
  rest-client (>= 2.0.0, < 2.2.0)
7
7
 
@@ -39,7 +39,7 @@ GEM
39
39
  public_suffix (5.0.4)
40
40
  racc (1.7.3)
41
41
  rainbow (3.1.1)
42
- rake (13.1.0)
42
+ rake (13.2.1)
43
43
  regexp_parser (2.8.3)
44
44
  rest-client (2.1.0)
45
45
  http-accept (>= 1.7.0, < 2.0)
data/README.md CHANGED
@@ -35,7 +35,7 @@ Crowdin API is a full-featured RESTful API that helps you to integrate localizat
35
35
  Add this line to your application's Gemfile:
36
36
 
37
37
  ```gemfile
38
- gem 'crowdin-api', '~> 1.10.0'
38
+ gem 'crowdin-api', '~> 1.11.0'
39
39
  ```
40
40
 
41
41
  And then execute:
@@ -84,7 +84,37 @@ module Crowdin
84
84
  response = ::RestClient::Request.execute(
85
85
  {
86
86
  method: :delete,
87
- url: config.base_url + config.target_api_url + "/projects/#{project_id}/labels/#{label_id}",
87
+ url: config.base_url + config.target_api_url + "/projects/#{project_id}/labels/#{label_id}/strings",
88
+ payload: query.to_json
89
+ }.merge(@options)
90
+ )
91
+
92
+ response.body.empty? ? response.code : JSON.parse(response.body)
93
+ rescue StandardError => e
94
+ e.message
95
+ end
96
+
97
+ def assign_label_to_screenshots(label_id = nil, query = {}, project_id = config.project_id)
98
+ label_id || raise_parameter_is_required_error(:label_id)
99
+ project_id || raise_project_id_is_required_error
100
+
101
+ request = Web::Request.new(
102
+ connection,
103
+ :post,
104
+ "#{config.target_api_url}/projects/#{project_id}/labels/#{label_id}/screenshots",
105
+ { params: query }
106
+ )
107
+ Web::SendRequest.new(request).perform
108
+ end
109
+
110
+ def unassign_label_from_screenshots(label_id = nil, query = {}, project_id = config.project_id)
111
+ label_id || raise_parameter_is_required_error(:label_id)
112
+ project_id || raise_project_id_is_required_error
113
+
114
+ response = ::RestClient::Request.execute(
115
+ {
116
+ method: :delete,
117
+ url: config.base_url + config.target_api_url + "/projects/#{project_id}/labels/#{label_id}/screenshots",
88
118
  payload: query.to_json
89
119
  }.merge(@options)
90
120
  )
@@ -64,6 +64,18 @@ module Crowdin
64
64
  )
65
65
  Web::SendRequest.new(request).perform
66
66
  end
67
+
68
+ def string_batch_operations(query = {}, project_id = config.project_id)
69
+ project_id || raise_project_id_is_required_error
70
+
71
+ request = Web::Request.new(
72
+ connection,
73
+ :patch,
74
+ "#{config.target_api_url}/projects/#{project_id}/strings",
75
+ { params: query }
76
+ )
77
+ Web::SendRequest.new(request).perform
78
+ end
67
79
  end
68
80
  end
69
81
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Crowdin
4
4
  class Client
5
- VERSION = '1.10.0'
5
+ VERSION = '1.11.0'
6
6
  end
7
7
  end
@@ -3,7 +3,7 @@
3
3
  describe Crowdin::ApiResources::Labels do
4
4
  describe 'Default endpoints' do
5
5
  describe '#list_labels' do
6
- it 'when request are valid', :default do
6
+ it 'returns 200 when request is valid', :default do
7
7
  stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/labels")
8
8
  list_labels = @crowdin.list_labels({}, project_id)
9
9
  expect(list_labels).to eq(200)
@@ -11,7 +11,7 @@ describe Crowdin::ApiResources::Labels do
11
11
  end
12
12
 
13
13
  describe '#add_label' do
14
- it 'when request are valid', :default do
14
+ it 'returns 200 when request is valid', :default do
15
15
  stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/labels")
16
16
  add_label = @crowdin.add_label({}, project_id)
17
17
  expect(add_label).to eq(200)
@@ -21,7 +21,7 @@ describe Crowdin::ApiResources::Labels do
21
21
  describe '#get_label' do
22
22
  let(:label_id) { 1 }
23
23
 
24
- it 'when request are valid', :default do
24
+ it 'returns 200 when request is valid', :default do
25
25
  stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/labels/#{label_id}")
26
26
  get_label = @crowdin.get_label(label_id, project_id)
27
27
  expect(get_label).to eq(200)
@@ -31,7 +31,7 @@ describe Crowdin::ApiResources::Labels do
31
31
  describe '#delete_label' do
32
32
  let(:label_id) { 1 }
33
33
 
34
- it 'when request are valid', :default do
34
+ it 'returns 200 when request is valid', :default do
35
35
  stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/labels/#{label_id}")
36
36
  delete_label = @crowdin.delete_label(label_id, project_id)
37
37
  expect(delete_label).to eq(200)
@@ -41,7 +41,7 @@ describe Crowdin::ApiResources::Labels do
41
41
  describe '#edit_label' do
42
42
  let(:label_id) { 1 }
43
43
 
44
- it 'when request are valid', :default do
44
+ it 'returns 200 when request is valid', :default do
45
45
  stub_request(:patch, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/labels/#{label_id}")
46
46
  edit_label = @crowdin.edit_label(label_id, {}, project_id)
47
47
  expect(edit_label).to eq(200)
@@ -51,7 +51,7 @@ describe Crowdin::ApiResources::Labels do
51
51
  describe '#assign_label_to_strings' do
52
52
  let(:label_id) { 1 }
53
53
 
54
- it 'when request are valid', :default do
54
+ it 'returns 200 when request is valid', :default do
55
55
  stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/labels/#{label_id}/strings")
56
56
  assign_label_to_strings = @crowdin.assign_label_to_strings(label_id, {}, project_id)
57
57
  expect(assign_label_to_strings).to eq(200)
@@ -61,11 +61,43 @@ describe Crowdin::ApiResources::Labels do
61
61
  describe '#unassign_label_from_strings' do
62
62
  let(:label_id) { 1 }
63
63
 
64
- it 'when request are valid', :default do
65
- stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/labels/#{label_id}")
64
+ it 'returns 200 when request is valid', :default do
65
+ stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/labels/#{label_id}/strings")
66
66
  unassign_label_from_strings = @crowdin.unassign_label_from_strings(label_id, {}, project_id)
67
67
  expect(unassign_label_from_strings).to eq(200)
68
68
  end
69
+
70
+ it 'returns error message when request was processed with an error' do
71
+ allow(RestClient::Request).to receive(:execute).and_raise('Error')
72
+ unassign_label_from_strings = @crowdin.unassign_label_from_strings(label_id, {}, project_id)
73
+ expect(unassign_label_from_strings).to eq('Error')
74
+ end
75
+ end
76
+
77
+ describe '#assign_label_to_screenshots' do
78
+ let(:label_id) { 1 }
79
+
80
+ it 'returns 200 when request is valid', :default do
81
+ stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/labels/#{label_id}/screenshots")
82
+ assign_label_to_screenshots = @crowdin.assign_label_to_screenshots(label_id, {}, project_id)
83
+ expect(assign_label_to_screenshots).to eq(200)
84
+ end
85
+ end
86
+
87
+ describe '#unassign_label_from_screenshots' do
88
+ let(:label_id) { 1 }
89
+
90
+ it 'returns 200 when request is valid', :default do
91
+ stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/labels/#{label_id}/screenshots")
92
+ unassign_label_from_screenshots = @crowdin.unassign_label_from_screenshots(label_id, {}, project_id)
93
+ expect(unassign_label_from_screenshots).to eq(200)
94
+ end
95
+
96
+ it 'returns error message when request was processed with an error' do
97
+ allow(RestClient::Request).to receive(:execute).and_raise('Error')
98
+ unassign_label_from_screenshots = @crowdin.unassign_label_from_screenshots(label_id, {}, project_id)
99
+ expect(unassign_label_from_screenshots).to eq('Error')
100
+ end
69
101
  end
70
102
  end
71
103
  end
@@ -3,7 +3,7 @@
3
3
  describe Crowdin::ApiResources::SourceStrings do
4
4
  describe 'Default endpoints' do
5
5
  describe '#list_strings' do
6
- it 'when request are valid', :default do
6
+ it 'returns 200 when request is valid', :default do
7
7
  stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/strings")
8
8
  list_strings = @crowdin.list_strings({}, project_id)
9
9
  expect(list_strings).to eq(200)
@@ -11,7 +11,7 @@ describe Crowdin::ApiResources::SourceStrings do
11
11
  end
12
12
 
13
13
  describe '#add_string' do
14
- it 'when request are valid', :default do
14
+ it 'returns 200 when request is valid', :default do
15
15
  stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/strings")
16
16
  add_string = @crowdin.add_string({}, project_id)
17
17
  expect(add_string).to eq(200)
@@ -21,7 +21,7 @@ describe Crowdin::ApiResources::SourceStrings do
21
21
  describe '#get_string' do
22
22
  let(:string_id) { 1 }
23
23
 
24
- it 'when request are valid', :default do
24
+ it 'returns 200 when request is valid', :default do
25
25
  stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/strings/#{string_id}")
26
26
  get_string = @crowdin.get_string(string_id, {}, project_id)
27
27
  expect(get_string).to eq(200)
@@ -31,7 +31,7 @@ describe Crowdin::ApiResources::SourceStrings do
31
31
  describe '#delete_string' do
32
32
  let(:string_id) { 1 }
33
33
 
34
- it 'when request are valid', :default do
34
+ it 'returns 200 when request is valid', :default do
35
35
  stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/strings/#{string_id}")
36
36
  delete_string = @crowdin.delete_string(string_id, project_id)
37
37
  expect(delete_string).to eq(200)
@@ -41,11 +41,19 @@ describe Crowdin::ApiResources::SourceStrings do
41
41
  describe '#edit_string' do
42
42
  let(:string_id) { 1 }
43
43
 
44
- it 'when request are valid', :default do
44
+ it 'returns 200 when request is valid', :default do
45
45
  stub_request(:patch, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/strings/#{string_id}")
46
46
  edit_string = @crowdin.edit_string(string_id, {}, project_id)
47
47
  expect(edit_string).to eq(200)
48
48
  end
49
49
  end
50
+
51
+ describe '#string_batch_operations' do
52
+ it 'returns 200 when request is valid', :default do
53
+ stub_request(:patch, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/strings")
54
+ string_batch_operations = @crowdin.string_batch_operations({}, project_id)
55
+ expect(string_batch_operations).to eq(200)
56
+ end
57
+ end
50
58
  end
51
59
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crowdin-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.0
4
+ version: 1.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Crowdin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-17 00:00:00.000000000 Z
11
+ date: 2024-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: open-uri
@@ -286,7 +286,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
286
286
  - !ruby/object:Gem::Version
287
287
  version: '0'
288
288
  requirements: []
289
- rubygems_version: 3.5.3
289
+ rubygems_version: 3.5.9
290
290
  signing_key:
291
291
  specification_version: 4
292
292
  summary: Ruby Client for the Crowdin API