crowdin-api 1.1.1 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/docs.yml +31 -0
  3. data/.github/workflows/test-and-lint.yml +1 -1
  4. data/.gitignore +2 -2
  5. data/.rubocop_todo.yml +114 -48
  6. data/Gemfile +3 -0
  7. data/README.md +61 -17
  8. data/bin/crowdin-console +5 -5
  9. data/crowdin-api.gemspec +1 -2
  10. data/lib/crowdin-api/api_resources/bundles.rb +104 -0
  11. data/lib/crowdin-api/api_resources/dictionaries.rb +32 -0
  12. data/lib/crowdin-api/api_resources/distributions.rb +92 -0
  13. data/lib/crowdin-api/api_resources/glossaries.rb +248 -0
  14. data/lib/crowdin-api/api_resources/labels.rb +98 -0
  15. data/lib/crowdin-api/api_resources/languages.rb +61 -0
  16. data/lib/crowdin-api/api_resources/machine_translation_engines.rb +79 -0
  17. data/lib/crowdin-api/api_resources/projects.rb +151 -0
  18. data/lib/crowdin-api/api_resources/reports.rb +184 -0
  19. data/lib/crowdin-api/api_resources/screenshots.rb +172 -0
  20. data/lib/crowdin-api/api_resources/source_files.rb +305 -0
  21. data/lib/crowdin-api/{api-resources → api_resources}/source_strings.rb +19 -24
  22. data/lib/crowdin-api/api_resources/storages.rb +66 -0
  23. data/lib/crowdin-api/api_resources/string_comments.rb +68 -0
  24. data/lib/crowdin-api/api_resources/string_translations.rb +193 -0
  25. data/lib/crowdin-api/api_resources/tasks.rb +102 -0
  26. data/lib/crowdin-api/api_resources/teams.rb +135 -0
  27. data/lib/crowdin-api/api_resources/translation_memory.rb +131 -0
  28. data/lib/crowdin-api/{api-resources → api_resources}/translation_status.rb +24 -30
  29. data/lib/crowdin-api/{api-resources → api_resources}/translations.rb +41 -59
  30. data/lib/crowdin-api/api_resources/users.rb +161 -0
  31. data/lib/crowdin-api/api_resources/vendors.rb +21 -0
  32. data/lib/crowdin-api/api_resources/webhooks.rb +68 -0
  33. data/lib/crowdin-api/api_resources/workflows.rb +59 -0
  34. data/lib/crowdin-api/client/client.rb +155 -47
  35. data/lib/crowdin-api/client/configuration.rb +16 -12
  36. data/lib/crowdin-api/client/version.rb +1 -1
  37. data/lib/crowdin-api/core/errors.rb +3 -1
  38. data/lib/crowdin-api/core/{api_errors_raiser.rb → errors_raisers.rb} +21 -11
  39. data/lib/crowdin-api/core/fetch_all_extensions.rb +9 -0
  40. data/lib/crowdin-api/core/request.rb +50 -90
  41. data/lib/crowdin-api/core/send_request.rb +67 -0
  42. data/lib/crowdin-api.rb +21 -11
  43. data/spec/api_resources/bundles_spec.rb +61 -0
  44. data/spec/api_resources/dictionaries_spec.rb +23 -0
  45. data/spec/api_resources/distributions_spec.rb +71 -0
  46. data/spec/api_resources/glossaries_spec.rb +210 -0
  47. data/spec/api_resources/labels_spec.rb +71 -0
  48. data/spec/api_resources/languages_spec.rb +51 -0
  49. data/spec/api_resources/machine_translation_engines_spec.rb +63 -0
  50. data/spec/api_resources/projects_spec.rb +215 -0
  51. data/spec/api_resources/reports_spec.rb +145 -0
  52. data/spec/api_resources/screenshots_spec.rb +134 -0
  53. data/spec/api_resources/source_files_spec.rb +184 -0
  54. data/spec/api_resources/source_strings_spec.rb +51 -0
  55. data/spec/api_resources/storages_spec.rb +41 -0
  56. data/spec/api_resources/string_comments_spec.rb +51 -0
  57. data/spec/api_resources/string_translations_spec.rb +141 -0
  58. data/spec/api_resources/tasks_spec.rb +79 -0
  59. data/spec/api_resources/teams_spec.rb +100 -0
  60. data/spec/api_resources/translation_memory_spec.rb +114 -0
  61. data/spec/api_resources/translation_status_spec.rb +61 -0
  62. data/spec/api_resources/translations_spec.rb +107 -0
  63. data/spec/api_resources/users_spec.rb +117 -0
  64. data/spec/api_resources/vendors_spec.rb +13 -0
  65. data/spec/api_resources/webhooks_spec.rb +51 -0
  66. data/spec/api_resources/workflows_spec.rb +41 -0
  67. data/spec/spec_helper.rb +23 -2
  68. data/spec/unit/client_spec.rb +91 -0
  69. metadata +69 -28
  70. data/bin/setup +0 -6
  71. data/lib/crowdin-api/api-resources/languages.rb +0 -81
  72. data/lib/crowdin-api/api-resources/projects.rb +0 -134
  73. data/lib/crowdin-api/api-resources/source_files.rb +0 -303
  74. data/lib/crowdin-api/api-resources/storages.rb +0 -102
  75. data/lib/crowdin-api/api-resources/workflows.rb +0 -59
  76. data/spec/core/config-instance_spec.rb +0 -72
  77. data/spec/crowdin-api_spec.rb +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4ec79bf0a2483fca9502087888c52323ebe12c0c755897f0c71759722f74fd89
