crowdin-api 1.2.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop_todo.yml +102 -43
  3. data/README.md +37 -6
  4. data/bin/crowdin-console +1 -1
  5. data/crowdin-api.gemspec +1 -2
  6. data/lib/crowdin-api/api_resources/bundles.rb +81 -0
  7. data/lib/crowdin-api/{api-resources → api_resources}/dictionaries.rb +8 -10
  8. data/lib/crowdin-api/{api-resources → api_resources}/distributions.rb +25 -32
  9. data/lib/crowdin-api/{api-resources → api_resources}/glossaries.rb +64 -82
  10. data/lib/crowdin-api/{api-resources → api_resources}/labels.rb +28 -47
  11. data/lib/crowdin-api/api_resources/languages.rb +61 -0
  12. data/lib/crowdin-api/api_resources/machine_translation_engines.rb +79 -0
  13. data/lib/crowdin-api/api_resources/projects.rb +124 -0
  14. data/lib/crowdin-api/api_resources/reports.rb +120 -0
  15. data/lib/crowdin-api/{api-resources → api_resources}/screenshots.rb +47 -61
  16. data/lib/crowdin-api/{api-resources → api_resources}/source_files.rb +68 -131
  17. data/lib/crowdin-api/{api-resources → api_resources}/source_strings.rb +19 -24
  18. data/lib/crowdin-api/api_resources/storages.rb +54 -0
  19. data/lib/crowdin-api/{api-resources → api_resources}/string_comments.rb +18 -23
  20. data/lib/crowdin-api/{api-resources → api_resources}/string_translations.rb +64 -91
  21. data/lib/crowdin-api/{api-resources → api_resources}/tasks.rb +30 -41
  22. data/lib/crowdin-api/api_resources/teams.rb +135 -0
  23. data/lib/crowdin-api/{api-resources → api_resources}/translation_memory.rb +38 -52
  24. data/lib/crowdin-api/{api-resources → api_resources}/translation_status.rb +24 -30
  25. data/lib/crowdin-api/{api-resources → api_resources}/translations.rb +41 -58
  26. data/lib/crowdin-api/api_resources/users.rb +161 -0
  27. data/lib/crowdin-api/api_resources/vendors.rb +21 -0
  28. data/lib/crowdin-api/{api-resources → api_resources}/webhooks.rb +19 -24
  29. data/lib/crowdin-api/api_resources/workflows.rb +59 -0
  30. data/lib/crowdin-api/client/client.rb +134 -39
  31. data/lib/crowdin-api/client/configuration.rb +12 -12
  32. data/lib/crowdin-api/client/version.rb +1 -1
  33. data/lib/crowdin-api/core/errors.rb +1 -0
  34. data/lib/crowdin-api/core/errors_raisers.rb +1 -1
  35. data/lib/crowdin-api/core/fetch_all_extensions.rb +14 -0
  36. data/lib/crowdin-api/core/request.rb +50 -90
  37. data/lib/crowdin-api/core/send_request.rb +67 -0
  38. data/lib/crowdin-api.rb +18 -24
  39. data/spec/api_resources/bundles_spec.rb +61 -0
  40. data/spec/api_resources/dictionaries_spec.rb +23 -0
  41. data/spec/api_resources/distributions_spec.rb +71 -0
  42. data/spec/api_resources/glossaries_spec.rb +167 -0
  43. data/spec/api_resources/labels_spec.rb +71 -0
  44. data/spec/api_resources/languages_spec.rb +51 -0
  45. data/spec/api_resources/machine_translation_engines_spec.rb +63 -0
  46. data/spec/api_resources/projects_spec.rb +215 -0
  47. data/spec/api_resources/reports_spec.rb +95 -0
  48. data/spec/api_resources/screenshots_spec.rb +134 -0
  49. data/spec/api_resources/source_files_spec.rb +184 -0
  50. data/spec/api_resources/source_strings_spec.rb +51 -0
  51. data/spec/api_resources/storages_spec.rb +41 -0
  52. data/spec/api_resources/string_comments_spec.rb +51 -0
  53. data/spec/api_resources/string_translations_spec.rb +141 -0
  54. data/spec/api_resources/tasks_spec.rb +79 -0
  55. data/spec/api_resources/teams_spec.rb +100 -0
  56. data/spec/api_resources/translation_memory_spec.rb +114 -0
  57. data/spec/api_resources/translation_status_spec.rb +61 -0
  58. data/spec/api_resources/translations_spec.rb +107 -0
  59. data/spec/api_resources/users_spec.rb +117 -0
  60. data/spec/api_resources/vendors_spec.rb +13 -0
  61. data/spec/api_resources/webhooks_spec.rb +51 -0
  62. data/spec/api_resources/workflows_spec.rb +41 -0
  63. data/spec/spec_helper.rb +23 -2
  64. data/spec/unit/client_spec.rb +85 -0
  65. metadata +67 -43
  66. data/bin/setup +0 -6
  67. data/lib/crowdin-api/api-resources/languages.rb +0 -82
  68. data/lib/crowdin-api/api-resources/machine_translation_engines.rb +0 -74
  69. data/lib/crowdin-api/api-resources/projects.rb +0 -148
  70. data/lib/crowdin-api/api-resources/reports.rb +0 -138
  71. data/lib/crowdin-api/api-resources/storages.rb +0 -106
  72. data/lib/crowdin-api/api-resources/teams.rb +0 -144
  73. data/lib/crowdin-api/api-resources/users.rb +0 -129
  74. data/lib/crowdin-api/api-resources/vendors.rb +0 -21
  75. data/lib/crowdin-api/api-resources/workflows.rb +0 -62
  76. data/lib/crowdin-api/core/utils.rb +0 -10
  77. data/spec/client/client-instance_spec.rb +0 -14
  78. data/spec/client/configuration-instance_spec.rb +0 -72
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bec711e702205bef5cf0bd74dc1a99c6f770225ee0fb37afa702cc8fb3712cab
4
- data.tar.gz: '09425dd51fe242b61eb7a3fe12331f5a6827504d5cd5b5157ff6824c56069a39'
3
+ metadata.gz: 283ff1afb3a211be3a2c06c0417decc9b6ff3fcca1e8c61c78523708c428d286
4
+ data.tar.gz: e6f02c86c39702e00eacc0908c6dec0a93783a7a4038e2eddbc634ca2d4887d3
5
5
  SHA512:
6
- metadata.gz: 8e7b0806bbc5a1caf4c963df4f7120cdff2dfd4f0df068f7a308ade71c6b45c9373f157338065e9a116a0dc081ceeea07a593d8933701f2c2d43a5640810a901
7
- data.tar.gz: f5d06bfce2e0257c4249a856923eb3ea8afd1f424efe26ee212193c647cbc2cb3ad4caa42bed305e9874198e433b4ac8b50e87d5dcfb244d3689febef5a67d41
6
+ metadata.gz: ca47c68a8c81d3de24a5ae913155ece611ae9400fdbea47933355d6043036c269d15ab067df037afcdc4aae1fa982991f49bee4603fb5f6816a783dd6d7c30b1
7
+ data.tar.gz: dcf04302fb3c882a81f630476b4e7dce4cf1e98320da04615d3d393fb4bdfadb9bc67aec732bee227321cd3af7cbc095363f0f0c22a903a5f954acb6101a243a
data/.rubocop_todo.yml CHANGED
@@ -1,13 +1,13 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2022-02-14 06:05:44 UTC using RuboCop version 1.23.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
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
9
  # Offense count: 1
10
- # Cop supports --auto-correct.
10
+ # This cop supports safe auto-correction (--auto-correct).
11
11
  # Configuration parameters: Include.
12
12
  # Include: **/*.gemspec
13
13
  Gemspec/RequireMFA:
@@ -21,8 +21,24 @@ Gemspec/RequiredRubyVersion:
21
21
  Exclude:
22
22
  - 'crowdin-api.gemspec'
23
23
 
24
+ # Offense count: 2
25
+ # This cop supports safe auto-correction (--auto-correct).
26
+ # Configuration parameters: EnforcedStyle, IndentOneStep, IndentationWidth.
27
+ # SupportedStyles: case, end
28
+ Layout/CaseIndentation:
29
+ Exclude:
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'
39
+
24
40
  # Offense count: 4
25
- # Cop supports --auto-correct.
41
+ # This cop supports safe auto-correction (--auto-correct).
26
42
  # Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
27
43
  # SupportedHashRocketStyles: key, separator, table
28
44
  # SupportedColonStyles: key, separator, table
