crowdin-api 1.1.1 → 1.3.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 (71) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test-and-lint.yml +1 -1
  3. data/.gitignore +2 -2
  4. data/.rubocop_todo.yml +114 -42
  5. data/README.md +26 -13
  6. data/bin/crowdin-console +5 -5
  7. data/crowdin-api.gemspec +1 -2
  8. data/lib/crowdin-api/api_resources/dictionaries.rb +32 -0
  9. data/lib/crowdin-api/api_resources/distributions.rb +92 -0
  10. data/lib/crowdin-api/api_resources/glossaries.rb +199 -0
  11. data/lib/crowdin-api/api_resources/labels.rb +98 -0
  12. data/lib/crowdin-api/api_resources/languages.rb +61 -0
  13. data/lib/crowdin-api/api_resources/machine_translation_engines.rb +79 -0
  14. data/lib/crowdin-api/api_resources/projects.rb +124 -0
  15. data/lib/crowdin-api/api_resources/reports.rb +120 -0
  16. data/lib/crowdin-api/api_resources/screenshots.rb +172 -0
  17. data/lib/crowdin-api/{api-resources → api_resources}/source_files.rb +68 -130
  18. data/lib/crowdin-api/{api-resources → api_resources}/source_strings.rb +19 -24
  19. data/lib/crowdin-api/api_resources/storages.rb +54 -0
  20. data/lib/crowdin-api/api_resources/string_comments.rb +68 -0
  21. data/lib/crowdin-api/api_resources/string_translations.rb +193 -0
  22. data/lib/crowdin-api/api_resources/tasks.rb +102 -0
  23. data/lib/crowdin-api/api_resources/teams.rb +135 -0
  24. data/lib/crowdin-api/api_resources/translation_memory.rb +131 -0
  25. data/lib/crowdin-api/{api-resources → api_resources}/translation_status.rb +24 -30
  26. data/lib/crowdin-api/{api-resources → api_resources}/translations.rb +41 -59
  27. data/lib/crowdin-api/api_resources/users.rb +161 -0
  28. data/lib/crowdin-api/api_resources/vendors.rb +21 -0
  29. data/lib/crowdin-api/api_resources/webhooks.rb +68 -0
  30. data/lib/crowdin-api/api_resources/workflows.rb +59 -0
  31. data/lib/crowdin-api/client/client.rb +72 -50
  32. data/lib/crowdin-api/client/configuration.rb +16 -12
  33. data/lib/crowdin-api/client/version.rb +1 -1
  34. data/lib/crowdin-api/core/errors.rb +2 -1
  35. data/lib/crowdin-api/core/{api_errors_raiser.rb → errors_raisers.rb} +21 -11
  36. data/lib/crowdin-api/core/request.rb +53 -88
  37. data/lib/crowdin-api/core/send_request.rb +67 -0
  38. data/lib/crowdin-api.rb +20 -11
  39. data/spec/api_resources/dictionaries_spec.rb +23 -0
  40. data/spec/api_resources/distributions_spec.rb +71 -0
  41. data/spec/api_resources/glossaries_spec.rb +167 -0
  42. data/spec/api_resources/labels_spec.rb +71 -0
  43. data/spec/api_resources/languages_spec.rb +51 -0
  44. data/spec/api_resources/machine_translation_engines_spec.rb +63 -0
  45. data/spec/api_resources/projects_spec.rb +215 -0
  46. data/spec/api_resources/reports_spec.rb +95 -0
  47. data/spec/api_resources/screenshots_spec.rb +134 -0
  48. data/spec/api_resources/source_files_spec.rb +13 -0
  49. data/spec/api_resources/source_strings_spec.rb +51 -0
  50. data/spec/api_resources/storages_spec.rb +13 -0
  51. data/spec/api_resources/string_comments_spec.rb +13 -0
  52. data/spec/api_resources/string_translations_spec.rb +13 -0
  53. data/spec/api_resources/tasks_spec.rb +79 -0
  54. data/spec/api_resources/teams_spec.rb +13 -0
  55. data/spec/api_resources/translation_memory_spec.rb +13 -0
  56. data/spec/api_resources/translation_status_spec.rb +15 -0
  57. data/spec/api_resources/translations_spec.rb +107 -0
  58. data/spec/api_resources/users_spec.rb +117 -0
  59. data/spec/api_resources/vendors_spec.rb +13 -0
  60. data/spec/api_resources/webhooks_spec.rb +51 -0
  61. data/spec/api_resources/workflows_spec.rb +41 -0
  62. data/spec/spec_helper.rb +20 -2
  63. data/spec/unit/client_spec.rb +85 -0
  64. metadata +65 -28
  65. data/bin/setup +0 -6
  66. data/lib/crowdin-api/api-resources/languages.rb +0 -81
  67. data/lib/crowdin-api/api-resources/projects.rb +0 -134
  68. data/lib/crowdin-api/api-resources/storages.rb +0 -102
  69. data/lib/crowdin-api/api-resources/workflows.rb +0 -59
  70. data/spec/core/config-instance_spec.rb +0 -72
  71. 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: 61895ba4796676e716e2a62d4255f518cfcf3b2c138912f201cddce16250a474
