crowdin-api 1.1.1 → 1.5.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.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/docs.yml +31 -0
  3. data/.github/workflows/test-and-lint.yml +1 -1
  4. data/.gitignore +2 -2
  5. data/.rubocop_todo.yml +114 -48
  6. data/Gemfile +3 -0
  7. data/README.md +61 -17
  8. data/bin/crowdin-console +5 -5
  9. data/crowdin-api.gemspec +1 -2
  10. data/lib/crowdin-api/api_resources/bundles.rb +104 -0
  11. data/lib/crowdin-api/api_resources/dictionaries.rb +32 -0
  12. data/lib/crowdin-api/api_resources/distributions.rb +92 -0
  13. data/lib/crowdin-api/api_resources/glossaries.rb +248 -0
  14. data/lib/crowdin-api/api_resources/labels.rb +98 -0
  15. data/lib/crowdin-api/api_resources/languages.rb +61 -0
  16. data/lib/crowdin-api/api_resources/machine_translation_engines.rb +79 -0
  17. data/lib/crowdin-api/api_resources/projects.rb +151 -0
  18. data/lib/crowdin-api/api_resources/reports.rb +184 -0
  19. data/lib/crowdin-api/api_resources/screenshots.rb +172 -0
  20. data/lib/crowdin-api/api_resources/source_files.rb +305 -0
  21. data/lib/crowdin-api/{api-resources → api_resources}/source_strings.rb +19 -24
  22. data/lib/crowdin-api/api_resources/storages.rb +66 -0
  23. data/lib/crowdin-api/api_resources/string_comments.rb +68 -0
  24. data/lib/crowdin-api/api_resources/string_translations.rb +193 -0
  25. data/lib/crowdin-api/api_resources/tasks.rb +102 -0
  26. data/lib/crowdin-api/api_resources/teams.rb +135 -0
  27. data/lib/crowdin-api/api_resources/translation_memory.rb +131 -0
  28. data/lib/crowdin-api/{api-resources → api_resources}/translation_status.rb +24 -30
  29. data/lib/crowdin-api/{api-resources → api_resources}/translations.rb +41 -59
  30. data/lib/crowdin-api/api_resources/users.rb +161 -0
  31. data/lib/crowdin-api/api_resources/vendors.rb +21 -0
  32. data/lib/crowdin-api/api_resources/webhooks.rb +68 -0
  33. data/lib/crowdin-api/api_resources/workflows.rb +59 -0
  34. data/lib/crowdin-api/client/client.rb +155 -47
  35. data/lib/crowdin-api/client/configuration.rb +16 -12
  36. data/lib/crowdin-api/client/version.rb +1 -1
  37. data/lib/crowdin-api/core/errors.rb +3 -1
  38. data/lib/crowdin-api/core/{api_errors_raiser.rb → errors_raisers.rb} +21 -11
  39. data/lib/crowdin-api/core/fetch_all_extensions.rb +9 -0
  40. data/lib/crowdin-api/core/request.rb +50 -90
  41. data/lib/crowdin-api/core/send_request.rb +67 -0
  42. data/lib/crowdin-api.rb +21 -11
  43. data/spec/api_resources/bundles_spec.rb +61 -0
  44. data/spec/api_resources/dictionaries_spec.rb +23 -0
  45. data/spec/api_resources/distributions_spec.rb +71 -0
  46. data/spec/api_resources/glossaries_spec.rb +210 -0
  47. data/spec/api_resources/labels_spec.rb +71 -0
  48. data/spec/api_resources/languages_spec.rb +51 -0
  49. data/spec/api_resources/machine_translation_engines_spec.rb +63 -0
  50. data/spec/api_resources/projects_spec.rb +215 -0
  51. data/spec/api_resources/reports_spec.rb +145 -0
  52. data/spec/api_resources/screenshots_spec.rb +134 -0
  53. data/spec/api_resources/source_files_spec.rb +184 -0
  54. data/spec/api_resources/source_strings_spec.rb +51 -0
  55. data/spec/api_resources/storages_spec.rb +41 -0
  56. data/spec/api_resources/string_comments_spec.rb +51 -0
  57. data/spec/api_resources/string_translations_spec.rb +141 -0
  58. data/spec/api_resources/tasks_spec.rb +79 -0
  59. data/spec/api_resources/teams_spec.rb +100 -0
  60. data/spec/api_resources/translation_memory_spec.rb +114 -0
  61. data/spec/api_resources/translation_status_spec.rb +61 -0
  62. data/spec/api_resources/translations_spec.rb +107 -0
  63. data/spec/api_resources/users_spec.rb +117 -0
  64. data/spec/api_resources/vendors_spec.rb +13 -0
  65. data/spec/api_resources/webhooks_spec.rb +51 -0
  66. data/spec/api_resources/workflows_spec.rb +41 -0
  67. data/spec/spec_helper.rb +23 -2
  68. data/spec/unit/client_spec.rb +91 -0
  69. metadata +69 -28
  70. data/bin/setup +0 -6
  71. data/lib/crowdin-api/api-resources/languages.rb +0 -81
  72. data/lib/crowdin-api/api-resources/projects.rb +0 -134
  73. data/lib/crowdin-api/api-resources/source_files.rb +0 -303
  74. data/lib/crowdin-api/api-resources/storages.rb +0 -102
  75. data/lib/crowdin-api/api-resources/workflows.rb +0 -59
  76. data/spec/core/config-instance_spec.rb +0 -72
  77. data/spec/crowdin-api_spec.rb +0 -7
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe Crowdin::ApiResources::Bundles do
4
+ describe 'Default endpoints' do
5
+ describe '#list_bundles' do
6
+ it 'when request are valid', :default do
7
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/bundles")
8
+ list_bundles = @crowdin.list_bundles({}, project_id)
9
+ expect(list_bundles).to eq(200)
10
+ end
11
+ end
12
+
13
+ describe '#add_bundle' do
14
+ it 'when request are valid', :default do
15
+ stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/bundles")
16
+ add_bundle = @crowdin.add_bundle({ name: '', format: '', sourcePatterns: [], exportPattern: '' }, project_id)
17
+ expect(add_bundle).to eq(200)
18
+ end
19
+ end
20
+
21
+ describe '#get_bundle' do
22
+ let(:bundle_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}/bundles/#{bundle_id}")
26
+ get_bundle = @crowdin.get_bundle(bundle_id, project_id)
27
+ expect(get_bundle).to eq(200)
28
+ end
29
+ end
30
+
31
+ describe '#delete_bundle' do
32
+ let(:bundle_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}/bundles/#{bundle_id}")
36
+ delete_bundle = @crowdin.delete_bundle(bundle_id, project_id)
37
+ expect(delete_bundle).to eq(200)
38
+ end
39
+ end
40
+
41
+ describe '#edit_bundle' do
42
+ let(:bundle_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}/bundles/#{bundle_id}")
46
+ edit_bundle = @crowdin.edit_bundle(bundle_id, {}, project_id)
47
+ expect(edit_bundle).to eq(200)
48
+ end
49
+ end
50
+
51
+ describe '#bundle_list_files' do
52
+ let(:bundle_id) { 1 }
53
+
54
+ it 'when request are valid', :default do
55
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/bundles/#{bundle_id}/files")
56
+ bundle_list_files = @crowdin.bundle_list_files(bundle_id, {}, project_id)
57
+ expect(bundle_list_files).to eq(200)
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe Crowdin::ApiResources::Dictionaries do
4
+ describe 'Default endpoints' do
5
+ describe '#list_dictionaries' do
6
+ it 'when request are valid', :default do
7
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/dictionaries")
8
+ list_dictionaries = @crowdin.list_dictionaries({}, project_id)
9
+ expect(list_dictionaries).to eq(200)
10
+ end
11
+ end
12
+
13
+ describe '#edit_dictionary' do
14
+ let(:language_id) { 1 }
15
+
16
+ it 'when request are valid', :default do
17
+ stub_request(:patch, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/dictionaries/#{language_id}")
18
+ edit_dictionary = @crowdin.edit_dictionary(language_id, {}, project_id)
19
+ expect(edit_dictionary).to eq(200)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe Crowdin::ApiResources::Distributions do
4
+ describe 'Default endpoints' do
5
+ describe '#list_distributions' do
6
+ it 'when request are valid', :default do
7
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/distributions")
8
+ list_distributions = @crowdin.list_distributions({}, project_id)
9
+ expect(list_distributions).to eq(200)
10
+ end
11
+ end
12
+
13
+ describe '#add_distribution' do
14
+ it 'when request are valid', :default do
15
+ stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/distributions")
16
+ add_distribution = @crowdin.add_distribution({}, project_id)
17
+ expect(add_distribution).to eq(200)
18
+ end
19
+ end
20
+
21
+ describe '#get_distribution' do
22
+ let(:hash) { 1 }
23
+
24
+ it 'when request are valid', :default do
25
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/distributions/#{hash}")
26
+ get_distribution = @crowdin.get_distribution(hash, project_id)
27
+ expect(get_distribution).to eq(200)
28
+ end
29
+ end
30
+
31
+ describe '#delete_distribution' do
32
+ let(:hash) { 1 }
33
+
34
+ it 'when request are valid', :default do
35
+ stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/distributions/#{hash}")
36
+ delete_distribution = @crowdin.delete_distribution(hash, project_id)
37
+ expect(delete_distribution).to eq(200)
38
+ end
39
+ end
40
+
41
+ describe '#edit_distribution' do
42
+ let(:hash) { 1 }
43
+
44
+ it 'when request are valid', :default do
45
+ stub_request(:patch, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/distributions/#{hash}")
46
+ edit_distribution = @crowdin.edit_distribution(hash, {}, project_id)
47
+ expect(edit_distribution).to eq(200)
48
+ end
49
+ end
50
+
51
+ describe '#get_distribution_release' do
52
+ let(:hash) { 1 }
53
+
54
+ it 'when request are valid', :default do
55
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/distributions/#{hash}/release")
56
+ get_distribution_release = @crowdin.get_distribution_release(hash, project_id)
57
+ expect(get_distribution_release).to eq(200)
58
+ end
59
+ end
60
+
61
+ describe '#release_distribution' do
62
+ let(:hash) { 1 }
63
+
64
+ it 'when request are valid', :default do
65
+ stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/distributions/#{hash}/release")
66
+ release_distribution = @crowdin.release_distribution(hash, project_id)
67
+ expect(release_distribution).to eq(200)
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,210 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe Crowdin::ApiResources::Glossaries do
4
+ describe 'Default endpoints' do
5
+ describe '#list_glossaries' do
6
+ it 'when request are valid', :default do
7
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/glossaries")
8
+ list_glossaries = @crowdin.list_glossaries
9
+ expect(list_glossaries).to eq(200)
10
+ end
11
+ end
12
+
13
+ describe '#add_glossary' do
14
+ it 'when request are valid', :default do
15
+ stub_request(:post, "https://api.crowdin.com/#{target_api_url}/glossaries")
16
+ add_glossary = @crowdin.add_glossary
17
+ expect(add_glossary).to eq(200)
18
+ end
19
+ end
20
+
21
+ describe '#get_glossary' do
22
+ let(:glossary_id) { 1 }
23
+
24
+ it 'when request are valid', :default do
25
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/glossaries/#{glossary_id}")
26
+ get_glossary = @crowdin.get_glossary(glossary_id)
27
+ expect(get_glossary).to eq(200)
28
+ end
29
+ end
30
+
31
+ describe '#delete_glossary' do
32
+ let(:glossary_id) { 1 }
33
+
34
+ it 'when request are valid', :default do
35
+ stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/glossaries/#{glossary_id}")
36
+ delete_glossary = @crowdin.delete_glossary(glossary_id)
37
+ expect(delete_glossary).to eq(200)
38
+ end
39
+ end
40
+
41
+ describe '#edit_glossary' do
42
+ let(:glossary_id) { 1 }
43
+
44
+ it 'when request are valid', :default do
45
+ stub_request(:patch, "https://api.crowdin.com/#{target_api_url}/glossaries/#{glossary_id}")
46
+ edit_glossary = @crowdin.edit_glossary(glossary_id)
47
+ expect(edit_glossary).to eq(200)
48
+ end
49
+ end
50
+
51
+ describe '#export_glossary' do
52
+ let(:glossary_id) { 1 }
53
+
54
+ it 'when request are valid', :default do
55
+ stub_request(:post, "https://api.crowdin.com/#{target_api_url}/glossaries/#{glossary_id}/exports")
56
+ export_glossary = @crowdin.export_glossary({}, glossary_id)
57
+ expect(export_glossary).to eq(200)
58
+ end
59
+ end
60
+
61
+ describe '#check_glossary_export_status' do
62
+ let(:glossary_id) { 1 }
63
+ let(:export_id) { 1 }
64
+
65
+ it 'when request are valid', :default do
66
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/glossaries/#{glossary_id}/exports/#{export_id}")
67
+ check_glossary_export_status = @crowdin.check_glossary_export_status(glossary_id, export_id)
68
+ expect(check_glossary_export_status).to eq(200)
69
+ end
70
+ end
71
+
72
+ describe '#download_glossary' do
73
+ let(:glossary_id) { 1 }
74
+ let(:export_id) { 1 }
75
+
76
+ it 'when request are valid', :default do
77
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/glossaries/#{glossary_id}/exports/#{export_id}/download")
78
+ download_glossary = @crowdin.download_glossary(glossary_id, export_id)
79
+ expect(download_glossary).to eq(200)
80
+ end
81
+ end
82
+
83
+ describe '#import_glossary' do
84
+ let(:glossary_id) { 1 }
85
+
86
+ it 'when request are valid', :default do
87
+ stub_request(:post, "https://api.crowdin.com/#{target_api_url}/glossaries/#{glossary_id}/imports")
88
+ import_glossary = @crowdin.import_glossary(glossary_id)
89
+ expect(import_glossary).to eq(200)
90
+ end
91
+ end
92
+
93
+ describe '#check_glossary_import_status' do
94
+ let(:glossary_id) { 1 }
95
+ let(:import_id) { 1 }
96
+
97
+ it 'when request are valid', :default do
98
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/glossaries/#{glossary_id}/imports/#{import_id}")
99
+ check_glossary_import_status = @crowdin.check_glossary_import_status(glossary_id, import_id)
100
+ expect(check_glossary_import_status).to eq(200)
101
+ end
102
+ end
103
+
104
+ describe '#list_terms' do
105
+ let(:glossary_id) { 1 }
106
+
107
+ it 'when request are valid', :default do
108
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/glossaries/#{glossary_id}/terms")
109
+ list_terms = @crowdin.list_terms(glossary_id)
110
+ expect(list_terms).to eq(200)
111
+ end
112
+ end
113
+
114
+ describe '#add_term' do
115
+ let(:glossary_id) { 1 }
116
+
117
+ it 'when request are valid', :default do
118
+ stub_request(:post, "https://api.crowdin.com/#{target_api_url}/glossaries/#{glossary_id}/terms")
119
+ add_term = @crowdin.add_term(glossary_id)
120
+ expect(add_term).to eq(200)
121
+ end
122
+ end
123
+
124
+ describe '#clear_glossary' do
125
+ let(:glossary_id) { 1 }
126
+
127
+ it 'when request are valid', :default do
128
+ stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/glossaries/#{glossary_id}/terms")
129
+ clear_glossary = @crowdin.clear_glossary(glossary_id)
130
+ expect(clear_glossary).to eq(200)
131
+ end
132
+ end
133
+
134
+ describe '#get_term' do
135
+ let(:glossary_id) { 1 }
136
+ let(:term_id) { 1 }
137
+
138
+ it 'when request are valid', :default do
139
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/glossaries/#{glossary_id}/terms/#{term_id}")
140
+ get_term = @crowdin.get_term(glossary_id, term_id)
141
+ expect(get_term).to eq(200)
142
+ end
143
+ end
144
+
145
+ describe '#delete_term' do
146
+ let(:glossary_id) { 1 }
147
+ let(:term_id) { 1 }
148
+
149
+ it 'when request are valid', :default do
150
+ stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/glossaries/#{glossary_id}/terms/#{term_id}")
151
+ delete_term = @crowdin.delete_term(glossary_id, term_id)
152
+ expect(delete_term).to eq(200)
153
+ end
154
+ end
155
+
156
+ describe '#edit_term' do
157
+ let(:glossary_id) { 1 }
158
+ let(:term_id) { 1 }
159
+
160
+ it 'when request are valid', :default do
161
+ stub_request(:patch, "https://api.crowdin.com/#{target_api_url}/glossaries/#{glossary_id}/terms/#{term_id}")
162
+ edit_term = @crowdin.edit_term(glossary_id, term_id)
163
+ expect(edit_term).to eq(200)
164
+ end
165
+ end
166
+
167
+ describe '#list_concepts' do
168
+ let(:glossary_id) { 1 }
169
+
170
+ it 'when request are valid', :default do
171
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/glossaries/#{glossary_id}/concepts")
172
+ concepts = @crowdin.list_concepts(glossary_id)
173
+ expect(concepts).to eq(200)
174
+ end
175
+ end
176
+
177
+ describe '#get_concept' do
178
+ let(:glossary_id) { 1 }
179
+ let(:concept_id) { 1 }
180
+
181
+ it 'when request are valid', :default do
182
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/glossaries/#{glossary_id}/concepts/#{concept_id}")
183
+ concept = @crowdin.get_concept(glossary_id, concept_id)
184
+ expect(concept).to eq(200)
185
+ end
186
+ end
187
+
188
+ describe '#update_concept' do
189
+ let(:glossary_id) { 1 }
190
+ let(:concept_id) { 1 }
191
+
192
+ it 'when request are valid', :default do
193
+ stub_request(:put, "https://api.crowdin.com/#{target_api_url}/glossaries/#{glossary_id}/concepts/#{concept_id}")
194
+ concept = @crowdin.update_concept(glossary_id, concept_id)
195
+ expect(concept).to eq(200)
196
+ end
197
+ end
198
+
199
+ describe '#update_concept' do
200
+ let(:glossary_id) { 1 }
201
+ let(:concept_id) { 1 }
202
+
203
+ it 'when request are valid', :default do
204
+ stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/glossaries/#{glossary_id}/concepts/#{concept_id}")
205
+ concept = @crowdin.delete_concept(glossary_id, concept_id)
206
+ expect(concept).to eq(200)
207
+ end
208
+ end
209
+ end
210
+ end
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe Crowdin::ApiResources::Labels do
4
+ describe 'Default endpoints' do
5
+ describe '#list_labels' do
6
+ it 'when request are valid', :default do
7
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/labels")
8
+ list_labels = @crowdin.list_labels({}, project_id)
9
+ expect(list_labels).to eq(200)
10
+ end
11
+ end
12
+
13
+ describe '#add_label' do
14
+ it 'when request are valid', :default do
15
+ stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/labels")
16
+ add_label = @crowdin.add_label({}, project_id)
17
+ expect(add_label).to eq(200)
18
+ end
19
+ end
20
+
21
+ describe '#get_label' do
22
+ let(:label_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}/labels/#{label_id}")
26
+ get_label = @crowdin.get_label(label_id, project_id)
27
+ expect(get_label).to eq(200)
28
+ end
29
+ end
30
+
31
+ describe '#delete_label' do
32
+ let(:label_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}/labels/#{label_id}")
36
+ delete_label = @crowdin.delete_label(label_id, project_id)
37
+ expect(delete_label).to eq(200)
38
+ end
39
+ end
40
+
41
+ describe '#edit_label' do
42
+ let(:label_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}/labels/#{label_id}")
46
+ edit_label = @crowdin.edit_label(label_id, {}, project_id)
47
+ expect(edit_label).to eq(200)
48
+ end
49
+ end
50
+
51
+ describe '#assign_label_to_strings' do
52
+ let(:label_id) { 1 }
53
+
54
+ it 'when request are valid', :default do
55
+ stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/labels/#{label_id}/strings")
56
+ assign_label_to_strings = @crowdin.assign_label_to_strings(label_id, {}, project_id)
57
+ expect(assign_label_to_strings).to eq(200)
58
+ end
59
+ end
60
+
61
+ describe '#unassign_label_from_strings' do
62
+ let(:label_id) { 1 }
63
+
64
+ it 'when request are valid', :default do
65
+ stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/labels/#{label_id}")
66
+ unassign_label_from_strings = @crowdin.unassign_label_from_strings(label_id, {}, project_id)
67
+ expect(unassign_label_from_strings).to eq(200)
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe Crowdin::ApiResources::Languages do
4
+ describe 'Default endpoints' do
5
+ describe '#list_languages' do
6
+ it 'when request are valid', :default do
7
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/languages")
8
+ list_languages = @crowdin.list_languages
9
+ expect(list_languages).to eq(200)
10
+ end
11
+ end
12
+
13
+ describe '#add_custom_language' do
14
+ it 'when request are valid', :default do
15
+ stub_request(:post, "https://api.crowdin.com/#{target_api_url}/languages")
16
+ add_custom_language = @crowdin.add_custom_language
17
+ expect(add_custom_language).to eq(200)
18
+ end
19
+ end
20
+
21
+ describe '#get_language' do
22
+ let(:language_id) { 1 }
23
+
24
+ it 'when request are valid', :default do
25
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/languages/#{language_id}")
26
+ get_language = @crowdin.get_language(language_id)
27
+ expect(get_language).to eq(200)
28
+ end
29
+ end
30
+
31
+ describe '#delete_custom_language' do
32
+ let(:language_id) { 1 }
33
+
34
+ it 'when request are valid', :default do
35
+ stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/languages/#{language_id}")
36
+ delete_custom_language = @crowdin.delete_custom_language(language_id)
37
+ expect(delete_custom_language).to eq(200)
38
+ end
39
+ end
40
+
41
+ describe '#edit_custom_language' do
42
+ let(:language_id) { 1 }
43
+
44
+ it 'when request are valid', :default do
45
+ stub_request(:patch, "https://api.crowdin.com/#{target_api_url}/languages/#{language_id}")
46
+ edit_custom_language = @crowdin.edit_custom_language(language_id)
47
+ expect(edit_custom_language).to eq(200)
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe Crowdin::ApiResources::MachineTranslationEngines do
4
+ describe 'Default endpoints' do
5
+ describe '#list_mts' do
6
+ it 'when request are valid', :default do
7
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/mts")
8
+ list_mts = @crowdin.list_mts
9
+ expect(list_mts).to eq(200)
10
+ end
11
+ end
12
+
13
+ describe '#get_mt' do
14
+ let(:mt_id) { 1 }
15
+
16
+ it 'when request are valid', :default do
17
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/mts/#{mt_id}")
18
+ get_mt = @crowdin.get_mt(mt_id)
19
+ expect(get_mt).to eq(200)
20
+ end
21
+ end
22
+
23
+ describe '#translate_via_mt' do
24
+ let(:mt_id) { 1 }
25
+
26
+ it 'when request are valid', :default do
27
+ stub_request(:post, "https://api.crowdin.com/#{target_api_url}/mts/#{mt_id}/translations")
28
+ translate_via_mt = @crowdin.translate_via_mt(mt_id)
29
+ expect(translate_via_mt).to eq(200)
30
+ end
31
+ end
32
+ end
33
+
34
+ describe 'Enterprise endpoints' do
35
+ describe '#edit_mt' do
36
+ let(:mt_id) { 1 }
37
+
38
+ it 'when request are valid', :enterprise do
39
+ stub_request(:patch, "https://domain.api.crowdin.com/#{target_api_url}/mts/#{mt_id}")
40
+ edit_mt = @crowdin.edit_mt(mt_id)
41
+ expect(edit_mt).to eq(200)
42
+ end
43
+ end
44
+
45
+ describe '#add_mt' do
46
+ it 'when request are valid', :enterprise do
47
+ stub_request(:post, "https://domain.api.crowdin.com/#{target_api_url}/mts")
48
+ add_mt = @crowdin.add_mt
49
+ expect(add_mt).to eq(200)
50
+ end
51
+ end
52
+
53
+ describe '#delete_mt' do
54
+ let(:mt_id) { 1 }
55
+
56
+ it 'when request are valid', :enterprise do
57
+ stub_request(:delete, "https://domain.api.crowdin.com/#{target_api_url}/mts/#{mt_id}")
58
+ delete_mt = @crowdin.delete_mt(mt_id)
59
+ expect(delete_mt).to eq(200)
60
+ end
61
+ end
62
+ end
63
+ end