@@ -31,115 +47,158 @@ Layout/HashAlignment:
31
47
  Exclude:
32
48
  - 'lib/crowdin-api/client/configuration.rb'
33
49
 
34
- # Offense count: 1
35
- # Cop supports --auto-correct.
50
+ # Offense count: 14
51
+ # This cop supports safe auto-correction (--auto-correct).
52
+ # Configuration parameters: EnforcedStyle.
53
+ # SupportedStyles: normal, indented_internal_methods
54
+ Layout/IndentationConsistency:
55
+ Exclude:
56
+ - 'lib/crowdin-api/client/client.rb'
57
+ - 'lib/crowdin-api/core/request.rb'
58
+ - 'lib/crowdin-api/core/send_request.rb'
59
+
60
+ # Offense count: 14
61
+ # This cop supports safe auto-correction (--auto-correct).
62
+ # Configuration parameters: Width, IgnoredPatterns.
63
+ Layout/IndentationWidth:
64
+ Exclude:
65
+ - 'lib/crowdin-api/client/client.rb'
66
+ - 'lib/crowdin-api/core/request.rb'
67
+ - 'lib/crowdin-api/core/send_request.rb'
68
+
69
+ # Offense count: 4
70
+ # This cop supports safe auto-correction (--auto-correct).
36
71
  # Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator.
37
72
  # SupportedStylesForExponentOperator: space, no_space
38
73
  Layout/SpaceAroundOperators:
39
74
  Exclude:
40
75
  - 'crowdin-api.gemspec'
76
+ - 'spec/api_resources/projects_spec.rb'
41
77
 
42
- # Offense count: 2
78
+ # Offense count: 3
43
79
  # Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
44
80
  Metrics/AbcSize:
45
- Max: 23
81
+ Max: 42
46
82
 
47
- # Offense count: 1
83
+ # Offense count: 46
48
84
  # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
49
85
  # IgnoredMethods: refine
50
86
  Metrics/BlockLength:
51
- Max: 54
87
+ Max: 171
52
88
 
53
- # Offense count: 12
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
54
100
  # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
55
101
  Metrics/MethodLength:
56
- Max: 18
102
+ Max: 41
57
103
 
58
104
  # Offense count: 8
59
105
  # Configuration parameters: CountComments, CountAsOne.
60
106
  Metrics/ModuleLength:
61
- Max: 199
107
+ Max: 196
62
108
 
63
109
  # Offense count: 2
64
- # Configuration parameters: CountKeywordArgs.
110
+ # Configuration parameters: Max, CountKeywordArgs.
65
111
  Metrics/ParameterLists:
66
112
  MaxOptionalParameters: 4
67
- Max: 6
68
113
 
69
- # Offense count: 2
114
+ # Offense count: 1
115
+ # Configuration parameters: IgnoredMethods.
116
+ Metrics/PerceivedComplexity:
117
+ Max: 19
118
+
119
+ # Offense count: 1
70
120
  Naming/AccessorMethodName:
71
121
  Exclude:
72
- - 'lib/crowdin-api/api-resources/users.rb'
73
- - 'lib/crowdin-api/core/request.rb'
122
+ - 'lib/crowdin-api/api_resources/users.rb'
74
123
 
75
- # Offense count: 3
124
+ # Offense count: 1
76
125
  # Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, CheckDefinitionPathHierarchyRoots, Regex, IgnoreExecutableScripts, AllowedAcronyms.
77
126
  # CheckDefinitionPathHierarchyRoots: lib, spec, test, src
78
127
  # AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
79
128
  Naming/FileName:
80
129
  Exclude:
81
130
  - 'lib/crowdin-api.rb'
82
- - 'spec/client/client-instance_spec.rb'
83
- - 'spec/client/configuration-instance_spec.rb'
84
131
 
85
- # Offense count: 3
132
+ # Offense count: 2
86
133
  # Configuration parameters: EnforcedStyleForLeadingUnderscores.
87
134
  # SupportedStylesForLeadingUnderscores: disallowed, required, optional
88
135
  Naming/MemoizedInstanceVariableName:
89
136
  Exclude:
90
137
  - 'lib/crowdin-api/client/client.rb'
91
138
 
