crowdin-api 1.1.1 → 1.3.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/.github/workflows/test-and-lint.yml +1 -1
- data/.gitignore +2 -2
- data/.rubocop_todo.yml +114 -42
- data/README.md +26 -13
- data/bin/crowdin-console +5 -5
- data/crowdin-api.gemspec +1 -2
- data/lib/crowdin-api/api_resources/dictionaries.rb +32 -0
- data/lib/crowdin-api/api_resources/distributions.rb +92 -0
- data/lib/crowdin-api/api_resources/glossaries.rb +199 -0
- data/lib/crowdin-api/api_resources/labels.rb +98 -0
- 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/screenshots.rb +172 -0
- data/lib/crowdin-api/{api-resources → api_resources}/source_files.rb +68 -130
- 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/string_comments.rb +68 -0
- data/lib/crowdin-api/api_resources/string_translations.rb +193 -0
- data/lib/crowdin-api/api_resources/tasks.rb +102 -0
- data/lib/crowdin-api/api_resources/teams.rb +135 -0
- data/lib/crowdin-api/api_resources/translation_memory.rb +131 -0
- data/lib/crowdin-api/{api-resources → api_resources}/translation_status.rb +24 -30
- data/lib/crowdin-api/{api-resources → api_resources}/translations.rb +41 -59
- 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/webhooks.rb +68 -0
- data/lib/crowdin-api/api_resources/workflows.rb +59 -0
- data/lib/crowdin-api/client/client.rb +72 -50
- data/lib/crowdin-api/client/configuration.rb +16 -12
- data/lib/crowdin-api/client/version.rb +1 -1
- data/lib/crowdin-api/core/errors.rb +2 -1
- data/lib/crowdin-api/core/{api_errors_raiser.rb → errors_raisers.rb} +21 -11
- data/lib/crowdin-api/core/request.rb +53 -88
- data/lib/crowdin-api/core/send_request.rb +67 -0
- data/lib/crowdin-api.rb +20 -11
- 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 +13 -0
- data/spec/api_resources/source_strings_spec.rb +51 -0
- data/spec/api_resources/storages_spec.rb +13 -0
- data/spec/api_resources/string_comments_spec.rb +13 -0
- data/spec/api_resources/string_translations_spec.rb +13 -0
- data/spec/api_resources/tasks_spec.rb +79 -0
- data/spec/api_resources/teams_spec.rb +13 -0
- data/spec/api_resources/translation_memory_spec.rb +13 -0
- data/spec/api_resources/translation_status_spec.rb +15 -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 +20 -2
- data/spec/unit/client_spec.rb +85 -0
- metadata +65 -28
- data/bin/setup +0 -6
- data/lib/crowdin-api/api-resources/languages.rb +0 -81
- data/lib/crowdin-api/api-resources/projects.rb +0 -134
- data/lib/crowdin-api/api-resources/storages.rb +0 -102
- data/lib/crowdin-api/api-resources/workflows.rb +0 -59
- data/spec/core/config-instance_spec.rb +0 -72
- data/spec/crowdin-api_spec.rb +0 -7
@@ -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,13 @@
|
|
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
|
+
end
|
13
|
+
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
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe Crowdin::ApiResources::Storages do
|
4
|
+
describe 'Default endpoints' do
|
5
|
+
describe '#list_storages' do
|
6
|
+
it 'when request are valid', :default do
|
7
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/storages")
|
8
|
+
list_storages = @crowdin.list_storages
|
9
|
+
expect(list_storages).to eq(200)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe Crowdin::ApiResources::StringComments do
|
4
|
+
describe 'Default endpoints' do
|
5
|
+
describe '#list_string_comments' do
|
6
|
+
it 'when request are valid', :default do
|
7
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/comments")
|
8
|
+
list_string_comments = @crowdin.list_string_comments({}, project_id)
|
9
|
+
expect(list_string_comments).to eq(200)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe Crowdin::ApiResources::StringTranslations do
|
4
|
+
describe 'Default endpoints' do
|
5
|
+
describe '#list_translation_approvals' do
|
6
|
+
it 'when request are valid', :default do
|
7
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/approvals")
|
8
|
+
list_translation_approvals = @crowdin.list_translation_approvals({}, project_id)
|
9
|
+
expect(list_translation_approvals).to eq(200)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe Crowdin::ApiResources::Tasks do
|
4
|
+
describe 'Default endpoints' do
|
5
|
+
describe '#list_tasks' do
|
6
|
+
it 'when request are valid', :default do
|
7
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/tasks")
|
8
|
+
list_tasks = @crowdin.list_tasks({}, project_id)
|
9
|
+
expect(list_tasks).to eq(200)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#add_task' do
|
14
|
+
it 'when request are valid', :default do
|
15
|
+
stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/tasks")
|
16
|
+
add_task = @crowdin.add_task({}, project_id)
|
17
|
+
expect(add_task).to eq(200)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#export_task_strings' do
|
22
|
+
let(:task_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}/tasks/#{task_id}/exports")
|
26
|
+
export_task_strings = @crowdin.export_task_strings(task_id, nil, project_id)
|
27
|
+
expect(export_task_strings).to eq(200)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#get_task' do
|
32
|
+
let(:task_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}/tasks/#{task_id}")
|
36
|
+
get_task = @crowdin.get_task(task_id, project_id)
|
37
|
+
expect(get_task).to eq(200)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#delete_task' do
|
42
|
+
let(:task_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}/tasks/#{task_id}")
|
46
|
+
delete_task = @crowdin.delete_task(task_id, project_id)
|
47
|
+
expect(delete_task).to eq(200)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '#edit_task' do
|
52
|
+
let(:task_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}/tasks/#{task_id}")
|
56
|
+
edit_task = @crowdin.edit_task(task_id, {}, project_id)
|
57
|
+
expect(edit_task).to eq(200)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe '#list_user_tasks' do
|
62
|
+
it 'when request are valid', :default do
|
63
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/user/tasks")
|
64
|
+
list_user_tasks = @crowdin.list_user_tasks({})
|
65
|
+
expect(list_user_tasks).to eq(200)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe '#edit_task_archived_status' do
|
70
|
+
let(:task_id) { 1 }
|
71
|
+
|
72
|
+
it 'when request are valid', :default do
|
73
|
+
stub_request(:patch, "https://api.crowdin.com/#{target_api_url}/user/tasks/#{task_id}")
|
74
|
+
edit_task_archived_status = @crowdin.edit_task_archived_status(task_id, {})
|
75
|
+
expect(edit_task_archived_status).to eq(200)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe Crowdin::ApiResources::Teams do
|
4
|
+
describe 'Enterprise endpoints' do
|
5
|
+
describe '#add_team_to_project' do
|
6
|
+
it 'when request are valid', :enterprise do
|
7
|
+
stub_request(:post, "https://domain.api.crowdin.com/#{target_api_url}/projects/#{project_id}/teams")
|
8
|
+
add_team_to_project = @crowdin.add_team_to_project({}, project_id)
|
9
|
+
expect(add_team_to_project).to eq(200)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe Crowdin::ApiResources::TranslationMemory do
|
4
|
+
describe 'Default endpoints' do
|
5
|
+
describe '#list_tms' do
|
6
|
+
it 'when request are valid', :default do
|
7
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/tms")
|
8
|
+
list_tms = @crowdin.list_tms
|
9
|
+
expect(list_tms).to eq(200)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe Crowdin::ApiResources::TranslationStatus do
|
4
|
+
describe 'Default endpoints' do
|
5
|
+
describe '#get_branch_progress' do
|
6
|
+
let(:branch_id) { 1 }
|
7
|
+
|
8
|
+
it 'when request are valid', :default do
|
9
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/branches/#{branch_id}/languages/progress")
|
10
|
+
get_branch_progress = @crowdin.get_branch_progress(branch_id, {}, project_id)
|
11
|
+
expect(get_branch_progress).to eq(200)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe Crowdin::ApiResources::Translations do
|
4
|
+
describe 'Default endpoints' do
|
5
|
+
describe '#pre_translation_status' do
|
6
|
+
let(:pre_translation_id) { 1 }
|
7
|
+
|
8
|
+
it 'when request are valid', :default do
|
9
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/pre-translations/#{pre_translation_id}")
|
10
|
+
pre_translation_status = @crowdin.pre_translation_status(pre_translation_id, project_id)
|
11
|
+
expect(pre_translation_status).to eq(200)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#apply_pre_translation' do
|
16
|
+
it 'when request are valid', :default do
|
17
|
+
stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/pre-translations")
|
18
|
+
apply_pre_translation = @crowdin.apply_pre_translation({}, project_id)
|
19
|
+
expect(apply_pre_translation).to eq(200)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#build_project_directory_translation' do
|
24
|
+
let(:directory_id) { 1 }
|
25
|
+
|
26
|
+
it 'when request are valid', :default do
|
27
|
+
stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/translations/builds/directories/#{directory_id}")
|
28
|
+
build_project_directory_translation = @crowdin.build_project_directory_translation(directory_id, {}, project_id)
|
29
|
+
expect(build_project_directory_translation).to eq(200)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
describe '#build_project_file_translation' do
|
34
|
+
let(:file_id) { 1 }
|
35
|
+
|
36
|
+
it 'when request are valid', :default do
|
37
|
+
stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/translations/builds/files/#{file_id}")
|
38
|
+
build_project_file_translation = @crowdin.build_project_file_translation(file_id, {}, nil, project_id)
|
39
|
+
expect(build_project_file_translation).to eq(200)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe '#list_project_builds' do
|
44
|
+
it 'when request are valid', :default do
|
45
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/translations/builds")
|
46
|
+
list_project_builds = @crowdin.list_project_builds({}, project_id)
|
47
|
+
expect(list_project_builds).to eq(200)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '#build_project_translation' do
|
52
|
+
it 'when request are valid', :default do
|
53
|
+
stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/translations/builds")
|
54
|
+
build_project_translation = @crowdin.build_project_translation({}, project_id)
|
55
|
+
expect(build_project_translation).to eq(200)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe '#upload_translations' do
|
60
|
+
let(:language_id) { 1 }
|
61
|
+
|
62
|
+
it 'when request are valid', :default do
|
63
|
+
stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/translations/#{language_id}")
|
64
|
+
upload_translations = @crowdin.upload_translations(language_id, {}, project_id)
|
65
|
+
expect(upload_translations).to eq(200)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
describe '#download_project_translations' do
|
70
|
+
let(:build_id) { 1 }
|
71
|
+
|
72
|
+
it 'when request are valid', :default do
|
73
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/translations/builds/#{build_id}/download")
|
74
|
+
download_project_translations = @crowdin.download_project_translations(build_id, nil, project_id)
|
75
|
+
expect(download_project_translations).to eq(200)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe '#check_project_build_status' do
|
80
|
+
let(:build_id) { 1 }
|
81
|
+
|
82
|
+
it 'when request are valid', :default do
|
83
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/translations/builds/#{build_id}")
|
84
|
+
check_project_build_status = @crowdin.check_project_build_status(build_id, project_id)
|
85
|
+
expect(check_project_build_status).to eq(200)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
describe '#cancel_build' do
|
90
|
+
let(:build_id) { 1 }
|
91
|
+
|
92
|
+
it 'when request are valid', :default do
|
93
|
+
stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/translations/builds/#{build_id}")
|
94
|
+
cancel_build = @crowdin.cancel_build(build_id, project_id)
|
95
|
+
expect(cancel_build).to eq(200)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
describe '#export_project_translation' do
|
100
|
+
it 'when request are valid', :default do
|
101
|
+
stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/translations/exports")
|
102
|
+
export_project_translation = @crowdin.export_project_translation({}, nil, project_id)
|
103
|
+
expect(export_project_translation).to eq(200)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe Crowdin::ApiResources::Users do
|
4
|
+
describe 'Default endpoints' do
|
5
|
+
describe '#get_authenticated_user' do
|
6
|
+
it 'when request are valid', :default do
|
7
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/user")
|
8
|
+
get_authenticated_user = @crowdin.get_authenticated_user
|
9
|
+
expect(get_authenticated_user).to eq(200)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#list_project_members' do
|
14
|
+
it 'when request are valid', :default do
|
15
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/members")
|
16
|
+
list_project_members = @crowdin.list_project_members({}, project_id)
|
17
|
+
expect(list_project_members).to eq(200)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#get_member_info' do
|
22
|
+
let(:member_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}/members/#{member_id}")
|
26
|
+
get_member_info = @crowdin.get_member_info(member_id, project_id)
|
27
|
+
expect(get_member_info).to eq(200)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe 'Enterprise endpoints' do
|
33
|
+
describe '#add_project_member' do
|
34
|
+
it 'when request are valid', :enterprise do
|
35
|
+
stub_request(:post, "https://domain.api.crowdin.com/#{target_api_url}/projects/#{project_id}/members")
|
36
|
+
add_project_member = @crowdin.add_project_member({}, project_id)
|
37
|
+
expect(add_project_member).to eq(200)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#get_project_member_permissions' do
|
42
|
+
let(:member_id) { 1 }
|
43
|
+
|
44
|
+
it 'when request are valid', :enterprise do
|
45
|
+
stub_request(:get, "https://domain.api.crowdin.com/#{target_api_url}/projects/#{project_id}/members/#{member_id}")
|
46
|
+
get_project_member_permissions = @crowdin.get_project_member_permissions(member_id, project_id)
|
47
|
+
expect(get_project_member_permissions).to eq(200)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '#replace_project_permissions' do
|
52
|
+
let(:member_id) { 1 }
|
53
|
+
|
54
|
+
it 'when request are valid', :enterprise do
|
55
|
+
stub_request(:put, "https://domain.api.crowdin.com/#{target_api_url}/projects/#{project_id}/members/#{member_id}")
|
56
|
+
replace_project_permissions = @crowdin.replace_project_permissions(member_id, {}, project_id)
|
57
|
+
expect(replace_project_permissions).to eq(200)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe '#delete_member_from_project' do
|
62
|
+
let(:member_id) { 1 }
|
63
|
+
|
64
|
+
it 'when request are valid', :enterprise do
|
65
|
+
stub_request(:delete, "https://domain.api.crowdin.com/#{target_api_url}/projects/#{project_id}/members/#{member_id}")
|
66
|
+
delete_member_from_project = @crowdin.delete_member_from_project(member_id, {}, project_id)
|
67
|
+
expect(delete_member_from_project).to eq(200)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe '#list_users' do
|
72
|
+
it 'when request are valid', :enterprise do
|
73
|
+
stub_request(:get, "https://domain.api.crowdin.com/#{target_api_url}/users")
|
74
|
+
list_users = @crowdin.list_users
|
75
|
+
expect(list_users).to eq(200)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe '#invite_user' do
|
80
|
+
it 'when request are valid', :enterprise do
|
81
|
+
stub_request(:post, "https://domain.api.crowdin.com/#{target_api_url}/users")
|
82
|
+
invite_user = @crowdin.invite_user
|
83
|
+
expect(invite_user).to eq(200)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
describe '#get_user' do
|
88
|
+
let(:user_id) { 1 }
|
89
|
+
|
90
|
+
it 'when request are valid', :enterprise do
|
91
|
+
stub_request(:get, "https://domain.api.crowdin.com/#{target_api_url}/users/#{user_id}")
|
92
|
+
get_user = @crowdin.get_user(user_id)
|
93
|
+
expect(get_user).to eq(200)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
describe '#delete_user' do
|
98
|
+
let(:user_id) { 1 }
|
99
|
+
|
100
|
+
it 'when request are valid', :enterprise do
|
101
|
+
stub_request(:delete, "https://domain.api.crowdin.com/#{target_api_url}/users/#{user_id}")
|
102
|
+
delete_user = @crowdin.delete_user(user_id)
|
103
|
+
expect(delete_user).to eq(200)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
describe '#edit_user' do
|
108
|
+
let(:user_id) { 1 }
|
109
|
+
|
110
|
+
it 'when request are valid', :enterprise do
|
111
|
+
stub_request(:patch, "https://domain.api.crowdin.com/#{target_api_url}/users/#{user_id}")
|
112
|
+
edit_user = @crowdin.edit_user(user_id)
|
113
|
+
expect(edit_user).to eq(200)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe Crowdin::ApiResources::Vendors do
|
4
|
+
describe 'Enterprise endpoints' do
|
5
|
+
describe '#list_vendors' do
|
6
|
+
it 'when request are valid', :enterprise do
|
7
|
+
stub_request(:get, "https://domain.api.crowdin.com/#{target_api_url}/vendors")
|
8
|
+
list_vendors = @crowdin.list_vendors
|
9
|
+
expect(list_vendors).to eq(200)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe Crowdin::ApiResources::Webhooks do
|
4
|
+
describe 'Default endpoints' do
|
5
|
+
describe '#list_webhooks' do
|
6
|
+
it 'when request are valid', :default do
|
7
|
+
stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/webhooks")
|
8
|
+
list_webhooks = @crowdin.list_webhooks({}, project_id)
|
9
|
+
expect(list_webhooks).to eq(200)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#add_webhook' do
|
14
|
+
it 'when request are valid', :default do
|
15
|
+
stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/webhooks")
|
16
|
+
add_webhook = @crowdin.add_webhook({}, project_id)
|
17
|
+
expect(add_webhook).to eq(200)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#get_webhook' do
|
22
|
+
let(:webhook_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}/webhooks/#{webhook_id}")
|
26
|
+
get_webhook = @crowdin.get_webhook(webhook_id, project_id)
|
27
|
+
expect(get_webhook).to eq(200)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#delete_webhook' do
|
32
|
+
let(:webhook_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}/webhooks/#{webhook_id}")
|
36
|
+
delete_webhook = @crowdin.delete_webhook(webhook_id, project_id)
|
37
|
+
expect(delete_webhook).to eq(200)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#edit_webhook' do
|
42
|
+
let(:webhook_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}/webhooks/#{webhook_id}")
|
46
|
+
edit_webhook = @crowdin.edit_webhook(webhook_id, {}, project_id)
|
47
|
+
expect(edit_webhook).to eq(200)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|