crowdin-api 1.4.0 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,6 +3,9 @@
3
3
  module Crowdin
4
4
  module ApiResources
5
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}
6
9
  def list_branches(query = {}, project_id = config.project_id)
7
10
  project_id || raise_project_id_is_required_error
8
11
 
@@ -15,6 +18,9 @@ module Crowdin
15
18
  Web::SendRequest.new(request).perform
16
19
  end
17
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}
18
24
  def add_branch(query = {}, project_id = config.project_id)
19
25
  project_id || raise_project_id_is_required_error
20
26
 
@@ -27,6 +33,9 @@ module Crowdin
27
33
  Web::SendRequest.new(request).perform
28
34
  end
29
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}
30
39
  def get_branch(branch_id = nil, project_id = config.project_id)
31
40
  branch_id || raise_parameter_is_required_error(:branch_id)
32
41
  project_id || raise_project_id_is_required_error
@@ -39,6 +48,9 @@ module Crowdin
39
48
  Web::SendRequest.new(request).perform
40
49
  end
41
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}
42
54
  def delete_branch(branch_id = nil, project_id = config.project_id)
43
55
  branch_id || raise_parameter_is_required_error(:branch_id)
44
56
  project_id || raise_project_id_is_required_error
@@ -51,6 +63,10 @@ module Crowdin
51
63
  Web::SendRequest.new(request).perform
52
64
  end
53
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}
54
70
  def edit_branch(branch_id = nil, query = {}, project_id = config.project_id)
55
71
  branch_id || raise_parameter_is_required_error(:branch_id)
56
72
  project_id || raise_project_id_is_required_error
@@ -64,6 +80,9 @@ module Crowdin
64
80
  Web::SendRequest.new(request).perform
65
81
  end
66
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}
67
86
  def list_directories(query = {}, project_id = config.project_id)
68
87
  project_id || raise_project_id_is_required_error
69
88
 
@@ -76,6 +95,9 @@ module Crowdin
76
95
  Web::SendRequest.new(request).perform
77
96
  end
78
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}
79
101
  def add_directory(query = {}, project_id = config.project_id)
80
102
  project_id || raise_project_id_is_required_error
81
103
 
@@ -88,6 +110,9 @@ module Crowdin
88
110
  Web::SendRequest.new(request).perform
89
111
  end
90
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}
91
116
  def get_directory(directory_id = nil, project_id = config.project_id)
92
117
  directory_id || raise_parameter_is_required_error(:directory_id)
93
118
  project_id || raise_project_id_is_required_error
@@ -100,6 +125,9 @@ module Crowdin
100
125
  Web::SendRequest.new(request).perform
101
126
  end
102
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}
103
131
  def delete_directory(directory_id = nil, project_id = config.project_id)
104
132
  directory_id || raise_parameter_is_required_error(:directory_id)
105
133
  project_id || raise_project_id_is_required_error
@@ -112,6 +140,10 @@ module Crowdin
112
140
  Web::SendRequest.new(request).perform
113
141
  end
114
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}
115
147
  def edit_directory(directory_id = nil, query = {}, project_id = config.project_id)
116
148
  directory_id || raise_parameter_is_required_error(:directory_id)
117
149
  project_id || raise_project_id_is_required_error
@@ -125,6 +157,9 @@ module Crowdin
125
157
  Web::SendRequest.new(request).perform
126
158
  end
127
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}
128
163
  def list_files(query = {}, project_id = config.project_id)
129
164
  project_id || raise_project_id_is_required_error
130
165
 
@@ -137,6 +172,9 @@ module Crowdin
137
172
  Web::SendRequest.new(request).perform
138
173
  end
139
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}
140
178
  def add_file(query = {}, project_id = config.project_id)
141
179
  project_id || raise_project_id_is_required_error
142
180
 
@@ -149,6 +187,9 @@ module Crowdin
149
187
  Web::SendRequest.new(request).perform
150
188
  end
151
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}
152
193
  def get_file(file_id = nil, project_id = config.project_id)
153
194
  file_id || raise_parameter_is_required_error(:file_id)
