crowdin-api 1.3.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -115,6 +115,70 @@ module Crowdin
115
115
  )
116
116
  Web::SendRequest.new(request, destination).perform
117
117
  end
118
+
119
+ def list_report_settings_templates(query = {}, project_id = config.project_id)
120
+ project_id || raise_project_id_is_required_error
121
+
122
+ request = Web::Request.new(
123
+ connection,
124
+ :get,
125
+ "#{config.target_api_url}/projects/#{project_id}/reports/settings-templates",
126
+ { params: query }
127
+ )
128
+ Web::SendRequest.new(request).perform
129
+ end
130
+
131
+ def add_report_settings_template(query = {}, project_id = config.project_id)
132
+ project_id || raise_project_id_is_required_error
133
+ %i[name currency unit mode config].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}/reports/settings-templates",
141
+ { params: query }
142
+ )
143
+ Web::SendRequest.new(request).perform
144
+ end
145
+
146
+ def get_report_settings_template(template_id = nil, project_id = config.project_id)
147
+ project_id || raise_project_id_is_required_error
148
+ template_id || raise_parameter_is_required_error(:template_id)
149
+
150
+ request = Web::Request.new(
151
+ connection,
152
+ :get,
153
+ "#{config.target_api_url}/projects/#{project_id}/reports/settings-templates/#{template_id}"
154
+ )
155
+ Web::SendRequest.new(request).perform
156
+ end
157
+
158
+ def edit_report_settings_template(query = {}, template_id = nil, project_id = config.project_id)
159
+ project_id || raise_project_id_is_required_error
160
+ template_id || raise_parameter_is_required_error(:template_id)
161
+
162
+ request = Web::Request.new(
163
+ connection,
164
+ :patch,
165
+ "#{config.target_api_url}/projects/#{project_id}/reports/settings-templates/#{template_id}",
166
+ { params: query }
167
+ )
168
+ Web::SendRequest.new(request).perform
169
+ end
170
+
171
+ def delete_report_settings_template(template_id = nil, project_id = config.project_id)
172
+ project_id || raise_project_id_is_required_error
173
+ template_id || raise_parameter_is_required_error(:template_id)
174
+
175
+ request = Web::Request.new(
176
+ connection,
177
+ :delete,
178
+ "#{config.target_api_url}/projects/#{project_id}/reports/settings-templates/#{template_id}"
179
+ )
180
+ Web::SendRequest.new(request).perform
181
+ end
118
182
  end
119
183
  end
120
184
  end
@@ -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
 
@@ -177,7 +177,7 @@ module Crowdin
177
177
  Web::SendRequest.new(request).perform
178
178
  end
179
179
 
180
- def edit_screenshot(vote_id = nil, project_id = config.project_id)
180
+ def cancel_vote(vote_id = nil, project_id = config.project_id)
181
181
  vote_id || raise_parameter_is_required_error(:vote_id)
182
182
  project_id || raise_project_id_is_required_error
183
183
 
@@ -30,6 +30,8 @@ module Crowdin
30
30
  Client.send(:include, Object.const_get("Crowdin::Errors::#{module_name}"))
31
31
  end
32
32
 
33
+ include Web::FetchAllExtensions
34
+
33
35
  # Config instance that includes configuration options for the Client
34
36
  attr_reader :config
35
37
  # Instance with established connection through RestClient to the Crowdin API
@@ -67,6 +69,89 @@ module Crowdin
67
69
  config.logger_enabled?
68
70
  end
69
71
 
