crowdin-api 1.2.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +102 -43
- data/README.md +37 -6
- data/bin/crowdin-console +1 -1
- data/crowdin-api.gemspec +1 -2
- data/lib/crowdin-api/api_resources/bundles.rb +81 -0
- data/lib/crowdin-api/{api-resources → api_resources}/dictionaries.rb +8 -10
- data/lib/crowdin-api/{api-resources → api_resources}/distributions.rb +25 -32
- data/lib/crowdin-api/{api-resources → api_resources}/glossaries.rb +64 -82
- data/lib/crowdin-api/{api-resources → api_resources}/labels.rb +28 -47
- data/lib/crowdin-api/api_resources/languages.rb +61 -0
- data/lib/crowdin-api/api_resources/machine_translation_engines.rb +79 -0
- data/lib/crowdin-api/api_resources/projects.rb +124 -0
- data/lib/crowdin-api/api_resources/reports.rb +120 -0
- data/lib/crowdin-api/{api-resources → api_resources}/screenshots.rb +47 -61
- data/lib/crowdin-api/{api-resources → api_resources}/source_files.rb +68 -131
- data/lib/crowdin-api/{api-resources → api_resources}/source_strings.rb +19 -24
- data/lib/crowdin-api/api_resources/storages.rb +54 -0
- data/lib/crowdin-api/{api-resources → api_resources}/string_comments.rb +18 -23
- data/lib/crowdin-api/{api-resources → api_resources}/string_translations.rb +64 -91
- data/lib/crowdin-api/{api-resources → api_resources}/tasks.rb +30 -41
- data/lib/crowdin-api/api_resources/teams.rb +135 -0
- data/lib/crowdin-api/{api-resources → api_resources}/translation_memory.rb +38 -52
- data/lib/crowdin-api/{api-resources → api_resources}/translation_status.rb +24 -30
- data/lib/crowdin-api/{api-resources → api_resources}/translations.rb +41 -58
- data/lib/crowdin-api/api_resources/users.rb +161 -0
- data/lib/crowdin-api/api_resources/vendors.rb +21 -0
- data/lib/crowdin-api/{api-resources → api_resources}/webhooks.rb +19 -24
- data/lib/crowdin-api/api_resources/workflows.rb +59 -0
- data/lib/crowdin-api/client/client.rb +134 -39
- data/lib/crowdin-api/client/configuration.rb +12 -12
- data/lib/crowdin-api/client/version.rb +1 -1
- data/lib/crowdin-api/core/errors.rb +1 -0
- data/lib/crowdin-api/core/errors_raisers.rb +1 -1
- data/lib/crowdin-api/core/fetch_all_extensions.rb +14 -0
- data/lib/crowdin-api/core/request.rb +50 -90
- data/lib/crowdin-api/core/send_request.rb +67 -0
- data/lib/crowdin-api.rb +18 -24
- data/spec/api_resources/bundles_spec.rb +61 -0
- data/spec/api_resources/dictionaries_spec.rb +23 -0
- data/spec/api_resources/distributions_spec.rb +71 -0
- data/spec/api_resources/glossaries_spec.rb +167 -0
- data/spec/api_resources/labels_spec.rb +71 -0
- data/spec/api_resources/languages_spec.rb +51 -0
- data/spec/api_resources/machine_translation_engines_spec.rb +63 -0
- data/spec/api_resources/projects_spec.rb +215 -0
- data/spec/api_resources/reports_spec.rb +95 -0
- data/spec/api_resources/screenshots_spec.rb +134 -0
- data/spec/api_resources/source_files_spec.rb +184 -0
- data/spec/api_resources/source_strings_spec.rb +51 -0
- data/spec/api_resources/storages_spec.rb +41 -0
- data/spec/api_resources/string_comments_spec.rb +51 -0
- data/spec/api_resources/string_translations_spec.rb +141 -0
- data/spec/api_resources/tasks_spec.rb +79 -0
- data/spec/api_resources/teams_spec.rb +100 -0
- data/spec/api_resources/translation_memory_spec.rb +114 -0
- data/spec/api_resources/translation_status_spec.rb +61 -0
- data/spec/api_resources/translations_spec.rb +107 -0
- data/spec/api_resources/users_spec.rb +117 -0
- data/spec/api_resources/vendors_spec.rb +13 -0
- data/spec/api_resources/webhooks_spec.rb +51 -0
- data/spec/api_resources/workflows_spec.rb +41 -0
- data/spec/spec_helper.rb +23 -2
- data/spec/unit/client_spec.rb +85 -0
- metadata +67 -43
- data/bin/setup +0 -6
- data/lib/crowdin-api/api-resources/languages.rb +0 -82
- data/lib/crowdin-api/api-resources/machine_translation_engines.rb +0 -74
- data/lib/crowdin-api/api-resources/projects.rb +0 -148
- data/lib/crowdin-api/api-resources/reports.rb +0 -138
- data/lib/crowdin-api/api-resources/storages.rb +0 -106
- data/lib/crowdin-api/api-resources/teams.rb +0 -144
- data/lib/crowdin-api/api-resources/users.rb +0 -129
- data/lib/crowdin-api/api-resources/vendors.rb +0 -21
- data/lib/crowdin-api/api-resources/workflows.rb +0 -62
- data/lib/crowdin-api/core/utils.rb +0 -10
- data/spec/client/client-instance_spec.rb +0 -14
- data/spec/client/configuration-instance_spec.rb +0 -72
@@ -0,0 +1,215 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe Crowdin::ApiResources::Projects do
|
4
|
+
describe 'Default endpoints' do
|
5
|
+
describe '#list_projects' do
|
6
|
+
let(:limit) { 1 }
|
7
|
+
let(:offset) { 1 }
|
8
|
+
|
9
|
+
it 'when request are valid', :default do
|
10
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects")
|
11
|
+
list_projects = @crowdin.list_projects
|
12
|
+
expect(list_projects).to eq(200)
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'when request are valid and includes query parameters', :default do
|
16
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects")
|
17
|
+
.with(query: { limit: limit, offset: offset })
|
18
|
+
list_projects = @crowdin.list_projects({ limit: limit, offset: offset })
|
19
|
+
expect(list_projects).to eq(200)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#add_project' do
|
24
|
+
let(:project_name) { 'test_project' }
|
25
|
+
let(:source_language_id) { 'en' }
|
26
|
+
|
27
|
+
it 'when request are valid', :default do
|
28
|
+
stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects")
|
29
|
+
.with(body: { name: project_name, sourceLanguageId: source_language_id })
|
30
|
+
add_project = @crowdin.add_project(name: project_name, sourceLanguageId: source_language_id)
|
31
|
+
expect(add_project).to eq(200)
|
32
|
+
end
|
33
|
+
|
34
|
+
let(:body) do
|
35
|
+
{ "data" => { "id" => 1, "name" => "test_project" } }
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'when request are valid and returns body', :default do
|
39
|
+
stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects")
|
40
|
+
.with(body: { name: project_name, sourceLanguageId: source_language_id })
|
41
|
+
.to_return(body: body.to_json)
|
42
|
+
add_project = @crowdin.add_project(name: project_name, sourceLanguageId: source_language_id)
|
43
|
+
expect(add_project).to eq(body)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe '#get_project' do
|
48
|
+
before do
|
49
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}")
|
50
|
+
end
|
51
|
+
|
52
|
+
let(:project_id) { 1 }
|
53
|
+
|
54
|
+
it 'when request are valid', :default do
|
55
|
+
get_project = @crowdin.get_project(project_id)
|
56
|
+
expect(get_project).to eq(200)
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'when request are invalid', :default do
|
60
|
+
expect { @crowdin.get_project }.to raise_error(ArgumentError)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe '#delete_project' do
|
65
|
+
before do
|
66
|
+
stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}")
|
67
|
+
end
|
68
|
+
|
69
|
+
let(:project_id) { 1 }
|
70
|
+
|
71
|
+
it 'when request are valid', :default do
|
72
|
+
delete_project = @crowdin.delete_project(project_id)
|
73
|
+
expect(delete_project).to eq(200)
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'when request are invalid', :default do
|
77
|
+
expect { @crowdin.delete_project }.to raise_error(ArgumentError)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe '#edit_project' do
|
82
|
+
let(:project_id) { 1 }
|
83
|
+
let(:body) { [{ op: 'replace', path: '/name', value: 'project_name' }] }
|
84
|
+
|
85
|
+
it 'when request are valid', :default do
|
86
|
+
stub_request(:patch, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}")
|
87
|
+
.with(body: body.to_json)
|
88
|
+
edit_project = @crowdin.edit_project(project_id, body)
|
89
|
+
expect(edit_project).to eq(200)
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'when request are invalid', :default do
|
93
|
+
stub_request(:patch, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}")
|
94
|
+
expect { @crowdin.edit_project }.to raise_error(ArgumentError)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
describe 'Enterprise endpoints' do
|
100
|
+
describe '#list_groups' do
|
101
|
+
let(:limit) { 1 }
|
102
|
+
let(:offset) { 1 }
|
103
|
+
|
104
|
+
it 'when Enterprise mode is not enabled', :default do
|
105
|
+
stub_request(:get, "https://domain.api.crowdin.com/#{target_api_url}/groups")
|
106
|
+
expect { @crowdin.list_groups }.to raise_error(Crowdin::Errors::OnlyForEnterpriseModeError)
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'when request are valid', :enterprise do
|
110
|
+
stub_request(:get, "https://domain.api.crowdin.com/#{target_api_url}/groups")
|
111
|
+
list_groups = @crowdin.list_groups
|
112
|
+
expect(list_groups).to eq(200)
|
113
|
+
end
|
114
|
+
|
115
|
+
it 'when request are valid and includes query parameters', :enterprise do
|
116
|
+
stub_request(:get, "https://domain.api.crowdin.com/#{target_api_url}/groups")
|
117
|
+
.with(query: { limit: limit, offset: offset })
|
118
|
+
list_groups = @crowdin.list_groups({ limit: limit, offset: offset })
|
119
|
+
expect(list_groups).to eq(200)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
describe '#add_group' do
|
124
|
+
let(:group_name) { 'test_group' }
|
125
|
+
|
126
|
+
it 'when Enterprise mode is not enabled', :default do
|
127
|
+
stub_request(:post, "https://domain.api.crowdin.com/#{target_api_url}/groups")
|
128
|
+
expect { @crowdin.add_group(name: group_name) }.to raise_error(Crowdin::Errors::OnlyForEnterpriseModeError)
|
129
|
+
end
|
130
|
+
|
131
|
+
it 'when request are valid', :enterprise do
|
132
|
+
stub_request(:post, "https://domain.api.crowdin.com/#{target_api_url}/groups")
|
133
|
+
.with(body: { name: group_name })
|
134
|
+
add_group = @crowdin.add_group(name: group_name)
|
135
|
+
expect(add_group).to eq(200)
|
136
|
+
end
|
137
|
+
|
138
|
+
let(:body) do
|
139
|
+
{ "data"=> { "id"=>1, "name"=>"test_group" } }
|
140
|
+
end
|
141
|
+
|
142
|
+
it 'when request are valid and returns body', :enterprise do
|
143
|
+
stub_request(:post, "https://domain.api.crowdin.com/#{target_api_url}/groups")
|
144
|
+
.with(body: { name: group_name })
|
145
|
+
.to_return(body: body.to_json)
|
146
|
+
add_group = @crowdin.add_group(name: group_name)
|
147
|
+
expect(add_group).to eq(body)
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
describe '#get_group' do
|
152
|
+
before do
|
153
|
+
stub_request(:get, "https://domain.api.crowdin.com/#{target_api_url}/groups/#{group_id}")
|
154
|
+
end
|
155
|
+
|
156
|
+
let(:group_id) { 1 }
|
157
|
+
|
158
|
+
it 'when Enterprise mode is not enabled', :default do
|
159
|
+
expect { @crowdin.get_group(group_id) }.to raise_error(Crowdin::Errors::OnlyForEnterpriseModeError)
|
160
|
+
end
|
161
|
+
|
162
|
+
it 'when request are valid', :enterprise do
|
163
|
+
get_group = @crowdin.get_group(group_id)
|
164
|
+
expect(get_group).to eq(200)
|
165
|
+
end
|
166
|
+
|
167
|
+
it 'when request are invalid', :enterprise do
|
168
|
+
expect { @crowdin.get_group }.to raise_error(ArgumentError)
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
describe '#delete_group' do
|
173
|
+
before do
|
174
|
+
stub_request(:delete, "https://domain.api.crowdin.com/#{target_api_url}/groups/#{group_id}")
|
175
|
+
end
|
176
|
+
|
177
|
+
let(:group_id) { 1 }
|
178
|
+
|
179
|
+
it 'when Enterprise mode is not enabled', :default do
|
180
|
+
expect { @crowdin.delete_group(group_id) }.to raise_error(Crowdin::Errors::OnlyForEnterpriseModeError)
|
181
|
+
end
|
182
|
+
|
183
|
+
it 'when request are valid', :enterprise do
|
184
|
+
delete_group = @crowdin.delete_group(group_id)
|
185
|
+
expect(delete_group).to eq(200)
|
186
|
+
end
|
187
|
+
|
188
|
+
it 'when request are invalid', :enterprise do
|
189
|
+
expect { @crowdin.delete_group }.to raise_error(ArgumentError)
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
describe '#edit_group' do
|
194
|
+
let(:group_id) { 1 }
|
195
|
+
let(:body) { [{ op: 'replace', path: '/name', value: 'group_name' }] }
|
196
|
+
|
197
|
+
it 'when Enterprise mode is not enabled', :default do
|
198
|
+
stub_request(:patch, "https://domain.api.crowdin.com/#{target_api_url}/groups/#{group_id}")
|
199
|
+
expect { @crowdin.edit_group(group_id, body) }.to raise_error(Crowdin::Errors::OnlyForEnterpriseModeError)
|
200
|
+
end
|
201
|
+
|
202
|
+
it 'when request are valid', :enterprise do
|
203
|
+
stub_request(:patch, "https://domain.api.crowdin.com/#{target_api_url}/groups/#{group_id}")
|
204
|
+
.with(body: body.to_json)
|
205
|
+
edit_group = @crowdin.edit_group(group_id, body)
|
206
|
+
expect(edit_group).to eq(200)
|
207
|
+
end
|
208
|
+
|
209
|
+
it 'when request are invalid', :enterprise do
|
210
|
+
stub_request(:patch, "https://api.crowdin.com/#{target_api_url}/groups/#{group_id}")
|
211
|
+
expect { @crowdin.edit_group }.to raise_error(ArgumentError)
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe Crowdin::ApiResources::Reports do
|
4
|
+
describe 'Default endpoints' do
|
5
|
+
describe '#generate_report' do
|
6
|
+
it 'when request are valid', :default do
|
7
|
+
stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/reports")
|
8
|
+
generate_report = @crowdin.generate_report({}, project_id)
|
9
|
+
expect(generate_report).to eq(200)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#check_report_generation_status' do
|
14
|
+
let(:report_id) { 1 }
|
15
|
+
|
16
|
+
it 'when request are valid', :default do
|
17
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/reports/#{report_id}")
|
18
|
+
check_report_generation_status = @crowdin.check_report_generation_status(report_id, project_id)
|
19
|
+
expect(check_report_generation_status).to eq(200)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#download_report' do
|
24
|
+
let(:report_id) { 1 }
|
25
|
+
|
26
|
+
it 'when request are valid', :default do
|
27
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/reports/#{report_id}/download")
|
28
|
+
download_report = @crowdin.download_report(report_id, nil, project_id)
|
29
|
+
expect(download_report).to eq(200)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe 'Enterprise endpoints' do
|
35
|
+
describe '#generate_group_report' do
|
36
|
+
let(:group_id) { 1 }
|
37
|
+
|
38
|
+
it 'when request are valid', :enterprise do
|
39
|
+
stub_request(:post, "https://domain.api.crowdin.com/#{target_api_url}/groups/#{group_id}/reports")
|
40
|
+
generate_group_report = @crowdin.generate_group_report(group_id, project_id)
|
41
|
+
expect(generate_group_report).to eq(200)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '#check_group_report_generation_status' do
|
46
|
+
let(:group_id) { 1 }
|
47
|
+
let(:report_id) { 1 }
|
48
|
+
|
49
|
+
it 'when request are valid', :enterprise do
|
50
|
+
stub_request(:get, "https://domain.api.crowdin.com/#{target_api_url}/groups/#{group_id}/reports/#{report_id}")
|
51
|
+
check_group_report_generation_status = @crowdin.check_group_report_generation_status(group_id, report_id)
|
52
|
+
expect(check_group_report_generation_status).to eq(200)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '#download_group_report' do
|
57
|
+
let(:group_id) { 1 }
|
58
|
+
let(:report_id) { 1 }
|
59
|
+
|
60
|
+
it 'when request are valid', :enterprise do
|
61
|
+
stub_request(:get, "https://domain.api.crowdin.com/#{target_api_url}/groups/#{group_id}/reports/#{report_id}/download")
|
62
|
+
download_group_report = @crowdin.download_group_report(group_id, project_id)
|
63
|
+
expect(download_group_report).to eq(200)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe '#generate_organization_report' do
|
68
|
+
it 'when request are valid', :enterprise do
|
69
|
+
stub_request(:post, "https://domain.api.crowdin.com/#{target_api_url}/reports")
|
70
|
+
generate_organization_report = @crowdin.generate_organization_report
|
71
|
+
expect(generate_organization_report).to eq(200)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe '#check_organization_report_generation_status' do
|
76
|
+
let(:report_id) { 1 }
|
77
|
+
|
78
|
+
it 'when request are valid', :enterprise do
|
79
|
+
stub_request(:get, "https://domain.api.crowdin.com/#{target_api_url}/reports/#{report_id}")
|
80
|
+
check_organization_report_generation_status = @crowdin.check_organization_report_generation_status(report_id)
|
81
|
+
expect(check_organization_report_generation_status).to eq(200)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe '#download_organization_report' do
|
86
|
+
let(:report_id) { 1 }
|
87
|
+
|
88
|
+
it 'when request are valid', :enterprise do
|
89
|
+
stub_request(:get, "https://domain.api.crowdin.com/#{target_api_url}/reports/#{report_id}/download")
|
90
|
+
download_organization_report = @crowdin.download_organization_report(report_id)
|
91
|
+
expect(download_organization_report).to eq(200)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,134 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe Crowdin::ApiResources::Screenshots do
|
4
|
+
describe 'Default endpoints' do
|
5
|
+
describe '#list_screenshots' do
|
6
|
+
it 'when request are valid', :default do
|
7
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/screenshots")
|
8
|
+
list_screenshots = @crowdin.list_screenshots({}, project_id)
|
9
|
+
expect(list_screenshots).to eq(200)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#add_screenshot' do
|
14
|
+
it 'when request are valid', :default do
|
15
|
+
stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/screenshots")
|
16
|
+
add_screenshot = @crowdin.add_screenshot({}, project_id)
|
17
|
+
expect(add_screenshot).to eq(200)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#get_screenshot' do
|
22
|
+
let(:screenshot_id) { 1 }
|
23
|
+
|
24
|
+
it 'when request are valid', :default do
|
25
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/screenshots/#{screenshot_id}")
|
26
|
+
get_screenshot = @crowdin.get_screenshot(screenshot_id, project_id)
|
27
|
+
expect(get_screenshot).to eq(200)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#update_screenshot' do
|
32
|
+
let(:screenshot_id) { 1 }
|
33
|
+
|
34
|
+
it 'when request are valid', :default do
|
35
|
+
stub_request(:put, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/screenshots/#{screenshot_id}")
|
36
|
+
update_screenshot = @crowdin.update_screenshot(screenshot_id, {}, project_id)
|
37
|
+
expect(update_screenshot).to eq(200)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#delete_screenshot' do
|
42
|
+
let(:screenshot_id) { 1 }
|
43
|
+
|
44
|
+
it 'when request are valid', :default do
|
45
|
+
stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/screenshots/#{screenshot_id}")
|
46
|
+
delete_screenshot = @crowdin.delete_screenshot(screenshot_id, project_id)
|
47
|
+
expect(delete_screenshot).to eq(200)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '#edit_screenshot' do
|
52
|
+
let(:screenshot_id) { 1 }
|
53
|
+
|
54
|
+
it 'when request are valid', :default do
|
55
|
+
stub_request(:patch, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/screenshots/#{screenshot_id}")
|
56
|
+
edit_screenshot = @crowdin.edit_screenshot(screenshot_id, {}, project_id)
|
57
|
+
expect(edit_screenshot).to eq(200)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe '#list_tags' do
|
62
|
+
let(:screenshot_id) { 1 }
|
63
|
+
|
64
|
+
it 'when request are valid', :default do
|
65
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/screenshots/#{screenshot_id}/tags")
|
66
|
+
list_tags = @crowdin.list_tags(screenshot_id, {}, project_id)
|
67
|
+
expect(list_tags).to eq(200)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe '#replace_tags' do
|
72
|
+
let(:screenshot_id) { 1 }
|
73
|
+
|
74
|
+
it 'when request are valid', :default do
|
75
|
+
stub_request(:put, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/screenshots/#{screenshot_id}/tags")
|
76
|
+
replace_tags = @crowdin.replace_tags(screenshot_id, {}, project_id)
|
77
|
+
expect(replace_tags).to eq(200)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe '#add_tag' do
|
82
|
+
let(:screenshot_id) { 1 }
|
83
|
+
|
84
|
+
it 'when request are valid', :default do
|
85
|
+
stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/screenshots/#{screenshot_id}/tags")
|
86
|
+
add_tag = @crowdin.add_tag(screenshot_id, {}, project_id)
|
87
|
+
expect(add_tag).to eq(200)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
describe '#clear_tags' do
|
92
|
+
let(:screenshot_id) { 1 }
|
93
|
+
|
94
|
+
it 'when request are valid', :default do
|
95
|
+
stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/screenshots/#{screenshot_id}/tags")
|
96
|
+
clear_tags = @crowdin.clear_tags(screenshot_id, project_id)
|
97
|
+
expect(clear_tags).to eq(200)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe '#get_tag' do
|
102
|
+
let(:screenshot_id) { 1 }
|
103
|
+
let(:tag_id) { 1 }
|
104
|
+
|
105
|
+
it 'when request are valid', :default do
|
106
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/screenshots/#{screenshot_id}/tags/#{tag_id}")
|
107
|
+
get_tag = @crowdin.get_tag(screenshot_id, tag_id, project_id)
|
108
|
+
expect(get_tag).to eq(200)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
describe '#delete_tag' do
|
113
|
+
let(:screenshot_id) { 1 }
|
114
|
+
let(:tag_id) { 1 }
|
115
|
+
|
116
|
+
it 'when request are valid', :default do
|
117
|
+
stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/screenshots/#{screenshot_id}/tags/#{tag_id}")
|
118
|
+
delete_tag = @crowdin.delete_tag(screenshot_id, tag_id, project_id)
|
119
|
+
expect(delete_tag).to eq(200)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
describe '#edit_tag' do
|
124
|
+
let(:screenshot_id) { 1 }
|
125
|
+
let(:tag_id) { 1 }
|
126
|
+
|
127
|
+
it 'when request are valid', :default do
|
128
|
+
stub_request(:patch, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/screenshots/#{screenshot_id}/tags/#{tag_id}")
|
129
|
+
edit_tag = @crowdin.edit_tag(screenshot_id, tag_id, {}, project_id)
|
130
|
+
expect(edit_tag).to eq(200)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
end
|
@@ -0,0 +1,184 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe Crowdin::ApiResources::SourceFiles do
|
4
|
+
describe 'Default endpoints' do
|
5
|
+
describe '#list_branches' do
|
6
|
+
it 'when request are valid', :default do
|
7
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/branches")
|
8
|
+
list_branches = @crowdin.list_branches({}, project_id)
|
9
|
+
expect(list_branches).to eq(200)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#add_branch' do
|
14
|
+
it 'when request are valid', :default do
|
15
|
+
stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/branches")
|
16
|
+
add_branch = @crowdin.add_branch({}, project_id)
|
17
|
+
expect(add_branch).to eq(200)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#get_branch' do
|
22
|
+
let(:branch_id) { 1 }
|
23
|
+
|
24
|
+
it 'when request are valid', :default do
|
25
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/branches/#{branch_id}")
|
26
|
+
get_branch = @crowdin.get_branch(branch_id, project_id)
|
27
|
+
expect(get_branch).to eq(200)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#delete_branch' do
|
32
|
+
let(:branch_id) { 1 }
|
33
|
+
|
34
|
+
it 'when request are valid', :default do
|
35
|
+
stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/branches/#{branch_id}")
|
36
|
+
delete_branch = @crowdin.delete_branch(branch_id, project_id)
|
37
|
+
expect(delete_branch).to eq(200)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#edit_branch' do
|
42
|
+
let(:branch_id) { 1 }
|
43
|
+
|
44
|
+
it 'when request are valid', :default do
|
45
|
+
stub_request(:patch, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/branches/#{branch_id}")
|
46
|
+
edit_branch = @crowdin.edit_branch(branch_id, {}, project_id)
|
47
|
+
expect(edit_branch).to eq(200)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '#list_directories' do
|
52
|
+
it 'when request are valid', :default do
|
53
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/directories")
|
54
|
+
list_directories = @crowdin.list_directories({}, project_id)
|
55
|
+
expect(list_directories).to eq(200)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe '#add_directory' do
|
60
|
+
it 'when request are valid', :default do
|
61
|
+
stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/directories")
|
62
|
+
add_directory = @crowdin.add_directory({}, project_id)
|
63
|
+
expect(add_directory).to eq(200)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe '#get_directory' do
|
68
|
+
let(:directory_id) { 1 }
|
69
|
+
|
70
|
+
it 'when request are valid', :default do
|
71
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/directories/#{directory_id}")
|
72
|
+
get_directory = @crowdin.get_directory(directory_id, project_id)
|
73
|
+
expect(get_directory).to eq(200)
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe '#delete_directory' do
|
78
|
+
let(:directory_id) { 1 }
|
79
|
+
|
80
|
+
it 'when request are valid', :default do
|
81
|
+
stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/directories/#{directory_id}")
|
82
|
+
delete_directory = @crowdin.delete_directory(directory_id, project_id)
|
83
|
+
expect(delete_directory).to eq(200)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
describe '#edit_directory' do
|
88
|
+
let(:directory_id) { 1 }
|
89
|
+
|
90
|
+
it 'when request are valid', :default do
|
91
|
+
stub_request(:patch, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/directories/#{directory_id}")
|
92
|
+
edit_directory = @crowdin.edit_directory(directory_id, {}, project_id)
|
93
|
+
expect(edit_directory).to eq(200)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
describe '#list_files' do
|
98
|
+
it 'when request are valid', :default do
|
99
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/files")
|
100
|
+
list_files = @crowdin.list_files({}, project_id)
|
101
|
+
expect(list_files).to eq(200)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
describe '#add_file' do
|
106
|
+
it 'when request are valid', :default do
|
107
|
+
stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/files")
|
108
|
+
add_file = @crowdin.add_file({}, project_id)
|
109
|
+
expect(add_file).to eq(200)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
describe '#get_file' do
|
114
|
+
let(:file_id) { 1 }
|
115
|
+
|
116
|
+
it 'when request are valid', :default do
|
117
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/files/#{file_id}")
|
118
|
+
get_file = @crowdin.get_file(file_id, project_id)
|
119
|
+
expect(get_file).to eq(200)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
describe '#update_or_restore_file' do
|
124
|
+
let(:file_id) { 1 }
|
125
|
+
|
126
|
+
it 'when request are valid', :default do
|
127
|
+
stub_request(:put, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/files/#{file_id}")
|
128
|
+
update_or_restore_file = @crowdin.update_or_restore_file(file_id, {}, project_id)
|
129
|
+
expect(update_or_restore_file).to eq(200)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
describe '#delete_file' do
|
134
|
+
let(:file_id) { 1 }
|
135
|
+
|
136
|
+
it 'when request are valid', :default do
|
137
|
+
stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/files/#{file_id}")
|
138
|
+
delete_file = @crowdin.delete_file(file_id, project_id)
|
139
|
+
expect(delete_file).to eq(200)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
describe '#edit_file' do
|
144
|
+
let(:file_id) { 1 }
|
145
|
+
|
146
|
+
it 'when request are valid', :default do
|
147
|
+
stub_request(:patch, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/files/#{file_id}")
|
148
|
+
edit_file = @crowdin.edit_file(file_id, {}, project_id)
|
149
|
+
expect(edit_file).to eq(200)
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
describe '#download_file' do
|
154
|
+
let(:file_id) { 1 }
|
155
|
+
|
156
|
+
it 'when request are valid', :default do
|
157
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/files/#{file_id}/download")
|
158
|
+
download_file = @crowdin.download_file(file_id, nil, project_id)
|
159
|
+
expect(download_file).to eq(200)
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
describe '#list_file_revisions' do
|
164
|
+
let(:file_id) { 1 }
|
165
|
+
|
166
|
+
it 'when request are valid', :default do
|
167
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/files/#{file_id}/revisions")
|
168
|
+
list_file_revisions = @crowdin.list_file_revisions(file_id, {}, project_id)
|
169
|
+
expect(list_file_revisions).to eq(200)
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
describe '#get_file_revision' do
|
174
|
+
let(:file_id) { 1 }
|
175
|
+
let(:revision_id) { 1 }
|
176
|
+
|
177
|
+
it 'when request are valid', :default do
|
178
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/files/#{file_id}/revisions/#{revision_id}")
|
179
|
+
get_file_revision = @crowdin.get_file_revision(file_id, revision_id, project_id)
|
180
|
+
expect(get_file_revision).to eq(200)
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe Crowdin::ApiResources::SourceStrings do
|
4
|
+
describe 'Default endpoints' do
|
5
|
+
describe '#list_strings' do
|
6
|
+
it 'when request are valid', :default do
|
7
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/strings")
|
8
|
+
list_strings = @crowdin.list_strings({}, project_id)
|
9
|
+
expect(list_strings).to eq(200)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#add_string' do
|
14
|
+
it 'when request are valid', :default do
|
15
|
+
stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/strings")
|
16
|
+
add_string = @crowdin.add_string({}, project_id)
|
17
|
+
expect(add_string).to eq(200)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#get_string' do
|
22
|
+
let(:string_id) { 1 }
|
23
|
+
|
24
|
+
it 'when request are valid', :default do
|
25
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/strings/#{string_id}")
|
26
|
+
get_string = @crowdin.get_string(string_id, {}, project_id)
|
27
|
+
expect(get_string).to eq(200)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#delete_string' do
|
32
|
+
let(:string_id) { 1 }
|
33
|
+
|
34
|
+
it 'when request are valid', :default do
|
35
|
+
stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/strings/#{string_id}")
|
36
|
+
delete_string = @crowdin.delete_string(string_id, project_id)
|
37
|
+
expect(delete_string).to eq(200)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#edit_string' do
|
42
|
+
let(:string_id) { 1 }
|
43
|
+
|
44
|
+
it 'when request are valid', :default do
|
45
|
+
stub_request(:patch, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/strings/#{string_id}")
|
46
|
+
edit_string = @crowdin.edit_string(string_id, {}, project_id)
|
47
|
+
expect(edit_string).to eq(200)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|