crowdin-api 1.2.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_todo.yml +102 -43
  3. data/README.md +37 -6
  4. data/bin/crowdin-console +1 -1
  5. data/crowdin-api.gemspec +1 -2
  6. data/lib/crowdin-api/api_resources/bundles.rb +81 -0
  7. data/lib/crowdin-api/{api-resources → api_resources}/dictionaries.rb +8 -10
  8. data/lib/crowdin-api/{api-resources → api_resources}/distributions.rb +25 -32
  9. data/lib/crowdin-api/{api-resources → api_resources}/glossaries.rb +64 -82
  10. data/lib/crowdin-api/{api-resources → api_resources}/labels.rb +28 -47
  11. data/lib/crowdin-api/api_resources/languages.rb +61 -0
  12. data/lib/crowdin-api/api_resources/machine_translation_engines.rb +79 -0
  13. data/lib/crowdin-api/api_resources/projects.rb +124 -0
  14. data/lib/crowdin-api/api_resources/reports.rb +120 -0
  15. data/lib/crowdin-api/{api-resources → api_resources}/screenshots.rb +47 -61
  16. data/lib/crowdin-api/{api-resources → api_resources}/source_files.rb +68 -131
  17. data/lib/crowdin-api/{api-resources → api_resources}/source_strings.rb +19 -24
  18. data/lib/crowdin-api/api_resources/storages.rb +54 -0
  19. data/lib/crowdin-api/{api-resources → api_resources}/string_comments.rb +18 -23
  20. data/lib/crowdin-api/{api-resources → api_resources}/string_translations.rb +64 -91
  21. data/lib/crowdin-api/{api-resources → api_resources}/tasks.rb +30 -41
  22. data/lib/crowdin-api/api_resources/teams.rb +135 -0
  23. data/lib/crowdin-api/{api-resources → api_resources}/translation_memory.rb +38 -52
  24. data/lib/crowdin-api/{api-resources → api_resources}/translation_status.rb +24 -30
  25. data/lib/crowdin-api/{api-resources → api_resources}/translations.rb +41 -58
  26. data/lib/crowdin-api/api_resources/users.rb +161 -0
  27. data/lib/crowdin-api/api_resources/vendors.rb +21 -0
  28. data/lib/crowdin-api/{api-resources → api_resources}/webhooks.rb +19 -24
  29. data/lib/crowdin-api/api_resources/workflows.rb +59 -0
  30. data/lib/crowdin-api/client/client.rb +134 -39
  31. data/lib/crowdin-api/client/configuration.rb +12 -12
  32. data/lib/crowdin-api/client/version.rb +1 -1
  33. data/lib/crowdin-api/core/errors.rb +1 -0
  34. data/lib/crowdin-api/core/errors_raisers.rb +1 -1
  35. data/lib/crowdin-api/core/fetch_all_extensions.rb +14 -0
  36. data/lib/crowdin-api/core/request.rb +50 -90
  37. data/lib/crowdin-api/core/send_request.rb +67 -0
  38. data/lib/crowdin-api.rb +18 -24
  39. data/spec/api_resources/bundles_spec.rb +61 -0
  40. data/spec/api_resources/dictionaries_spec.rb +23 -0
  41. data/spec/api_resources/distributions_spec.rb +71 -0
  42. data/spec/api_resources/glossaries_spec.rb +167 -0
  43. data/spec/api_resources/labels_spec.rb +71 -0
  44. data/spec/api_resources/languages_spec.rb +51 -0
  45. data/spec/api_resources/machine_translation_engines_spec.rb +63 -0
  46. data/spec/api_resources/projects_spec.rb +215 -0
  47. data/spec/api_resources/reports_spec.rb +95 -0
  48. data/spec/api_resources/screenshots_spec.rb +134 -0
  49. data/spec/api_resources/source_files_spec.rb +184 -0
  50. data/spec/api_resources/source_strings_spec.rb +51 -0
  51. data/spec/api_resources/storages_spec.rb +41 -0
  52. data/spec/api_resources/string_comments_spec.rb +51 -0
  53. data/spec/api_resources/string_translations_spec.rb +141 -0
  54. data/spec/api_resources/tasks_spec.rb +79 -0
  55. data/spec/api_resources/teams_spec.rb +100 -0
  56. data/spec/api_resources/translation_memory_spec.rb +114 -0
  57. data/spec/api_resources/translation_status_spec.rb +61 -0
  58. data/spec/api_resources/translations_spec.rb +107 -0
  59. data/spec/api_resources/users_spec.rb +117 -0
  60. data/spec/api_resources/vendors_spec.rb +13 -0
  61. data/spec/api_resources/webhooks_spec.rb +51 -0
  62. data/spec/api_resources/workflows_spec.rb +41 -0
  63. data/spec/spec_helper.rb +23 -2
  64. data/spec/unit/client_spec.rb +85 -0
  65. metadata +67 -43
  66. data/bin/setup +0 -6
  67. data/lib/crowdin-api/api-resources/languages.rb +0 -82
  68. data/lib/crowdin-api/api-resources/machine_translation_engines.rb +0 -74
  69. data/lib/crowdin-api/api-resources/projects.rb +0 -148
  70. data/lib/crowdin-api/api-resources/reports.rb +0 -138
  71. data/lib/crowdin-api/api-resources/storages.rb +0 -106
  72. data/lib/crowdin-api/api-resources/teams.rb +0 -144
  73. data/lib/crowdin-api/api-resources/users.rb +0 -129
  74. data/lib/crowdin-api/api-resources/vendors.rb +0 -21
  75. data/lib/crowdin-api/api-resources/workflows.rb +0 -62
  76. data/lib/crowdin-api/core/utils.rb +0 -10
  77. data/spec/client/client-instance_spec.rb +0 -14
  78. data/spec/client/configuration-instance_spec.rb +0 -72
