crowdin-api 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 61895ba4796676e716e2a62d4255f518cfcf3b2c138912f201cddce16250a474
4
- data.tar.gz: 6cd484b5d394e9b0c2ed2597003d1a64db1d656242d241728c3d4d9f650df87d
3
+ metadata.gz: 283ff1afb3a211be3a2c06c0417decc9b6ff3fcca1e8c61c78523708c428d286
4
+ data.tar.gz: e6f02c86c39702e00eacc0908c6dec0a93783a7a4038e2eddbc634ca2d4887d3
5
5
  SHA512:
6
- metadata.gz: 14a37cc1eba04d6170dfe082d50ff3ddc033997c1f4f3eab26ab3f9c04b7b35a419c5642cda28b0fbfb258588b234d24dbb685a004cf14841d85bf7f3b12a790
7
- data.tar.gz: 4c60ed5dbb6dbe6ab2dfd64f92d508be2f13ac2223a6a34292fb09c1fa1ebcb320ce3ee0ee2c56ba04fc15bc5d598d569528212bc505076d23c7c5ace0515f72
6
+ metadata.gz: ca47c68a8c81d3de24a5ae913155ece611ae9400fdbea47933355d6043036c269d15ab067df037afcdc4aae1fa982991f49bee4603fb5f6816a783dd6d7c30b1
7
+ data.tar.gz: dcf04302fb3c882a81f630476b4e7dce4cf1e98320da04615d3d393fb4bdfadb9bc67aec732bee227321cd3af7cbc095363f0f0c22a903a5f954acb6101a243a
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,6 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2022-05-09 23:17:26 UTC using RuboCop version 1.26.0.
3
+ # on 2022-08-12 15:14:54 UTC using RuboCop version 1.26.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
@@ -21,16 +21,21 @@ Gemspec/RequiredRubyVersion:
21
21
  Exclude:
22
22
  - 'crowdin-api.gemspec'
23
23
 
24
- # Offense count: 18
24
+ # Offense count: 2
25
25
  # This cop supports safe auto-correction (--auto-correct).
26
- # Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment.
27
- Layout/ExtraSpacing:
26
+ # Configuration parameters: EnforcedStyle, IndentOneStep, IndentationWidth.
27
+ # SupportedStyles: case, end
28
+ Layout/CaseIndentation:
28
29
  Exclude:
29
- - 'lib/crowdin-api/api_resources/machine_translation_engines.rb'
30
- - 'lib/crowdin-api/api_resources/reports.rb'
31
- - 'lib/crowdin-api/api_resources/teams.rb'
32
- - 'lib/crowdin-api/api_resources/users.rb'
33
- - 'lib/crowdin-api/api_resources/workflows.rb'
30
+ - 'lib/crowdin-api/client/client.rb'
31
+
32
+ # Offense count: 1
33
+ # This cop supports safe auto-correction (--auto-correct).
34
+ # Configuration parameters: EnforcedStyleAlignWith, Severity.
35
+ # SupportedStylesAlignWith: keyword, variable, start_of_line
36
+ Layout/EndAlignment:
37
+ Exclude:
38
+ - 'lib/crowdin-api/client/client.rb'
34
39
 
35
40
  # Offense count: 4
36
41
  # This cop supports safe auto-correction (--auto-correct).
@@ -42,7 +47,7 @@ Layout/HashAlignment:
42
47
  Exclude:
43
48
  - 'lib/crowdin-api/client/configuration.rb'
44
49
 
45
- # Offense count: 13
50
+ # Offense count: 14
46
51
  # This cop supports safe auto-correction (--auto-correct).
47
52
  # Configuration parameters: EnforcedStyle.
48
53
  # SupportedStyles: normal, indented_internal_methods
@@ -52,7 +57,7 @@ Layout/IndentationConsistency:
52
57
  - 'lib/crowdin-api/core/request.rb'
53
58
  - 'lib/crowdin-api/core/send_request.rb'
54
59
 
55
- # Offense count: 13
60
+ # Offense count: 14
56
61
  # This cop supports safe auto-correction (--auto-correct).
57
62
  # Configuration parameters: Width, IgnoredPatterns.
58
63
  Layout/IndentationWidth:
@@ -61,59 +66,60 @@ Layout/IndentationWidth:
61
66
  - 'lib/crowdin-api/core/request.rb'
62
67
  - 'lib/crowdin-api/core/send_request.rb'
63
68
 
64
- # Offense count: 22
69
+ # Offense count: 4
65
70
  # This cop supports safe auto-correction (--auto-correct).
66
71
  # Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator.
67
72
  # SupportedStylesForExponentOperator: space, no_space
68
73
  Layout/SpaceAroundOperators:
69
74
  Exclude:
70
75
  - 'crowdin-api.gemspec'
71
- - 'lib/crowdin-api/api_resources/machine_translation_engines.rb'
72
- - 'lib/crowdin-api/api_resources/reports.rb'
73
- - 'lib/crowdin-api/api_resources/teams.rb'
74
- - 'lib/crowdin-api/api_resources/users.rb'
75
- - 'lib/crowdin-api/api_resources/workflows.rb'
76
76
  - 'spec/api_resources/projects_spec.rb'