4
+ data.tar.gz: 6cd484b5d394e9b0c2ed2597003d1a64db1d656242d241728c3d4d9f650df87d
5
5
  SHA512:
6
- metadata.gz: aea9c98831b8abfacb4fe670d4d9025cee21cf33334083645ad9f4767f5d375249a9d2fde8ab7739fec3ca61f1ade03496f23b12377414ce18f62eea2819f453
7
- data.tar.gz: 5e69bf63d256bb96faaa11d749635253ad4625b6741d3d312cd7b61af127bd09d494ee87350b7b589e9c8c78de807bccba25286480627aa0e80153554e81fd1f
6
+ metadata.gz: 14a37cc1eba04d6170dfe082d50ff3ddc033997c1f4f3eab26ab3f9c04b7b35a419c5642cda28b0fbfb258588b234d24dbb685a004cf14841d85bf7f3b12a790
7
+ data.tar.gz: 4c60ed5dbb6dbe6ab2dfd64f92d508be2f13ac2223a6a34292fb09c1fa1ebcb320ce3ee0ee2c56ba04fc15bc5d598d569528212bc505076d23c7c5ace0515f72
@@ -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-05-09 23:17:26 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,112 +21,153 @@ Gemspec/RequiredRubyVersion:
21
21
  Exclude:
22
22
  - 'crowdin-api.gemspec'
23
23
 
24
- # Offense count: 2
25
- # Cop supports --auto-correct.
24
+ # Offense count: 18
25
+ # This cop supports safe auto-correction (--auto-correct).
26
26
  # Configuration parameters: AllowForAlignment, AllowBeforeTrailingComments, ForceEqualSignAlignment.
27
27
  Layout/ExtraSpacing:
28
28
  Exclude:
29
- - 'bin/crowdin-console'
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
34
 