92
- # Offense count: 3
93
- # Cop supports --auto-correct.
94
- # Configuration parameters: PreferredName.
95
- Naming/RescuedExceptionsVariableName:
96
- Exclude:
97
- - 'lib/crowdin-api/core/request.rb'
98
-
99
- # Offense count: 8
100
- # Cop supports --auto-correct.
139
+ # Offense count: 7
140
+ # This cop supports safe auto-correction (--auto-correct).
101
141
  # Configuration parameters: EnforcedStyle.
102
142
  # SupportedStyles: separated, grouped
103
143
  Style/AccessorGrouping:
104
144
  Exclude:
105
- - 'lib/crowdin-api/client/client.rb'
106
145
  - 'lib/crowdin-api/client/configuration.rb'
146
+ - 'lib/crowdin-api/core/request.rb'
107
147
 
108
148
  # Offense count: 2
109
- # Cop supports --auto-correct.
149
+ # This cop supports unsafe auto-correction (--auto-correct-all).
110
150
  Style/CollectionCompact:
111
151
  Exclude:
112
152
  - 'lib/crowdin-api/core/request.rb'
113
153
 
114
- # Offense count: 22
154
+ # Offense count: 27
115
155
  # Configuration parameters: AllowedConstants.
116
156
  Style/Documentation:
117
157
  Enabled: false
118
158
 
119
159
  # Offense count: 1
120
- # Cop supports --auto-correct.
160
+ # This cop supports safe auto-correction (--auto-correct).
161
+ # Configuration parameters: EnforcedStyle.
162
+ # SupportedStyles: allowed_in_returns, forbidden
163
+ Style/DoubleNegation:
164
+ Exclude:
165
+ - 'lib/crowdin-api/client/configuration.rb'
166
+
167
+ # Offense count: 1
168
+ # This cop supports safe auto-correction (--auto-correct).
121
169
  # Configuration parameters: EnforcedStyle.
122
170
  # SupportedStyles: always, always_true, never
123
171
  Style/FrozenStringLiteralComment:
124
172
  Exclude:
125
173
  - 'bin/crowdin-console'
126
174
 
175
+ # Offense count: 1
176
+ # Configuration parameters: MinBodyLength.
177
+ Style/GuardClause:
178
+ Exclude:
179
+ - 'lib/crowdin-api/client/client.rb'
180
+
127
181
  # Offense count: 1
128
182
  Style/MixinUsage:
129
183
  Exclude:
130
184
  - 'bin/crowdin-console'
131
185
 
132
- # Offense count: 2
133
- # Cop supports --auto-correct.
134
- # Configuration parameters: EnforcedStyle.
135
- # SupportedStyles: implicit, explicit
136
- Style/RescueStandardError:
186
+ # Offense count: 1
187
+ # This cop supports safe auto-correction (--auto-correct).
188
+ Style/RedundantFreeze:
137
189
  Exclude:
138
- - 'lib/crowdin-api/api-resources/labels.rb'
139
- - 'lib/crowdin-api/api-resources/string_translations.rb'
190
+ - 'lib/crowdin-api/core/fetch_all_extensions.rb'
140
191
 
141
- # Offense count: 1
142
- # Cop supports --auto-correct.
192
+ # Offense count: 8
193
+ # This cop supports safe auto-correction (--auto-correct).
194
+ # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
195
+ # SupportedStyles: single_quotes, double_quotes
196
+ Style/StringLiterals:
197
+ Exclude:
198
+ - 'spec/api_resources/projects_spec.rb'
199
+
200
+ # Offense count: 2
201
+ # This cop supports safe auto-correction (--auto-correct).
143
202
  # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
144
203
  # URISchemes: http, https
145
204
  Layout/LineLength:
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.2.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
 
@@ -74,7 +76,7 @@ crowdin = Crowdin::Client.new do |config|
74
76
  config.api_token = 'YourApiToken'
75
77
  end
76
78
 
77
- # Or you can intialize Enterprise Client instance by specifying your
79
+ # Or you can initialize Enterprise Client instance by specifying your
78
80
  # organization_domain in config options
79
81
  crowdin = Crowdin::Client.new do |config|
80
82
  config.api_token = 'YourEnterpriseApiToken'
@@ -82,7 +84,7 @@ crowdin = Crowdin::Client.new do |config|
82
84
  end
83
85
  # Note: we use full specified organization domain if that includes '.com'
84
86
  # config.organization_domain = your_domain -> https://your_domain.api.crowdin.com
