crowdin-api 1.5.0 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/build-and-publish.yml +5 -2
- data/.github/workflows/docs.yml +4 -2
- data/.github/workflows/lint-pr-title.yml +18 -0
- data/.github/workflows/test-and-lint.yml +5 -2
- data/.rubocop.yml +3 -0
- data/CONTRIBUTING.md +4 -1
- data/README.md +3 -25
- 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/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/spec/api_resources/bundles_spec.rb +31 -0
- data/spec/api_resources/glossaries_spec.rb +170 -149
- 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 +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c30c686d6eb10b527235cfbb182aad55d47ad1a8a546b96a4215a60b1b2e29fd
|
4
|
+
data.tar.gz: cec244035e78c4abef7de5e44d845f4ccc306fd12a6b60e33762f26d88dca5f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73df7b0e5b4a5281d9894f45ca81bf77e4afa2404ea84c6b50c5a6a97d146b629d610d9131cb0962e4f4dfeccfaafd290e2b225271e40691d18c602d53872201
|
7
|
+
data.tar.gz: 388067874b3264c10e38eef41270416637b93a1b4affad5427e05f4fe246fc3f39377e5b25fb1e1f21d641dea6a3ba6165e75f9aeca0fd621028a0db09d07177
|
@@ -12,12 +12,15 @@ jobs:
|
|
12
12
|
packages: write
|
13
13
|
contents: read
|
14
14
|
steps:
|
15
|
-
- uses: actions/checkout@
|
15
|
+
- uses: actions/checkout@v3
|
16
|
+
|
16
17
|
- name: Set up Ruby 2.6
|
17
|
-
uses: ruby/setup-ruby@
|
18
|
+
uses: ruby/setup-ruby@v1
|
18
19
|
with:
|
19
20
|
ruby-version: 2.6
|
21
|
+
|
20
22
|
- run: bundle install
|
23
|
+
|
21
24
|
- name: Publish to RubyGems
|
22
25
|
run: |
|
23
26
|
mkdir -p $HOME/.gem
|
data/.github/workflows/docs.yml
CHANGED
@@ -9,11 +9,13 @@ jobs:
|
|
9
9
|
docs:
|
10
10
|
runs-on: ubuntu-latest
|
11
11
|
steps:
|
12
|
-
- uses: actions/checkout@
|
12
|
+
- uses: actions/checkout@v3
|
13
|
+
|
13
14
|
- name: Set up Ruby 2.6
|
14
|
-
uses: ruby/setup-ruby@
|
15
|
+
uses: ruby/setup-ruby@v1
|
15
16
|
with:
|
16
17
|
ruby-version: 2.6
|
18
|
+
|
17
19
|
- run: bundle install
|
18
20
|
|
19
21
|
- name: Cleanup the Readme
|
@@ -0,0 +1,18 @@
|
|
1
|
+
name: lint-pr-title
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request_target:
|
5
|
+
types:
|
6
|
+
- opened
|
7
|
+
- reopened
|
8
|
+
- edited
|
9
|
+
- synchronize
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
main:
|
13
|
+
runs-on: ubuntu-latest
|
14
|
+
|
15
|
+
steps:
|
16
|
+
- uses: amannn/action-semantic-pull-request@v5
|
17
|
+
env:
|
18
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
@@ -15,17 +15,20 @@ jobs:
|
|
15
15
|
ruby-version: [ '2.6', '2.7', '3.0' ]
|
16
16
|
steps:
|
17
17
|
- name: Checkout code
|
18
|
-
uses: actions/checkout@
|
18
|
+
uses: actions/checkout@v3
|
19
|
+
|
19
20
|
- name: Set up Ruby
|
20
21
|
uses: ruby/setup-ruby@v1
|
21
22
|
with:
|
22
23
|
ruby-version: ${{ matrix.ruby-version }}
|
23
24
|
bundler-cache: true
|
25
|
+
|
24
26
|
- name: Run tests and linter
|
25
27
|
run: |
|
26
28
|
bundle exec rubocop
|
27
29
|
bundle exec rake
|
30
|
+
|
28
31
|
- name: Publish code coverage report
|
29
|
-
uses: codecov/codecov-action@
|
32
|
+
uses: codecov/codecov-action@v3
|
30
33
|
with:
|
31
34
|
token: ${{ secrets.CODECOV_TOKEN }}
|
data/.rubocop.yml
CHANGED
data/CONTRIBUTING.md
CHANGED
@@ -59,12 +59,15 @@ Unsure where to begin contributing to Crowdin Ruby Client? You can start by look
|
|
59
59
|
|
60
60
|
Before sending your pull requests, make sure you followed the list below:
|
61
61
|
|
62
|
-
- Read
|
62
|
+
- Read these guidelines.
|
63
63
|
- Read [Code of Conduct](/CODE_OF_CONDUCT.md).
|
64
64
|
- Ensure that your code adheres to standard conventions, as used in the rest of the project.
|
65
65
|
- Ensure that there are unit tests for your code.
|
66
66
|
- Run unit tests.
|
67
67
|
|
68
|
+
> **Note**
|
69
|
+
> This project uses the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) specification for commit messages and PR titles.
|
70
|
+
|
68
71
|
#### Philosophy of code contribution
|
69
72
|
|
70
73
|
- Include unit tests when you contribute new features, as they help to a) prove that your code works correctly, and b) guard against future breaking changes to lower the maintenance cost.
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# Crowdin Ruby client
|
4
4
|
|
5
|
-
The Crowdin Ruby client is a lightweight interface to the Crowdin API
|
5
|
+
The Crowdin Ruby client is a lightweight interface to the Crowdin API. It provides common services for making API requests.
|
6
6
|
|
7
7
|
Crowdin API is a full-featured RESTful API that helps you to integrate localization into your development process. The endpoints that we use allow you to easily make calls to retrieve information and to execute actions needed.
|
8
8
|
|
@@ -23,18 +23,6 @@ Crowdin API is a full-featured RESTful API that helps you to integrate localizat
|
|
23
23
|
|
24
24
|
</div>
|
25
25
|
|
26
|
-
## Table of Contents
|
27
|
-
* [Requirements](#requirements)
|
28
|
-
* [Installation](#installation)
|
29
|
-
* [Quick Start](#quick-start)
|
30
|
-
* [Initialization](#initialization)
|
31
|
-
* [Usage](#usage)
|
32
|
-
* [Fetch all records](#fetch-all-records)
|
33
|
-
* [Command-Line Client](#command-line-client)
|
34
|
-
* [Seeking Assistance](#seeking-assistance)
|
35
|
-
* [Contributing](#contributing)
|
36
|
-
* [License](#license)
|
37
|
-
|
38
26
|
## Requirements
|
39
27
|
* Ruby >= 2.4
|
40
28
|
|
@@ -43,7 +31,7 @@ Crowdin API is a full-featured RESTful API that helps you to integrate localizat
|
|
43
31
|
Add this line to your application's Gemfile:
|
44
32
|
|
45
33
|
```gemfile
|
46
|
-
gem 'crowdin-api', '~> 1.
|
34
|
+
gem 'crowdin-api', '~> 1.6.0'
|
47
35
|
```
|
48
36
|
|
49
37
|
And then execute:
|
@@ -58,14 +46,6 @@ Or install it yourself as:
|
|
58
46
|
gem install crowdin-api
|
59
47
|
```
|
60
48
|
|
61
|
-
---
|
62
|
-
|
63
|
-
:bookmark_tabs: For versions *0.6.0* and lower see the [branch api/v1](https://github.com/crowdin/crowdin-api-client-ruby/tree/api/v1). Please note that these versions are no longer supported.
|
64
|
-
|
65
|
-
:exclamation: Migration from version *0.6.0* to *1.x.x* requires changes in your code.
|
66
|
-
|
67
|
-
---
|
68
|
-
|
69
49
|
## Quick start
|
70
50
|
|
71
51
|
### Initialization
|
@@ -201,11 +181,9 @@ When execute you'll have IRB console with configured *@crowdin* instance
|
|
201
181
|
|
202
182
|
If you find any problems or would like to suggest a feature, please read the [How can I contribute](/CONTRIBUTING.md#how-can-i-contribute) section in our contributing guidelines.
|
203
183
|
|
204
|
-
Need help working with Crowdin Ruby client or have any questions? [Contact](https://crowdin.com/contacts) Customer Success Service.
|
205
|
-
|
206
184
|
## Contributing
|
207
185
|
|
208
|
-
If you
|
186
|
+
If you would like to contribute please read the [Contributing](/CONTRIBUTING.md) guidelines.
|
209
187
|
|
210
188
|
## License
|
211
189
|
|
@@ -36,6 +36,55 @@ module Crowdin
|
|
36
36
|
Web::SendRequest.new(request).perform
|
37
37
|
end
|
38
38
|
|
39
|
+
# @param bundle_id [Integer] Bundle ID
|
40
|
+
# * {https://developer.crowdin.com/api/v2/#operation/api.projects.bundles.exports.post API Documentation}
|
41
|
+
# * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.bundles.exports.post Enterprise API Documentation}
|
42
|
+
def export_bundle(bundle_id, project_id = config.project_id)
|
43
|
+
bundle_id || raise_parameter_is_required_error(:bundle_id)
|
44
|
+
project_id || raise_project_id_is_required_error
|
45
|
+
|
46
|
+
request = Web::Request.new(
|
47
|
+
connection,
|
48
|
+
:post,
|
49
|
+
"#{config.target_api_url}/projects/#{project_id}/bundles/#{bundle_id}/exports"
|
50
|
+
)
|
51
|
+
Web::SendRequest.new(request).perform
|
52
|
+
end
|
53
|
+
|
54
|
+
# @param bundle_id [Integer] Bundle ID
|
55
|
+
# @param export_id [String] Export ID
|
56
|
+
# * {https://developer.crowdin.com/api/v2/#operation/api.projects.bundles.exports.get API Documentation}
|
57
|
+
# * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.bundles.exports.get Enterprise API Documentation}
|
58
|
+
def check_bundle_export_status(bundle_id, export_id, project_id = config.project_id)
|
59
|
+
bundle_id || raise_parameter_is_required_error(:bundle_id)
|
60
|
+
export_id || raise_parameter_is_required_error(:export_id)
|
61
|
+
project_id || raise_project_id_is_required_error
|
62
|
+
|
63
|
+
request = Web::Request.new(
|
64
|
+
connection,
|
65
|
+
:get,
|
66
|
+
"#{config.target_api_url}/projects/#{project_id}/bundles/#{bundle_id}/exports/#{export_id}"
|
67
|
+
)
|
68
|
+
Web::SendRequest.new(request).perform
|
69
|
+
end
|
70
|
+
|
71
|
+
# @param bundle_id [Integer] Bundle ID
|
72
|
+
# @param export_id [String] Export ID
|
73
|
+
# * {https://developer.crowdin.com/api/v2/#operation/api.projects.bundles.exports.download.get API Documentation}
|
74
|
+
# * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.bundles.exports.download.get Enterprise API Documentation}
|
75
|
+
def download_bundle(bundle_id, export_id, project_id = config.project_id)
|
76
|
+
bundle_id || raise_parameter_is_required_error(:bundle_id)
|
77
|
+
export_id || raise_parameter_is_required_error(:export_id)
|
78
|
+
project_id || raise_project_id_is_required_error
|
79
|
+
|
80
|
+
request = Web::Request.new(
|
81
|
+
connection,
|
82
|
+
:get,
|
83
|
+
"#{config.target_api_url}/projects/#{project_id}/bundles/#{bundle_id}/exports/#{export_id}/download"
|
84
|
+
)
|
85
|
+
Web::SendRequest.new(request).perform
|
86
|
+
end
|
87
|
+
|
39
88
|
# @param bundle_id [Integer] Bundle ID
|
40
89
|
# * {https://developer.crowdin.com/api/v2/#operation/api.projects.bundles.get API Documentation}
|
41
90
|
# * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.bundles.get Enterprise API Documentation}
|
@@ -243,6 +243,22 @@ module Crowdin
|
|
243
243
|
)
|
244
244
|
Web::SendRequest.new(request).perform
|
245
245
|
end
|
246
|
+
|
247
|
+
def search_glossaries_concordance(project_id = nil, query = {})
|
248
|
+
project_id || raise_project_id_is_required_error
|
249
|
+
|
250
|
+
%i[source_language_id target_language_id expression].each do |param|
|
251
|
+
query[param] || raise_parameter_is_required_error(param)
|
252
|
+
end
|
253
|
+
|
254
|
+
request = Web::Request.new(
|
255
|
+
connection,
|
256
|
+
:post,
|
257
|
+
"#{config.target_api_url}/projects/#{project_id}/glossaries/concordance",
|
258
|
+
{ params: query }
|
259
|
+
)
|
260
|
+
Web::SendRequest.new(request).perform
|
261
|
+
end
|
246
262
|
end
|
247
263
|
end
|
248
264
|
end
|
@@ -188,6 +188,22 @@ module Crowdin
|
|
188
188
|
)
|
189
189
|
Web::SendRequest.new(request).perform
|
190
190
|
end
|
191
|
+
|
192
|
+
def add_translation_alignment(project_id = nil, query = {})
|
193
|
+
project_id || raise_project_id_is_required_error
|
194
|
+
|
195
|
+
%i[source_language_id target_language_id text].each do |param|
|
196
|
+
query[param] || raise_parameter_is_required_error(param)
|
197
|
+
end
|
198
|
+
|
199
|
+
request = Web::Request.new(
|
200
|
+
connection,
|
201
|
+
:post,
|
202
|
+
"#{config.target_api_url}/projects/#{project_id}/translations/alignment",
|
203
|
+
{ params: query }
|
204
|
+
)
|
205
|
+
Web::SendRequest.new(request).perform
|
206
|
+
end
|
191
207
|
end
|
192
208
|
end
|
193
209
|
end
|
@@ -126,6 +126,22 @@ module Crowdin
|
|
126
126
|
)
|
127
127
|
Web::SendRequest.new(request).perform
|
128
128
|
end
|
129
|
+
|
130
|
+
def search_tms_concordance(project_id = nil, query = {})
|
131
|
+
project_id || raise_project_id_is_required_error
|
132
|
+
|
133
|
+
%i[source_language_id target_language_id expression auto_substitution min_relevant].each do |param|
|
134
|
+
query[param] || raise_parameter_is_required_error(param)
|
135
|
+
end
|
136
|
+
|
137
|
+
request = Web::Request.new(
|
138
|
+
connection,
|
139
|
+
:post,
|
140
|
+
"#{config.target_api_url}/projects/#{project_id}/tms/concordance",
|
141
|
+
{ params: query }
|
142
|
+
)
|
143
|
+
Web::SendRequest.new(request).perform
|
144
|
+
end
|
129
145
|
end
|
130
146
|
end
|
131
147
|
end
|
@@ -18,6 +18,37 @@ describe Crowdin::ApiResources::Bundles do
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
+
describe '#export_bundle' do
|
22
|
+
let(:bundle_id) { 1 }
|
23
|
+
it 'when request are valid', :default do
|
24
|
+
stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/bundles/#{bundle_id}/exports")
|
25
|
+
export_bundle = @crowdin.export_bundle(bundle_id, project_id)
|
26
|
+
expect(export_bundle).to eq(200)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe '#check_bundle_export_status' do
|
31
|
+
let(:bundle_id) { 1 }
|
32
|
+
let(:export_id) { 1 }
|
33
|
+
|
34
|
+
it 'when request are valid', :default do
|
35
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/bundles/#{bundle_id}/exports/#{export_id}")
|
36
|
+
check_bundle_export_status = @crowdin.check_bundle_export_status(bundle_id, export_id, project_id)
|
37
|
+
expect(check_bundle_export_status).to eq(200)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#download_bundle' do
|
42
|
+
let(:bundle_id) { 1 }
|
43
|
+
let(:export_id) { 1 }
|
44
|
+
|
45
|
+
it 'when request are valid', :default do
|
46
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/bundles/#{bundle_id}/exports/#{export_id}/download")
|
47
|
+
download_bundle = @crowdin.download_bundle(bundle_id, export_id, project_id)
|
48
|
+
expect(download_bundle).to eq(200)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
21
52
|
describe '#get_bundle' do
|
22
53
|
let(:bundle_id) { 1 }
|
23
54
|
|
@@ -1,210 +1,231 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
describe Crowdin::ApiResources::Glossaries do
|
4
|
-
describe '
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
expect(list_glossaries).to eq(200)
|
10
|
-
end
|
3
|
+
describe Crowdin::ApiResources::Glossaries, 'Default endpoints' do
|
4
|
+
describe '#list_glossaries' do
|
5
|
+
it 'when request are valid', :default do
|
6
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/glossaries")
|
7
|
+
list_glossaries = @crowdin.list_glossaries
|
8
|
+
expect(list_glossaries).to eq(200)
|
11
9
|
end
|
10
|
+
end
|
12
11
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
end
|
12
|
+
describe '#add_glossary' do
|
13
|
+
it 'when request are valid', :default do
|
14
|
+
stub_request(:post, "https://api.crowdin.com/#{target_api_url}/glossaries")
|
15
|
+
add_glossary = @crowdin.add_glossary
|
16
|
+
expect(add_glossary).to eq(200)
|
19
17
|
end
|
18
|
+
end
|
20
19
|
|
21
|
-
|
22
|
-
|
20
|
+
describe '#get_glossary' do
|
21
|
+
let(:glossary_id) { 1 }
|
23
22
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end
|
23
|
+
it 'when request are valid', :default do
|
24
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/glossaries/#{glossary_id}")
|
25
|
+
get_glossary = @crowdin.get_glossary(glossary_id)
|
26
|
+
expect(get_glossary).to eq(200)
|
29
27
|
end
|
28
|
+
end
|
30
29
|
|
31
|
-
|
32
|
-
|
30
|
+
describe '#delete_glossary' do
|
31
|
+
let(:glossary_id) { 1 }
|
33
32
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
end
|
33
|
+
it 'when request are valid', :default do
|
34
|
+
stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/glossaries/#{glossary_id}")
|
35
|
+
delete_glossary = @crowdin.delete_glossary(glossary_id)
|
36
|
+
expect(delete_glossary).to eq(200)
|
39
37
|
end
|
38
|
+
end
|
40
39
|
|
41
|
-
|
42
|
-
|
40
|
+
describe '#edit_glossary' do
|
41
|
+
let(:glossary_id) { 1 }
|
43
42
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
end
|
43
|
+
it 'when request are valid', :default do
|
44
|
+
stub_request(:patch, "https://api.crowdin.com/#{target_api_url}/glossaries/#{glossary_id}")
|
45
|
+
edit_glossary = @crowdin.edit_glossary(glossary_id)
|
46
|
+
expect(edit_glossary).to eq(200)
|
49
47
|
end
|
48
|
+
end
|
50
49
|
|
51
|
-
|
52
|
-
|
50
|
+
describe '#export_glossary' do
|
51
|
+
let(:glossary_id) { 1 }
|
53
52
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
end
|
53
|
+
it 'when request are valid', :default do
|
54
|
+
stub_request(:post, "https://api.crowdin.com/#{target_api_url}/glossaries/#{glossary_id}/exports")
|
55
|
+
export_glossary = @crowdin.export_glossary({}, glossary_id)
|
56
|
+
expect(export_glossary).to eq(200)
|
59
57
|
end
|
58
|
+
end
|
60
59
|
|
61
|
-
|
62
|
-
|
63
|
-
|
60
|
+
describe '#check_glossary_export_status' do
|
61
|
+
let(:glossary_id) { 1 }
|
62
|
+
let(:export_id) { 1 }
|
64
63
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
end
|
64
|
+
it 'when request are valid', :default do
|
65
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/glossaries/#{glossary_id}/exports/#{export_id}")
|
66
|
+
check_glossary_export_status = @crowdin.check_glossary_export_status(glossary_id, export_id)
|
67
|
+
expect(check_glossary_export_status).to eq(200)
|
70
68
|
end
|
69
|
+
end
|
71
70
|
|
72
|
-
|
73
|
-
|
74
|
-
|
71
|
+
describe '#download_glossary' do
|
72
|
+
let(:glossary_id) { 1 }
|
73
|
+
let(:export_id) { 1 }
|
75
74
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
end
|
75
|
+
it 'when request are valid', :default do
|
76
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/glossaries/#{glossary_id}/exports/#{export_id}/download")
|
77
|
+
download_glossary = @crowdin.download_glossary(glossary_id, export_id)
|
78
|
+
expect(download_glossary).to eq(200)
|
81
79
|
end
|
80
|
+
end
|
82
81
|
|
83
|
-
|
84
|
-
|
82
|
+
describe '#import_glossary' do
|
83
|
+
let(:glossary_id) { 1 }
|
85
84
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
end
|
85
|
+
it 'when request are valid', :default do
|
86
|
+
stub_request(:post, "https://api.crowdin.com/#{target_api_url}/glossaries/#{glossary_id}/imports")
|
87
|
+
import_glossary = @crowdin.import_glossary(glossary_id)
|
88
|
+
expect(import_glossary).to eq(200)
|
91
89
|
end
|
90
|
+
end
|
92
91
|
|
93
|
-
|
94
|
-
|
95
|
-
|
92
|
+
describe '#check_glossary_import_status' do
|
93
|
+
let(:glossary_id) { 1 }
|
94
|
+
let(:import_id) { 1 }
|
96
95
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
end
|
96
|
+
it 'when request are valid', :default do
|
97
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/glossaries/#{glossary_id}/imports/#{import_id}")
|
98
|
+
check_glossary_import_status = @crowdin.check_glossary_import_status(glossary_id, import_id)
|
99
|
+
expect(check_glossary_import_status).to eq(200)
|
102
100
|
end
|
101
|
+
end
|
103
102
|
|
104
|
-
|
105
|
-
|
103
|
+
describe '#clear_glossary' do
|
104
|
+
let(:glossary_id) { 1 }
|
106
105
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
end
|
106
|
+
it 'when request are valid', :default do
|
107
|
+
stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/glossaries/#{glossary_id}/terms")
|
108
|
+
clear_glossary = @crowdin.clear_glossary(glossary_id)
|
109
|
+
expect(clear_glossary).to eq(200)
|
112
110
|
end
|
111
|
+
end
|
113
112
|
|
114
|
-
|
115
|
-
|
113
|
+
describe '#search_glossaries_concordance' do
|
114
|
+
let(:project_id) { 1 }
|
116
115
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
116
|
+
it 'returns 200 when request is valid', :default do
|
117
|
+
query = { source_language_id: 'en', target_language_id: 'ar', expression: 'Hello world!' }
|
118
|
+
stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/glossaries/concordance")
|
119
|
+
search_glossaries_concordance = @crowdin.search_glossaries_concordance(project_id, query)
|
120
|
+
expect(search_glossaries_concordance).to eq(200)
|
122
121
|
end
|
123
122
|
|
124
|
-
|
125
|
-
|
123
|
+
it 'raises ArgumentError when request is missing required query parameter', :default do
|
124
|
+
query = { source_language_id: 'en', target_language_id: 'ar' }
|
125
|
+
stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/glossaries/concordance")
|
126
|
+
expect do
|
127
|
+
@crowdin.search_glossaries_concordance(project_id, query)
|
128
|
+
end.to raise_error(ArgumentError, ':expression is required')
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
126
132
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
133
|
+
describe Crowdin::ApiResources::Glossaries, 'Concept endpoints' do
|
134
|
+
describe '#list_concepts' do
|
135
|
+
let(:glossary_id) { 1 }
|
136
|
+
|
137
|
+
it 'when request are valid', :default do
|
138
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/glossaries/#{glossary_id}/concepts")
|
139
|
+
concepts = @crowdin.list_concepts(glossary_id)
|
140
|
+
expect(concepts).to eq(200)
|
132
141
|
end
|
142
|
+
end
|
133
143
|
|
134
|
-
|
135
|
-
|
136
|
-
|
144
|
+
describe '#get_concept' do
|
145
|
+
let(:glossary_id) { 1 }
|
146
|
+
let(:concept_id) { 1 }
|
137
147
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
end
|
148
|
+
it 'when request are valid', :default do
|
149
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/glossaries/#{glossary_id}/concepts/#{concept_id}")
|
150
|
+
concept = @crowdin.get_concept(glossary_id, concept_id)
|
151
|
+
expect(concept).to eq(200)
|
143
152
|
end
|
153
|
+
end
|
144
154
|
|
145
|
-
|
146
|
-
|
147
|
-
|
155
|
+
describe '#update_concept' do
|
156
|
+
let(:glossary_id) { 1 }
|
157
|
+
let(:concept_id) { 1 }
|
148
158
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
end
|
159
|
+
it 'when request are valid', :default do
|
160
|
+
stub_request(:put, "https://api.crowdin.com/#{target_api_url}/glossaries/#{glossary_id}/concepts/#{concept_id}")
|
161
|
+
concept = @crowdin.update_concept(glossary_id, concept_id)
|
162
|
+
expect(concept).to eq(200)
|
154
163
|
end
|
164
|
+
end
|
155
165
|
|
156
|
-
|
157
|
-
|
158
|
-
|
166
|
+
describe '#update_concept' do
|
167
|
+
let(:glossary_id) { 1 }
|
168
|
+
let(:concept_id) { 1 }
|
159
169
|
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
end
|
170
|
+
it 'when request are valid', :default do
|
171
|
+
stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/glossaries/#{glossary_id}/concepts/#{concept_id}")
|
172
|
+
concept = @crowdin.delete_concept(glossary_id, concept_id)
|
173
|
+
expect(concept).to eq(200)
|
165
174
|
end
|
175
|
+
end
|
176
|
+
end
|
166
177
|
|
167
|
-
|
168
|
-
|
178
|
+
describe Crowdin::ApiResources::Glossaries, 'Term endpoints' do
|
179
|
+
describe '#list_terms' do
|
180
|
+
let(:glossary_id) { 1 }
|
169
181
|
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
end
|
182
|
+
it 'when request are valid', :default do
|
183
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/glossaries/#{glossary_id}/terms")
|
184
|
+
list_terms = @crowdin.list_terms(glossary_id)
|
185
|
+
expect(list_terms).to eq(200)
|
175
186
|
end
|
187
|
+
end
|
176
188
|
|
177
|
-
|
178
|
-
|
179
|
-
let(:concept_id) { 1 }
|
189
|
+
describe '#add_term' do
|
190
|
+
let(:glossary_id) { 1 }
|
180
191
|
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
end
|
192
|
+
it 'when request are valid', :default do
|
193
|
+
stub_request(:post, "https://api.crowdin.com/#{target_api_url}/glossaries/#{glossary_id}/terms")
|
194
|
+
add_term = @crowdin.add_term(glossary_id)
|
195
|
+
expect(add_term).to eq(200)
|
186
196
|
end
|
197
|
+
end
|
198
|
+
|
199
|
+
describe '#get_term' do
|
200
|
+
let(:glossary_id) { 1 }
|
201
|
+
let(:term_id) { 1 }
|
202
|
+
|
203
|
+
it 'when request are valid', :default do
|
204
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/glossaries/#{glossary_id}/terms/#{term_id}")
|
205
|
+
get_term = @crowdin.get_term(glossary_id, term_id)
|
206
|
+
expect(get_term).to eq(200)
|
207
|
+
end
|
208
|
+
end
|
187
209
|
|
188
|
-
|
189
|
-
|
190
|
-
|
210
|
+
describe '#delete_term' do
|
211
|
+
let(:glossary_id) { 1 }
|
212
|
+
let(:term_id) { 1 }
|
191
213
|
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
end
|
214
|
+
it 'when request are valid', :default do
|
215
|
+
stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/glossaries/#{glossary_id}/terms/#{term_id}")
|
216
|
+
delete_term = @crowdin.delete_term(glossary_id, term_id)
|
217
|
+
expect(delete_term).to eq(200)
|
197
218
|
end
|
219
|
+
end
|
198
220
|
|
199
|
-
|
200
|
-
|
201
|
-
|
221
|
+
describe '#edit_term' do
|
222
|
+
let(:glossary_id) { 1 }
|
223
|
+
let(:term_id) { 1 }
|
202
224
|
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
end
|
225
|
+
it 'when request are valid', :default do
|
226
|
+
stub_request(:patch, "https://api.crowdin.com/#{target_api_url}/glossaries/#{glossary_id}/terms/#{term_id}")
|
227
|
+
edit_term = @crowdin.edit_term(glossary_id, term_id)
|
228
|
+
expect(edit_term).to eq(200)
|
208
229
|
end
|
209
230
|
end
|
210
231
|
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.6.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: 2023-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: open-uri
|
@@ -171,6 +171,7 @@ extra_rdoc_files: []
|
|
171
171
|
files:
|
172
172
|
- ".github/workflows/build-and-publish.yml"
|
173
173
|
- ".github/workflows/docs.yml"
|
174
|
+
- ".github/workflows/lint-pr-title.yml"
|
174
175
|
- ".github/workflows/test-and-lint.yml"
|
175
176
|
- ".gitignore"
|
176
177
|
- ".rspec"
|