31
- # Offense count: 1
32
- # Cop supports --auto-correct.
35
+ # Offense count: 4
36
+ # This cop supports safe auto-correction (--auto-correct).
37
+ # Configuration parameters: AllowMultipleStyles, EnforcedHashRocketStyle, EnforcedColonStyle, EnforcedLastArgumentHashStyle.
38
+ # SupportedHashRocketStyles: key, separator, table
39
+ # SupportedColonStyles: key, separator, table
40
+ # SupportedLastArgumentHashStyles: always_inspect, always_ignore, ignore_implicit, ignore_explicit
41
+ Layout/HashAlignment:
42
+ Exclude:
43
+ - 'lib/crowdin-api/client/configuration.rb'
44
+
45
+ # Offense count: 13
46
+ # This cop supports safe auto-correction (--auto-correct).
47
+ # Configuration parameters: EnforcedStyle.
48
+ # SupportedStyles: normal, indented_internal_methods
49
+ Layout/IndentationConsistency:
50
+ Exclude:
51
+ - 'lib/crowdin-api/client/client.rb'
52
+ - 'lib/crowdin-api/core/request.rb'
53
+ - 'lib/crowdin-api/core/send_request.rb'
54
+
55
+ # Offense count: 13
56
+ # This cop supports safe auto-correction (--auto-correct).
57
+ # Configuration parameters: Width, IgnoredPatterns.
58
+ Layout/IndentationWidth:
59
+ Exclude:
60
+ - 'lib/crowdin-api/client/client.rb'
61
+ - 'lib/crowdin-api/core/request.rb'
62
+ - 'lib/crowdin-api/core/send_request.rb'
63
+
64
+ # Offense count: 22
65
+ # This cop supports safe auto-correction (--auto-correct).
33
66
  # Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator.
34
67
  # SupportedStylesForExponentOperator: space, no_space
35
68
  Layout/SpaceAroundOperators:
36
69
  Exclude:
37
70
  - '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
+ - 'spec/api_resources/projects_spec.rb'
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'
38
84
 
39
85
  # Offense count: 2
40
86
  # Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
41
87
  Metrics/AbcSize:
42
88
  Max: 23
43
89
 
44
- # Offense count: 1
90
+ # Offense count: 4
45
91
  # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
46
92
  # IgnoredMethods: refine
47
93
  Metrics/BlockLength:
48
- Max: 54
94
+ Max: 171
49
95
 
50
- # Offense count: 4
96
+ # Offense count: 13
51
97
  # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
52
98
  Metrics/MethodLength:
53
99
  Max: 18
54
100
 
55
- # Offense count: 2
101
+ # Offense count: 9
56
102
  # Configuration parameters: CountComments, CountAsOne.
57
103
  Metrics/ModuleLength:
58
- Max: 205
104
+ Max: 199
59
105
 
60
- # Offense count: 1
61
- # Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
106
+ # Offense count: 3
107
+ # Configuration parameters: CountKeywordArgs.
62
108
  Metrics/ParameterLists:
109
+ MaxOptionalParameters: 4
63
110
  Max: 6
64
111
 
65
- # Offense count: 1
112
+ # Offense count: 2
66
113
  Naming/AccessorMethodName:
67
114
  Exclude:
68
- - 'lib/crowdin-api/core/request.rb'
115
+ - 'lib/crowdin-api/api_resources/users.rb'
116
+ - 'lib/crowdin-api/core/send_request.rb'
69
117
 
70
- # Offense count: 3
118
+ # Offense count: 1
71
119
  # Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, CheckDefinitionPathHierarchyRoots, Regex, IgnoreExecutableScripts, AllowedAcronyms.
72
120
  # CheckDefinitionPathHierarchyRoots: lib, spec, test, src
73
121
  # 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
122
  Naming/FileName:
75
123
  Exclude:
76
124
  - 'lib/crowdin-api.rb'
77
- - 'spec/core/config-instance_spec.rb'
78
- - 'spec/crowdin-api_spec.rb'
79
125
 
80
- # Offense count: 3
126
+ # Offense count: 2
81
127
  # Configuration parameters: EnforcedStyleForLeadingUnderscores.
82
128
  # SupportedStylesForLeadingUnderscores: disallowed, required, optional
83
129
  Naming/MemoizedInstanceVariableName:
84
130
  Exclude:
85
131
  - 'lib/crowdin-api/client/client.rb'
86
132
 
87
- # Offense count: 3
88
- # Cop supports --auto-correct.
133
+ # Offense count: 6
134
+ # This cop supports safe auto-correction (--auto-correct).
89
135
  # Configuration parameters: PreferredName.
90
136
  Naming/RescuedExceptionsVariableName:
91
137
  Exclude:
92
- - 'lib/crowdin-api/core/request.rb'
138
+ - 'lib/crowdin-api/core/send_request.rb'
93
139
 
94
140
  # Offense count: 7
95
- # Cop supports --auto-correct.
141
+ # This cop supports safe auto-correction (--auto-correct).
96
142
  # Configuration parameters: EnforcedStyle.
97
143
  # SupportedStyles: separated, grouped
98
144
  Style/AccessorGrouping:
99
145
  Exclude:
100
- - 'lib/crowdin-api/client/client.rb'
101
146
  - 'lib/crowdin-api/client/configuration.rb'
147
+ - 'lib/crowdin-api/core/request.rb'
102
148
 
103
- # Offense count: 2
104
- # Cop supports --auto-correct.
149
+ # Offense count: 4
150
+ # This cop supports unsafe auto-correction (--auto-correct-all).
105
151
  Style/CollectionCompact:
106
152
  Exclude:
107
153
  - 'lib/crowdin-api/core/request.rb'
154
+ - 'lib/crowdin-api/core/send_request.rb'
108
155
 
109
- # Offense count: 12
156
+ # Offense count: 24
110
157
  # Configuration parameters: AllowedConstants.
111
158
  Style/Documentation:
159
+ Enabled: false
160
+
161
+ # Offense count: 1
162
+ # This cop supports safe auto-correction (--auto-correct).
163
+ # Configuration parameters: EnforcedStyle.
164
+ # SupportedStyles: allowed_in_returns, forbidden
165
+ Style/DoubleNegation:
112
166
  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
167
  - 'lib/crowdin-api/client/configuration.rb'
125
- - 'lib/crowdin-api/core/api_errors_raiser.rb'
126
- - 'lib/crowdin-api/core/request.rb'
127
168
 
128
169
  # Offense count: 1
129
- # Cop supports --auto-correct.
170
+ # This cop supports safe auto-correction (--auto-correct).
130
171
  # Configuration parameters: EnforcedStyle.
131
172
  # SupportedStyles: always, always_true, never
132
173
  Style/FrozenStringLiteralComment:
@@ -137,3 +178,34 @@ Style/FrozenStringLiteralComment:
137
178
  Style/MixinUsage:
138
179
  Exclude:
139
180
  - 'bin/crowdin-console'
