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.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +102 -43
- data/README.md +37 -6
- data/bin/crowdin-console +1 -1
- data/crowdin-api.gemspec +1 -2
- data/lib/crowdin-api/api_resources/bundles.rb +81 -0
- data/lib/crowdin-api/{api-resources → api_resources}/dictionaries.rb +8 -10
- data/lib/crowdin-api/{api-resources → api_resources}/distributions.rb +25 -32
- data/lib/crowdin-api/{api-resources → api_resources}/glossaries.rb +64 -82
- data/lib/crowdin-api/{api-resources → api_resources}/labels.rb +28 -47
- data/lib/crowdin-api/api_resources/languages.rb +61 -0
- data/lib/crowdin-api/api_resources/machine_translation_engines.rb +79 -0
- data/lib/crowdin-api/api_resources/projects.rb +124 -0
- data/lib/crowdin-api/api_resources/reports.rb +120 -0
- data/lib/crowdin-api/{api-resources → api_resources}/screenshots.rb +47 -61
- data/lib/crowdin-api/{api-resources → api_resources}/source_files.rb +68 -131
- data/lib/crowdin-api/{api-resources → api_resources}/source_strings.rb +19 -24
- data/lib/crowdin-api/api_resources/storages.rb +54 -0
- data/lib/crowdin-api/{api-resources → api_resources}/string_comments.rb +18 -23
- data/lib/crowdin-api/{api-resources → api_resources}/string_translations.rb +64 -91
- data/lib/crowdin-api/{api-resources → api_resources}/tasks.rb +30 -41
- data/lib/crowdin-api/api_resources/teams.rb +135 -0
- data/lib/crowdin-api/{api-resources → api_resources}/translation_memory.rb +38 -52
- data/lib/crowdin-api/{api-resources → api_resources}/translation_status.rb +24 -30
- data/lib/crowdin-api/{api-resources → api_resources}/translations.rb +41 -58
- data/lib/crowdin-api/api_resources/users.rb +161 -0
- data/lib/crowdin-api/api_resources/vendors.rb +21 -0
- data/lib/crowdin-api/{api-resources → api_resources}/webhooks.rb +19 -24
- data/lib/crowdin-api/api_resources/workflows.rb +59 -0
- data/lib/crowdin-api/client/client.rb +134 -39
- data/lib/crowdin-api/client/configuration.rb +12 -12
- data/lib/crowdin-api/client/version.rb +1 -1
- data/lib/crowdin-api/core/errors.rb +1 -0
- data/lib/crowdin-api/core/errors_raisers.rb +1 -1
- data/lib/crowdin-api/core/fetch_all_extensions.rb +14 -0
- data/lib/crowdin-api/core/request.rb +50 -90
- data/lib/crowdin-api/core/send_request.rb +67 -0
- data/lib/crowdin-api.rb +18 -24
- data/spec/api_resources/bundles_spec.rb +61 -0
- data/spec/api_resources/dictionaries_spec.rb +23 -0
- data/spec/api_resources/distributions_spec.rb +71 -0
- data/spec/api_resources/glossaries_spec.rb +167 -0
- data/spec/api_resources/labels_spec.rb +71 -0
- data/spec/api_resources/languages_spec.rb +51 -0
- data/spec/api_resources/machine_translation_engines_spec.rb +63 -0
- data/spec/api_resources/projects_spec.rb +215 -0
- data/spec/api_resources/reports_spec.rb +95 -0
- data/spec/api_resources/screenshots_spec.rb +134 -0
- data/spec/api_resources/source_files_spec.rb +184 -0
- data/spec/api_resources/source_strings_spec.rb +51 -0
- data/spec/api_resources/storages_spec.rb +41 -0
- data/spec/api_resources/string_comments_spec.rb +51 -0
- data/spec/api_resources/string_translations_spec.rb +141 -0
- data/spec/api_resources/tasks_spec.rb +79 -0
- data/spec/api_resources/teams_spec.rb +100 -0
- data/spec/api_resources/translation_memory_spec.rb +114 -0
- data/spec/api_resources/translation_status_spec.rb +61 -0
- data/spec/api_resources/translations_spec.rb +107 -0
- data/spec/api_resources/users_spec.rb +117 -0
- data/spec/api_resources/vendors_spec.rb +13 -0
- data/spec/api_resources/webhooks_spec.rb +51 -0
- data/spec/api_resources/workflows_spec.rb +41 -0
- data/spec/spec_helper.rb +23 -2
- data/spec/unit/client_spec.rb +85 -0
- metadata +67 -43
- data/bin/setup +0 -6
- data/lib/crowdin-api/api-resources/languages.rb +0 -82
- data/lib/crowdin-api/api-resources/machine_translation_engines.rb +0 -74
- data/lib/crowdin-api/api-resources/projects.rb +0 -148
- data/lib/crowdin-api/api-resources/reports.rb +0 -138
- data/lib/crowdin-api/api-resources/storages.rb +0 -106
- data/lib/crowdin-api/api-resources/teams.rb +0 -144
- data/lib/crowdin-api/api-resources/users.rb +0 -129
- data/lib/crowdin-api/api-resources/vendors.rb +0 -21
- data/lib/crowdin-api/api-resources/workflows.rb +0 -62
- data/lib/crowdin-api/core/utils.rb +0 -10
- data/spec/client/client-instance_spec.rb +0 -14
- data/spec/client/configuration-instance_spec.rb +0 -72
@@ -7,26 +7,24 @@ module Crowdin
|
|
7
7
|
project_id || raise_project_id_is_required_error
|
8
8
|
|
9
9
|
request = Web::Request.new(
|
10
|
-
|
10
|
+
connection,
|
11
11
|
:get,
|
12
|
-
"/projects/#{project_id}/branches",
|
13
|
-
query
|
12
|
+
"#{config.target_api_url}/projects/#{project_id}/branches",
|
13
|
+
{ params: query }
|
14
14
|
)
|
15
|
-
|
16
|
-
request.perform
|
15
|
+
Web::SendRequest.new(request).perform
|
17
16
|
end
|
18
17
|
|
19
18
|
def add_branch(query = {}, project_id = config.project_id)
|
20
19
|
project_id || raise_project_id_is_required_error
|
21
20
|
|
22
21
|
request = Web::Request.new(
|
23
|
-
|
22
|
+
connection,
|
24
23
|
:post,
|
25
|
-
"/projects/#{project_id}/branches",
|
26
|
-
query
|
24
|
+
"#{config.target_api_url}/projects/#{project_id}/branches",
|
25
|
+
{ params: query }
|
27
26
|
)
|
28
|
-
|
29
|
-
request.perform
|
27
|
+
Web::SendRequest.new(request).perform
|
30
28
|
end
|
31
29
|
|
32
30
|
def get_branch(branch_id = nil, project_id = config.project_id)
|
@@ -34,12 +32,11 @@ module Crowdin
|
|
34
32
|
project_id || raise_project_id_is_required_error
|
35
33
|
|
36
34
|
request = Web::Request.new(
|
37
|
-
|
35
|
+
connection,
|
38
36
|
:get,
|
39
|
-
"/projects/#{project_id}/branches/#{branch_id}"
|
37
|
+
"#{config.target_api_url}/projects/#{project_id}/branches/#{branch_id}"
|
40
38
|
)
|
41
|
-
|
42
|
-
request.perform
|
39
|
+
Web::SendRequest.new(request).perform
|
43
40
|
end
|
44
41
|
|
45
42
|
def delete_branch(branch_id = nil, project_id = config.project_id)
|
@@ -47,12 +44,11 @@ module Crowdin
|
|
47
44
|
project_id || raise_project_id_is_required_error
|
48
45
|
|
49
46
|
request = Web::Request.new(
|
50
|
-
|
47
|
+
connection,
|
51
48
|
:delete,
|
52
|
-
"/projects/#{project_id}/branches/#{branch_id}"
|
49
|
+
"#{config.target_api_url}/projects/#{project_id}/branches/#{branch_id}"
|
53
50
|
)
|
54
|
-
|
55
|
-
request.perform
|
51
|
+
Web::SendRequest.new(request).perform
|
56
52
|
end
|
57
53
|
|
58
54
|
def edit_branch(branch_id = nil, query = {}, project_id = config.project_id)
|
@@ -60,39 +56,36 @@ module Crowdin
|
|
60
56
|
project_id || raise_project_id_is_required_error
|
61
57
|
|
62
58
|
request = Web::Request.new(
|
63
|
-
|
59
|
+
connection,
|
64
60
|
:patch,
|
65
|
-
"/projects/#{project_id}/branches/#{branch_id}",
|
66
|
-
query
|
61
|
+
"#{config.target_api_url}/projects/#{project_id}/branches/#{branch_id}",
|
62
|
+
{ params: query }
|
67
63
|
)
|
68
|
-
|
69
|
-
request.perform
|
64
|
+
Web::SendRequest.new(request).perform
|
70
65
|
end
|
71
66
|
|
72
67
|
def list_directories(query = {}, project_id = config.project_id)
|
73
68
|
project_id || raise_project_id_is_required_error
|
74
69
|
|
75
70
|
request = Web::Request.new(
|
76
|
-
|
71
|
+
connection,
|
77
72
|
:get,
|
78
|
-
"/projects/#{project_id}/directories",
|
79
|
-
query
|
73
|
+
"#{config.target_api_url}/projects/#{project_id}/directories",
|
74
|
+
{ params: query }
|
80
75
|
)
|
81
|
-
|
82
|
-
request.perform
|
76
|
+
Web::SendRequest.new(request).perform
|
83
77
|
end
|
84
78
|
|
85
79
|
def add_directory(query = {}, project_id = config.project_id)
|
86
80
|
project_id || raise_project_id_is_required_error
|
87
81
|
|
88
82
|
request = Web::Request.new(
|
89
|
-
|
83
|
+
connection,
|
90
84
|
:post,
|
91
|
-
"/projects/#{project_id}/directories",
|
92
|
-
query
|
85
|
+
"#{config.target_api_url}/projects/#{project_id}/directories",
|
86
|
+
{ params: query }
|
93
87
|
)
|
94
|
-
|
95
|
-
request.perform
|
88
|
+
Web::SendRequest.new(request).perform
|
96
89
|
end
|
97
90
|
|
98
91
|
def get_directory(directory_id = nil, project_id = config.project_id)
|
@@ -100,12 +93,11 @@ module Crowdin
|
|
100
93
|
project_id || raise_project_id_is_required_error
|
101
94
|
|
102
95
|
request = Web::Request.new(
|
103
|
-
|
96
|
+
connection,
|
104
97
|
:get,
|
105
|
-
"/projects/#{project_id}/directories/#{directory_id}"
|
98
|
+
"#{config.target_api_url}/projects/#{project_id}/directories/#{directory_id}"
|
106
99
|
)
|
107
|
-
|
108
|
-
request.perform
|
100
|
+
Web::SendRequest.new(request).perform
|
109
101
|
end
|
110
102
|
|
111
103
|
def delete_directory(directory_id = nil, project_id = config.project_id)
|
@@ -113,12 +105,11 @@ module Crowdin
|
|
113
105
|
project_id || raise_project_id_is_required_error
|
114
106
|
|
115
107
|
request = Web::Request.new(
|
116
|
-
|
108
|
+
connection,
|
117
109
|
:delete,
|
118
|
-
"/projects/#{project_id}/directories/#{directory_id}"
|
110
|
+
"#{config.target_api_url}/projects/#{project_id}/directories/#{directory_id}"
|
119
111
|
)
|
120
|
-
|
121
|
-
request.perform
|
112
|
+
Web::SendRequest.new(request).perform
|
122
113
|
end
|
123
114
|
|
124
115
|
def edit_directory(directory_id = nil, query = {}, project_id = config.project_id)
|
@@ -126,58 +117,36 @@ module Crowdin
|
|
126
117
|
project_id || raise_project_id_is_required_error
|
127
118
|
|
128
119
|
request = Web::Request.new(
|
129
|
-
|
120
|
+
connection,
|
130
121
|
:patch,
|
131
|
-
"/projects/#{project_id}/directories/#{directory_id}",
|
132
|
-
query
|
122
|
+
"#{config.target_api_url}/projects/#{project_id}/directories/#{directory_id}",
|
123
|
+
{ params: query }
|
133
124
|
)
|
134
|
-
|
135
|
-
request.perform
|
125
|
+
Web::SendRequest.new(request).perform
|
136
126
|
end
|
137
127
|
|
138
128
|
def list_files(query = {}, project_id = config.project_id)
|
139
129
|
project_id || raise_project_id_is_required_error
|
140
130
|
|
141
131
|
request = Web::Request.new(
|
142
|
-
|
132
|
+
connection,
|
143
133
|
:get,
|
144
|
-
"/projects/#{project_id}/files",
|
145
|
-
query
|
134
|
+
"#{config.target_api_url}/projects/#{project_id}/files",
|
135
|
+
{ params: query }
|
146
136
|
)
|
147
|
-
|
148
|
-
request.perform
|
137
|
+
Web::SendRequest.new(request).perform
|
149
138
|
end
|
150
139
|
|
151
|
-
#
|
152
|
-
# Add custom language.
|
153
|
-
#
|
154
|
-
# === Parameters
|
155
|
-
#
|
156
|
-
# * +:projectId+ [Integer] - Project Identifier. Get via list_projects. Can be initialized with the Crowdin Client
|
157
|
-
# * +:storageId+ [Integer] - Storage Identifier. Get via list_storages
|
158
|
-
# * +:name+ [String] - File name. Note: Can't contain \ / : * ? " < > | symbols. ZIP files are not allowed.
|
159
|
-
#
|
160
|
-
# === Example
|
161
|
-
#
|
162
|
-
# when you're initialized Crowdin Client with a project_id
|
163
|
-
#
|
164
|
-
# crowdin.add_file(storage_id: your_storage_id, name: 'your_filename')
|
165
|
-
#
|
166
|
-
# or you can specify project_id
|
167
|
-
#
|
168
|
-
# crowdin.add_file({ storage_id: your_storage_id, name: 'your_filename' }, your_project_id)
|
169
|
-
#
|
170
140
|
def add_file(query = {}, project_id = config.project_id)
|
171
141
|
project_id || raise_project_id_is_required_error
|
172
142
|
|
173
143
|
request = Web::Request.new(
|
174
|
-
|
144
|
+
connection,
|
175
145
|
:post,
|
176
|
-
"/projects/#{project_id}/files",
|
177
|
-
query
|
146
|
+
"#{config.target_api_url}/projects/#{project_id}/files",
|
147
|
+
{ params: query }
|
178
148
|
)
|
179
|
-
|
180
|
-
request.perform
|
149
|
+
Web::SendRequest.new(request).perform
|
181
150
|
end
|
182
151
|
|
183
152
|
def get_file(file_id = nil, project_id = config.project_id)
|
@@ -185,12 +154,11 @@ module Crowdin
|
|
185
154
|
project_id || raise_project_id_is_required_error
|
186
155
|
|
187
156
|
request = Web::Request.new(
|
188
|
-
|
157
|
+
connection,
|
189
158
|
:get,
|
190
|
-
"/projects/#{project_id}/files/#{file_id}"
|
159
|
+
"#{config.target_api_url}/projects/#{project_id}/files/#{file_id}"
|
191
160
|
)
|
192
|
-
|
193
|
-
request.perform
|
161
|
+
Web::SendRequest.new(request).perform
|
194
162
|
end
|
195
163
|
|
196
164
|
def update_or_restore_file(file_id = nil, query = {}, project_id = config.project_id)
|
@@ -198,13 +166,12 @@ module Crowdin
|
|
198
166
|
project_id || raise_project_id_is_required_error
|
199
167
|
|
200
168
|
request = Web::Request.new(
|
201
|
-
|
169
|
+
connection,
|
202
170
|
:put,
|
203
|
-
"/projects/#{project_id}/files/#{file_id}",
|
204
|
-
query
|
171
|
+
"#{config.target_api_url}/projects/#{project_id}/files/#{file_id}",
|
172
|
+
{ params: query }
|
205
173
|
)
|
206
|
-
|
207
|
-
request.perform
|
174
|
+
Web::SendRequest.new(request).perform
|
208
175
|
end
|
209
176
|
|
210
177
|
def delete_file(file_id = nil, project_id = config.project_id)
|
@@ -212,12 +179,11 @@ module Crowdin
|
|
212
179
|
project_id || raise_project_id_is_required_error
|
213
180
|
|
214
181
|
request = Web::Request.new(
|
215
|
-
|
182
|
+
connection,
|
216
183
|
:delete,
|
217
|
-
"/projects/#{project_id}/files/#{file_id}"
|
184
|
+
"#{config.target_api_url}/projects/#{project_id}/files/#{file_id}"
|
218
185
|
)
|
219
|
-
|
220
|
-
request.perform
|
186
|
+
Web::SendRequest.new(request).perform
|
221
187
|
end
|
222
188
|
|
223
189
|
def edit_file(file_id = nil, query = {}, project_id = config.project_id)
|
@@ -225,13 +191,12 @@ module Crowdin
|
|
225
191
|
project_id || raise_project_id_is_required_error
|
226
192
|
|
227
193
|
request = Web::Request.new(
|
228
|
-
|
194
|
+
connection,
|
229
195
|
:patch,
|
230
|
-
"/projects/#{project_id}/files/#{file_id}",
|
231
|
-
query
|
196
|
+
"#{config.target_api_url}/projects/#{project_id}/files/#{file_id}",
|
197
|
+
{ params: query }
|
232
198
|
)
|
233
|
-
|
234
|
-
request.perform
|
199
|
+
Web::SendRequest.new(request).perform
|
235
200
|
end
|
236
201
|
|
237
202
|
def download_file(file_id = nil, destination = nil, project_id = config.project_id)
|
@@ -239,51 +204,24 @@ module Crowdin
|
|
239
204
|
project_id || raise_project_id_is_required_error
|
240
205
|
|
241
206
|
request = Web::Request.new(
|
242
|
-
|
207
|
+
connection,
|
243
208
|
:get,
|
244
|
-
"/projects/#{project_id}/files/#{file_id}/download"
|
245
|
-
{},
|
246
|
-
{},
|
247
|
-
destination
|
209
|
+
"#{config.target_api_url}/projects/#{project_id}/files/#{file_id}/download"
|
248
210
|
)
|
249
|
-
|
250
|
-
request.perform
|
211
|
+
Web::SendRequest.new(request, destination).perform
|
251
212
|
end
|
252
213
|
|
253
|
-
#
|
254
|
-
# List file revisions.
|
255
|
-
#
|
256
|
-
# === Parameters
|
257
|
-
#
|
258
|
-
# * +:projectId+ [Integer] - Project Identifier. Get via list_projects. Can be initialized with the Crowdin Client
|
259
|
-
# * +:fileId+ [Integer] - File Identifier. Get via list_files
|
260
|
-
#
|
261
|
-
# Optional:
|
262
|
-
# * +:limit+ [Integer 1..500] - A maximum number of items to retrieve, default - 25
|
263
|
-
# * +:offset+ [Integer >= 0] - A starting offset in the collection, default - 0
|
264
|
-
#
|
265
|
-
# === Example
|
266
|
-
#
|
267
|
-
# when you're initialized Crowdin Client with a project_id
|
268
|
-
#
|
269
|
-
# crowdin.list_file_revisions(your_file_id, limit: your_value)
|
270
|
-
#
|
271
|
-
# or you can specify project_id
|
272
|
-
#
|
273
|
-
# crowdin.list_file_revisions(your_file_id, { limit: your_value }, your_project_id)
|
274
|
-
#
|
275
214
|
def list_file_revisions(file_id = nil, query = {}, project_id = config.project_id)
|
276
215
|
file_id || raise_parameter_is_required_error(:file_id)
|
277
216
|
project_id || raise_project_id_is_required_error
|
278
217
|
|
279
218
|
request = Web::Request.new(
|
280
|
-
|
219
|
+
connection,
|
281
220
|
:get,
|
282
|
-
"/projects/#{project_id}/files/#{file_id}/revisions",
|
283
|
-
query
|
221
|
+
"#{config.target_api_url}/projects/#{project_id}/files/#{file_id}/revisions",
|
222
|
+
{ params: query }
|
284
223
|
)
|
285
|
-
|
286
|
-
request.perform
|
224
|
+
Web::SendRequest.new(request).perform
|
287
225
|
end
|
288
226
|
|
289
227
|
def get_file_revision(file_id = nil, revision_id = nil, project_id = config.project_id)
|
@@ -292,12 +230,11 @@ module Crowdin
|
|
292
230
|
project_id || raise_project_id_is_required_error
|
293
231
|
|
294
232
|
request = Web::Request.new(
|
295
|
-
|
233
|
+
connection,
|
296
234
|
:get,
|
297
|
-
"/projects/#{project_id}/files/#{file_id}/revisions/#{revision_id}"
|
235
|
+
"#{config.target_api_url}/projects/#{project_id}/files/#{file_id}/revisions/#{revision_id}"
|
298
236
|
)
|
299
|
-
|
300
|
-
request.perform
|
237
|
+
Web::SendRequest.new(request).perform
|
301
238
|
end
|
302
239
|
end
|
303
240
|
end
|
@@ -7,26 +7,24 @@ module Crowdin
|
|
7
7
|
project_id || raise_project_id_is_required_error
|
8
8
|
|
9
9
|
request = Web::Request.new(
|
10
|
-
|
10
|
+
connection,
|
11
11
|
:get,
|
12
|
-
"/projects/#{project_id}/strings",
|
13
|
-
query
|
12
|
+
"#{config.target_api_url}/projects/#{project_id}/strings",
|
13
|
+
{ params: query }
|
14
14
|
)
|
15
|
-
|
16
|
-
request.perform
|
15
|
+
Web::SendRequest.new(request).perform
|
17
16
|
end
|
18
17
|
|
19
18
|
def add_string(query = {}, project_id = config.project_id)
|
20
19
|
project_id || raise_project_id_is_required_error
|
21
20
|
|
22
21
|
request = Web::Request.new(
|
23
|
-
|
22
|
+
connection,
|
24
23
|
:post,
|
25
|
-
"/projects/#{project_id}/strings",
|
26
|
-
query
|
24
|
+
"#{config.target_api_url}/projects/#{project_id}/strings",
|
25
|
+
{ params: query }
|
27
26
|
)
|
28
|
-
|
29
|
-
request.perform
|
27
|
+
Web::SendRequest.new(request).perform
|
30
28
|
end
|
31
29
|
|
32
30
|
def get_string(string_id = nil, query = {}, project_id = config.project_id)
|
@@ -34,13 +32,12 @@ module Crowdin
|
|
34
32
|
project_id || raise_project_id_is_required_error
|
35
33
|
|
36
34
|
request = Web::Request.new(
|
37
|
-
|
35
|
+
connection,
|
38
36
|
:get,
|
39
|
-
"/projects/#{project_id}/strings/#{string_id}",
|
40
|
-
query
|
37
|
+
"#{config.target_api_url}/projects/#{project_id}/strings/#{string_id}",
|
38
|
+
{ params: query }
|
41
39
|
)
|
42
|
-
|
43
|
-
request.perform
|
40
|
+
Web::SendRequest.new(request).perform
|
44
41
|
end
|
45
42
|
|
46
43
|
def delete_string(string_id = nil, project_id = config.project_id)
|
@@ -48,12 +45,11 @@ module Crowdin
|
|
48
45
|
project_id || raise_project_id_is_required_error
|
49
46
|
|
50
47
|
request = Web::Request.new(
|
51
|
-
|
48
|
+
connection,
|
52
49
|
:delete,
|
53
|
-
"/projects/#{project_id}/strings/#{string_id}"
|
50
|
+
"#{config.target_api_url}/projects/#{project_id}/strings/#{string_id}"
|
54
51
|
)
|
55
|
-
|
56
|
-
request.perform
|
52
|
+
Web::SendRequest.new(request).perform
|
57
53
|
end
|
58
54
|
|
59
55
|
def edit_string(string_id = nil, query = {}, project_id = config.project_id)
|
@@ -61,13 +57,12 @@ module Crowdin
|
|
61
57
|
project_id || raise_project_id_is_required_error
|
62
58
|
|
63
59
|
request = Web::Request.new(
|
64
|
-
|
60
|
+
connection,
|
65
61
|
:patch,
|
66
|
-
"/projects/#{project_id}/strings/#{string_id}",
|
67
|
-
query
|
62
|
+
"#{config.target_api_url}/projects/#{project_id}/strings/#{string_id}",
|
63
|
+
{ params: query }
|
68
64
|
)
|
69
|
-
|
70
|
-
request.perform
|
65
|
+
Web::SendRequest.new(request).perform
|
71
66
|
end
|
72
67
|
end
|
73
68
|
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Crowdin
|
4
|
+
module ApiResources
|
5
|
+
module Storages
|
6
|
+
def list_storages(query = {})
|
7
|
+
request = Web::Request.new(
|
8
|
+
connection,
|
9
|
+
:get,
|
10
|
+
"#{config.target_api_url}/storages",
|
11
|
+
{ params: query }
|
12
|
+
)
|
13
|
+
Web::SendRequest.new(request).perform
|
14
|
+
end
|
15
|
+
|
16
|
+
def add_storage(file = nil)
|
17
|
+
file || raise_parameter_is_required_error(:file)
|
18
|
+
|
19
|
+
file = file.is_a?(File) ? file : File.open(file, 'r')
|
20
|
+
headers = { 'Content-Type' => 'application/octet-stream', 'Crowdin-API-FileName' => File.basename(file) }
|
21
|
+
|
22
|
+
request = Web::Request.new(
|
23
|
+
connection,
|
24
|
+
:post,
|
25
|
+
"#{config.target_api_url}/storages",
|
26
|
+
{ params: file, headers: headers }
|
27
|
+
)
|
28
|
+
Web::SendRequest.new(request).perform
|
29
|
+
end
|
30
|
+
|
31
|
+
def get_storage(storage_id = nil)
|
32
|
+
storage_id || raise_parameter_is_required_error(:storage_id)
|
33
|
+
|
34
|
+
request = Web::Request.new(
|
35
|
+
connection,
|
36
|
+
:get,
|
37
|
+
"#{config.target_api_url}/storages/#{storage_id}"
|
38
|
+
)
|
39
|
+
Web::SendRequest.new(request).perform
|
40
|
+
end
|
41
|
+
|
42
|
+
def delete_storage(storage_id = nil)
|
43
|
+
storage_id || raise_parameter_is_required_error(:storage_id)
|
44
|
+
|
45
|
+
request = Web::Request.new(
|
46
|
+
connection,
|
47
|
+
:delete,
|
48
|
+
"#{config.target_api_url}/storages/#{storage_id}"
|
49
|
+
)
|
50
|
+
Web::SendRequest.new(request).perform
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -7,26 +7,24 @@ module Crowdin
|
|
7
7
|
project_id || raise_project_id_is_required_error
|
8
8
|
|
9
9
|
request = Web::Request.new(
|
10
|
-
|
10
|
+
connection,
|
11
11
|
:get,
|
12
|
-
"/projects/#{project_id}/comments",
|
13
|
-
query
|
12
|
+
"#{config.target_api_url}/projects/#{project_id}/comments",
|
13
|
+
{ params: query }
|
14
14
|
)
|
15
|
-
|
16
|
-
request.perform
|
15
|
+
Web::SendRequest.new(request).perform
|
17
16
|
end
|
18
17
|
|
19
18
|
def add_string_comment(query = {}, project_id = config.project_id)
|
20
19
|
project_id || raise_project_id_is_required_error
|
21
20
|
|
22
21
|
request = Web::Request.new(
|
23
|
-
|
22
|
+
connection,
|
24
23
|
:post,
|
25
|
-
"/projects/#{project_id}/comments",
|
26
|
-
query
|
24
|
+
"#{config.target_api_url}/projects/#{project_id}/comments",
|
25
|
+
{ params: query }
|
27
26
|
)
|
28
|
-
|
29
|
-
request.perform
|
27
|
+
Web::SendRequest.new(request).perform
|
30
28
|
end
|
31
29
|
|
32
30
|
def get_string_comment(string_comment_id = nil, project_id = config.project_id)
|
@@ -34,12 +32,11 @@ module Crowdin
|
|
34
32
|
project_id || raise_project_id_is_required_error
|
35
33
|
|
36
34
|
request = Web::Request.new(
|
37
|
-
|
35
|
+
connection,
|
38
36
|
:get,
|
39
|
-
"/projects/#{project_id}/comments/#{string_comment_id}"
|
37
|
+
"#{config.target_api_url}/projects/#{project_id}/comments/#{string_comment_id}"
|
40
38
|
)
|
41
|
-
|
42
|
-
request.perform
|
39
|
+
Web::SendRequest.new(request).perform
|
43
40
|
end
|
44
41
|
|
45
42
|
def delete_string_comment(string_comment_id = nil, project_id = config.project_id)
|
@@ -47,12 +44,11 @@ module Crowdin
|
|
47
44
|
project_id || raise_project_id_is_required_error
|
48
45
|
|
49
46
|
request = Web::Request.new(
|
50
|
-
|
47
|
+
connection,
|
51
48
|
:delete,
|
52
|
-
"/projects/#{project_id}/comments/#{string_comment_id}"
|
49
|
+
"#{config.target_api_url}/projects/#{project_id}/comments/#{string_comment_id}"
|
53
50
|
)
|
54
|
-
|
55
|
-
request.perform
|
51
|
+
Web::SendRequest.new(request).perform
|
56
52
|
end
|
57
53
|
|
58
54
|
def edit_string_comment(string_comment_id = nil, query = {}, project_id = config.project_id)
|
@@ -60,13 +56,12 @@ module Crowdin
|
|
60
56
|
project_id || raise_project_id_is_required_error
|
61
57
|
|
62
58
|
request = Web::Request.new(
|
63
|
-
|
59
|
+
connection,
|
64
60
|
:patch,
|
65
|
-
"/projects/#{project_id}/comments/#{string_comment_id}",
|
66
|
-
query
|
61
|
+
"#{config.target_api_url}/projects/#{project_id}/comments/#{string_comment_id}",
|
62
|
+
{ params: query }
|
67
63
|
)
|
68
|
-
|
69
|
-
request.perform
|
64
|
+
Web::SendRequest.new(request).perform
|
70
65
|
end
|
71
66
|
end
|
72
67
|
end
|