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.
- checksums.yaml +4 -4
- data/.github/workflows/test-and-lint.yml +1 -1
- data/.gitignore +2 -2
- data/.rubocop_todo.yml +114 -42
- data/README.md +26 -13
- data/bin/crowdin-console +5 -5
- data/crowdin-api.gemspec +1 -2
- data/lib/crowdin-api/api_resources/dictionaries.rb +32 -0
- data/lib/crowdin-api/api_resources/distributions.rb +92 -0
- data/lib/crowdin-api/api_resources/glossaries.rb +199 -0
- data/lib/crowdin-api/api_resources/labels.rb +98 -0
- data/lib/crowdin-api/api_resources/languages.rb +61 -0
- data/lib/crowdin-api/api_resources/machine_translation_engines.rb +79 -0
- data/lib/crowdin-api/api_resources/projects.rb +124 -0
- data/lib/crowdin-api/api_resources/reports.rb +120 -0
- data/lib/crowdin-api/api_resources/screenshots.rb +172 -0
- data/lib/crowdin-api/{api-resources → api_resources}/source_files.rb +68 -130
- data/lib/crowdin-api/{api-resources → api_resources}/source_strings.rb +19 -24
- data/lib/crowdin-api/api_resources/storages.rb +54 -0
- data/lib/crowdin-api/api_resources/string_comments.rb +68 -0
- data/lib/crowdin-api/api_resources/string_translations.rb +193 -0
- data/lib/crowdin-api/api_resources/tasks.rb +102 -0
- data/lib/crowdin-api/api_resources/teams.rb +135 -0
- data/lib/crowdin-api/api_resources/translation_memory.rb +131 -0
- data/lib/crowdin-api/{api-resources → api_resources}/translation_status.rb +24 -30
- data/lib/crowdin-api/{api-resources → api_resources}/translations.rb +41 -59
- data/lib/crowdin-api/api_resources/users.rb +161 -0
- data/lib/crowdin-api/api_resources/vendors.rb +21 -0
- data/lib/crowdin-api/api_resources/webhooks.rb +68 -0
- data/lib/crowdin-api/api_resources/workflows.rb +59 -0
- data/lib/crowdin-api/client/client.rb +72 -50
- data/lib/crowdin-api/client/configuration.rb +16 -12
- data/lib/crowdin-api/client/version.rb +1 -1
- data/lib/crowdin-api/core/errors.rb +2 -1
- data/lib/crowdin-api/core/{api_errors_raiser.rb → errors_raisers.rb} +21 -11
- data/lib/crowdin-api/core/request.rb +53 -88
- data/lib/crowdin-api/core/send_request.rb +67 -0
- data/lib/crowdin-api.rb +20 -11
- data/spec/api_resources/dictionaries_spec.rb +23 -0
- data/spec/api_resources/distributions_spec.rb +71 -0
- data/spec/api_resources/glossaries_spec.rb +167 -0
- data/spec/api_resources/labels_spec.rb +71 -0
- data/spec/api_resources/languages_spec.rb +51 -0
- data/spec/api_resources/machine_translation_engines_spec.rb +63 -0
- data/spec/api_resources/projects_spec.rb +215 -0
- data/spec/api_resources/reports_spec.rb +95 -0
- data/spec/api_resources/screenshots_spec.rb +134 -0
- data/spec/api_resources/source_files_spec.rb +13 -0
- data/spec/api_resources/source_strings_spec.rb +51 -0
- data/spec/api_resources/storages_spec.rb +13 -0
- data/spec/api_resources/string_comments_spec.rb +13 -0
- data/spec/api_resources/string_translations_spec.rb +13 -0
- data/spec/api_resources/tasks_spec.rb +79 -0
- data/spec/api_resources/teams_spec.rb +13 -0
- data/spec/api_resources/translation_memory_spec.rb +13 -0
- data/spec/api_resources/translation_status_spec.rb +15 -0
- data/spec/api_resources/translations_spec.rb +107 -0
- data/spec/api_resources/users_spec.rb +117 -0
- data/spec/api_resources/vendors_spec.rb +13 -0
- data/spec/api_resources/webhooks_spec.rb +51 -0
- data/spec/api_resources/workflows_spec.rb +41 -0
- data/spec/spec_helper.rb +20 -2
- data/spec/unit/client_spec.rb +85 -0
- metadata +65 -28
- data/bin/setup +0 -6
- data/lib/crowdin-api/api-resources/languages.rb +0 -81
- data/lib/crowdin-api/api-resources/projects.rb +0 -134
- data/lib/crowdin-api/api-resources/storages.rb +0 -102
- data/lib/crowdin-api/api-resources/workflows.rb +0 -59
- data/spec/core/config-instance_spec.rb +0 -72
- data/spec/crowdin-api_spec.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61895ba4796676e716e2a62d4255f518cfcf3b2c138912f201cddce16250a474
|
4
|
+
data.tar.gz: 6cd484b5d394e9b0c2ed2597003d1a64db1d656242d241728c3d4d9f650df87d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 14a37cc1eba04d6170dfe082d50ff3ddc033997c1f4f3eab26ab3f9c04b7b35a419c5642cda28b0fbfb258588b234d24dbb685a004cf14841d85bf7f3b12a790
|
7
|
+
data.tar.gz: 4c60ed5dbb6dbe6ab2dfd64f92d508be2f13ac2223a6a34292fb09c1fa1ebcb320ce3ee0ee2c56ba04fc15bc5d598d569528212bc505076d23c7c5ace0515f72
|
data/.gitignore
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on
|
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
|
-
#
|
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:
|
25
|
-
#
|
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
|
-
- '
|
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:
|
32
|
-
#
|
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:
|
90
|
+
# Offense count: 4
|
45
91
|
# Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
|
46
92
|
# IgnoredMethods: refine
|
47
93
|
Metrics/BlockLength:
|
48
|
-
Max:
|
94
|
+
Max: 171
|
49
95
|
|
50
|
-
# Offense count:
|
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:
|
101
|
+
# Offense count: 9
|
56
102
|
# Configuration parameters: CountComments, CountAsOne.
|
57
103
|
Metrics/ModuleLength:
|
58
|
-
Max:
|
104
|
+
Max: 199
|
59
105
|
|
60
|
-
# Offense count:
|
61
|
-
# Configuration parameters: CountKeywordArgs
|
106
|
+
# Offense count: 3
|
107
|
+
# Configuration parameters: CountKeywordArgs.
|
62
108
|
Metrics/ParameterLists:
|
109
|
+
MaxOptionalParameters: 4
|
63
110
|
Max: 6
|
64
111
|
|
65
|
-
# Offense count:
|
112
|
+
# Offense count: 2
|
66
113
|
Naming/AccessorMethodName:
|
67
114
|
Exclude:
|
68
|
-
- 'lib/crowdin-api/
|
115
|
+
- 'lib/crowdin-api/api_resources/users.rb'
|
116
|
+
- 'lib/crowdin-api/core/send_request.rb'
|
69
117
|
|
70
|
-
# Offense count:
|
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:
|
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:
|
88
|
-
#
|
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/
|
138
|
+
- 'lib/crowdin-api/core/send_request.rb'
|
93
139
|
|
94
140
|
# Offense count: 7
|
95
|
-
#
|
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:
|
104
|
-
#
|
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:
|
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
|
-
#
|
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
|
-
|
13
|
+
## Status
|
14
14
|
|
15
15
|
[](https://rubygems.org/gems/crowdin-api)
|
16
16
|
[](https://rubygems.org/gems/crowdin-api)
|
@@ -22,21 +22,25 @@ For more about Crowdin API v2 see the documentation:
|
|
22
22
|
[](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
|
-
* [
|
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.
|
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
|
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
|
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
|
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
|
-
|
125
|
-
# your_destination - filename or
|
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
|
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
|
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::
|
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')
|
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]
|
43
|
-
config.project_id = options[:project_id]
|
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
|