72
+ #
73
+ # FetchAll options:
74
+ # * limit, Integer, default: 500 | How many records need to load per one request
75
+ # * offset, Integer, default: 0 | How many records need to skip
76
+ # * request_delay, Integer (seconds), default: 0 | Delay between requests
77
+ #
78
+ #
79
+ # Note: Please, specify project_id while Client initialization if you need to use methods that need it within FetchAll
80
+ #
81
+ # === Example
82
+ #
83
+ # @crowdin.fetch_all(:list_projects)
84
+ #
85
+ # with specified options
86
+ #
87
+ # @crowdin.fetch_all(:list_projects, { limit: 10, request_delay: 1 })
88
+ #
89
+ # playing with response per fetch. Note: the block actually don't make any effect to finite result
90
+ #
91
+ # @crowdin.fetch_all(:list_projects, { limit: 10, request_delay: 1 }) { |response| puts response['data'] }
92
+ #
93
+ # also you can specify retry configuration to handle some exceptions
94
+ #
95
+ # Retry configuration options:
96
+ # * request_delay, Integer (seconds), default: 0 | Delay between retries
97
+ # * retries_count, Integer, default: 0
98
+ # * error_messages, Array
99
+ #
100
+ # @crowdin.fetch_all(:list_projects, {}, { request_delay: 2, retries_count: 3, error_messages: ['401'] })
101
+ #
102
+ # fetch all execution will be terminated if response error are same as in error_messages array
103
+ # otherwise system will retry so many times, as indicated at tries_count
104
+ #
105
+ def fetch_all(api_resource, opts = {}, retry_opts = {})
106
+ unless api_resource.to_s.start_with?('list_')
107
+ raise(Errors::FetchAllProcessingError, "#{api_resource} method aren't supported for FetchAll")
108
+ end
109
+
110
+ limit = opts[:limit] || Web::FetchAllExtensions::MAX_ITEMS_COUNT_PER_REQUEST
111
+ offset = opts[:offset] || 0
112
+ request_delay = opts[:request_delay] || 0
113
+
114
+ retry_request_delay = retry_opts[:request_delay] || 0
115
+ retries_count = retry_opts[:retries_count] || 0
116
+ retry_error_messages = retry_opts[:error_messages] || []
117
+
118
+ result = []
119
+ loop do
120
+ response = case api_resource
121
+ when :list_terms
122
+ send(api_resource, opts[:glossary_id], { limit: limit, offset: offset }.merge(opts))
123
+ when :list_file_revisions
124
+ send(api_resource, opts[:file_id], { limit: limit, offset: offset }.merge(opts))
125
+ else
126
+ send(api_resource, { limit: limit, offset: offset }.merge(opts))
127
+ end
128
+
129
+ if response.is_a?(String) && response.match('Something went wrong')
130
+ if retries_count.positive?
131
+ retry_error_messages.each do |message|
132
+ break if response.match(message)
133
+ end
134
+
135
+ retries_count -= 1
136
+ sleep retry_request_delay
137
+ else
138
+ raise(Errors::FetchAllProcessingError, response)
139
+ end
140
+ else
141
+ yield response if block_given?
142
+ deserialized_response = response['data']
143
+ result.concat(deserialized_response)
144
+ offset += deserialized_response.size
145
+ break if deserialized_response.size < limit
146
+ end
147
+
148
+ sleep request_delay
149
+ end
150
+ result
151
+ rescue StandardError => e
152
+ raise(Errors::FetchAllProcessingError, "FetchAll wasn't processed. Details - #{e.message}")
153
+ end
154
+
70
155
  private
71
156
 
72
157
  def build_configuration
@@ -85,6 +170,7 @@ module Crowdin
85
170
 
86
171
  def set_default_logger
87
172
  require 'logger'
173
+
88
174
  @logger ||= Logger.new($stdout)
89
175
  update_rest_client_logger
90
176
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Crowdin
4
4
  class Client
5
- VERSION = '1.3.0'
5
+ VERSION = '1.5.0'
6
6
  end
7
7
  end
@@ -4,5 +4,6 @@ module Crowdin
4
4
  module Errors
5
5
  class OnlyForEnterpriseModeError < StandardError; end
6
6
  class LoggerAreNotEnabledError < StandardError; end
7
+ class FetchAllProcessingError < StandardError; end
7
8
  end
8
9
  end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Crowdin
4
+ module Web
5
+ module FetchAllExtensions
6
+ MAX_ITEMS_COUNT_PER_REQUEST = 500.freeze
7
+ end
8
+ end
9
+ end
@@ -29,29 +29,24 @@ module Crowdin
29
29
  connection.delete
30
30
  end
31
31
 