4
- data.tar.gz: b38ea8b69348734224f7631403f2ac0c6b33496c9098556688c4e648c85cbb6c
3
+ metadata.gz: 92b7e78f934fe0170055ff679da134b9b4444caba51677c19ba8903a1eaf55ec
4
+ data.tar.gz: 22ebff0813e0d4d1c0217a3c9163e738f3b58fa6124d09f5cfff4cf3ddb3330c
5
5
  SHA512:
6
- metadata.gz: aea9c98831b8abfacb4fe670d4d9025cee21cf33334083645ad9f4767f5d375249a9d2fde8ab7739fec3ca61f1ade03496f23b12377414ce18f62eea2819f453
7
- data.tar.gz: 5e69bf63d256bb96faaa11d749635253ad4625b6741d3d312cd7b61af127bd09d494ee87350b7b589e9c8c78de807bccba25286480627aa0e80153554e81fd1f
6
+ metadata.gz: e0705ea1264b498c2a8080445ab79ccc353347e65f928acd68008ea96a1a8a97c0c947b332d88fb9171ba1d02001e231498cc34102d2c8dd6967d1b858204f7a
7
+ data.tar.gz: 81c748f6b6cf1090bb218d486548634c37c2a10594d937745abdd07e2cea097a8e9dd64617a85e85c06cc35b97b7ac4a5f4ffa3bc7846970efa860ef99fe3522
@@ -0,0 +1,31 @@
1
+ name: Docs
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - '*'
7
+
8
+ jobs:
9
+ docs:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v2
13
+ - name: Set up Ruby 2.6
14
+ uses: ruby/setup-ruby@477b21f02be01bcb8030d50f37cfec92bfa615b6
15
+ with:
16
+ ruby-version: 2.6
17
+ - run: bundle install
18
+
19
+ - name: Cleanup the Readme
20
+ run: |
21
+ sed -i /\<div/d README.md
22
+ sed -i /\<\\/div/d README.md
23
+
24
+ - name: Generate Docs
25
+ run: yardoc lib/crowdin-api/api_resources/*.rb
26
+
27
+ - name: Deploy 🚀
28
+ uses: JamesIves/github-pages-deploy-action@v4.4.1
29
+ with:
30
+ branch: gh-pages
31
+ folder: doc
@@ -12,7 +12,7 @@ jobs:
12
12
  runs-on: ubuntu-latest
13
13
  strategy:
14
14
  matrix:
15
- ruby-version: ['2.6', '2.7', '3.0']
15
+ ruby-version: [ '2.6', '2.7', '3.0' ]
16
16
  steps:
17
17
  - name: Checkout code
18
18
  uses: actions/checkout@v2
data/.gitignore CHANGED
@@ -1,12 +1,12 @@
1
1
  # Ignore Ruby logs
2
- .ruby-version
3
2
  .idea
4
3
 
5
4
  # Ignore MacOS logs
6
5
  .DS_Store
7
6
 
8
- # Ignore versioning file
7
+ # Ignore versioning files
9
8
  Gemfile.lock
9
+ .ruby-version
10
10
 
11
11
  # Ignore tests coverage folder
12
12
  coverage
data/.rubocop_todo.yml CHANGED
@@ -1,13 +1,13 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2021-12-13 20:26:23 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:
@@ -22,118 +22,184 @@ Gemspec/RequiredRubyVersion:
22
22
  - 'crowdin-api.gemspec'
23
23
 
24
24
  # Offense count: 2
25
- # Cop supports --auto-correct.
26
- # Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment.
27
- Layout/ExtraSpacing:
25
+ # This cop supports safe auto-correction (--auto-correct).
26
+ # Configuration parameters: EnforcedStyle, IndentOneStep, IndentationWidth.
27
+ # SupportedStyles: case, end
28
+ Layout/CaseIndentation:
28
29
  Exclude:
29
- - 'bin/crowdin-console'
30
+ - 'lib/crowdin-api/client/client.rb'
30
31
 
31
32
  # Offense count: 1
32
- # Cop supports --auto-correct.
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
+
40
+ # Offense count: 4
41
+ # This cop supports safe auto-correction (--auto-correct).
42
+ # Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
43
+ # SupportedHashRocketStyles: key, separator, table
44
+ # SupportedColonStyles: key, separator, table
45
+ # SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
46
+ Layout/HashAlignment:
47
+ Exclude:
48
+ - 'lib/crowdin-api/client/configuration.rb'
49
+
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).
33
71
  # Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator.
34
72
  # SupportedStylesForExponentOperator: space, no_space
35
73
  Layout/SpaceAroundOperators:
36
74
  Exclude:
37
75
  - 'crowdin-api.gemspec'
76
+ - 'spec/api_resources/projects_spec.rb'
38
77
 
39
- # Offense count: 2
78
+ # Offense count: 3
40
79
  # Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
41
80
  Metrics/AbcSize:
42
- Max: 23
81
+ Max: 42
43
82
 
44
- # Offense count: 1
83
+ # Offense count: 46
45
84
  # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
46
85
  # IgnoredMethods: refine
47
86
  Metrics/BlockLength:
48
- Max: 54
87
+ Max: 171
49
88
 
50
- # Offense count: 4
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
51
100
  # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
52
101
  Metrics/MethodLength:
53
- Max: 18
102
+ Max: 41
54
103
 
55
- # Offense count: 2
104
+ # Offense count: 8
56
105
  # Configuration parameters: CountComments, CountAsOne.
57
106
  Metrics/ModuleLength:
58
- Max: 205
107
+ Max: 256
59
108
 
60
- # Offense count: 1
61
- # Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
109
+ # Offense count: 2
110
+ # Configuration parameters: Max, CountKeywordArgs.
62
111
  Metrics/ParameterLists:
63
- Max: 6
112
+ MaxOptionalParameters: 4
113
+
114
+ # Offense count: 1
115
+ # Configuration parameters: IgnoredMethods.
116
+ Metrics/PerceivedComplexity:
117
+ Max: 19
64
118
 
65
119
  # Offense count: 1
66
120
  Naming/AccessorMethodName:
67
121
  Exclude:
68
- - 'lib/crowdin-api/core/request.rb'
122
+ - 'lib/crowdin-api/api_resources/users.rb'
69
123
 
70
- # Offense count: 3
124
+ # Offense count: 1
71
125
  # Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, CheckDefinitionPathHierarchyRoots, Regex, IgnoreExecutableScripts, AllowedAcronyms.
72
126
  # CheckDefinitionPathHierarchyRoots: lib, spec, test, src
73
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
74
128
  Naming/FileName:
75
129
  Exclude:
76
130
  - 'lib/crowdin-api.rb'
77
- - 'spec/core/config-instance_spec.rb'
78
- - 'spec/crowdin-api_spec.rb'
79
131
 
80
- # Offense count: 3
132
+ # Offense count: 2
81
133
  # Configuration parameters: EnforcedStyleForLeadingUnderscores.
82
134
  # SupportedStylesForLeadingUnderscores: disallowed, required, optional
83
135
  Naming/MemoizedInstanceVariableName:
84
136
  Exclude:
85
137
  - 'lib/crowdin-api/client/client.rb'
86
138
 
87
- # Offense count: 3
88
- # Cop supports --auto-correct.
89
- # Configuration parameters: PreferredName.
90
- Naming/RescuedExceptionsVariableName:
91
- Exclude:
92
- - 'lib/crowdin-api/core/request.rb'
93
-
94
139
  # Offense count: 7
95
- # Cop supports --auto-correct.
140
+ # This cop supports safe auto-correction (--auto-correct).
96
141
  # Configuration parameters: EnforcedStyle.
97
142
  # SupportedStyles: separated, grouped
98
143
  Style/AccessorGrouping:
99
144
  Exclude:
100
- - 'lib/crowdin-api/client/client.rb'
101
145
  - 'lib/crowdin-api/client/configuration.rb'
146
+ - 'lib/crowdin-api/core/request.rb'
102
147
 
103
148
  # Offense count: 2
104
- # Cop supports --auto-correct.
149
+ # This cop supports unsafe auto-correction (--auto-correct-all).
105
150
  Style/CollectionCompact:
106
151
  Exclude:
107
152
  - 'lib/crowdin-api/core/request.rb'
108
153
 
109
- # Offense count: 12
154
+ # Offense count: 27
110
155
  # Configuration parameters: AllowedConstants.
111
156
  Style/Documentation:
157
+ Enabled: false
158
+
159
+ # Offense count: 1
160
+ # This cop supports safe auto-correction (--auto-correct).
161
+ # Configuration parameters: EnforcedStyle.
162
+ # SupportedStyles: allowed_in_returns, forbidden
163
+ Style/DoubleNegation:
112
164
  Exclude:
113
- - 'spec/**/*'
114
- - 'test/**/*'
115
- - 'lib/crowdin-api/api-resources/languages.rb'
116
- - 'lib/crowdin-api/api-resources/projects.rb'
117
- - 'lib/crowdin-api/api-resources/source_files.rb'
118
- - 'lib/crowdin-api/api-resources/source_strings.rb'
119
- - 'lib/crowdin-api/api-resources/storages.rb'
120
- - 'lib/crowdin-api/api-resources/translation_status.rb'
121
- - 'lib/crowdin-api/api-resources/translations.rb'
122
- - 'lib/crowdin-api/api-resources/workflows.rb'
123
- - 'lib/crowdin-api/client/client.rb'
124
165
  - 'lib/crowdin-api/client/configuration.rb'