85
- # config.organization_domain = your_domain.com -> your_domain.com
87
+ # config.organization_domain = your_domain.com -> https://your_domain.com
86
88
 
87
89
  # All supported Crowdin Client config options now:
88
90
  crowdin = Crowdin::Client.new do |config|
@@ -121,9 +123,9 @@ projects = crowdin.list_projects(offset: 10, limit: 20)
121
123
  project = crowdin.get_project(your_project_id)
122
124
 
123
125
  # Edit project
124
- project = crowdin.edit_project(project_id, [{op: 'replace',
125
- path: '/name',
126
- value: 'your_new_project_name'}])
126
+ project = crowdin.edit_project(project_id, [{ op: 'replace',
127
+ path: '/name',
128
+ value: 'your_new_project_name' }])
127
129
 
128
130
  # Add Storage
129
131
  storage = crowdin.add_storage(File.open('YourFilename.extension', 'r'))
@@ -141,6 +143,35 @@ file = crowdin.download_file(your_file_id, your_destination, your_project_id)
141
143
  file_revisions = crowdin.list_file_revisions(your_file_id, limit: 10)
142
144
  # or you can specify your project_id
143
145
  file_revisions = crowdin.list_file_revisions(your_file_id, { limit: 10 }, your_project_id)
146
+
147
+ # Note: more examples you can find in spec folder
148
+ ```
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'] })
144
175
  ```
145
176
 
146
177
  ### Command-Line Client
data/bin/crowdin-console CHANGED
@@ -12,7 +12,7 @@ require 'optparse'
12
12
  #
13
13
  # bundle exec crowdin-console --enable-logger --api-token YOUR_API_TOKEN --project-id YOUR_PROJECT_ID
14
14
  #
15
- # or Enterpise API:
15
+ # or Enterprise API:
16
16
  #
17
17
  # bundle exec crowdin-console --enterprise --api-token YOUR_ENTERPRISE_API_TOKEN --organization-domain YOUR_DOMAIN
18
18
  #
data/crowdin-api.gemspec CHANGED
@@ -13,7 +13,6 @@ Gem::Specification.new do |gem|
13
13
  gem.license = 'MIT'
14
14
 
15
15
  gem.files = `git ls-files`.split("\n")
16
- gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
16
  gem.require_paths = ['lib']
18
17
  gem.bindir = 'bin'
19
18
  gem.executables << 'crowdin-console'
@@ -25,9 +24,9 @@ Gem::Specification.new do |gem|
25
24
 
26
25
  gem.add_development_dependency 'bundler', '~> 2.2', '>= 2.2.32'
27
26
  gem.add_development_dependency 'codecov', '~> 0.6.0'
27
+ gem.add_development_dependency 'pry', '~> 0.14.1'
28
28
  gem.add_development_dependency 'rake', '~> 13.0', '>= 13.0.6'
29
29
  gem.add_development_dependency 'rspec', '~> 3.10'
30
30
  gem.add_development_dependency 'rubocop', '~> 1.23'
31
- gem.add_development_dependency 'sinatra', '~> 2.1'
32
31
  gem.add_development_dependency 'webmock', '~> 3.14'
33
32
  end
@@ -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
@@ -7,13 +7,12 @@ module Crowdin
7
7
  project_id || raise_project_id_is_required_error
8
8
 
9
9
  request = Web::Request.new(
10
- self,
10
+ connection,
11
11
  :get,
12
- "/projects/#{project_id}/dictionaries",
13
- query
12
+ "#{config.target_api_url}/projects/#{project_id}/dictionaries",
13
+ { params: query }
14
14
  )
15
-
16
- request.perform
15
+ Web::SendRequest.new(request).perform
17
16
  end
18
17
 
19
18
  def edit_dictionary(language_id = nil, query = {}, project_id = config.project_id)
@@ -21,13 +20,12 @@ module Crowdin
21
20
  project_id || raise_project_id_is_required_error
22
21
 
23
22
  request = Web::Request.new(
24
- self,
23
+ connection,
25
24
  :patch,
26
- "/projects/#{project_id}/dictionaries/#{language_id}",
27
- query
25
+ "#{config.target_api_url}/projects/#{project_id}/dictionaries/#{language_id}",
26
+ { params: query }
28
27
  )