32
- def patch?
33
- method.eql?(:patch)
34
- end
35
-
36
- def patch
37
- connection.patch(prepare_payload(payload[:params]), payload[:headers]) { |response, _, _| response }
32
+ def process_with_body
33
+ connection.send(method, prepare_payload(payload[:params]), payload[:headers]) { |response, _, _| response }
38
34
  end
39
35
 
40
36
  def post?
41
37
  method.eql?(:post)
42
38
  end
39
+ alias post process_with_body
43
40
 
44
- def post
45
- connection.post(prepare_payload(payload[:params]), payload[:headers]) { |response, _, _| response }
41
+ def patch?
42
+ method.eql?(:patch)
46
43
  end
44
+ alias patch process_with_body
47
45
 
48
46
  def put?
49
47
  method.eql?(:put)
50
48
  end
51
-
52
- def put
53
- connection.put(prepare_payload(payload[:params]), payload[:headers]) { |response, _, _| response }
54
- end
49
+ alias put process_with_body
55
50
 
56
51
  private
57
52
 
data/lib/crowdin-api.rb CHANGED
@@ -5,7 +5,7 @@ module Crowdin
5
5
  API_RESOURCES_MODULES = %i[Storages Languages Projects Workflows SourceFiles Translations SourceStrings
6
6
  StringTranslations StringComments Screenshots Glossaries TranslationMemory
7
7
  MachineTranslationEngines Reports Tasks Users Teams Vendors Webhooks
8
- Dictionaries Distributions Labels TranslationStatus].freeze
8
+ Dictionaries Distributions Labels TranslationStatus Bundles].freeze
9
9
 
10
10
  # Error Raisers modules
11
11
  ERROR_RAISERS_MODULES = %i[ApiErrorsRaiser ClientErrorsRaiser].freeze
@@ -21,6 +21,7 @@ require 'crowdin-api/core/errors'
21
21
  require 'crowdin-api/core/errors_raisers'
22
22
  require 'crowdin-api/core/request'
23
23
  require 'crowdin-api/core/send_request'
24
+ require 'crowdin-api/core/fetch_all_extensions'
24
25
 
25
26
  # API modules
