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,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Crowdin
|
4
|
+
module ApiResources
|
5
|
+
module Notifications
|
6
|
+
def send_notification_to_authenticated_user(query = {})
|
7
|
+
%i[message].each do |param|
|
8
|
+
query[param] || raise_parameter_is_required_error(param)
|
9
|
+
end
|
10
|
+
|
11
|
+
request = Web::Request.new(
|
12
|
+
connection,
|
13
|
+
:post,
|
14
|
+
"#{config.target_api_url}/notify",
|
15
|
+
{ params: query }
|
16
|
+
)
|
17
|
+
Web::SendRequest.new(request).perform
|
18
|
+
end
|
19
|
+
|
20
|
+
def send_notification_to_organization_members(query = {})
|
21
|
+
enterprise_mode? || raise_only_for_enterprise_mode_error
|
22
|
+
|
23
|
+
%i[message].each do |param|
|
24
|
+
query[param] || raise_parameter_is_required_error(param)
|
25
|
+
end
|
26
|
+
|
27
|
+
request = Web::Request.new(
|
28
|
+
connection,
|
29
|
+
:post,
|
30
|
+
"#{config.target_api_url}/notify",
|
31
|
+
{ params: query }
|
32
|
+
)
|
33
|
+
Web::SendRequest.new(request).perform
|
34
|
+
end
|
35
|
+
|
36
|
+
def send_notifications_to_project_members(query = {}, project_id = config.project_id)
|
37
|
+
project_id || raise_project_id_is_required_error
|
38
|
+
|
39
|
+
%i[message].each do |param|
|
40
|
+
query[param] || raise_parameter_is_required_error(param)
|
41
|
+
end
|
42
|
+
|
43
|
+
request = Web::Request.new(
|
44
|
+
connection,
|
45
|
+
:post,
|
46
|
+
"#{config.target_api_url}/projects/#{project_id}/notify",
|
47
|
+
{ params: query }
|
48
|
+
)
|
49
|
+
Web::SendRequest.new(request).perform
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -22,7 +22,7 @@ module Crowdin
|
|
22
22
|
def add_storage(file = nil)
|
23
23
|
file || raise_parameter_is_required_error(:file)
|
24
24
|
|
25
|
-
file
|
25
|
+
file ||= File.open(file, 'r')
|
26
26
|
headers = { 'Content-Type' => 'application/octet-stream', 'Crowdin-API-FileName' => File.basename(file) }
|
27
27
|
|
28
28
|
request = Web::Request.new(
|
@@ -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
|
data/lib/crowdin-api.rb
CHANGED
@@ -5,7 +5,8 @@ module Crowdin
|
|
5
5
|
API_RESOURCES_MODULES = %i[Storages Languages Projects Workflows SourceFiles Translations SourceStrings
|
6
6
|
StringTranslations StringComments Screenshots Glossaries TranslationMemory
|
7
7
|
MachineTranslationEngines Reports Tasks Users Teams Vendors Webhooks
|
8
|
-
Dictionaries Distributions Labels TranslationStatus Bundles
|
8
|
+
Dictionaries Distributions Labels TranslationStatus Bundles Notifications
|
9
|
+
Applications].freeze
|
9
10
|
|
10
11
|
# Error Raisers modules
|
11
12
|
ERROR_RAISERS_MODULES = %i[ApiErrorsRaiser ClientErrorsRaiser].freeze
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe Crowdin::ApiResources::Applications do
|
4
|
+
let(:application_identifier) { 'identifier' }
|
5
|
+
let(:path) { 'application_path' }
|
6
|
+
describe 'Default endpoints' do
|
7
|
+
describe '#get_application_data' do
|
8
|
+
it 'when request are valid', :default do
|
9
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/applications/#{application_identifier}/api/#{path}")
|
10
|
+
get_application_data = @crowdin.get_application_data(application_identifier, path)
|
11
|
+
expect(get_application_data).to eq(200)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#update_or_restore_application_data' do
|
16
|
+
it 'when request are valid', :default do
|
17
|
+
stub_request(:put, "https://api.crowdin.com/#{target_api_url}/applications/#{application_identifier}/api/#{path}")
|
18
|
+
get_application_data = @crowdin.update_or_restore_application_data({}, application_identifier, path)
|
19
|
+
expect(get_application_data).to eq(200)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#add_application_data' do
|
24
|
+
it 'when request are valid', :default do
|
25
|
+
stub_request(:post, "https://api.crowdin.com/#{target_api_url}/applications/#{application_identifier}/api/#{path}")
|
26
|
+
get_application_data = @crowdin.add_application_data({}, application_identifier, path)
|
27
|
+
expect(get_application_data).to eq(200)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#delete_application_data' do
|
32
|
+
it 'when request are valid', :default do
|
33
|
+
stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/applications/#{application_identifier}/api/#{path}")
|
34
|
+
get_application_data = @crowdin.delete_application_data({}, application_identifier, path)
|
35
|
+
expect(get_application_data).to eq(200)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#edit_application_data' do
|
40
|
+
it 'when request are valid', :default do
|
41
|
+
stub_request(:patch, "https://api.crowdin.com/#{target_api_url}/applications/#{application_identifier}/api/#{path}")
|
42
|
+
get_application_data = @crowdin.edit_application_data({}, application_identifier, path)
|
43
|
+
expect(get_application_data).to eq(200)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
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
|