77
77
 
78
- # Offense count: 1
79
- # This cop supports safe auto-correction (--auto-correct).
80
- # Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods.
81
- Lint/UnusedMethodArgument:
82
- Exclude:
83
- - 'lib/crowdin-api/core/send_request.rb'
84
-
85
- # Offense count: 2
78
+ # Offense count: 3
86
79
  # Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
87
80
  Metrics/AbcSize:
88
- Max: 23
81
+ Max: 42
89
82
 
90
- # Offense count: 4
83
+ # Offense count: 46
91
84
  # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
92
85
  # IgnoredMethods: refine
93
86
  Metrics/BlockLength:
94
87
  Max: 171
95
88
 
96
- # Offense count: 13
89
+ # Offense count: 1
90
+ # Configuration parameters: CountComments, CountAsOne.
91
+ Metrics/ClassLength:
92
+ Max: 101
93
+
94
+ # Offense count: 1
95
+ # Configuration parameters: IgnoredMethods.
96
+ Metrics/CyclomaticComplexity:
97
+ Max: 18
98
+
99
+ # Offense count: 6
97
100
  # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
98
101
  Metrics/MethodLength:
99
- Max: 18
102
+ Max: 41
100
103
 
101
- # Offense count: 9
104
+ # Offense count: 8
102
105
  # Configuration parameters: CountComments, CountAsOne.
103
106
  Metrics/ModuleLength:
104
- Max: 199
107
+ Max: 196
105
108
 
106
- # Offense count: 3
107
- # Configuration parameters: CountKeywordArgs.
109
+ # Offense count: 2
110
+ # Configuration parameters: Max, CountKeywordArgs.
108
111
  Metrics/ParameterLists:
109
112
  MaxOptionalParameters: 4
110
- Max: 6
111
113
 
112
- # Offense count: 2
114
+ # Offense count: 1
115
+ # Configuration parameters: IgnoredMethods.
116
+ Metrics/PerceivedComplexity:
117
+ Max: 19
118
+
119
+ # Offense count: 1
113
120
  Naming/AccessorMethodName:
114
121
  Exclude:
115
122
  - 'lib/crowdin-api/api_resources/users.rb'
116
- - 'lib/crowdin-api/core/send_request.rb'
117
123
 
118
124
  # Offense count: 1
119
125
  # Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, CheckDefinitionPathHierarchyRoots, Regex, IgnoreExecutableScripts, AllowedAcronyms.
@@ -130,13 +136,6 @@ Naming/MemoizedInstanceVariableName:
130
136
  Exclude:
131
137
  - 'lib/crowdin-api/client/client.rb'
132
138
 
133
- # Offense count: 6
134
- # This cop supports safe auto-correction (--auto-correct).
135
- # Configuration parameters: PreferredName.
136
- Naming/RescuedExceptionsVariableName:
137
- Exclude:
138
- - 'lib/crowdin-api/core/send_request.rb'
139
-
140
139
  # Offense count: 7
141
140
  # This cop supports safe auto-correction (--auto-correct).
142
141
  # Configuration parameters: EnforcedStyle.
@@ -146,14 +145,13 @@ Style/AccessorGrouping:
146
145
  - 'lib/crowdin-api/client/configuration.rb'
147
146
  - 'lib/crowdin-api/core/request.rb'
148
147
 
149
- # Offense count: 4
148
+ # Offense count: 2
150
149
  # This cop supports unsafe auto-correction (--auto-correct-all).
151
150
  Style/CollectionCompact:
152
151
  Exclude:
153
152
  - 'lib/crowdin-api/core/request.rb'
154
- - 'lib/crowdin-api/core/send_request.rb'
155
153
 
156
- # Offense count: 24
154
+ # Offense count: 27
157
155
  # Configuration parameters: AllowedConstants.
158
156
  Style/Documentation:
159
157
  Enabled: false
@@ -175,25 +173,21 @@ Style/FrozenStringLiteralComment:
175
173
  - 'bin/crowdin-console'
176
174
 
177
175
  # Offense count: 1
178
- Style/MixinUsage:
176
+ # Configuration parameters: MinBodyLength.
177
+ Style/GuardClause:
179
178
  Exclude:
180
- - 'bin/crowdin-console'
179
+ - 'lib/crowdin-api/client/client.rb'
181
180
 
182
- # Offense count: 2
183
- # This cop supports safe auto-correction (--auto-correct).
184
- # Configuration parameters: EnforcedStyle.
185
- # SupportedStyles: implicit, explicit
186
- Style/RescueStandardError:
181
+ # Offense count: 1
182
+ Style/MixinUsage:
187
183
  Exclude:
188
- - 'lib/crowdin-api/api_resources/labels.rb'
189
- - 'lib/crowdin-api/api_resources/string_translations.rb'
184
+ - 'bin/crowdin-console'
190
185
 
191
186
  # Offense count: 1
192
- # This cop supports unsafe auto-correction (--auto-correct-all).
193
- # Configuration parameters: Mode.
194
- Style/StringConcatenation:
187
+ # This cop supports safe auto-correction (--auto-correct).
188
+ Style/RedundantFreeze:
195
189
  Exclude:
196
- - 'lib/crowdin-api/api_resources/projects.rb'
190
+ - 'lib/crowdin-api/core/fetch_all_extensions.rb'
197
191
 
198
192
  # Offense count: 8
199
193
  # This cop supports safe auto-correction (--auto-correct).
@@ -203,9 +197,9 @@ Style/StringLiterals:
203
197
  Exclude:
204
198
  - 'spec/api_resources/projects_spec.rb'
205
199
 
206
- # Offense count: 1
200
+ # Offense count: 2
207
201
  # This cop supports safe auto-correction (--auto-correct).
208
202
  # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
209
203
  # URISchemes: http, https
210
204
  Layout/LineLength:
211
- Max: 121
205
+ Max: 122
data/README.md CHANGED
@@ -27,6 +27,7 @@ For more about Crowdin API v2 see the documentation:
27
27
  * [Quick Start](#quick-start)
28
28
  * [Initialization](#initialization)
29
29
  * [Usage](#usage)
30
+ * [Fetch all records](#fetch-all-records)
30
31
  * [Command-Line Client](#command-line-client)
31
32
  * [Seeking Assistance](#seeking-assistance)
32
33
  * [Contributing](#contributing)
@@ -40,7 +41,7 @@ For more about Crowdin API v2 see the documentation:
40
41
  Add this line to your application's Gemfile:
41
42
 
42
43
  ```gemfile
43
- gem 'crowdin-api', '~> 1.3.0'
44
+ gem 'crowdin-api', '~> 1.4.0'
44
45
  ```
45
46
 
46
47
  And then execute:
@@ -66,6 +67,7 @@ gem install crowdin-api
66
67
  ## Quick start
67
68
 
68
69
  ### Initialization
70
+
69
71
  ```ruby
70
72
  require 'crowdin-api'
71
73
 
@@ -145,6 +147,33 @@ file_revisions = crowdin.list_file_revisions(your_file_id, { limit: 10 }, your_p
145
147
  # Note: more examples you can find in spec folder
146
148
  ```
147
149
 
150
+ ### Fetch all records
151
+
152
+ There is a possibility to fetch all records from paginatable methods using `fetch_all` method.
153
+
154
+ ```ruby
155
+ # FetchAll options:
156
+ # * limit, Integer, default: 500 | How many records need to load per one request
157
+ # * offset, Integer, default: 0
158
+ # * request_delay, Integer (seconds), default: 0 | Delay between requests. To specify a delay in milliseconds use float values like 0.100
159
+
160
+ # Examples:
161
+
162
+ @crowdin.fetch_all(:list_projects)
163
+
164
+ # with options
165
+ @crowdin.fetch_all(:list_projects, { limit: 10, request_delay: 1 })
166
+
167
+ # playing with response per fetch
168
+ # Note: the block actually don't make any effect to finite result
169
+ @crowdin.fetch_all(:list_projects, { limit: 10, request_delay: 1 }) { |response| puts response['data'] }
170
+
171
+ # also, you could specify a retry configuration to handle some exceptions
172
+ # fetch all execution will be terminated if response status code is the same as one of the error_messages array value
173
+ # otherwise, the request will be retried so many times, as indicated at retries_count
174
+ @crowdin.fetch_all(:list_projects, {}, { request_delay: 2, retries_count: 3, error_messages: ['401'] })
175
+ ```
176
+
148
177
  ### Command-Line Client
149
178
 
150
179
  The Crowdin Ruby client support crowdin-console, where you can test endpoints easier
@@ -0,0 +1,81 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Crowdin
4
+ module ApiResources
5
+ module Bundles
6
+ def list_bundles(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}/bundles",
13
+ { params: query }
14
+ )
15
+ Web::SendRequest.new(request).perform
16
+ end
17
+
18
+ def add_bundle(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}/bundles",
25
+ { params: query }
26
+ )
27
+ Web::SendRequest.new(request).perform
28
+ end
29
+
30
+ def get_bundle(bundle_id, project_id = config.project_id)
31
+ bundle_id || raise_parameter_is_required_error(:bundle_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}/bundles/#{bundle_id}"
38
+ )
39
+ Web::SendRequest.new(request).perform
40
+ end
41
+
42
+ def delete_bundle(bundle_id, project_id = config.project_id)
43
+ bundle_id || raise_parameter_is_required_error(:bundle_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}/bundles/#{bundle_id}"
50
+ )
51
+ Web::SendRequest.new(request).perform
52
+ end
53
+
54
+ def edit_bundle(bundle_id, query = {}, project_id = config.project_id)
55
+ bundle_id || raise_parameter_is_required_error(:bundle_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}/bundles/#{bundle_id}",
62
+ { params: query }
63
+ )
64
+ Web::SendRequest.new(request).perform
65
+ end
66
+
67
+ def bundle_list_files(bundle_id, query = {}, project_id = config.project_id)
68
+ bundle_id || raise_parameter_is_required_error(:bundle_id)
69
+ project_id || raise_project_id_is_required_error
70
+
71
+ request = Web::Request.new(
72
+ connection,
73
+ :get,
74
+ "#{config.target_api_url}/projects/#{project_id}/bundles/#{bundle_id}/files",
75
+ { params: query }
76
+ )
77
+ Web::SendRequest.new(request).perform
78
+ end
79
+ end
80
+ end
81
+ end
@@ -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 Web::FetchAllExtensions::API_RESOURCES_FOR_FETCH_ALL.include?(api_resource)
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.4.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,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Crowdin
4
+ module Web
5
+ module FetchAllExtensions
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
+ end
13
+ end
14
+ 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({}, 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
@@ -9,5 +9,176 @@ describe Crowdin::ApiResources::SourceFiles do
9
9
  expect(list_branches).to eq(200)
10
10
  end
11
11
  end
12
+
13
+ describe '#add_branch' do
14
+ it 'when request are valid', :default do
15
+ stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/branches")
16
+ add_branch = @crowdin.add_branch({}, project_id)
17
+ expect(add_branch).to eq(200)
18
+ end
19
+ end
20
+
21
+ describe '#get_branch' do
22
+ let(:branch_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}/branches/#{branch_id}")
26
+ get_branch = @crowdin.get_branch(branch_id, project_id)
27
+ expect(get_branch).to eq(200)
28
+ end
29
+ end
30
+
31
+ describe '#delete_branch' do
32
+ let(:branch_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}/branches/#{branch_id}")
36
+ delete_branch = @crowdin.delete_branch(branch_id, project_id)
37
+ expect(delete_branch).to eq(200)
38
+ end
39
+ end
40
+
41
+ describe '#edit_branch' do
42
+ let(:branch_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}/branches/#{branch_id}")
46
+ edit_branch = @crowdin.edit_branch(branch_id, {}, project_id)
47
+ expect(edit_branch).to eq(200)
48
+ end
49
+ end
50
+
51
+ describe '#list_directories' do
52
+ it 'when request are valid', :default do
53
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/directories")
54
+ list_directories = @crowdin.list_directories({}, project_id)
55
+ expect(list_directories).to eq(200)
56
+ end
57
+ end
58
+
59
+ describe '#add_directory' do
60
+ it 'when request are valid', :default do
61
+ stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/directories")
62
+ add_directory = @crowdin.add_directory({}, project_id)
63
+ expect(add_directory).to eq(200)
64
+ end
65
+ end
66
+
67
+ describe '#get_directory' do
68
+ let(:directory_id) { 1 }
69
+
70
+ it 'when request are valid', :default do
71
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/directories/#{directory_id}")
72
+ get_directory = @crowdin.get_directory(directory_id, project_id)
73
+ expect(get_directory).to eq(200)
74
+ end
75
+ end
76
+
77
+ describe '#delete_directory' do
78
+ let(:directory_id) { 1 }
79
+
80
+ it 'when request are valid', :default do
81
+ stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/directories/#{directory_id}")
82
+ delete_directory = @crowdin.delete_directory(directory_id, project_id)
83
+ expect(delete_directory).to eq(200)
84
+ end
85
+ end
86
+
87
+ describe '#edit_directory' do
88
+ let(:directory_id) { 1 }
89
+
90
+ it 'when request are valid', :default do
91
+ stub_request(:patch, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/directories/#{directory_id}")
92
+ edit_directory = @crowdin.edit_directory(directory_id, {}, project_id)
93
+ expect(edit_directory).to eq(200)
94
+ end
95
+ end
96
+
97
+ describe '#list_files' do
98
+ it 'when request are valid', :default do
99
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/files")
100
+ list_files = @crowdin.list_files({}, project_id)
101
+ expect(list_files).to eq(200)
102
+ end
103
+ end
104
+
105
+ describe '#add_file' do
106
+ it 'when request are valid', :default do
107
+ stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/files")
108
+ add_file = @crowdin.add_file({}, project_id)
109
+ expect(add_file).to eq(200)
110
+ end
111
+ end
112
+
113
+ describe '#get_file' do
114
+ let(:file_id) { 1 }
115
+
116
+ it 'when request are valid', :default do
117
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/files/#{file_id}")
118
+ get_file = @crowdin.get_file(file_id, project_id)
119
+ expect(get_file).to eq(200)
120
+ end
121
+ end
122
+
123
+ describe '#update_or_restore_file' do
124
+ let(:file_id) { 1 }
125
+
126
+ it 'when request are valid', :default do
127
+ stub_request(:put, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/files/#{file_id}")
128
+ update_or_restore_file = @crowdin.update_or_restore_file(file_id, {}, project_id)
129
+ expect(update_or_restore_file).to eq(200)
130
+ end
131
+ end
132
+
133
+ describe '#delete_file' do
134
+ let(:file_id) { 1 }
135
+
136
+ it 'when request are valid', :default do
137
+ stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/files/#{file_id}")
138
+ delete_file = @crowdin.delete_file(file_id, project_id)
139
+ expect(delete_file).to eq(200)
140
+ end
141
+ end
142
+
143
+ describe '#edit_file' do
144
+ let(:file_id) { 1 }
145
+
146
+ it 'when request are valid', :default do
147
+ stub_request(:patch, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/files/#{file_id}")
148
+ edit_file = @crowdin.edit_file(file_id, {}, project_id)
149
+ expect(edit_file).to eq(200)
150
+ end
151
+ end
152
+
153
+ describe '#download_file' do
154
+ let(:file_id) { 1 }
155
+
156
+ it 'when request are valid', :default do
157
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/files/#{file_id}/download")
158
+ download_file = @crowdin.download_file(file_id, nil, project_id)
159
+ expect(download_file).to eq(200)
160
+ end
161
+ end
162
+
163
+ describe '#list_file_revisions' do
164
+ let(:file_id) { 1 }
165
+
166
+ it 'when request are valid', :default do
167
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/files/#{file_id}/revisions")
168
+ list_file_revisions = @crowdin.list_file_revisions(file_id, {}, project_id)
169
+ expect(list_file_revisions).to eq(200)
170
+ end
171
+ end
172
+
173
+ describe '#get_file_revision' do
174
+ let(:file_id) { 1 }
175
+ let(:revision_id) { 1 }
176
+
177
+ it 'when request are valid', :default do
178
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/files/#{file_id}/revisions/#{revision_id}")
179
+ get_file_revision = @crowdin.get_file_revision(file_id, revision_id, project_id)
180
+ expect(get_file_revision).to eq(200)
181
+ end
182
+ end
12
183
  end
13
184
  end
@@ -9,5 +9,33 @@ describe Crowdin::ApiResources::Storages do
9
9
  expect(list_storages).to eq(200)
10
10
  end
11
11
  end
12
+
13
+ describe '#add_storage' do
14
+ it 'when request are valid', :default do
15
+ stub_request(:post, "https://api.crowdin.com/#{target_api_url}/storages")
16
+ add_storage = @crowdin.add_storage('README.md')
17
+ expect(add_storage).to eq(200)
18
+ end
19
+ end
20
+
21
+ describe '#get_storage' do
22
+ let(:storage_id) { 1 }
23
+
24
+ it 'when request are valid', :default do
25
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/storages/#{storage_id}")
26
+ get_storage = @crowdin.get_storage(storage_id)
27
+ expect(get_storage).to eq(200)
28
+ end
29
+ end
30
+
31
+ describe '#delete_storage' do
32
+ let(:storage_id) { 1 }
33
+
34
+ it 'when request are valid', :default do
35
+ stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/storages/#{storage_id}")
36
+ delete_storage = @crowdin.delete_storage(storage_id)
37
+ expect(delete_storage).to eq(200)
38
+ end
39
+ end
12
40
  end
13
41
  end
@@ -9,5 +9,43 @@ describe Crowdin::ApiResources::StringComments do
9
9
  expect(list_string_comments).to eq(200)
10
10
  end
11
11
  end
12
+
13
+ describe '#add_string_comment' do
14
+ it 'when request are valid', :default do
15
+ stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/comments")
16
+ add_string_comment = @crowdin.add_string_comment({}, project_id)
17
+ expect(add_string_comment).to eq(200)
18
+ end
19
+ end
20
+
21
+ describe '#get_string_comment' do
22
+ let(:string_comment_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}/comments/#{string_comment_id}")
26
+ get_string_comment = @crowdin.get_string_comment(string_comment_id, project_id)
27
+ expect(get_string_comment).to eq(200)
28
+ end
29
+ end
30
+
31
+ describe '#delete_string_comment' do
32
+ let(:string_comment_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}/comments/#{string_comment_id}")
36
+ delete_string_comment = @crowdin.delete_string_comment(string_comment_id, project_id)
37
+ expect(delete_string_comment).to eq(200)
38
+ end
39
+ end
40
+
41
+ describe '#edit_string_comment' do
42
+ let(:string_comment_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}/comments/#{string_comment_id}")
46
+ edit_string_comment = @crowdin.edit_string_comment(string_comment_id, {}, project_id)
47
+ expect(edit_string_comment).to eq(200)
48
+ end
49
+ end
12
50
  end
13
51
  end
@@ -9,5 +9,133 @@ describe Crowdin::ApiResources::StringTranslations do
9
9
  expect(list_translation_approvals).to eq(200)
10
10
  end
11
11
  end
12
+
13
+ describe '#add_approval' do
14
+ it 'when request are valid', :default do
15
+ stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/approvals")
16
+ add_approval = @crowdin.add_approval({}, project_id)
17
+ expect(add_approval).to eq(200)
18
+ end
19
+ end
20
+
21
+ describe '#get_approval' do
22
+ let(:approval_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}/approvals/#{approval_id}")
26
+ get_approval = @crowdin.get_approval(approval_id, project_id)
27
+ expect(get_approval).to eq(200)
28
+ end
29
+ end
30
+
31
+ describe '#remove_approval' do
32
+ let(:approval_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}/approvals/#{approval_id}")
36
+ remove_approval = @crowdin.remove_approval(approval_id, project_id)
37
+ expect(remove_approval).to eq(200)
38
+ end
39
+ end
40
+
41
+ describe '#list_language_translations' do
42
+ let(:language_id) { 1 }
43
+
44
+ it 'when request are valid', :default do
45
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/languages/#{language_id}/translations")
46
+ list_language_translations = @crowdin.list_language_translations(language_id, {}, project_id)
47
+ expect(list_language_translations).to eq(200)
48
+ end
49
+ end
50
+
51
+ describe '#list_string_translations' do
52
+ it 'when request are valid', :default do
53
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/translations")
54
+ list_string_translations = @crowdin.list_string_translations({}, project_id)
55
+ expect(list_string_translations).to eq(200)
56
+ end
57
+ end
58
+
59
+ describe '#add_translation' do
60
+ it 'when request are valid', :default do
61
+ stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/translations")
62
+ add_translation = @crowdin.add_translation({}, project_id)
63
+ expect(add_translation).to eq(200)
64
+ end
65
+ end
66
+
67
+ describe '#delete_string_translations' do
68
+ it 'when request are valid', :default do
69
+ stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/translations")
70
+ delete_string_translations = @crowdin.delete_string_translations({}, project_id)
71
+ expect(delete_string_translations).to eq(200)
72
+ end
73
+ end
74
+
75
+ describe '#get_translation' do
76
+ let(:translation_id) { 1 }
77
+
78
+ it 'when request are valid', :default do
79
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/translations/#{translation_id}")
80
+ get_translation = @crowdin.get_translation(translation_id, {}, project_id)
81
+ expect(get_translation).to eq(200)
82
+ end
83
+ end
84
+
85
+ describe '#restore_translation' do
86
+ let(:translation_id) { 1 }
87
+
88
+ it 'when request are valid', :default do
89
+ stub_request(:put, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/translations/#{translation_id}")
90
+ restore_translation = @crowdin.restore_translation(translation_id, project_id)
91
+ expect(restore_translation).to eq(200)
92
+ end
93
+ end
94
+
95
+ describe '#delete_translation' do
96
+ let(:translation_id) { 1 }
97
+
98
+ it 'when request are valid', :default do
99
+ stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/translations/#{translation_id}")
100
+ delete_translation = @crowdin.delete_translation(translation_id, project_id)
101
+ expect(delete_translation).to eq(200)
102
+ end
103
+ end
104
+
105
+ describe '#list_translation_votes' do
106
+ it 'when request are valid', :default do
107
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/votes")
108
+ list_translation_votes = @crowdin.list_translation_votes({}, project_id)
109
+ expect(list_translation_votes).to eq(200)
110
+ end
111
+ end
112
+
113
+ describe '#add_vote' do
114
+ it 'when request are valid', :default do
115
+ stub_request(:post, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/votes")
116
+ add_vote = @crowdin.add_vote({}, project_id)
117
+ expect(add_vote).to eq(200)
118
+ end
119
+ end
120
+
121
+ describe '#get_vote' do
122
+ let(:vote_id) { 1 }
123
+
124
+ it 'when request are valid', :default do
125
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/votes/#{vote_id}")
126
+ get_vote = @crowdin.get_vote(vote_id, project_id)
127
+ expect(get_vote).to eq(200)
128
+ end
129
+ end
130
+
131
+ describe '#cancel_vote' do
132
+ let(:vote_id) { 1 }
133
+
134
+ it 'when request are valid', :default do
135
+ stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/votes/#{vote_id}")
136
+ cancel_vote = @crowdin.cancel_vote(vote_id, project_id)
137
+ expect(cancel_vote).to eq(200)
138
+ end
139
+ end
12
140
  end
13
141
  end
@@ -9,5 +9,92 @@ describe Crowdin::ApiResources::Teams do
9
9
  expect(add_team_to_project).to eq(200)
10
10
  end
11
11
  end
12
+
13
+ describe '#list_teams' do
14
+ it 'when request are valid', :enterprise do
15
+ stub_request(:get, "https://domain.api.crowdin.com/#{target_api_url}/teams")
16
+ list_teams = @crowdin.list_teams({})
17
+ expect(list_teams).to eq(200)
18
+ end
19
+ end
20
+
21
+ describe '#add_team' do
22
+ it 'when request are valid', :enterprise do
23
+ stub_request(:post, "https://domain.api.crowdin.com/#{target_api_url}/teams")
24
+ add_team = @crowdin.add_team({})
25
+ expect(add_team).to eq(200)
26
+ end
27
+ end
28
+
29
+ describe '#get_team' do
30
+ let(:team_id) { 1 }
31
+
32
+ it 'when request are valid', :enterprise do
33
+ stub_request(:get, "https://domain.api.crowdin.com/#{target_api_url}/teams/#{team_id}")
34
+ get_team = @crowdin.get_team(team_id, {})
35
+ expect(get_team).to eq(200)
36
+ end
37
+ end
38
+
39
+ describe '#delete_team' do
40
+ let(:team_id) { 1 }
41
+
42
+ it 'when request are valid', :enterprise do
43
+ stub_request(:delete, "https://domain.api.crowdin.com/#{target_api_url}/teams/#{team_id}")
44
+ delete_team = @crowdin.delete_team(team_id)
45
+ expect(delete_team).to eq(200)
46
+ end
47
+ end
48
+
49
+ describe '#edit_team' do
50
+ let(:team_id) { 1 }
51
+
52
+ it 'when request are valid', :enterprise do
53
+ stub_request(:patch, "https://domain.api.crowdin.com/#{target_api_url}/teams/#{team_id}")
54
+ edit_team = @crowdin.edit_team(team_id, {})
55
+ expect(edit_team).to eq(200)
56
+ end
57
+ end
58
+
59
+ describe '#team_members_list' do
60
+ let(:team_id) { 1 }
61
+
62
+ it 'when request are valid', :enterprise do
63
+ stub_request(:get, "https://domain.api.crowdin.com/#{target_api_url}/teams/#{team_id}/members")
64
+ team_members_list = @crowdin.team_members_list(team_id, {})
65
+ expect(team_members_list).to eq(200)
66
+ end
67
+ end
68
+
69
+ describe '#add_team_members' do
70
+ let(:team_id) { 1 }
71
+
72
+ it 'when request are valid', :enterprise do
73
+ stub_request(:post, "https://domain.api.crowdin.com/#{target_api_url}/teams/#{team_id}/members")
74
+ add_team_members = @crowdin.add_team_members(team_id, {})
75
+ expect(add_team_members).to eq(200)
76
+ end
77
+ end
78
+
79
+ describe '#delete_all_team_members' do
80
+ let(:team_id) { 1 }
81
+
82
+ it 'when request are valid', :enterprise do
83
+ stub_request(:delete, "https://domain.api.crowdin.com/#{target_api_url}/teams/#{team_id}/members")
84
+ delete_all_team_members = @crowdin.delete_all_team_members(team_id)
85
+ expect(delete_all_team_members).to eq(200)
86
+ end
87
+ end
88
+
89
+ describe '#delete_team_member' do
90
+ let(:team_id) { 1 }
91
+ let(:member_id) { 1 }
92
+
93
+ it 'when request are valid', :enterprise do
94
+ stub_request(:delete, "https://domain.api.crowdin.com/#{target_api_url}/teams/#{team_id}/members/#{member_id}")
95
+ delete_team_member = @crowdin.delete_team_member(team_id, member_id)
96
+ expect(delete_team_member).to eq(200)
97
+ end
98
+ end
12
99
  end
13
100
  end
@@ -9,5 +9,106 @@ describe Crowdin::ApiResources::TranslationMemory do
9
9
  expect(list_tms).to eq(200)
10
10
  end
11
11
  end
12
+
13
+ describe '#add_tm' do
14
+ it 'when request are valid', :default do
15
+ stub_request(:post, "https://api.crowdin.com/#{target_api_url}/tms")
16
+ add_tm = @crowdin.add_tm
17
+ expect(add_tm).to eq(200)
18
+ end
19
+ end
20
+
21
+ describe '#get_tm' do
22
+ let(:tm_id) { 1 }
23
+
24
+ it 'when request are valid', :default do
25
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/tms/#{tm_id}")
26
+ get_tm = @crowdin.get_tm(tm_id)
27
+ expect(get_tm).to eq(200)
28
+ end
29
+ end
30
+
31
+ describe '#delete_tm' do
32
+ let(:tm_id) { 1 }
33
+
34
+ it 'when request are valid', :default do
35
+ stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/tms/#{tm_id}")
36
+ delete_tm = @crowdin.delete_tm(tm_id)
37
+ expect(delete_tm).to eq(200)
38
+ end
39
+ end
40
+
41
+ describe '#edit_tm' do
42
+ let(:tm_id) { 1 }
43
+
44
+ it 'when request are valid', :default do
45
+ stub_request(:patch, "https://api.crowdin.com/#{target_api_url}/tms/#{tm_id}")
46
+ edit_tm = @crowdin.edit_tm(tm_id)
47
+ expect(edit_tm).to eq(200)
48
+ end
49
+ end
50
+
51
+ describe '#clear_tm' do
52
+ let(:tm_id) { 1 }
53
+
54
+ it 'when request are valid', :default do
55
+ stub_request(:delete, "https://api.crowdin.com/#{target_api_url}/tms/#{tm_id}/segments")
56
+ clear_tm = @crowdin.clear_tm(tm_id)
57
+ expect(clear_tm).to eq(200)
58
+ end
59
+ end
60
+
61
+ describe '#export_tm' do
62
+ let(:tm_id) { 1 }
63
+
64
+ it 'when request are valid', :default do
65
+ stub_request(:post, "https://api.crowdin.com/#{target_api_url}/tms/#{tm_id}/exports")
66
+ export_tm = @crowdin.export_tm(tm_id)
67
+ expect(export_tm).to eq(200)
68
+ end
69
+ end
70
+
71
+ describe '#check_tm_export_status' do
72
+ let(:tm_id) { 1 }
73
+ let(:export_id) { 1 }
74
+
75
+ it 'when request are valid', :default do
76
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/tms/#{tm_id}/exports/#{export_id}")
77
+ check_tm_export_status = @crowdin.check_tm_export_status(tm_id, export_id)
78
+ expect(check_tm_export_status).to eq(200)
79
+ end
80
+ end
81
+
82
+ describe '#download_tm' do
83
+ let(:tm_id) { 1 }
84
+ let(:export_id) { 1 }
85
+
86
+ it 'when request are valid', :default do
87
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/tms/#{tm_id}/exports/#{export_id}/download")
88
+ download_tm = @crowdin.download_tm(tm_id, export_id)
89
+ expect(download_tm).to eq(200)
90
+ end
91
+ end
92
+
93
+ describe '#import_tm' do
94
+ let(:tm_id) { 1 }
95
+
96
+ it 'when request are valid', :default do
97
+ stub_request(:post, "https://api.crowdin.com/#{target_api_url}/tms/#{tm_id}/imports")
98
+ import_tm = @crowdin.import_tm(tm_id)
99
+ expect(import_tm).to eq(200)
100
+ end
101
+ end
102
+
103
+ describe '#check_tm_import_status' do
104
+ let(:tm_id) { 1 }
105
+ let(:import_id) { 1 }
106
+
107
+ it 'when request are valid', :default do
108
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/tms/#{tm_id}/imports/#{import_id}")
109
+ check_tm_import_status = @crowdin.check_tm_import_status(tm_id, import_id)
110
+ expect(check_tm_import_status).to eq(200)
111
+ end
112
+ end
12
113
  end
13
114
  end
@@ -11,5 +11,51 @@ describe Crowdin::ApiResources::TranslationStatus do
11
11
  expect(get_branch_progress).to eq(200)
12
12
  end
13
13
  end
14
+
15
+ describe '#get_directory_progress' do
16
+ let(:directory_id) { 1 }
17
+
18
+ it 'when request are valid', :default do
19
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/directories/#{directory_id}/languages/progress")
20
+ get_directory_progress = @crowdin.get_directory_progress(directory_id, {}, project_id)
21
+ expect(get_directory_progress).to eq(200)
22
+ end
23
+ end
24
+
25
+ describe '#get_file_progress' do
26
+ let(:file_id) { 1 }
27
+
28
+ it 'when request are valid', :default do
29
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/files/#{file_id}/languages/progress")
30
+ get_file_progress = @crowdin.get_file_progress(file_id, {}, project_id)
31
+ expect(get_file_progress).to eq(200)
32
+ end
33
+ end
34
+
35
+ describe '#get_language_progress' do
36
+ let(:language_id) { 1 }
37
+
38
+ it 'when request are valid', :default do
39
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/languages/#{language_id}/progress")
40
+ get_language_progress = @crowdin.get_language_progress(language_id, {}, project_id)
41
+ expect(get_language_progress).to eq(200)
42
+ end
43
+ end
44
+
45
+ describe '#get_project_progress' do
46
+ it 'when request are valid', :default do
47
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/languages/progress")
48
+ get_project_progress = @crowdin.get_project_progress({}, project_id)
49
+ expect(get_project_progress).to eq(200)
50
+ end
51
+ end
52
+
53
+ describe '#get_qa_progress' do
54
+ it 'when request are valid', :default do
55
+ stub_request(:get, "https://api.crowdin.com/#{target_api_url}/projects/#{project_id}/qa-checks")
56
+ get_qa_progress = @crowdin.get_qa_progress({}, project_id)
57
+ expect(get_qa_progress).to eq(200)
58
+ end
59
+ end
14
60
  end
15
61
  end
data/spec/spec_helper.rb CHANGED
@@ -21,7 +21,10 @@ RSpec.configure do |config|
21
21
  config.include_context 'crowdin_client_options'
22
22
 
23
23
  config.before(:each) do |spec|
24
- @crowdin = Crowdin::Client.new { |cfg| cfg.organization_domain = 'domain' } if spec.metadata[:enterprise]
25
- @crowdin = Crowdin::Client.new if spec.metadata[:default]
24
+ @crowdin = if spec.metadata[:enterprise]
25
+ Crowdin::Client.new { |cfg| cfg.organization_domain = organization_domain }
26
+ else # default
27
+ Crowdin::Client.new
28
+ end
26
29
  end
27
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crowdin-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Crowdin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-13 00:00:00.000000000 Z
11
+ date: 2022-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: open-uri
@@ -184,6 +184,7 @@ files:
184
184
  - bin/crowdin-console
185
185
  - crowdin-api.gemspec
186
186
  - lib/crowdin-api.rb
187
+ - lib/crowdin-api/api_resources/bundles.rb
187
188
  - lib/crowdin-api/api_resources/dictionaries.rb
188
189
  - lib/crowdin-api/api_resources/distributions.rb
189
190
  - lib/crowdin-api/api_resources/glossaries.rb
@@ -212,8 +213,10 @@ files:
212
213
  - lib/crowdin-api/client/version.rb
213
214
  - lib/crowdin-api/core/errors.rb
214
215
  - lib/crowdin-api/core/errors_raisers.rb
216
+ - lib/crowdin-api/core/fetch_all_extensions.rb
215
217
  - lib/crowdin-api/core/request.rb
216
218
  - lib/crowdin-api/core/send_request.rb
219
+ - spec/api_resources/bundles_spec.rb
217
220
  - spec/api_resources/dictionaries_spec.rb
218
221
  - spec/api_resources/distributions_spec.rb
219
222
  - spec/api_resources/glossaries_spec.rb