181
+
182
+ # Offense count: 2
183
+ # This cop supports safe auto-correction (--auto-correct).
184
+ # Configuration parameters: EnforcedStyle.
185
+ # SupportedStyles: implicit, explicit
186
+ Style/RescueStandardError:
187
+ Exclude:
188
+ - 'lib/crowdin-api/api_resources/labels.rb'
189
+ - 'lib/crowdin-api/api_resources/string_translations.rb'
190
+
191
+ # Offense count: 1
192
+ # This cop supports unsafe auto-correction (--auto-correct-all).
193
+ # Configuration parameters: Mode.
194
+ Style/StringConcatenation:
195
+ Exclude:
196
+ - 'lib/crowdin-api/api_resources/projects.rb'
197
+
198
+ # Offense count: 8
199
+ # This cop supports safe auto-correction (--auto-correct).
200
+ # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
201
+ # SupportedStyles: single_quotes, double_quotes
202
+ Style/StringLiterals:
203
+ Exclude:
204
+ - 'spec/api_resources/projects_spec.rb'
205
+
206
+ # Offense count: 1
207
+ # This cop supports safe auto-correction (--auto-correct).
208
+ # Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
209
+ # URISchemes: http, https
210
+ Layout/LineLength:
211
+ Max: 121
data/README.md CHANGED
@@ -10,7 +10,7 @@ For more about Crowdin API v2 see the documentation:
10
10
  - [Crowdin](https://support.crowdin.com/api/v2/)
11
11
  - [Crowdin Enterprise](https://support.crowdin.com/enterprise/api/)
12
12
 
13
- ### Status
13
+ ## Status
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)
@@ -22,21 +22,25 @@ For more about Crowdin API v2 see the documentation:
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
24
  ## Table of Contents
25
+ * [Requirements](#requirements)
25
26
  * [Installation](#installation)
26
27
  * [Quick Start](#quick-start)
27
28
  * [Initialization](#initialization)
28
- * [How to call methods](#how-to-call-methods)
29
+ * [Usage](#usage)
29
30
  * [Command-Line Client](#command-line-client)
30
31
  * [Seeking Assistance](#seeking-assistance)
31
32
  * [Contributing](#contributing)
32
33
  * [License](#license)
33
34
 
35
+ ## Requirements
36
+ * Ruby >= 2.4
37
+
34
38
  ## Installation
35
39
 
36
40
  Add this line to your application's Gemfile:
37
41
 
38
42
  ```gemfile
39
- gem 'crowdin-api', '~> 1.1.0'
43
+ gem 'crowdin-api', '~> 1.3.0'
40
44
  ```
41
45
 
42
46
  And then execute:
@@ -70,14 +74,15 @@ crowdin = Crowdin::Client.new do |config|
70
74
  config.api_token = 'YourApiToken'
71
75
  end
72
76
 
73
- # Or you can intialize Enterprise Client instance by specifying your organization_domain in config options
77
+ # Or you can initialize Enterprise Client instance by specifying your
78
+ # organization_domain in config options
74
79
  crowdin = Crowdin::Client.new do |config|
75
80
  config.api_token = 'YourEnterpriseApiToken'
76
81
  config.organization_domain = 'YourOrganizationDomain'
77
82
  end
78
- # Note: we use full specified organization domain if that includes .com
83
+ # Note: we use full specified organization domain if that includes '.com'
79
84
  # config.organization_domain = your_domain -> https://your_domain.api.crowdin.com
80
- # config.organization_domain = your_domain.com -> your_domain.com
85
+ # config.organization_domain = your_domain.com -> https://your_domain.com
81
86
 
82
87
  # All supported Crowdin Client config options now:
83
88
  crowdin = Crowdin::Client.new do |config|
@@ -86,8 +91,8 @@ crowdin = Crowdin::Client.new do |config|
86
91
  config.project_id = 'YourProjectId' # [Integer] nil by default
87
92
  config.enable_logger = true # [Boolean] false by default
88
93
  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
94
+ # Note: Client will initialize default Logger instance if you have specify
95
+ # enable_logger to true, you can change it by crowdin.logger = YourLogger
91
96
 
92
97
  # Also you can specify proxy by adding it to ENV['http_proxy'] before Client initialization
93
98
  ```
@@ -115,14 +120,20 @@ projects = crowdin.list_projects(offset: 10, limit: 20)
115
120
  # Get specified project
116
121
  project = crowdin.get_project(your_project_id)
117
122
 
123
+ # Edit project
124
+ project = crowdin.edit_project(project_id, [{ op: 'replace',
125
+ path: '/name',
126
+ value: 'your_new_project_name' }])
127
+
118
128
  # Add Storage
119
129
  storage = crowdin.add_storage(File.open('YourFilename.extension', 'r'))
120
- # or you can specify only filename
130
+ # or you can specify only absolute path to file
121
131
  storage = crowdin.add_storage('YourFilename.extension')
122
132
 
123
133
  # 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
134
+ file = crowdin.download_file(your_file_id, your_destination, your_project_id)
135
+ # your_destination - filename or absolute path to file, optional
136
+ # Without destination option file will be saved to the current directory with a default filename
126
137
  # project_id is optional, as it can be initialized with a Crowdin Client
127
138
 
128
139
  # File revisions
@@ -130,6 +141,8 @@ filename = crowdin.download_file(your_file_id, your_destination, your_project_id
130
141
  file_revisions = crowdin.list_file_revisions(your_file_id, limit: 10)
131
142
  # or you can specify your project_id
132
143
  file_revisions = crowdin.list_file_revisions(your_file_id, { limit: 10 }, your_project_id)
144
+
145
+ # Note: more examples you can find in spec folder
133
146
  ```
134
147
 
135
148
  ### Command-Line Client
@@ -143,9 +156,9 @@ $ bundle exec crowdin-console --enable-logger --api-token API_TOKEN --project-id
143
156
  Or Crowdin Enterprise
144
157
 
145
158
  ```console
146
- $ bundle exec crowdin-console --enable-logger --enterprise --api-token API_TOKEN --organization-domain YOUR_DOMAIN --project-id PROJECT_ID
159
+ $ bundle exec crowdin-console --enable-logger --enterprise --api-token API_TOKEN --organization-domain DOMAIN --project-id PROJECT_ID
147
160
  ```
148
- Note: you can specify full organization domain by adding .com
161
+ Note: you can specify full organization domain by adding '.com'
149
162
 
150
163
  When execute you'll have IRB console with configured *@crowdin* instance
151
164
 
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,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Crowdin
4
+ module ApiResources
5
+ module Dictionaries
6
+ def list_dictionaries(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}/dictionaries",
13
+ { params: query }
14
+ )
15
+ Web::SendRequest.new(request).perform
16
+ end
17
+
18
+ def edit_dictionary(language_id = nil, query = {}, project_id = config.project_id)
19
+ language_id || raise_parameter_is_required_error(:language_id)
20
+ project_id || raise_project_id_is_required_error
21
+
22
+ request = Web::Request.new(
23
+ connection,
24
+ :patch,
25
+ "#{config.target_api_url}/projects/#{project_id}/dictionaries/#{language_id}",
26
+ { params: query }
27
+ )
28
+ Web::SendRequest.new(request).perform
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,92 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Crowdin
4
+ module ApiResources
5
+ module Distributions
6
+ def list_distributions(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}/distributions",
13
+ { params: query }
14
+ )
15
+ Web::SendRequest.new(request).perform
16
+ end
17
+
18
+ def add_distribution(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}/distributions",
25
+ { params: query }
26
+ )
27
+ Web::SendRequest.new(request).perform
28
+ end
29
+
30
+ def get_distribution(hash = nil, project_id = config.project_id)
31
+ hash || raise_parameter_is_required_error(:hash)
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}/distributions/#{hash}"
38
+ )
39
+ Web::SendRequest.new(request).perform
40
+ end
41
+
42
+ def delete_distribution(hash = nil, project_id = config.project_id)
43
+ hash || raise_parameter_is_required_error(:hash)
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}/distributions/#{hash}"
50
+ )
51
+ Web::SendRequest.new(request).perform
52
+ end
53
+
54
+ def edit_distribution(hash = nil, query = {}, project_id = config.project_id)
55
+ hash || raise_parameter_is_required_error(:hash)
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}/distributions/#{hash}",
62
+ { params: query }
63
+ )
64
+ Web::SendRequest.new(request).perform
65
+ end
66
+
67
+ def get_distribution_release(hash = nil, project_id = config.project_id)
68
+ hash || raise_parameter_is_required_error(:hash)
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}/distributions/#{hash}/release"
75
+ )
76
+ Web::SendRequest.new(request).perform
77
+ end
78
+
79
+ def release_distribution(hash = nil, project_id = config.project_id)
80
+ hash || raise_parameter_is_required_error(:hash)
81
+ project_id || raise_project_id_is_required_error
82
+
83
+ request = Web::Request.new(
84
+ connection,
85
+ :post,
86
+ "#{config.target_api_url}/projects/#{project_id}/distributions/#{hash}/release"
87
+ )
88
+ Web::SendRequest.new(request).perform
89
+ end
90
+ end
91
+ end
92
+ end