125
- - 'lib/crowdin-api/core/api_errors_raiser.rb'
126
- - 'lib/crowdin-api/core/request.rb'
127
166
 
128
167
  # Offense count: 1
129
- # Cop supports --auto-correct.
168
+ # This cop supports safe auto-correction (--auto-correct).
130
169
  # Configuration parameters: EnforcedStyle.
131
170
  # SupportedStyles: always, always_true, never
132
171
  Style/FrozenStringLiteralComment:
133
172
  Exclude:
134
173
  - 'bin/crowdin-console'
135
174
 
175
+ # Offense count: 1
176
+ # Configuration parameters: MinBodyLength.
177
+ Style/GuardClause:
178
+ Exclude:
179
+ - 'lib/crowdin-api/client/client.rb'
180
+
136
181
  # Offense count: 1
137
182
  Style/MixinUsage:
138
183
  Exclude:
139
184
  - 'bin/crowdin-console'
185
+
186
+ # Offense count: 1
187
+ # This cop supports safe auto-correction (--auto-correct).
188
+ Style/RedundantFreeze:
189
+ Exclude:
190
+ - 'lib/crowdin-api/core/fetch_all_extensions.rb'
191
+
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).
202
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
203
+ # URISchemes: http, https
204
+ Layout/LineLength:
205
+ Max: 122
data/Gemfile CHANGED
@@ -2,4 +2,7 @@
2
2
 
