crowdin-api 1.5.0 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +9 -0
- data/.github/workflows/build-and-publish.yml +11 -7
- data/.github/workflows/dependency-analysis.yml +15 -0
- data/.github/workflows/docs.yml +12 -9
- data/.github/workflows/lint-pr-title.yml +18 -0
- data/.github/workflows/release.yml +29 -0
- data/.github/workflows/test-and-lint.yml +6 -3
- data/.gitignore +0 -1
- data/.release-it.json +31 -0
- data/.rubocop.yml +3 -0
- data/CONTRIBUTING.md +6 -1
- data/Gemfile.lock +109 -0
- data/README.md +10 -28
- data/crowdin-api.gemspec +1 -1
- data/lib/crowdin-api/api_resources/applications.rb +81 -0
- data/lib/crowdin-api/api_resources/bundles.rb +49 -0
- data/lib/crowdin-api/api_resources/glossaries.rb +16 -0
- data/lib/crowdin-api/api_resources/notifications.rb +53 -0
- data/lib/crowdin-api/api_resources/storages.rb +1 -1
- data/lib/crowdin-api/api_resources/string_translations.rb +16 -0
- data/lib/crowdin-api/api_resources/translation_memory.rb +16 -0
- data/lib/crowdin-api/client/version.rb +1 -1
- data/lib/crowdin-api.rb +2 -1
- data/spec/api_resources/applications_spec.rb +47 -0
- data/spec/api_resources/bundles_spec.rb +31 -0
- data/spec/api_resources/glossaries_spec.rb +170 -149
- data/spec/api_resources/notifications_spec.rb +64 -0
- data/spec/api_resources/string_translations_spec.rb +19 -0
- data/spec/api_resources/translation_memory_spec.rb +21 -0
- data/spec/unit/client_spec.rb +6 -0
- metadata +15 -5
@@ -0,0 +1,64 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe Crowdin::ApiResources::Notifications do
|
4
|
+
describe 'Default endpoints' do
|
5
|
+
describe '#send_notification_to_authenticated_user' do
|
6
|
+
it 'when request are valid', :default do
|
7
|
+
stub_request(:post, "https://api.crowdin.com/#{target_api_url}/notify")
|
8
|
+
.with(body: { 'message' => 'New notification message' })
|
9
|
+
query = { message: 'New notification message' }
|
10
|
+
response = @crowdin.send_notification_to_authenticated_user(query)
|
11
|
+
expect(response).to eq(200)
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'raises ArgumentError when request is missing required query parameter', :default do
|
15
|
+
expect do
|
16
|
+
@crowdin.send_notification_to_authenticated_user({})
|
17
|
+
end.to raise_error(ArgumentError, ':message is required')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#send_notifications_to_project_members' do
|
22
|
+
let(:project_id) { 1 }
|
23
|
+
|
24
|
+
it 'when request are valid', :default do
|
25
|
+
stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/notify")
|
26
|
+
.with(body: { 'message' => 'New notification message' })
|
27
|
+
query = { message: 'New notification message' }
|
28
|
+
response = @crowdin.send_notifications_to_project_members(query, project_id)
|
29
|
+
expect(response).to eq(200)
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'raises ArgumentError when request is missing required query parameter', :default do
|
33
|
+
expect do
|
34
|
+
@crowdin.send_notifications_to_project_members({}, project_id)
|
35
|
+
end.to raise_error(ArgumentError, ':message is required')
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'raises ArgumentError when request is missing project_id parameter', :default do
|
39
|
+
query = { message: 'New notification message' }
|
40
|
+
expect do
|
41
|
+
@crowdin.send_notifications_to_project_members(query, nil)
|
42
|
+
end.to raise_error(ArgumentError, ':project_id is required in parameters or while Client initialization')
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe 'Enterprise endpoints' do
|
48
|
+
describe '#send_notification_to_organization_members' do
|
49
|
+
it 'when request are valid', :enterprise do
|
50
|
+
stub_request(:post, "https://domain.api.crowdin.com/#{target_api_url}/notify")
|
51
|
+
.with(body: { 'message' => 'New notification message' })
|
52
|
+
query = { message: 'New notification message' }
|
53
|
+
response = @crowdin.send_notification_to_organization_members(query)
|
54
|
+
expect(response).to eq(200)
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'raises ArgumentError when request is missing required query parameter', :enterprise do
|
58
|
+
expect do
|
59
|
+
@crowdin.send_notification_to_organization_members({})
|
60
|
+
end.to raise_error(ArgumentError, ':message is required')
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -137,5 +137,24 @@ describe Crowdin::ApiResources::StringTranslations do
|
|
137
137
|
expect(cancel_vote).to eq(200)
|
138
138
|
end
|
139
139
|
end
|
140
|
+
|
141
|
+
describe '#add_translation_alignment' do
|
142
|
+
let(:project_id) { 1 }
|
143
|
+
|
144
|
+
it 'returns 200 when request is valid', :default do
|
145
|
+
query = { source_language_id: 'en', target_language_id: 'ar', text: 'Hello world!' }
|
146
|
+
stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/translations/alignment")
|
147
|
+
add_translation_alignment = @crowdin.add_translation_alignment(project_id, query)
|
148
|
+
expect(add_translation_alignment).to eq(200)
|
149
|
+
end
|
150
|
+
|
151
|
+
it 'raises ArgumentError when request is missing required query parameter', :default do
|
152
|
+
query = { source_language_id: 'en', target_language_id: 'ar' }
|
153
|
+
stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/translations/alignment")
|
154
|
+
expect do
|
155
|
+
@crowdin.add_translation_alignment(project_id, query)
|
156
|
+
end.to raise_error(ArgumentError, ':text is required')
|
157
|
+
end
|
158
|
+
end
|
140
159
|
end
|
141
160
|
end
|
@@ -110,5 +110,26 @@ describe Crowdin::ApiResources::TranslationMemory do
|
|
110
110
|
expect(check_tm_import_status).to eq(200)
|
111
111
|
end
|
112
112
|
end
|
113
|
+
|
114
|
+
describe '#search_tms_concordance' do
|
115
|
+
let(:project_id) { 1 }
|
116
|
+
|
117
|
+
it 'returns 200 when request is valid', :default do
|
118
|
+
query = { source_language_id: 'en', target_language_id: 'ar', expression: 'Hello world!',
|
119
|
+
auto_substitution: true, min_relevant: 60 }
|
120
|
+
stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/tms/concordance")
|
121
|
+
search_tms_concordance = @crowdin.search_tms_concordance(project_id, query)
|
122
|
+
expect(search_tms_concordance).to eq(200)
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'raises ArgumentError when request is missing required query parameter', :default do
|
126
|
+
query = { source_language_id: 'en', target_language_id: 'ar', expression: 'Hello world!',
|
127
|
+
auto_substitution: true }
|
128
|
+
stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/tms/concordance")
|
129
|
+
expect do
|
130
|
+
@crowdin.search_tms_concordance(project_id, query)
|
131
|
+
end.to raise_error(ArgumentError, ':min_relevant is required')
|
132
|
+
end
|
133
|
+
end
|
113
134
|
end
|
114
135
|
end
|
data/spec/unit/client_spec.rb
CHANGED
@@ -88,4 +88,10 @@ describe 'Crowdin Client' do
|
|
88
88
|
expect { @crowdin.fetch_all(:add_bundle).to raise_error(Crowdin::Errors::FetchAllProcessingError) }
|
89
89
|
end
|
90
90
|
end
|
91
|
+
|
92
|
+
describe 'Crowdin Client fetch_all' do
|
93
|
+
it 'should raise error if fetch_all is called for unsupported methods' do
|
94
|
+
expect { @crowdin.fetch_all(:export_bundle).to raise_error(Crowdin::Errors::FetchAllProcessingError) }
|
95
|
+
end
|
96
|
+
end
|
91
97
|
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.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Crowdin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: open-uri
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
version: 2.0.0
|
40
40
|
- - "<"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: 2.
|
42
|
+
version: 2.2.0
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -49,7 +49,7 @@ dependencies:
|
|
49
49
|
version: 2.0.0
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: 2.
|
52
|
+
version: 2.2.0
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
name: bundler
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -169,22 +169,29 @@ executables:
|
|
169
169
|
extensions: []
|
170
170
|
extra_rdoc_files: []
|
171
171
|
files:
|
172
|
+
- ".github/dependabot.yml"
|
172
173
|
- ".github/workflows/build-and-publish.yml"
|
174
|
+
- ".github/workflows/dependency-analysis.yml"
|
173
175
|
- ".github/workflows/docs.yml"
|
176
|
+
- ".github/workflows/lint-pr-title.yml"
|
177
|
+
- ".github/workflows/release.yml"
|
174
178
|
- ".github/workflows/test-and-lint.yml"
|
175
179
|
- ".gitignore"
|
180
|
+
- ".release-it.json"
|
176
181
|
- ".rspec"
|
177
182
|
- ".rubocop.yml"
|
178
183
|
- ".rubocop_todo.yml"
|
179
184
|
- CODE_OF_CONDUCT.md
|
180
185
|
- CONTRIBUTING.md
|
181
186
|
- Gemfile
|
187
|
+
- Gemfile.lock
|
182
188
|
- LICENSE
|
183
189
|
- README.md
|
184
190
|
- Rakefile
|
185
191
|
- bin/crowdin-console
|
186
192
|
- crowdin-api.gemspec
|
187
193
|
- lib/crowdin-api.rb
|
194
|
+
- lib/crowdin-api/api_resources/applications.rb
|
188
195
|
- lib/crowdin-api/api_resources/bundles.rb
|
189
196
|
- lib/crowdin-api/api_resources/dictionaries.rb
|
190
197
|
- lib/crowdin-api/api_resources/distributions.rb
|
@@ -192,6 +199,7 @@ files:
|
|
192
199
|
- lib/crowdin-api/api_resources/labels.rb
|
193
200
|
- lib/crowdin-api/api_resources/languages.rb
|
194
201
|
- lib/crowdin-api/api_resources/machine_translation_engines.rb
|
202
|
+
- lib/crowdin-api/api_resources/notifications.rb
|
195
203
|
- lib/crowdin-api/api_resources/projects.rb
|
196
204
|
- lib/crowdin-api/api_resources/reports.rb
|
197
205
|
- lib/crowdin-api/api_resources/screenshots.rb
|
@@ -217,6 +225,7 @@ files:
|
|
217
225
|
- lib/crowdin-api/core/fetch_all_extensions.rb
|
218
226
|
- lib/crowdin-api/core/request.rb
|
219
227
|
- lib/crowdin-api/core/send_request.rb
|
228
|
+
- spec/api_resources/applications_spec.rb
|
220
229
|
- spec/api_resources/bundles_spec.rb
|
221
230
|
- spec/api_resources/dictionaries_spec.rb
|
222
231
|
- spec/api_resources/distributions_spec.rb
|
@@ -224,6 +233,7 @@ files:
|
|
224
233
|
- spec/api_resources/labels_spec.rb
|
225
234
|
- spec/api_resources/languages_spec.rb
|
226
235
|
- spec/api_resources/machine_translation_engines_spec.rb
|
236
|
+
- spec/api_resources/notifications_spec.rb
|
227
237
|
- spec/api_resources/projects_spec.rb
|
228
238
|
- spec/api_resources/reports_spec.rb
|
229
239
|
- spec/api_resources/screenshots_spec.rb
|
@@ -262,7 +272,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
262
272
|
- !ruby/object:Gem::Version
|
263
273
|
version: '0'
|
264
274
|
requirements: []
|
265
|
-
rubygems_version: 3.
|
275
|
+
rubygems_version: 3.5.3
|
266
276
|
signing_key:
|
267
277
|
specification_version: 4
|
268
278
|
summary: Ruby Client for the Crowdin API
|