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,305 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Crowdin
4
+ module ApiResources
5
+ module SourceFiles
6
+ # @param query [Hash] Request Body
7
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.branches.getMany API Documentation}
8
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.branches.getMany Enterprise API Documentation}
9
+ def list_branches(query = {}, project_id = config.project_id)
10
+ project_id || raise_project_id_is_required_error
11
+
12
+ request = Web::Request.new(
13
+ connection,
14
+ :get,
15
+ "#{config.target_api_url}/projects/#{project_id}/branches",
16
+ { params: query }
17
+ )
18
+ Web::SendRequest.new(request).perform
19
+ end
20
+
21
+ # @param query [Hash] Request Body
22
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.branches.post API Documentation}
23
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.branches.post Enterprise API Documentation}
24
+ def add_branch(query = {}, project_id = config.project_id)
25
+ project_id || raise_project_id_is_required_error
26
+
27
+ request = Web::Request.new(
28
+ connection,
29
+ :post,
30
+ "#{config.target_api_url}/projects/#{project_id}/branches",
31
+ { params: query }
32
+ )
33
+ Web::SendRequest.new(request).perform
34
+ end
35
+
36
+ # @param branch_id [Integer] Branch ID
37
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.branches.get API Documentation}
38
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.branches.get Enterprise API Documentation}
39
+ def get_branch(branch_id = nil, project_id = config.project_id)
40
+ branch_id || raise_parameter_is_required_error(:branch_id)
41
+ project_id || raise_project_id_is_required_error
42
+
43
+ request = Web::Request.new(
44
+ connection,
45
+ :get,
46
+ "#{config.target_api_url}/projects/#{project_id}/branches/#{branch_id}"
47
+ )
48
+ Web::SendRequest.new(request).perform
49
+ end
50
+
51
+ # @param branch_id [Hash] Branch ID
52
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.branches.delete API Documentation}
53
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.branches.delete Enterprise API Documentation}
54
+ def delete_branch(branch_id = nil, project_id = config.project_id)
55
+ branch_id || raise_parameter_is_required_error(:branch_id)
56
+ project_id || raise_project_id_is_required_error
57
+
58
+ request = Web::Request.new(
59
+ connection,
60
+ :delete,
61
+ "#{config.target_api_url}/projects/#{project_id}/branches/#{branch_id}"
62
+ )
63
+ Web::SendRequest.new(request).perform
64
+ end
65
+
66
+ # @param query [Hash] Request Body
67
+ # @param branch_id [Integer] Branch ID
68
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.branches.patch API Documentation}
69
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.branches.patch Enterprise API Documentation}
70
+ def edit_branch(branch_id = nil, query = {}, project_id = config.project_id)
71
+ branch_id || raise_parameter_is_required_error(:branch_id)
72
+ project_id || raise_project_id_is_required_error
73
+
74
+ request = Web::Request.new(
75
+ connection,
76
+ :patch,
77
+ "#{config.target_api_url}/projects/#{project_id}/branches/#{branch_id}",
78
+ { params: query }
79
+ )
80
+ Web::SendRequest.new(request).perform
81
+ end
82
+
83
+ # @param query [Hash] Request Body
84
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.directories.getMany API Documentation}
85
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.directories.getMany Enterprise API Documentation}
86
+ def list_directories(query = {}, project_id = config.project_id)
87
+ project_id || raise_project_id_is_required_error
88
+
89
+ request = Web::Request.new(
90
+ connection,
91
+ :get,
92
+ "#{config.target_api_url}/projects/#{project_id}/directories",
93
+ { params: query }
94
+ )
95
+ Web::SendRequest.new(request).perform
96
+ end
97
+
98
+ # @param query [Hash] Request Body
99
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.directories.post API Documentation}
100
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.directories.post Enterprise API Documentation}
101
+ def add_directory(query = {}, project_id = config.project_id)
102
+ project_id || raise_project_id_is_required_error
103
+
104
+ request = Web::Request.new(
105
+ connection,
106
+ :post,
107
+ "#{config.target_api_url}/projects/#{project_id}/directories",
108
+ { params: query }
109
+ )
110
+ Web::SendRequest.new(request).perform
111
+ end
112
+
113
+ # @param directory_id [Integer] Directory ID
114
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.directories.get API Documentation}
115
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.directories.get Enterprise API Documentation}
116
+ def get_directory(directory_id = nil, project_id = config.project_id)
117
+ directory_id || raise_parameter_is_required_error(:directory_id)
118
+ project_id || raise_project_id_is_required_error
119
+
120
+ request = Web::Request.new(
121
+ connection,
122
+ :get,
123
+ "#{config.target_api_url}/projects/#{project_id}/directories/#{directory_id}"
124
+ )
125
+ Web::SendRequest.new(request).perform
126
+ end
127
+
128
+ # @param directory_id [Integer] Directory ID
129
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.directories.delete API Documentation}
130
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.directories.delete Enterprise API Documentation}
131
+ def delete_directory(directory_id = nil, project_id = config.project_id)
132
+ directory_id || raise_parameter_is_required_error(:directory_id)
133
+ project_id || raise_project_id_is_required_error
134
+
135
+ request = Web::Request.new(
136
+ connection,
137
+ :delete,
138
+ "#{config.target_api_url}/projects/#{project_id}/directories/#{directory_id}"
139
+ )
140
+ Web::SendRequest.new(request).perform
141
+ end
142
+
143
+ # @param query [Hash] Request Body
144
+ # @param directory_id [Integer] Directory ID
145
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.directories.patch API Documentation}
146
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.directories.patch Enterprise API Documentation}
147
+ def edit_directory(directory_id = nil, query = {}, project_id = config.project_id)
148
+ directory_id || raise_parameter_is_required_error(:directory_id)
149
+ project_id || raise_project_id_is_required_error
150
+
151
+ request = Web::Request.new(
152
+ connection,
153
+ :patch,
154
+ "#{config.target_api_url}/projects/#{project_id}/directories/#{directory_id}",
155
+ { params: query }
156
+ )
157
+ Web::SendRequest.new(request).perform
158
+ end
159
+
160
+ # @param query [Hash] Request Body
161
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.files.getMany API Documentation}
162
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.files.getMany Enterprise API Documentation}
163
+ def list_files(query = {}, project_id = config.project_id)
164
+ project_id || raise_project_id_is_required_error
165
+
166
+ request = Web::Request.new(
167
+ connection,
168
+ :get,
169
+ "#{config.target_api_url}/projects/#{project_id}/files",
170
+ { params: query }
171
+ )
172
+ Web::SendRequest.new(request).perform
173
+ end
174
+
175
+ # @param query [Hash] Request Body
176
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.files.post API Documentation}
177
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.files.post Enterprise API Documentation}
178
+ def add_file(query = {}, project_id = config.project_id)
179
+ project_id || raise_project_id_is_required_error
180
+
181
+ request = Web::Request.new(
182
+ connection,
183
+ :post,
184
+ "#{config.target_api_url}/projects/#{project_id}/files",
185
+ { params: query }
186
+ )
187
+ Web::SendRequest.new(request).perform
188
+ end
189
+
190
+ # @param file_id [Integer] File ID
191
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.files.get API Documentation}
192
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.files.get Enterprise API Documentation}
193
+ def get_file(file_id = nil, project_id = config.project_id)
194
+ file_id || raise_parameter_is_required_error(:file_id)
195
+ project_id || raise_project_id_is_required_error
196
+
197
+ request = Web::Request.new(
198
+ connection,
199
+ :get,
200
+ "#{config.target_api_url}/projects/#{project_id}/files/#{file_id}"
201
+ )
202
+ Web::SendRequest.new(request).perform
203
+ end
204
+
205
+ # @param query [Hash] Request Body
206
+ # @param file_id [Integer] File ID
207
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.files.put API Documentation}
208
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.files.put Enterprise API Documentation}
209
+ def update_or_restore_file(file_id = nil, query = {}, project_id = config.project_id)
210
+ file_id || raise_parameter_is_required_error(:file_id)
211
+ project_id || raise_project_id_is_required_error
212
+
213
+ request = Web::Request.new(
214
+ connection,
215
+ :put,
216
+ "#{config.target_api_url}/projects/#{project_id}/files/#{file_id}",
217
+ { params: query }
218
+ )
219
+ Web::SendRequest.new(request).perform
220
+ end
221
+
222
+ # @param file_id [Integer] File ID
223
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.files.delete API Documentation}
224
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.files.delete Enterprise API Documentation}
225
+ def delete_file(file_id = nil, project_id = config.project_id)
226
+ file_id || raise_parameter_is_required_error(:file_id)
227
+ project_id || raise_project_id_is_required_error
228
+
229
+ request = Web::Request.new(
230
+ connection,
231
+ :delete,
232
+ "#{config.target_api_url}/projects/#{project_id}/files/#{file_id}"
233
+ )
234
+ Web::SendRequest.new(request).perform
235
+ end
236
+
237
+ # @param query [Hash] Request Body
238
+ # @param file_id [Integer] File ID
239
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.files.patch API Documentation}
240
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.files.patch Enterprise API Documentation}
241
+ def edit_file(file_id = nil, query = {}, project_id = config.project_id)
242
+ file_id || raise_parameter_is_required_error(:file_id)
243
+ project_id || raise_project_id_is_required_error
244
+
245
+ request = Web::Request.new(
246
+ connection,
247
+ :patch,
248
+ "#{config.target_api_url}/projects/#{project_id}/files/#{file_id}",
249
+ { params: query }
250
+ )
251
+ Web::SendRequest.new(request).perform
252
+ end
253
+
254
+ # @param file_id [Integer] File ID
255
+ # @param destination [String] Destination of File
256
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.files.download.get API Documentation}
257
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.files.download.get Enterprise API Documentation}
258
+ def download_file(file_id = nil, destination = nil, project_id = config.project_id)
259
+ file_id || raise_parameter_is_required_error(:file_id)
260
+ project_id || raise_project_id_is_required_error
261
+
262
+ request = Web::Request.new(
263
+ connection,
264
+ :get,
265
+ "#{config.target_api_url}/projects/#{project_id}/files/#{file_id}/download"
266
+ )
267
+ Web::SendRequest.new(request, destination).perform
268
+ end
269
+
270
+ # @param query [Hash] Request Body
271
+ # @param file_id [Integer] File ID
272
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.files.revisions.getMany API Documentation}
273
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.files.revisions.getMany Enterprise API Documentation}
274
+ def list_file_revisions(file_id = nil, query = {}, project_id = config.project_id)
275
+ file_id || raise_parameter_is_required_error(:file_id)
276
+ project_id || raise_project_id_is_required_error
277
+
278
+ request = Web::Request.new(
279
+ connection,
280
+ :get,
281
+ "#{config.target_api_url}/projects/#{project_id}/files/#{file_id}/revisions",
282
+ { params: query }
283
+ )
284
+ Web::SendRequest.new(request).perform
285
+ end
286
+
287
+ # @param revision_id [Integer] Revision ID
288
+ # @param file_id [Integer] File ID
289
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.files.revisions.get API Documentation}
290
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.files.revisions.get Enterprise API Documentation}
291
+ def get_file_revision(file_id = nil, revision_id = nil, project_id = config.project_id)
292
+ file_id || raise_parameter_is_required_error(:file_id)
293
+ revision_id || raise_parameter_is_required_error(:revision_id)
294
+ project_id || raise_project_id_is_required_error
295
+
296
+ request = Web::Request.new(
297
+ connection,
298
+ :get,
299
+ "#{config.target_api_url}/projects/#{project_id}/files/#{file_id}/revisions/#{revision_id}"
300
+ )
301
+ Web::SendRequest.new(request).perform
302
+ end
303
+ end
304
+ end
305
+ 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
- self,
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
- self,
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
- self,
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
- self,
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
- self,
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,66 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Crowdin
4
+ module ApiResources
5
+ module Storages
6
+ # @param query [Hash] Request Body
7
+ # * {https://developer.crowdin.com/api/v2/#operation/api.storages.getMany API Documentation}
8
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.storages.getMany Enterprise API Documentation}
9
+ def list_storages(query = {})
10
+ request = Web::Request.new(
11
+ connection,
12
+ :get,
13
+ "#{config.target_api_url}/storages",
14
+ { params: query }
15
+ )
16
+ Web::SendRequest.new(request).perform
17
+ end
18
+
19
+ # @param file [string] File path
20
+ # * {https://developer.crowdin.com/api/v2/#operation/api.storages.post API Documentation}
21
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.storages.post Enterprise API Documentation}
22
+ def add_storage(file = nil)
23
+ file || raise_parameter_is_required_error(:file)
24
+
25
+ file = file.is_a?(File) ? file : File.open(file, 'r')
26
+ headers = { 'Content-Type' => 'application/octet-stream', 'Crowdin-API-FileName' => File.basename(file) }
27
+
28
+ request = Web::Request.new(
29
+ connection,
30
+ :post,
31
+ "#{config.target_api_url}/storages",
32
+ { params: file, headers: headers }
33
+ )
34
+ Web::SendRequest.new(request).perform
35
+ end
36
+
37
+ # @param storage_id [Integer] Storage ID
38
+ # * {https://developer.crowdin.com/api/v2/#operation/api.storages.get API Documentation}
39
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.storages.get Enterprise API Documentation}
40
+ def get_storage(storage_id = nil)
41
+ storage_id || raise_parameter_is_required_error(:storage_id)
42
+
43
+ request = Web::Request.new(
44
+ connection,
45
+ :get,
46
+ "#{config.target_api_url}/storages/#{storage_id}"
47
+ )
48
+ Web::SendRequest.new(request).perform
49
+ end
50
+
51
+ # @param storage_id [Integer] Storage ID
52
+ # * {https://developer.crowdin.com/api/v2/#operation/api.storages.delete API Documentation}
53
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.storages.delete Enterprise API Documentation}
54
+ def delete_storage(storage_id = nil)
55
+ storage_id || raise_parameter_is_required_error(:storage_id)
56
+
57
+ request = Web::Request.new(
58
+ connection,
59
+ :delete,
60
+ "#{config.target_api_url}/storages/#{storage_id}"
61
+ )
62
+ Web::SendRequest.new(request).perform
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Crowdin
4
+ module ApiResources
5
+ module StringComments
6
+ def list_string_comments(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}/comments",
13
+ { params: query }
14
+ )
15
+ Web::SendRequest.new(request).perform
16
+ end
17
+
18
+ def add_string_comment(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}/comments",
25
+ { params: query }
26
+ )
27
+ Web::SendRequest.new(request).perform
28
+ end
29
+
30
+ def get_string_comment(string_comment_id = nil, project_id = config.project_id)
31
+ string_comment_id || raise_parameter_is_required_error(:string_comment_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}/comments/#{string_comment_id}"
38
+ )
39
+ Web::SendRequest.new(request).perform
40
+ end
41
+
42
+ def delete_string_comment(string_comment_id = nil, project_id = config.project_id)
43
+ string_comment_id || raise_parameter_is_required_error(:string_comment_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}/comments/#{string_comment_id}"
50
+ )
51
+ Web::SendRequest.new(request).perform
52
+ end
53
+
54
+ def edit_string_comment(string_comment_id = nil, query = {}, project_id = config.project_id)
55
+ string_comment_id || raise_parameter_is_required_error(:string_comment_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}/comments/#{string_comment_id}",
62
+ { params: query }
63
+ )
64
+ Web::SendRequest.new(request).perform
65
+ end
66
+ end
67
+ end
68
+ end