3
3
  source 'https://rubygems.org'
4
4
 
5
+ # For Documentation
6
+ gem 'yard', '~> 0.9.28'
7
+
5
8
  gemspec
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [<p align='center'><img src='https://support.crowdin.com/assets/logos/crowdin-dark-symbol.png' data-canonical-src='https://support.crowdin.com/assets/logos/crowdin-dark-symbol.png' width='200' height='200' align='center'/></p>](https://crowdin.com)
1
+ [<p align='center'><img src='https://support.crowdin.com/assets/logos/crowdin-dark-symbol.png' data-canonical-src='https://support.crowdin.com/assets/logos/crowdin-dark-symbol.png' width='150' height='150' align='center'/></p>](https://crowdin.com)
2
2
 
3
3
  # Crowdin Ruby client
4
4
 
@@ -6,11 +6,11 @@ The Crowdin Ruby client is a lightweight interface to the Crowdin API v2. It pro
6
6
 
7
7
  Crowdin API is a full-featured RESTful API that helps you to integrate localization into your development process. The endpoints that we use allow you to easily make calls to retrieve information and to execute actions needed.
8
8
 
9
- For more about Crowdin API v2 see the documentation:
10
- - [Crowdin](https://support.crowdin.com/api/v2/)
11
- - [Crowdin Enterprise](https://support.crowdin.com/enterprise/api/)
9
+ <div align="center">
12
10
 
13
- ### Status
11
+ [**`API Client Docs`**](http://crowdin.github.io/crowdin-api-client-ruby/) &nbsp;|&nbsp;
12
+ [**`Crowdin API`**](https://developer.crowdin.com/api/v2/) &nbsp;|&nbsp;
13
+ [**`Crowdin Enterprise API`**](https://developer.crowdin.com/enterprise/api/v2/)
14
14
 
15
15
  [![Gem](https://img.shields.io/gem/v/crowdin-api?logo=ruby&cacheSeconds=1800)](https://rubygems.org/gems/crowdin-api)
16
16
  [![Gem](https://img.shields.io/gem/dt/crowdin-api?cacheSeconds=1800)](https://rubygems.org/gems/crowdin-api)
@@ -21,22 +21,29 @@ For more about Crowdin API v2 see the documentation:
21
21
  [![GitHub issues](https://img.shields.io/github/issues/crowdin/crowdin-api-client-ruby?cacheSeconds=1800)](https://github.com/crowdin/crowdin-api-client-ruby/issues)
22
22
  [![GitHub](https://img.shields.io/github/license/crowdin/crowdin-api-client-ruby?cacheSeconds=1800)](https://github.com/crowdin/crowdin-api-client-ruby/blob/main/LICENSE)
23
23
 
24
+ </div>
25
+
24
26
  ## Table of Contents
27
+ * [Requirements](#requirements)
25
28
  * [Installation](#installation)
26
29
  * [Quick Start](#quick-start)
27
30
  * [Initialization](#initialization)
28
- * [How to call methods](#how-to-call-methods)
31
+ * [Usage](#usage)
32
+ * [Fetch all records](#fetch-all-records)
29
33
  * [Command-Line Client](#command-line-client)
30
34
  * [Seeking Assistance](#seeking-assistance)
31
35
  * [Contributing](#contributing)
32
36
  * [License](#license)
33
37
 
38
+ ## Requirements
39
+ * Ruby >= 2.4
40
+
34
41
  ## Installation
35
42
 
36
43
  Add this line to your application's Gemfile:
37
44
 
38
45
  ```gemfile
39
- gem 'crowdin-api', '~> 1.1.0'
46
+ gem 'crowdin-api', '~> 1.5.0'
40
47
  ```
41
48
 
42
49
  And then execute:
@@ -62,6 +69,7 @@ gem install crowdin-api
62
69
  ## Quick start
63
70
 
64
71
  ### Initialization
72
+
65
73
  ```ruby
66
74
  require 'crowdin-api'
67
75
 
@@ -70,14 +78,15 @@ crowdin = Crowdin::Client.new do |config|
70
78
  config.api_token = 'YourApiToken'
71
79
  end
72
80
 
73
- # Or you can intialize Enterprise Client instance by specifying your organization_domain in config options
81
+ # Or you can initialize Enterprise Client instance by specifying your
82
+ # organization_domain in config options
74
83
  crowdin = Crowdin::Client.new do |config|
75
84
  config.api_token = 'YourEnterpriseApiToken'
76
85
  config.organization_domain = 'YourOrganizationDomain'
77
86
  end
78
- # Note: we use full specified organization domain if that includes .com
87
+ # Note: we use full specified organization domain if that includes '.com'
79
88
  # config.organization_domain = your_domain -> https://your_domain.api.crowdin.com
80
- # config.organization_domain = your_domain.com -> your_domain.com
89
+ # config.organization_domain = your_domain.com -> https://your_domain.com
81
90
 
82
91
  # All supported Crowdin Client config options now:
83
92
  crowdin = Crowdin::Client.new do |config|
@@ -86,8 +95,8 @@ crowdin = Crowdin::Client.new do |config|
86
95
  config.project_id = 'YourProjectId' # [Integer] nil by default
87
96
  config.enable_logger = true # [Boolean] false by default
88
97
  end
89
- # Note: Client will initialize default Logger instance if you have specify enable_logger to true,
90
- # you can change it by crowdin.logger = YourLogger
98
+ # Note: Client will initialize default Logger instance if you have specify
99
+ # enable_logger to true, you can change it by crowdin.logger = YourLogger
91
100
 
92
101
  # Also you can specify proxy by adding it to ENV['http_proxy'] before Client initialization
93
102
  ```
@@ -115,14 +124,20 @@ projects = crowdin.list_projects(offset: 10, limit: 20)
115
124
  # Get specified project
116
125
  project = crowdin.get_project(your_project_id)
117
126
 
127
+ # Edit project
128
+ project = crowdin.edit_project(project_id, [{ op: 'replace',
129
+ path: '/name',
130
+ value: 'your_new_project_name' }])
131
+
118
132
  # Add Storage
119
133
  storage = crowdin.add_storage(File.open('YourFilename.extension', 'r'))
120
- # or you can specify only filename
134
+ # or you can specify only absolute path to file
121
135
  storage = crowdin.add_storage('YourFilename.extension')
122
136
 
123
137
  # Download file
124
- filename = crowdin.download_file(your_file_id, your_destination, your_project_id)
125
- # your_destination - filename or full path to file, default - saving to currect directory with default filename
138
+ file = crowdin.download_file(your_file_id, your_destination, your_project_id)
139
+ # your_destination - filename or absolute path to file, optional
140
+ # Without destination option file will be saved to the current directory with a default filename
126
141
  # project_id is optional, as it can be initialized with a Crowdin Client
127
142
 
128
143
  # File revisions
@@ -130,6 +145,35 @@ filename = crowdin.download_file(your_file_id, your_destination, your_project_id
130
145
  file_revisions = crowdin.list_file_revisions(your_file_id, limit: 10)
131
146
  # or you can specify your project_id
132
147
  file_revisions = crowdin.list_file_revisions(your_file_id, { limit: 10 }, your_project_id)
148
+
149
+ # Note: more examples you can find in spec folder
150
+ ```
151
+
152
+ ### Fetch all records
153
+
154
+ There is a possibility to fetch all records from paginatable methods using `fetch_all` method.
155
+
156
+ ```ruby
157
+ # FetchAll options:
158
+ # * limit, Integer, default: 500 | How many records need to load per one request
159
+ # * offset, Integer, default: 0
160
+ # * request_delay, Integer (seconds), default: 0 | Delay between requests. To specify a delay in milliseconds use float values like 0.100
161
+
162
+ # Examples:
163
+
164
+ @crowdin.fetch_all(:list_projects)
165
+
166
+ # with options
167
+ @crowdin.fetch_all(:list_projects, { limit: 10, request_delay: 1 })
168
+
169
+ # playing with response per fetch
170
+ # Note: the block actually don't make any effect to finite result
171
+ @crowdin.fetch_all(:list_projects, { limit: 10, request_delay: 1 }) { |response| puts response['data'] }
172
+
173
+ # also, you could specify a retry configuration to handle some exceptions
174
+ # fetch all execution will be terminated if response status code is the same as one of the error_messages array value
175
+ # otherwise, the request will be retried so many times, as indicated at retries_count
176
+ @crowdin.fetch_all(:list_projects, {}, { request_delay: 2, retries_count: 3, error_messages: ['401'] })
133
177
  ```
134
178
 
135
179
  ### Command-Line Client
@@ -143,9 +187,9 @@ $ bundle exec crowdin-console --enable-logger --api-token API_TOKEN --project-id
143
187
  Or Crowdin Enterprise
144
188
 
145
189
  ```console
146
- $ bundle exec crowdin-console --enable-logger --enterprise --api-token API_TOKEN --organization-domain YOUR_DOMAIN --project-id PROJECT_ID
190
+ $ bundle exec crowdin-console --enable-logger --enterprise --api-token API_TOKEN --organization-domain DOMAIN --project-id PROJECT_ID
147
191
  ```
148
- Note: you can specify full organization domain by adding .com
192
+ Note: you can specify full organization domain by adding '.com'
149
193
 
150
194
  When execute you'll have IRB console with configured *@crowdin* instance
151
195
 
data/bin/crowdin-console CHANGED
@@ -12,12 +12,12 @@ 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
  #
19
19
 
20
- include Crowdin::Errors::ApiErrorsRaiser
20
+ include Crowdin::Errors::ClcErrorsRaiser
21
21
 
22
22
  options = {}
23
23
 
@@ -27,7 +27,7 @@ OptionParser.new do |opts|
27
27
  opts.on('--enterprise', 'Enterprise API') { |v| options[:enterprise] = v }
28
28
  opts.on('--api-token TOKEN', 'API Token') { |v| options[:api_token] = v }
29
29
  opts.on('--organization-domain DOMAIN', 'Organization Domain') { |v| options[:organization_domain] = v }
30
- opts.on('--project-id ID', 'Project ID') { |v| options[:project_id] = v }
30
+ opts.on('--project-id ID', 'Project ID') { |v| options[:project_id] = v }
31
31
  opts.on('--enable-logger', 'Enable logger') { |v| options[:enable_logger] = v }
32
32
  end.parse!
33
33
 
@@ -39,8 +39,8 @@ if options[:enterprise]
39
39
  @crowdin = Crowdin::Client.new do |config|
40
40
  config.api_token = options[:api_token]
41
41
  config.organization_domain = options[:organization_domain]
42
- config.enable_logger = options[:enable_logger] || false
43
- config.project_id = options[:project_id] || nil
42
+ config.enable_logger = options[:enable_logger] || false
43
+ config.project_id = options[:project_id] || nil
44
44
  end
45
45
  else
46
46
  @crowdin = Crowdin::Client.new do |config|
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,104 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Crowdin
4
+ module ApiResources
5
+ module Bundles
6
+ # @param query [Hash] Request Body
7
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.bundles.getMany API Documentation}
8
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.bundles.getMany Enterprise API Documentation}
9
+ def list_bundles(query = {}, project_id = config.project_id)
10
+ project_id || raise_project_id_is_required_error
11
+
12
+ request = Web::Request.new(
13
+ connection,
14
+ :get,
15
+ "#{config.target_api_url}/projects/#{project_id}/bundles",
16
+ { params: query }
17
+ )
18
+ Web::SendRequest.new(request).perform
19
+ end
20
+
21
+ # @param query [Hash] Request Body
22
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.bundles.post API Documentation}
23
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.bundles.post Enterprise API Documentation}
24
+ def add_bundle(query = {}, project_id = config.project_id)
25
+ project_id || raise_project_id_is_required_error
26
+ %i[name format sourcePatterns exportPattern].each do |param|
27
+ query[param] || raise_parameter_is_required_error(param)
28
+ end
29
+
30
+ request = Web::Request.new(
31
+ connection,
32
+ :post,
33
+ "#{config.target_api_url}/projects/#{project_id}/bundles",
34
+ { params: query }
35
+ )
36
+ Web::SendRequest.new(request).perform
37
+ end
38
+
39
+ # @param bundle_id [Integer] Bundle ID
40
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.bundles.get API Documentation}
41
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.bundles.get Enterprise API Documentation}
42
+ def get_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
+ :get,
49
+ "#{config.target_api_url}/projects/#{project_id}/bundles/#{bundle_id}"
50
+ )
51
+ Web::SendRequest.new(request).perform
52
+ end
53
+
54
+ # @param bundle_id [Integer] Bundle ID
55
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.bundles.delete API Documentation}
56
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.bundles.delete Enterprise API Documentation}
57
+ def delete_bundle(bundle_id, project_id = config.project_id)
58
+ bundle_id || raise_parameter_is_required_error(:bundle_id)
59
+ project_id || raise_project_id_is_required_error
60
+
61
+ request = Web::Request.new(
62
+ connection,
63
+ :delete,
64
+ "#{config.target_api_url}/projects/#{project_id}/bundles/#{bundle_id}"
65
+ )
66
+ Web::SendRequest.new(request).perform
67
+ end
68
+
69
+ # @param bundle_id [Integer] Bundle ID
70
+ # @param query [Hash] Request Body
71
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.bundles.patch API Documentation}
72
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.bundles.patch Enterprise API Documentation}
73
+ def edit_bundle(bundle_id, query = {}, project_id = config.project_id)
74
+ bundle_id || raise_parameter_is_required_error(:bundle_id)
75
+ project_id || raise_project_id_is_required_error
76
+
77
+ request = Web::Request.new(
78
+ connection,
79
+ :patch,
80
+ "#{config.target_api_url}/projects/#{project_id}/bundles/#{bundle_id}",
81
+ { params: query }
82
+ )
83
+ Web::SendRequest.new(request).perform
84
+ end
85
+
86
+ # @param bundle_id [Integer] Bundle ID
87
+ # @param query [Hash] Request Body
88
+ # * {https://developer.crowdin.com/api/v2/#operation/api.projects.bundles.files.getMany API Documentation}
89
+ # * {https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.bundles.files.getMany Enterprise API Documentation}
90
+ def bundle_list_files(bundle_id, query = {}, project_id = config.project_id)
91
+ bundle_id || raise_parameter_is_required_error(:bundle_id)
92
+ project_id || raise_project_id_is_required_error
93
+
94
+ request = Web::Request.new(
95
+ connection,
96
+ :get,
97
+ "#{config.target_api_url}/projects/#{project_id}/bundles/#{bundle_id}/files",
98
+ { params: query }
99
+ )
100
+ Web::SendRequest.new(request).perform
101
+ end
102
+ end
103
+ end
104
+ end