26
27
  Crowdin::API_RESOURCES_MODULES.each do |api_resource|
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ describe Crowdin::ApiResources::Bundles do
4
+ describe 'Default endpoints' do
5
+ describe '#list_bundles' do
6
+ it 'when request are valid', :default do
7
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/bundles")
8
+ list_bundles = @crowdin.list_bundles({}, project_id)
9
+ expect(list_bundles).to eq(200)
10
+ end
11
+ end
12
+
13
+ describe '#add_bundle' do
14
+ it 'when request are valid', :default do
15
+ stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/bundles")
16
+ add_bundle = @crowdin.add_bundle({ name: '', format: '', sourcePatterns: [], exportPattern: '' }, project_id)
17
+ expect(add_bundle).to eq(200)
18
+ end
19
+ end
20
+
21
+ describe '#get_bundle' do
22
+ let(:bundle_id) { 1 }
23
+
24
+ it 'when request are valid', :default do
25
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/bundles/#{bundle_id}")
26
+ get_bundle = @crowdin.get_bundle(bundle_id, project_id)
27
+ expect(get_bundle).to eq(200)
28
+ end
29
+ end
30
+
31
+ describe '#delete_bundle' do
32
+ let(:bundle_id) { 1 }
33
+
34
+ it 'when request are valid', :default do
35
+ stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/bundles/#{bundle_id}")
36
+ delete_bundle = @crowdin.delete_bundle(bundle_id, project_id)
37
+ expect(delete_bundle).to eq(200)
38
+ end
39
+ end
40
+
41
+ describe '#edit_bundle' do
42
+ let(:bundle_id) { 1 }
43
+
44
+ it 'when request are valid', :default do
45
+ stub_request(:patch, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/bundles/#{bundle_id}")
46
+ edit_bundle = @crowdin.edit_bundle(bundle_id, {}, project_id)
47
+ expect(edit_bundle).to eq(200)
48
+ end
49
+ end
50
+
51
+ describe '#bundle_list_files' do
52
+ let(:bundle_id) { 1 }
53
+
54
+ it 'when request are valid', :default do
55
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/bundles/#{bundle_id}/files")
56
+ bundle_list_files = @crowdin.bundle_list_files(bundle_id, {}, project_id)
57
+ expect(bundle_list_files).to eq(200)
58
+ end
59
+ end
60
+ end
61
+ end
@@ -163,5 +163,48 @@ describe Crowdin::ApiResources::Glossaries do
163
163
  expect(edit_term).to eq(200)
164
164
  end
165
165
  end
166
+
167
+ describe '#list_concepts' do
168
+ let(:glossary_id) { 1 }
169
+
170
+ it 'when request are valid', :default do
171
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/glossaries/#{glossary_id}/concepts")
172
+ concepts = @crowdin.list_concepts(glossary_id)
173
+ expect(concepts).to eq(200)
174
+ end
175
+ end
176
+
177
+ describe '#get_concept' do
178
+ let(:glossary_id) { 1 }
179
+ let(:concept_id) { 1 }
180
+
181
+ it 'when request are valid', :default do
182
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/glossaries/#{glossary_id}/concepts/#{concept_id}")
183
+ concept = @crowdin.get_concept(glossary_id, concept_id)
184
+ expect(concept).to eq(200)
185
+ end
186
+ end
187
+
188
+ describe '#update_concept' do
189
+ let(:glossary_id) { 1 }
190
+ let(:concept_id) { 1 }
191
+
192
+ it 'when request are valid', :default do
193
+ stub_request(:put, "https://api.crowdin.com/#{target_api_url}/glossaries/#{glossary_id}/concepts/#{concept_id}")
194
+ concept = @crowdin.update_concept(glossary_id, concept_id)
195
+ expect(concept).to eq(200)
196
+ end
197
+ end
198
+
199
+ describe '#update_concept' do
200
+ let(:glossary_id) { 1 }
201
+ let(:concept_id) { 1 }
202
+
203
+ it 'when request are valid', :default do
204
+ stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/glossaries/#{glossary_id}/concepts/#{concept_id}")
205
+ concept = @crowdin.delete_concept(glossary_id, concept_id)
206
+ expect(concept).to eq(200)
207
+ end
208
+ end
166
209
  end
167
210
  end
@@ -92,4 +92,54 @@ describe Crowdin::ApiResources::Reports do
92
92
  end
93
93
  end
94
94
  end
95
+
96
+ describe 'Setting Templates endpoints' do
97
+ describe 'List Report Settings templates' do
98
+ it 'when request are valid', :default do
99
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/reports/settings-templates")
100
+ settings_templates = @crowdin.list_report_settings_templates({}, project_id)
101
+ expect(settings_templates).to eq(200)
102
+ end
103
+ end
104
+
105
+ describe 'Add Report Settings template' do
106
+ it 'when request are valid', :default do
107
+ stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/reports/settings-templates")
108
+ settings_templates = @crowdin.add_report_settings_template(
109
+ { name: '', currency: '', unit: '', mode: '', config: '' }, project_id
110
+ )
111
+ expect(settings_templates).to eq(200)
112
+ end
113
+ end
114
+
115
+ describe 'Get Report Settings template' do
116
+ let(:template_id) { 1 }
117
+
118
+ it 'when request are valid', :default do
119
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/reports/settings-templates/#{template_id}")
120
+ settings_templates = @crowdin.get_report_settings_template(template_id, project_id)
121
+ expect(settings_templates).to eq(200)
122
+ end
123
+ end
124
+
125
+ describe 'Get Report Settings template' do
126
+ let(:template_id) { 1 }
127
+
128
+ it 'when request are valid', :default do
129
+ stub_request(:patch, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/reports/settings-templates/#{template_id}")
130
+ settings_templates = @crowdin.edit_report_settings_template({}, template_id, project_id)
131
+ expect(settings_templates).to eq(200)
132
+ end
133
+ end
134
+
135
+ describe 'Get Report Settings template' do
136
+ let(:template_id) { 1 }
137
+
138
+ it 'when request are valid', :default do
139
+ stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/reports/settings-templates/#{template_id}")
140
+ settings_templates = @crowdin.delete_report_settings_template(template_id, project_id)
141
+ expect(settings_templates).to eq(200)
142
+ end
143
+ end
144
+ end
95
145
  end