154
195
  project_id || raise_project_id_is_required_error
@@ -161,6 +202,10 @@ module Crowdin
161
202
  Web::SendRequest.new(request).perform
162
203
  end
163
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}
164
209
  def update_or_restore_file(file_id = nil, query = {}, project_id = config.project_id)
165
210
  file_id || raise_parameter_is_required_error(:file_id)
166
211
  project_id || raise_project_id_is_required_error
@@ -174,6 +219,9 @@ module Crowdin
174
219
  Web::SendRequest.new(request).perform
175
220
  end
176
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}
177
225
  def delete_file(file_id = nil, project_id = config.project_id)
178
226
  file_id || raise_parameter_is_required_error(:file_id)
179
227
  project_id || raise_project_id_is_required_error
@@ -186,6 +234,10 @@ module Crowdin
186
234
  Web::SendRequest.new(request).perform
187
235
  end
188
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}
189
241
  def edit_file(file_id = nil, query = {}, project_id = config.project_id)
190
242
  file_id || raise_parameter_is_required_error(:file_id)
191
243
  project_id || raise_project_id_is_required_error
@@ -199,6 +251,10 @@ module Crowdin
199
251
  Web::SendRequest.new(request).perform
200
252
  end
201
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}
202
258
  def download_file(file_id = nil, destination = nil, project_id = config.project_id)
203
259
  file_id || raise_parameter_is_required_error(:file_id)
204
260
  project_id || raise_project_id_is_required_error
@@ -211,6 +267,10 @@ module Crowdin
211
267
  Web::SendRequest.new(request, destination).perform
212
268
  end
213
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}
214
274
  def list_file_revisions(file_id = nil, query = {}, project_id = config.project_id)
215
275
  file_id || raise_parameter_is_required_error(:file_id)
216
276
  project_id || raise_project_id_is_required_error
@@ -224,6 +284,10 @@ module Crowdin
224
284
  Web::SendRequest.new(request).perform
225
285
  end
226
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}
227
291
  def get_file_revision(file_id = nil, revision_id = nil, project_id = config.project_id)
228
292
  file_id || raise_parameter_is_required_error(:file_id)
229
293
  revision_id || raise_parameter_is_required_error(:revision_id)
@@ -3,6 +3,9 @@
3
3
  module Crowdin
4
4
  module ApiResources
5
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}
6
9
  def list_storages(query = {})
7
10
  request = Web::Request.new(
8
11
  connection,
@@ -13,6 +16,9 @@ module Crowdin
13
16
  Web::SendRequest.new(request).perform
14
17
  end
15
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}
16
22
  def add_storage(file = nil)
17
23
  file || raise_parameter_is_required_error(:file)
18
24
 
@@ -28,6 +34,9 @@ module Crowdin
28
34
  Web::SendRequest.new(request).perform
29
35
  end
30
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}
31
40
  def get_storage(storage_id = nil)
32
41
  storage_id || raise_parameter_is_required_error(:storage_id)
33
42
 
@@ -39,6 +48,9 @@ module Crowdin
39
48
  Web::SendRequest.new(request).perform
40
49
  end
41
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}
42
54
  def delete_storage(storage_id = nil)
43
55
  storage_id || raise_parameter_is_required_error(:storage_id)
44
56
 
@@ -188,6 +188,22 @@ module Crowdin
188
188
  )
189
189
  Web::SendRequest.new(request).perform
190
190
  end
191
+
192
+ def add_translation_alignment(project_id = nil, query = {})
193
+ project_id || raise_project_id_is_required_error
194
+
195
+ %i[source_language_id target_language_id text].each do |param|
196
+ query[param] || raise_parameter_is_required_error(param)
197
+ end
198
+
199
+ request = Web::Request.new(
200
+ connection,
201
+ :post,
202
+ "#{config.target_api_url}/projects/#{project_id}/translations/alignment",
203
+ { params: query }
204
+ )
205
+ Web::SendRequest.new(request).perform
206
+ end
191
207
  end
192
208
  end
193
209
  end