data/lib/crowdin-api.rb CHANGED
@@ -1,5 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ module Crowdin
4
+ # API Resources modules
5
+ API_RESOURCES_MODULES = %i[Storages Languages Projects Workflows SourceFiles Translations SourceStrings
6
+ StringTranslations StringComments Screenshots Glossaries TranslationMemory
7
+ MachineTranslationEngines Reports Tasks Users Teams Vendors Webhooks
8
+ Dictionaries Distributions Labels TranslationStatus Bundles].freeze
9
+
10
+ # Error Raisers modules
11
+ ERROR_RAISERS_MODULES = %i[ApiErrorsRaiser ClientErrorsRaiser].freeze
12
+ end
13
+
3
14
  # Libs
4
15
  require 'json'
5
16
  require 'open-uri'
@@ -9,32 +20,15 @@ require 'rest-client'
9
20
  require 'crowdin-api/core/errors'
10
21
  require 'crowdin-api/core/errors_raisers'
11
22
  require 'crowdin-api/core/request'
12
- require 'crowdin-api/core/utils'
23
+ require 'crowdin-api/core/send_request'
24
+ require 'crowdin-api/core/fetch_all_extensions'
13
25
 
14
26
  # API modules
15
- require 'crowdin-api/api-resources/storages'
16
- require 'crowdin-api/api-resources/languages'
17
- require 'crowdin-api/api-resources/projects'
18
- require 'crowdin-api/api-resources/workflows'
19
- require 'crowdin-api/api-resources/source_files'
20
- require 'crowdin-api/api-resources/translations'
21
- require 'crowdin-api/api-resources/source_strings'
22
- require 'crowdin-api/api-resources/string_translations'
23
- require 'crowdin-api/api-resources/string_comments'
24
- require 'crowdin-api/api-resources/screenshots'
25
- require 'crowdin-api/api-resources/glossaries'
26
- require 'crowdin-api/api-resources/translation_memory'
27
- require 'crowdin-api/api-resources/machine_translation_engines'
28
- require 'crowdin-api/api-resources/reports'
29
- require 'crowdin-api/api-resources/tasks'
30
- require 'crowdin-api/api-resources/users'
31
- require 'crowdin-api/api-resources/teams'
32
- require 'crowdin-api/api-resources/vendors'
33
- require 'crowdin-api/api-resources/webhooks'
34
- require 'crowdin-api/api-resources/dictionaries'
35
- require 'crowdin-api/api-resources/distributions'
36
- require 'crowdin-api/api-resources/labels'
37
- require 'crowdin-api/api-resources/translation_status'
27
+ Crowdin::API_RESOURCES_MODULES.each do |api_resource|
28
+ require "crowdin-api/api_resources/#{api_resource.to_s.gsub(/([a-z\d])([A-Z])/, '\1_\2').downcase}"
29
+ rescue LoadError
30
+ # Ignored
31
+ end
38
32
 
39
33
  # Client modules
40
34
  require 'crowdin-api/client/version'
@@ -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({}, 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,167 @@
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
+ end
167
+ 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