29
-
30
- request.perform
28
+ Web::SendRequest.new(request).perform
31
29
  end
32
30
  end
33
31
  end
@@ -7,26 +7,24 @@ module Crowdin
7
7
  project_id || raise_project_id_is_required_error
8
8
 
9
9
  request = Web::Request.new(
10
- self,
10
+ connection,
11
11
  :get,
12
- "/projects/#{project_id}/distributions",
13
- query
12
+ "#{config.target_api_url}/projects/#{project_id}/distributions",
13
+ { params: query }
14
14
  )
15
-
16
- request.perform
15
+ Web::SendRequest.new(request).perform
17
16
  end
18
17
 
19
18
  def add_distribution(query = {}, project_id = config.project_id)
20
19
  project_id || raise_project_id_is_required_error
21
20
 
22
21
  request = Web::Request.new(
23
- self,
22
+ connection,
24
23
  :post,
25
- "/projects/#{project_id}/distributions",
26
- query
24
+ "#{config.target_api_url}/projects/#{project_id}/distributions",
25
+ { params: query }
27
26
  )
28
-
29
- request.perform
27
+ Web::SendRequest.new(request).perform
30
28
  end
31
29
 
32
30
  def get_distribution(hash = nil, project_id = config.project_id)
@@ -34,12 +32,11 @@ module Crowdin
34
32
  project_id || raise_project_id_is_required_error
35
33
 
36
34
  request = Web::Request.new(
37
- self,
35
+ connection,
38
36
  :get,
39
- "/projects/#{project_id}/distributions/#{hash}"
37
+ "#{config.target_api_url}/projects/#{project_id}/distributions/#{hash}"
40
38
  )
41
-
42
- request.perform
39
+ Web::SendRequest.new(request).perform
43
40
  end
44
41
 
45
42
  def delete_distribution(hash = nil, project_id = config.project_id)
@@ -47,12 +44,11 @@ module Crowdin
47
44
  project_id || raise_project_id_is_required_error
48
45
 
49
46
  request = Web::Request.new(
50
- self,
47
+ connection,
51
48
  :delete,
52
- "/projects/#{project_id}/distributions/#{hash}"
49
+ "#{config.target_api_url}/projects/#{project_id}/distributions/#{hash}"
53
50
  )
54
-
55
- request.perform
51
+ Web::SendRequest.new(request).perform
56
52
  end
57
53
 
58
54
  def edit_distribution(hash = nil, query = {}, project_id = config.project_id)
@@ -60,26 +56,24 @@ module Crowdin
60
56
  project_id || raise_project_id_is_required_error
61
57
 
62
58
  request = Web::Request.new(
63
- self,
59
+ connection,
64
60
  :patch,
65
- "/projects/#{project_id}/distributions/#{hash}",
66
- query
61
+ "#{config.target_api_url}/projects/#{project_id}/distributions/#{hash}",
62
+ { params: query }
67
63
  )
68
-
69
- request.perform
64
+ Web::SendRequest.new(request).perform
70
65
  end
71
66
 
72
- def get_destribution_release(hash = nil, project_id = config.project_id)
67
+ def get_distribution_release(hash = nil, project_id = config.project_id)
73
68
  hash || raise_parameter_is_required_error(:hash)
74
69
  project_id || raise_project_id_is_required_error
75
70
 
76
71
  request = Web::Request.new(
77
- self,
72
+ connection,
78
73
  :get,
79
- "/projects/#{project_id}/distributions/#{hash}/release"
74
+ "#{config.target_api_url}/projects/#{project_id}/distributions/#{hash}/release"
80
75
  )
81
-
82
- request.perform
76
+ Web::SendRequest.new(request).perform
83
77
  end
84
78
 
85
79
  def release_distribution(hash = nil, project_id = config.project_id)
@@ -87,12 +81,11 @@ module Crowdin
87
81
  project_id || raise_project_id_is_required_error
88
82
 
89
83
  request = Web::Request.new(
90
- self,
84
+ connection,
91
85
  :post,
92
- "/projects/#{project_id}/distributions/#{hash}/release"
86
+ "#{config.target_api_url}/projects/#{project_id}/distributions/#{hash}/release"
93
87
  )
94
-
95
- request.perform
88
+ Web::SendRequest.new(request).perform
96
89
  end
97
90
  end
98
91
  end