@@ -126,6 +126,22 @@ module Crowdin
126
126
  )
127
127
  Web::SendRequest.new(request).perform
128
128
  end
129
+
130
+ def search_tms_concordance(project_id = nil, query = {})
131
+ project_id || raise_project_id_is_required_error
132
+
133
+ %i[source_language_id target_language_id expression auto_substitution min_relevant].each do |param|
134
+ query[param] || raise_parameter_is_required_error(param)
135
+ end
136
+
137
+ request = Web::Request.new(
138
+ connection,
139
+ :post,
140
+ "#{config.target_api_url}/projects/#{project_id}/tms/concordance",
141
+ { params: query }
142
+ )
143
+ Web::SendRequest.new(request).perform
144
+ end
129
145
  end
130
146
  end
131
147
  end
@@ -103,7 +103,7 @@ module Crowdin
103
103
  # otherwise system will retry so many times, as indicated at tries_count
104
104
  #
105
105
  def fetch_all(api_resource, opts = {}, retry_opts = {})
106
- unless Web::FetchAllExtensions::API_RESOURCES_FOR_FETCH_ALL.include?(api_resource)
106
+ unless api_resource.to_s.start_with?('list_')
107
107
  raise(Errors::FetchAllProcessingError, "#{api_resource} method aren't supported for FetchAll")
108
108
  end
109
109
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Crowdin
4
4
  class Client
5
- VERSION = '1.4.0'
5
+ VERSION = '1.6.0'
6
6
  end
7
7
  end
@@ -4,11 +4,6 @@ module Crowdin
4
4
  module Web
5
5
  module FetchAllExtensions
6
6
  MAX_ITEMS_COUNT_PER_REQUEST = 500.freeze
7
- API_RESOURCES_FOR_FETCH_ALL = %i[list_vendors list_dictionaries list_directories list_distributions
8
- list_workflow_templates list_languages list_labels list_mts list_files
9
- list_projects list_groups list_branches list_strings list_storages
10
- list_string_comments list_tasks list_user_tasks list_webhooks
11
- list_terms list_file_revisions list_bundles].freeze
12
7
  end
13
8
  end
14
9
  end
@@ -13,11 +13,42 @@ describe Crowdin::ApiResources::Bundles do
13
13
  describe '#add_bundle' do
14
14
  it 'when request are valid', :default do
15
15
  stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/bundles")
16
- add_bundle = @crowdin.add_bundle({}, project_id)
16
+ add_bundle = @crowdin.add_bundle({ name: '', format: '', sourcePatterns: [], exportPattern: '' }, project_id)
17
17
  expect(add_bundle).to eq(200)
18
18
  end
19
19
  end
20
20
 
21
+ describe '#export_bundle' do
22
+ let(:bundle_id) { 1 }
23
+ it 'when request are valid', :default do
24
+ stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/bundles/#{bundle_id}/exports")
25
+ export_bundle = @crowdin.export_bundle(bundle_id, project_id)
26
+ expect(export_bundle).to eq(200)
27
+ end
28
+ end
29
+
30
+ describe '#check_bundle_export_status' do
31
+ let(:bundle_id) { 1 }
32
+ let(:export_id) { 1 }
33
+
34
+ it 'when request are valid', :default do
35
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/bundles/#{bundle_id}/exports/#{export_id}")
36
+ check_bundle_export_status = @crowdin.check_bundle_export_status(bundle_id, export_id, project_id)
37
+ expect(check_bundle_export_status).to eq(200)
38
+ end
39
+ end
40
+
41
+ describe '#download_bundle' do
42
+ let(:bundle_id) { 1 }
43
+ let(:export_id) { 1 }
44
+
45
+ it 'when request are valid', :default do
46
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/bundles/#{bundle_id}/exports/#{export_id}/download")
47
+ download_bundle = @crowdin.download_bundle(bundle_id, export_id, project_id)
48
+ expect(download_bundle).to eq(200)
49
+ end
50
+ end
51
+
21
52
  describe '#get_bundle' do
22
53
  let(:bundle_id) { 1 }
23
54