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.
- checksums.yaml +4 -4
- data/.github/workflows/docs.yml +31 -0
- data/.github/workflows/test-and-lint.yml +1 -1
- data/.gitignore +2 -2
- data/.rubocop_todo.yml +114 -48
- data/Gemfile +3 -0
- data/README.md +61 -17
- data/bin/crowdin-console +5 -5
- data/crowdin-api.gemspec +1 -2
- data/lib/crowdin-api/api_resources/bundles.rb +104 -0
- 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 +248 -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 +151 -0
- data/lib/crowdin-api/api_resources/reports.rb +184 -0
- data/lib/crowdin-api/api_resources/screenshots.rb +172 -0
- data/lib/crowdin-api/api_resources/source_files.rb +305 -0
- data/lib/crowdin-api/{api-resources → api_resources}/source_strings.rb +19 -24
- data/lib/crowdin-api/api_resources/storages.rb +66 -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 +155 -47
- 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 +3 -1
- data/lib/crowdin-api/core/{api_errors_raiser.rb → errors_raisers.rb} +21 -11
- data/lib/crowdin-api/core/fetch_all_extensions.rb +9 -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 +21 -11
- 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 +210 -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 +145 -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 +91 -0
- metadata +69 -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/source_files.rb +0 -303
- 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,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Crowdin
|
|
4
|
+
module ApiResources
|
|
5
|
+
module Dictionaries
|
|
6
|
+
def list_dictionaries(query = {}, project_id = config.project_id)
|
|
7
|
+
project_id || raise_project_id_is_required_error
|
|
8
|
+
|
|
9
|
+
request = Web::Request.new(
|
|
10
|
+
connection,
|
|
11
|
+
:get,
|
|
12
|
+
"#{config.target_api_url}/projects/#{project_id}/dictionaries",
|
|
13
|
+
{ params: query }
|
|
14
|
+
)
|
|
15
|
+
Web::SendRequest.new(request).perform
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def edit_dictionary(language_id = nil, query = {}, project_id = config.project_id)
|
|
19
|
+
language_id || raise_parameter_is_required_error(:language_id)
|
|
20
|
+
project_id || raise_project_id_is_required_error
|
|
21
|
+
|
|
22
|
+
request = Web::Request.new(
|
|
23
|
+
connection,
|
|
24
|
+
:patch,
|
|
25
|
+
"#{config.target_api_url}/projects/#{project_id}/dictionaries/#{language_id}",
|
|
26
|
+
{ params: query }
|
|
27
|
+
)
|
|
28
|
+
Web::SendRequest.new(request).perform
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Crowdin
|
|
4
|
+
module ApiResources
|
|
5
|
+
module Distributions
|
|
6
|
+
def list_distributions(query = {}, project_id = config.project_id)
|
|
7
|
+
project_id || raise_project_id_is_required_error
|
|
8
|
+
|
|
9
|
+
request = Web::Request.new(
|
|
10
|
+
connection,
|
|
11
|
+
:get,
|
|
12
|
+
"#{config.target_api_url}/projects/#{project_id}/distributions",
|
|
13
|
+
{ params: query }
|
|
14
|
+
)
|
|
15
|
+
Web::SendRequest.new(request).perform
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def add_distribution(query = {}, project_id = config.project_id)
|
|
19
|
+
project_id || raise_project_id_is_required_error
|
|
20
|
+
|
|
21
|
+
request = Web::Request.new(
|
|
22
|
+
connection,
|
|
23
|
+
:post,
|
|
24
|
+
"#{config.target_api_url}/projects/#{project_id}/distributions",
|
|
25
|
+
{ params: query }
|
|
26
|
+
)
|
|
27
|
+
Web::SendRequest.new(request).perform
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def get_distribution(hash = nil, project_id = config.project_id)
|
|
31
|
+
hash || raise_parameter_is_required_error(:hash)
|
|
32
|
+
project_id || raise_project_id_is_required_error
|
|
33
|
+
|
|
34
|
+
request = Web::Request.new(
|
|
35
|
+
connection,
|
|
36
|
+
:get,
|
|
37
|
+
"#{config.target_api_url}/projects/#{project_id}/distributions/#{hash}"
|
|
38
|
+
)
|
|
39
|
+
Web::SendRequest.new(request).perform
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def delete_distribution(hash = nil, project_id = config.project_id)
|
|
43
|
+
hash || raise_parameter_is_required_error(:hash)
|
|
44
|
+
project_id || raise_project_id_is_required_error
|
|
45
|
+
|
|
46
|
+
request = Web::Request.new(
|
|
47
|
+
connection,
|
|
48
|
+
:delete,
|
|
49
|
+
"#{config.target_api_url}/projects/#{project_id}/distributions/#{hash}"
|
|
50
|
+
)
|
|
51
|
+
Web::SendRequest.new(request).perform
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def edit_distribution(hash = nil, query = {}, project_id = config.project_id)
|
|
55
|
+
hash || raise_parameter_is_required_error(:hash)
|
|
56
|
+
project_id || raise_project_id_is_required_error
|
|
57
|
+
|
|
58
|
+
request = Web::Request.new(
|
|
59
|
+
connection,
|
|
60
|
+
:patch,
|
|
61
|
+
"#{config.target_api_url}/projects/#{project_id}/distributions/#{hash}",
|
|
62
|
+
{ params: query }
|
|
63
|
+
)
|
|
64
|
+
Web::SendRequest.new(request).perform
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def get_distribution_release(hash = nil, project_id = config.project_id)
|
|
68
|
+
hash || raise_parameter_is_required_error(:hash)
|
|
69
|
+
project_id || raise_project_id_is_required_error
|
|
70
|
+
|
|
71
|
+
request = Web::Request.new(
|
|
72
|
+
connection,
|
|
73
|
+
:get,
|
|
74
|
+
"#{config.target_api_url}/projects/#{project_id}/distributions/#{hash}/release"
|
|
75
|
+
)
|
|
76
|
+
Web::SendRequest.new(request).perform
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def release_distribution(hash = nil, project_id = config.project_id)
|
|
80
|
+
hash || raise_parameter_is_required_error(:hash)
|
|
81
|
+
project_id || raise_project_id_is_required_error
|
|
82
|
+
|
|
83
|
+
request = Web::Request.new(
|
|
84
|
+
connection,
|
|
85
|
+
:post,
|
|
86
|
+
"#{config.target_api_url}/projects/#{project_id}/distributions/#{hash}/release"
|
|
87
|
+
)
|
|
88
|
+
Web::SendRequest.new(request).perform
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Crowdin
|
|
4
|
+
module ApiResources
|
|
5
|
+
module Glossaries
|
|
6
|
+
def list_glossaries(query = {})
|
|
7
|
+
request = Web::Request.new(
|
|
8
|
+
connection,
|
|
9
|
+
:get,
|
|
10
|
+
"#{config.target_api_url}/glossaries",
|
|
11
|
+
{ params: query }
|
|
12
|
+
)
|
|
13
|
+
Web::SendRequest.new(request).perform
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def add_glossary(query = {})
|
|
17
|
+
request = Web::Request.new(
|
|
18
|
+
connection,
|
|
19
|
+
:post,
|
|
20
|
+
"#{config.target_api_url}/glossaries",
|
|
21
|
+
{ params: query }
|
|
22
|
+
)
|
|
23
|
+
Web::SendRequest.new(request).perform
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def get_glossary(glossary_id = nil, query = {})
|
|
27
|
+
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
|
28
|
+
|
|
29
|
+
request = Web::Request.new(
|
|
30
|
+
connection,
|
|
31
|
+
:get,
|
|
32
|
+
"#{config.target_api_url}/glossaries/#{glossary_id}",
|
|
33
|
+
{ params: query }
|
|
34
|
+
)
|
|
35
|
+
Web::SendRequest.new(request).perform
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def delete_glossary(glossary_id = nil)
|
|
39
|
+
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
|
40
|
+
|
|
41
|
+
request = Web::Request.new(
|
|
42
|
+
connection,
|
|
43
|
+
:delete,
|
|
44
|
+
"#{config.target_api_url}/glossaries/#{glossary_id}"
|
|
45
|
+
)
|
|
46
|
+
Web::SendRequest.new(request).perform
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def edit_glossary(glossary_id = nil, query = {})
|
|
50
|
+
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
|
51
|
+
|
|
52
|
+
request = Web::Request.new(
|
|
53
|
+
connection,
|
|
54
|
+
:patch,
|
|
55
|
+
"#{config.target_api_url}/glossaries/#{glossary_id}",
|
|
56
|
+
{ params: query }
|
|
57
|
+
)
|
|
58
|
+
Web::SendRequest.new(request).perform
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def export_glossary(query = {}, glossary_id = nil, destination = nil)
|
|
62
|
+
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
|
63
|
+
|
|
64
|
+
request = Web::Request.new(
|
|
65
|
+
connection,
|
|
66
|
+
:post,
|
|
67
|
+
"#{config.target_api_url}/glossaries/#{glossary_id}/exports",
|
|
68
|
+
{ params: query }
|
|
69
|
+
)
|
|
70
|
+
Web::SendRequest.new(request, destination).perform
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def check_glossary_export_status(glossary_id = nil, export_id = nil)
|
|
74
|
+
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
|
75
|
+
export_id || raise_parameter_is_required_error(:export_id)
|
|
76
|
+
|
|
77
|
+
request = Web::Request.new(
|
|
78
|
+
connection,
|
|
79
|
+
:get,
|
|
80
|
+
"#{config.target_api_url}/glossaries/#{glossary_id}/exports/#{export_id}"
|
|
81
|
+
)
|
|
82
|
+
Web::SendRequest.new(request).perform
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def download_glossary(glossary_id = nil, export_id = nil, destination = nil)
|
|
86
|
+
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
|
87
|
+
export_id || raise_parameter_is_required_error(:export_id)
|
|
88
|
+
|
|
89
|
+
request = Web::Request.new(
|
|
90
|
+
connection,
|
|
91
|
+
:get,
|
|
92
|
+
"#{config.target_api_url}/glossaries/#{glossary_id}/exports/#{export_id}/download"
|
|
93
|
+
)
|
|
94
|
+
Web::SendRequest.new(request, destination).perform
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def import_glossary(glossary_id = nil, query = {})
|
|
98
|
+
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
|
99
|
+
|
|
100
|
+
request = Web::Request.new(
|
|
101
|
+
connection,
|
|
102
|
+
:post,
|
|
103
|
+
"#{config.target_api_url}/glossaries/#{glossary_id}/imports",
|
|
104
|
+
{ params: query }
|
|
105
|
+
)
|
|
106
|
+
Web::SendRequest.new(request).perform
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
def check_glossary_import_status(glossary_id = nil, import_id = nil)
|
|
110
|
+
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
|
111
|
+
import_id || raise_parameter_is_required_error(:import_id)
|
|
112
|
+
|
|
113
|
+
request = Web::Request.new(
|
|
114
|
+
connection,
|
|
115
|
+
:get,
|
|
116
|
+
"#{config.target_api_url}/glossaries/#{glossary_id}/imports/#{import_id}"
|
|
117
|
+
)
|
|
118
|
+
Web::SendRequest.new(request).perform
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def list_terms(glossary_id = nil, query = {})
|
|
122
|
+
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
|
123
|
+
|
|
124
|
+
request = Web::Request.new(
|
|
125
|
+
connection,
|
|
126
|
+
:get,
|
|
127
|
+
"#{config.target_api_url}/glossaries/#{glossary_id}/terms",
|
|
128
|
+
{ params: query }
|
|
129
|
+
)
|
|
130
|
+
Web::SendRequest.new(request).perform
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def add_term(glossary_id = nil, query = {})
|
|
134
|
+
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
|
135
|
+
|
|
136
|
+
request = Web::Request.new(
|
|
137
|
+
connection,
|
|
138
|
+
:post,
|
|
139
|
+
"#{config.target_api_url}/glossaries/#{glossary_id}/terms",
|
|
140
|
+
{ params: query }
|
|
141
|
+
)
|
|
142
|
+
Web::SendRequest.new(request).perform
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
def clear_glossary(glossary_id = nil, query = {})
|
|
146
|
+
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
|
147
|
+
|
|
148
|
+
response = ::RestClient::Request.execute(
|
|
149
|
+
{
|
|
150
|
+
method: :delete,
|
|
151
|
+
url: config.base_url + config.target_api_url + "/glossaries/#{glossary_id}/terms",
|
|
152
|
+
payload: query.to_json
|
|
153
|
+
}.merge(@options)
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
response.body.empty? ? response.code : JSON.parse(response.body)
|
|
157
|
+
rescue StandardError => e
|
|
158
|
+
e.message
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
def get_term(glossary_id = nil, term_id = nil)
|
|
162
|
+
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
|
163
|
+
term_id || raise_parameter_is_required_error(:term_id)
|
|
164
|
+
|
|
165
|
+
request = Web::Request.new(
|
|
166
|
+
connection,
|
|
167
|
+
:get,
|
|
168
|
+
"#{config.target_api_url}/glossaries/#{glossary_id}/terms/#{term_id}"
|
|
169
|
+
)
|
|
170
|
+
Web::SendRequest.new(request).perform
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
def delete_term(glossary_id = nil, term_id = nil)
|
|
174
|
+
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
|
175
|
+
term_id || raise_parameter_is_required_error(:term_id)
|
|
176
|
+
|
|
177
|
+
request = Web::Request.new(
|
|
178
|
+
connection,
|
|
179
|
+
:delete,
|
|
180
|
+
"#{config.target_api_url}/glossaries/#{glossary_id}/terms/#{term_id}"
|
|
181
|
+
)
|
|
182
|
+
Web::SendRequest.new(request).perform
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
def edit_term(glossary_id = nil, term_id = nil, query = {})
|
|
186
|
+
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
|
187
|
+
term_id || raise_parameter_is_required_error(:term_id)
|
|
188
|
+
|
|
189
|
+
request = Web::Request.new(
|
|
190
|
+
connection,
|
|
191
|
+
:patch,
|
|
192
|
+
"#{config.target_api_url}/glossaries/#{glossary_id}/terms/#{term_id}",
|
|
193
|
+
{ params: query }
|
|
194
|
+
)
|
|
195
|
+
Web::SendRequest.new(request).perform
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
def list_concepts(glossary_id = nil, query = {})
|
|
199
|
+
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
|
200
|
+
|
|
201
|
+
request = Web::Request.new(
|
|
202
|
+
connection,
|
|
203
|
+
:get,
|
|
204
|
+
"#{config.target_api_url}/glossaries/#{glossary_id}/concepts",
|
|
205
|
+
{ params: query }
|
|
206
|
+
)
|
|
207
|
+
Web::SendRequest.new(request).perform
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
def get_concept(glossary_id = nil, concept_id = nil)
|
|
211
|
+
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
|
212
|
+
concept_id || raise_parameter_is_required_error(:concept_id)
|
|
213
|
+
|
|
214
|
+
request = Web::Request.new(
|
|
215
|
+
connection,
|
|
216
|
+
:get,
|
|
217
|
+
"#{config.target_api_url}/glossaries/#{glossary_id}/concepts/#{concept_id}"
|
|
218
|
+
)
|
|
219
|
+
Web::SendRequest.new(request).perform
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
def update_concept(glossary_id = nil, concept_id = nil, query = {})
|
|
223
|
+
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
|
224
|
+
concept_id || raise_parameter_is_required_error(:concept_id)
|
|
225
|
+
|
|
226
|
+
request = Web::Request.new(
|
|
227
|
+
connection,
|
|
228
|
+
:put,
|
|
229
|
+
"#{config.target_api_url}/glossaries/#{glossary_id}/concepts/#{concept_id}",
|
|
230
|
+
{ params: query }
|
|
231
|
+
)
|
|
232
|
+
Web::SendRequest.new(request).perform
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
def delete_concept(glossary_id = nil, concept_id = nil)
|
|
236
|
+
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
|
237
|
+
concept_id || raise_parameter_is_required_error(:concept_id)
|
|
238
|
+
|
|
239
|
+
request = Web::Request.new(
|
|
240
|
+
connection,
|
|
241
|
+
:delete,
|
|
242
|
+
"#{config.target_api_url}/glossaries/#{glossary_id}/concepts/#{concept_id}"
|
|
243
|
+
)
|
|
244
|
+
Web::SendRequest.new(request).perform
|
|
245
|
+
end
|
|
246
|
+
end
|
|
247
|
+
end
|
|
248
|
+
end
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Crowdin
|
|
4
|
+
module ApiResources
|
|
5
|
+
module Labels
|
|
6
|
+
def list_labels(query = {}, project_id = config.project_id)
|
|
7
|
+
project_id || raise_project_id_is_required_error
|
|
8
|
+
|
|
9
|
+
request = Web::Request.new(
|
|
10
|
+
connection,
|
|
11
|
+
:get,
|
|
12
|
+
"#{config.target_api_url}/projects/#{project_id}/labels",
|
|
13
|
+
{ params: query }
|
|
14
|
+
)
|
|
15
|
+
Web::SendRequest.new(request).perform
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def add_label(query = {}, project_id = config.project_id)
|
|
19
|
+
project_id || raise_project_id_is_required_error
|
|
20
|
+
|
|
21
|
+
request = Web::Request.new(
|
|
22
|
+
connection,
|
|
23
|
+
:post,
|
|
24
|
+
"#{config.target_api_url}/projects/#{project_id}/labels",
|
|
25
|
+
{ params: query }
|
|
26
|
+
)
|
|
27
|
+
Web::SendRequest.new(request).perform
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def get_label(label_id = nil, project_id = config.project_id)
|
|
31
|
+
label_id || raise_parameter_is_required_error(:label_id)
|
|
32
|
+
project_id || raise_project_id_is_required_error
|
|
33
|
+
|
|
34
|
+
request = Web::Request.new(
|
|
35
|
+
connection,
|
|
36
|
+
:get,
|
|
37
|
+
"#{config.target_api_url}/projects/#{project_id}/labels/#{label_id}"
|
|
38
|
+
)
|
|
39
|
+
Web::SendRequest.new(request).perform
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def delete_label(label_id = nil, project_id = config.project_id)
|
|
43
|
+
label_id || raise_parameter_is_required_error(:label_id)
|
|
44
|
+
project_id || raise_project_id_is_required_error
|
|
45
|
+
|
|
46
|
+
request = Web::Request.new(
|
|
47
|
+
connection,
|
|
48
|
+
:delete,
|
|
49
|
+
"#{config.target_api_url}/projects/#{project_id}/labels/#{label_id}"
|
|
50
|
+
)
|
|
51
|
+
Web::SendRequest.new(request).perform
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def edit_label(label_id = nil, query = {}, project_id = config.project_id)
|
|
55
|
+
label_id || raise_parameter_is_required_error(:label_id)
|
|
56
|
+
project_id || raise_project_id_is_required_error
|
|
57
|
+
|
|
58
|
+
request = Web::Request.new(
|
|
59
|
+
connection,
|
|
60
|
+
:patch,
|
|
61
|
+
"#{config.target_api_url}/projects/#{project_id}/labels/#{label_id}",
|
|
62
|
+
{ params: query }
|
|
63
|
+
)
|
|
64
|
+
Web::SendRequest.new(request).perform
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def assign_label_to_strings(label_id = nil, query = {}, project_id = config.project_id)
|
|
68
|
+
label_id || raise_parameter_is_required_error(:label_id)
|
|
69
|
+
project_id || raise_project_id_is_required_error
|
|
70
|
+
|
|
71
|
+
request = Web::Request.new(
|
|
72
|
+
connection,
|
|
73
|
+
:post,
|
|
74
|
+
"#{config.target_api_url}/projects/#{project_id}/labels/#{label_id}/strings",
|
|
75
|
+
{ params: query }
|
|
76
|
+
)
|
|
77
|
+
Web::SendRequest.new(request).perform
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
def unassign_label_from_strings(label_id = nil, query = {}, project_id = config.project_id)
|
|
81
|
+
label_id || raise_parameter_is_required_error(:label_id)
|
|
82
|
+
project_id || raise_project_id_is_required_error
|
|
83
|
+
|
|
84
|
+
response = ::RestClient::Request.execute(
|
|
85
|
+
{
|
|
86
|
+
method: :delete,
|
|
87
|
+
url: config.base_url + config.target_api_url + "/projects/#{project_id}/labels/#{label_id}",
|
|
88
|
+
payload: query.to_json
|
|
89
|
+
}.merge(@options)
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
response.body.empty? ? response.code : JSON.parse(response.body)
|
|
93
|
+
rescue StandardError => e
|
|
94
|
+
e.message
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
end
|
|
98
|
+
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Crowdin
|
|
4
|
+
module ApiResources
|
|
5
|
+
module Languages
|
|
6
|
+
def list_languages(query = {})
|
|
7
|
+
request = Web::Request.new(
|
|
8
|
+
connection,
|
|
9
|
+
:get,
|
|
10
|
+
"#{config.target_api_url}/languages",
|
|
11
|
+
{ params: query }
|
|
12
|
+
)
|
|
13
|
+
Web::SendRequest.new(request).perform
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def add_custom_language(query = {})
|
|
17
|
+
request = Web::Request.new(
|
|
18
|
+
connection,
|
|
19
|
+
:post,
|
|
20
|
+
"#{config.target_api_url}/languages",
|
|
21
|
+
{ params: query }
|
|
22
|
+
)
|
|
23
|
+
Web::SendRequest.new(request).perform
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def get_language(language_id = nil)
|
|
27
|
+
language_id || raise_parameter_is_required_error(:language_id)
|
|
28
|
+
|
|
29
|
+
request = Web::Request.new(
|
|
30
|
+
connection,
|
|
31
|
+
:get,
|
|
32
|
+
"#{config.target_api_url}/languages/#{language_id}"
|
|
33
|
+
)
|
|
34
|
+
Web::SendRequest.new(request).perform
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def delete_custom_language(language_id = nil)
|
|
38
|
+
language_id || raise_parameter_is_required_error(:language_id)
|
|
39
|
+
|
|
40
|
+
request = Web::Request.new(
|
|
41
|
+
connection,
|
|
42
|
+
:delete,
|
|
43
|
+
"#{config.target_api_url}/languages/#{language_id}"
|
|
44
|
+
)
|
|
45
|
+
Web::SendRequest.new(request).perform
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def edit_custom_language(language_id = nil, query = {})
|
|
49
|
+
language_id || raise_parameter_is_required_error(:language_id)
|
|
50
|
+
|
|
51
|
+
request = Web::Request.new(
|
|
52
|
+
connection,
|
|
53
|
+
:patch,
|
|
54
|
+
"#{config.target_api_url}/languages/#{language_id}",
|
|
55
|
+
{ params: query }
|
|
56
|
+
)
|
|
57
|
+
Web::SendRequest.new(request).perform
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Crowdin
|
|
4
|
+
module ApiResources
|
|
5
|
+
module MachineTranslationEngines
|
|
6
|
+
def list_mts(query = {})
|
|
7
|
+
request = Web::Request.new(
|
|
8
|
+
connection,
|
|
9
|
+
:get,
|
|
10
|
+
"#{config.target_api_url}/mts",
|
|
11
|
+
{ params: query }
|
|
12
|
+
)
|
|
13
|
+
Web::SendRequest.new(request).perform
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def get_mt(mt_id = nil)
|
|
17
|
+
mt_id || raise_parameter_is_required_error(:mt_id)
|
|
18
|
+
|
|
19
|
+
request = Web::Request.new(
|
|
20
|
+
connection,
|
|
21
|
+
:get,
|
|
22
|
+
"#{config.target_api_url}/mts/#{mt_id}"
|
|
23
|
+
)
|
|
24
|
+
Web::SendRequest.new(request).perform
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def translate_via_mt(mt_id = nil, query = {})
|
|
28
|
+
mt_id || raise_parameter_is_required_error(:mt_id)
|
|
29
|
+
|
|
30
|
+
request = Web::Request.new(
|
|
31
|
+
connection,
|
|
32
|
+
:post,
|
|
33
|
+
"#{config.target_api_url}/mts/#{mt_id}/translations",
|
|
34
|
+
{ params: query }
|
|
35
|
+
)
|
|
36
|
+
Web::SendRequest.new(request).perform
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# -- For Enterprise mode only --
|
|
40
|
+
|
|
41
|
+
def edit_mt(mt_id = nil, query = {})
|
|
42
|
+
enterprise_mode? || raise_only_for_enterprise_mode_error
|
|
43
|
+
mt_id || raise_parameter_is_required_error(:mt_id)
|
|
44
|
+
|
|
45
|
+
request = Web::Request.new(
|
|
46
|
+
connection,
|
|
47
|
+
:patch,
|
|
48
|
+
"#{config.target_api_url}/mts/#{mt_id}",
|
|
49
|
+
{ params: query }
|
|
50
|
+
)
|
|
51
|
+
Web::SendRequest.new(request).perform
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def add_mt(query = {})
|
|
55
|
+
enterprise_mode? || raise_only_for_enterprise_mode_error
|
|
56
|
+
|
|
57
|
+
request = Web::Request.new(
|
|
58
|
+
connection,
|
|
59
|
+
:post,
|
|
60
|
+
"#{config.target_api_url}/mts",
|
|
61
|
+
{ params: query }
|
|
62
|
+
)
|
|
63
|
+
Web::SendRequest.new(request).perform
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def delete_mt(mt_id = nil)
|
|
67
|
+
enterprise_mode? || raise_only_for_enterprise_mode_error
|
|
68
|
+
mt_id || raise_parameter_is_required_error(:mt_id)
|
|
69
|
+
|
|
70
|
+
request = Web::Request.new(
|
|
71
|
+
connection,
|
|
72
|
+
:delete,
|
|
73
|
+
"#{config.target_api_url}/mts/#{mt_id}"
|
|
74
|
+
)
|
|
75
|
+
Web::SendRequest.new(request).perform
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|