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 +4 -4
- data/Gemfile.lock +2 -2
- data/README.md +1 -1
- data/lib/crowdin-api/api_resources/labels.rb +31 -1
- data/lib/crowdin-api/api_resources/source_strings.rb +12 -0
- data/lib/crowdin-api/client/version.rb +1 -1
- data/spec/api_resources/labels_spec.rb +40 -8
- data/spec/api_resources/source_strings_spec.rb +13 -5
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22ed7c31fb89ca5299a07d1fe3c828f7686e36d74ad710dc5e1b115598f90fe7
|
4
|
+
data.tar.gz: fd8069c348ff758595bbc18a3f8684f6d220b1a53d00fac2fc0af0751b213087
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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
|
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
@@ -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
|
@@ -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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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
|
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.
|
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-
|
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.
|
289
|
+
rubygems_version: 3.5.9
|
290
290
|
signing_key:
|
291
291
|
specification_version: 4
|
292
292
|
summary: Ruby Client for the Crowdin API
|