crowdin-api 1.1.1 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -0,0 +1,41 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe Crowdin::ApiResources::Workflows do
|
4
|
+
describe 'Enterprise endpoints' do
|
5
|
+
describe '#list_workflow_steps' do
|
6
|
+
it 'when request are valid', :enterprise do
|
7
|
+
stub_request(:get, "https://domain.api.crowdin.com/#{target_api_url}/projects/#{project_id}/workflow-steps")
|
8
|
+
list_workflow_steps = @crowdin.list_workflow_steps({}, project_id)
|
9
|
+
expect(list_workflow_steps).to eq(200)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#get_workflow_step' do
|
14
|
+
let(:step_id) { 1 }
|
15
|
+
|
16
|
+
it 'when request are valid', :enterprise do
|
17
|
+
stub_request(:get, "https://domain.api.crowdin.com/#{target_api_url}/projects/#{project_id}/workflow-steps/#{step_id}")
|
18
|
+
get_workflow_step = @crowdin.get_workflow_step(step_id, project_id)
|
19
|
+
expect(get_workflow_step).to eq(200)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#list_workflow_templates' do
|
24
|
+
it 'when request are valid', :enterprise do
|
25
|
+
stub_request(:get, "https://domain.api.crowdin.com/#{target_api_url}/workflow-templates")
|
26
|
+
list_workflow_templates = @crowdin.list_workflow_templates
|
27
|
+
expect(list_workflow_templates).to eq(200)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#get_workflow_template' do
|
32
|
+
let(:template_id) { 1 }
|
33
|
+
|
34
|
+
it 'when request are valid', :enterprise do
|
35
|
+
stub_request(:get, "https://domain.api.crowdin.com/#{target_api_url}/workflow-templates/#{template_id}")
|
36
|
+
get_workflow_template = @crowdin.get_workflow_template(template_id)
|
37
|
+
expect(get_workflow_template).to eq(200)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,9 +1,27 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'simplecov'
|
4
|
-
SimpleCov.start
|
5
|
-
|
6
4
|
require 'codecov'
|
5
|
+
|
6
|
+
SimpleCov.start
|
7
7
|
SimpleCov.formatter = SimpleCov::Formatter::Codecov
|
8
8
|
|
9
|
+
require 'webmock/rspec'
|
9
10
|
require 'crowdin-api'
|
11
|
+
|
12
|
+
RSpec.shared_context 'crowdin_client_options' do
|
13
|
+
let(:api_token) { 'api_token' }
|
14
|
+
let(:project_id) { 1 }
|
15
|
+
let(:organization_domain) { 'domain' }
|
16
|
+
let(:full_organization_domain) { 'domain.com' }
|
17
|
+
let(:target_api_url) { 'api/v2' }
|
18
|
+
end
|
19
|
+
|
20
|
+
RSpec.configure do |config|
|
21
|
+
config.include_context 'crowdin_client_options'
|
22
|
+
|
23
|
+
config.before(:each) do |spec|
|
24
|
+
@crowdin = Crowdin::Client.new { |cfg| cfg.organization_domain = 'domain' } if spec.metadata[:enterprise]
|
25
|
+
@crowdin = Crowdin::Client.new if spec.metadata[:default]
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
describe 'Crowdin Client' do
|
4
|
+
it 'should have a list of API Resources' do
|
5
|
+
expect(Crowdin::API_RESOURCES_MODULES).to_not be_nil
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'should have a list of Error Raisers' do
|
9
|
+
expect(Crowdin::ERROR_RAISERS_MODULES).to_not be_nil
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should have a version' do
|
13
|
+
expect(Crowdin::Client::VERSION).to_not be_nil
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'Crowdin Client with a default options' do
|
17
|
+
it 'should have a RestClient connection', :default do
|
18
|
+
expect(@crowdin.connection.class).to eq(RestClient::Resource)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should have options and headers for RestClient', :default do
|
22
|
+
expect(@crowdin.options.class).to eq(Hash)
|
23
|
+
expect(@crowdin.options).to include(:headers)
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should have a Config instance', :default do
|
27
|
+
expect(@crowdin.config.class).to eq(Crowdin::Configuration)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should have a disabled Logger by default', :default do
|
31
|
+
expect(@crowdin.logger_enabled?).to be_falsey
|
32
|
+
expect(@crowdin.logger).to be_nil
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should have a disabled Enterprise mode by default', :default do
|
36
|
+
expect(@crowdin.enterprise_mode?).to be_falsey
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should have a default target api url', :default do
|
40
|
+
expect(@crowdin.config.target_api_url).to eq('/api/v2')
|
41
|
+
end
|
42
|
+
it 'should have a default base url', :default do
|
43
|
+
expect(@crowdin.config.base_url).to eq('https://api.crowdin.com')
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe 'Crowdin Client with enabled Logger' do
|
48
|
+
before do
|
49
|
+
@crowdin = Crowdin::Client.new do |config|
|
50
|
+
config.enable_logger = true
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'should have a Logger instance' do
|
55
|
+
expect(@crowdin.logger_enabled?).to be_truthy
|
56
|
+
expect(@crowdin.logger.class).to eq(Logger)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe 'Crowdin Client with enabled Enterprise mode' do
|
61
|
+
before do
|
62
|
+
@crowdin = Crowdin::Client.new do |config|
|
63
|
+
config.organization_domain = organization_domain
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'should have a generated Enterprise url' do
|
68
|
+
expect(@crowdin.enterprise_mode?).to be_truthy
|
69
|
+
expect(@crowdin.config.base_url).to eq("https://#{organization_domain}.api.crowdin.com")
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe 'Crowdin Client with enabled Enterprise mode and specified full organization domain' do
|
74
|
+
before do
|
75
|
+
@crowdin = Crowdin::Client.new do |config|
|
76
|
+
config.organization_domain = full_organization_domain
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'should have a generated Enterprise url' do
|
81
|
+
expect(@crowdin.enterprise_mode?).to be_truthy
|
82
|
+
expect(@crowdin.config.base_url).to eq("https://#{full_organization_domain}")
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crowdin-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Crowdin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: open-uri
|
@@ -84,6 +84,20 @@ dependencies:
|
|
84
84
|
- - "~>"
|
85
85
|
- !ruby/object:Gem::Version
|
86
86
|
version: 0.6.0
|
87
|
+
- !ruby/object:Gem::Dependency
|
88
|
+
name: pry
|
89
|
+
requirement: !ruby/object:Gem::Requirement
|
90
|
+
requirements:
|
91
|
+
- - "~>"
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 0.14.1
|
94
|
+
type: :development
|
95
|
+
prerelease: false
|
96
|
+
version_requirements: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - "~>"
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: 0.14.1
|
87
101
|
- !ruby/object:Gem::Dependency
|
88
102
|
name: rake
|
89
103
|
requirement: !ruby/object:Gem::Requirement
|
@@ -132,20 +146,6 @@ dependencies:
|
|
132
146
|
- - "~>"
|
133
147
|
- !ruby/object:Gem::Version
|
134
148
|
version: '1.23'
|
135
|
-
- !ruby/object:Gem::Dependency
|
136
|
-
name: sinatra
|
137
|
-
requirement: !ruby/object:Gem::Requirement
|
138
|
-
requirements:
|
139
|
-
- - "~>"
|
140
|
-
- !ruby/object:Gem::Version
|
141
|
-
version: '2.1'
|
142
|
-
type: :development
|
143
|
-
prerelease: false
|
144
|
-
version_requirements: !ruby/object:Gem::Requirement
|
145
|
-
requirements:
|
146
|
-
- - "~>"
|
147
|
-
- !ruby/object:Gem::Version
|
148
|
-
version: '2.1'
|
149
149
|
- !ruby/object:Gem::Dependency
|
150
150
|
name: webmock
|
151
151
|
requirement: !ruby/object:Gem::Requirement
|
@@ -182,26 +182,63 @@ files:
|
|
182
182
|
- README.md
|
183
183
|
- Rakefile
|
184
184
|
- bin/crowdin-console
|
185
|
-
- bin/setup
|
186
185
|
- crowdin-api.gemspec
|
187
186
|
- lib/crowdin-api.rb
|
188
|
-
- lib/crowdin-api/
|
189
|
-
- lib/crowdin-api/
|
190
|
-
- lib/crowdin-api/
|
191
|
-
- lib/crowdin-api/
|
192
|
-
- lib/crowdin-api/
|
193
|
-
- lib/crowdin-api/
|
194
|
-
- lib/crowdin-api/
|
195
|
-
- lib/crowdin-api/
|
187
|
+
- lib/crowdin-api/api_resources/dictionaries.rb
|
188
|
+
- lib/crowdin-api/api_resources/distributions.rb
|
189
|
+
- lib/crowdin-api/api_resources/glossaries.rb
|
190
|
+
- lib/crowdin-api/api_resources/labels.rb
|
191
|
+
- lib/crowdin-api/api_resources/languages.rb
|
192
|
+
- lib/crowdin-api/api_resources/machine_translation_engines.rb
|
193
|
+
- lib/crowdin-api/api_resources/projects.rb
|
194
|
+
- lib/crowdin-api/api_resources/reports.rb
|
195
|
+
- lib/crowdin-api/api_resources/screenshots.rb
|
196
|
+
- lib/crowdin-api/api_resources/source_files.rb
|
197
|
+
- lib/crowdin-api/api_resources/source_strings.rb
|
198
|
+
- lib/crowdin-api/api_resources/storages.rb
|
199
|
+
- lib/crowdin-api/api_resources/string_comments.rb
|
200
|
+
- lib/crowdin-api/api_resources/string_translations.rb
|
201
|
+
- lib/crowdin-api/api_resources/tasks.rb
|
202
|
+
- lib/crowdin-api/api_resources/teams.rb
|
203
|
+
- lib/crowdin-api/api_resources/translation_memory.rb
|
204
|
+
- lib/crowdin-api/api_resources/translation_status.rb
|
205
|
+
- lib/crowdin-api/api_resources/translations.rb
|
206
|
+
- lib/crowdin-api/api_resources/users.rb
|
207
|
+
- lib/crowdin-api/api_resources/vendors.rb
|
208
|
+
- lib/crowdin-api/api_resources/webhooks.rb
|
209
|
+
- lib/crowdin-api/api_resources/workflows.rb
|
196
210
|
- lib/crowdin-api/client/client.rb
|
197
211
|
- lib/crowdin-api/client/configuration.rb
|
198
212
|
- lib/crowdin-api/client/version.rb
|
199
|
-
- lib/crowdin-api/core/api_errors_raiser.rb
|
200
213
|
- lib/crowdin-api/core/errors.rb
|
214
|
+
- lib/crowdin-api/core/errors_raisers.rb
|
201
215
|
- lib/crowdin-api/core/request.rb
|
202
|
-
-
|
203
|
-
- spec/
|
216
|
+
- lib/crowdin-api/core/send_request.rb
|
217
|
+
- spec/api_resources/dictionaries_spec.rb
|
218
|
+
- spec/api_resources/distributions_spec.rb
|
219
|
+
- spec/api_resources/glossaries_spec.rb
|
220
|
+
- spec/api_resources/labels_spec.rb
|
221
|
+
- spec/api_resources/languages_spec.rb
|
222
|
+
- spec/api_resources/machine_translation_engines_spec.rb
|
223
|
+
- spec/api_resources/projects_spec.rb
|
224
|
+
- spec/api_resources/reports_spec.rb
|
225
|
+
- spec/api_resources/screenshots_spec.rb
|
226
|
+
- spec/api_resources/source_files_spec.rb
|
227
|
+
- spec/api_resources/source_strings_spec.rb
|
228
|
+
- spec/api_resources/storages_spec.rb
|
229
|
+
- spec/api_resources/string_comments_spec.rb
|
230
|
+
- spec/api_resources/string_translations_spec.rb
|
231
|
+
- spec/api_resources/tasks_spec.rb
|
232
|
+
- spec/api_resources/teams_spec.rb
|
233
|
+
- spec/api_resources/translation_memory_spec.rb
|
234
|
+
- spec/api_resources/translation_status_spec.rb
|
235
|
+
- spec/api_resources/translations_spec.rb
|
236
|
+
- spec/api_resources/users_spec.rb
|
237
|
+
- spec/api_resources/vendors_spec.rb
|
238
|
+
- spec/api_resources/webhooks_spec.rb
|
239
|
+
- spec/api_resources/workflows_spec.rb
|
204
240
|
- spec/spec_helper.rb
|
241
|
+
- spec/unit/client_spec.rb
|
205
242
|
homepage: https://github.com/crowdin/crowdin-api-client-ruby
|
206
243
|
licenses:
|
207
244
|
- MIT
|
data/bin/setup
DELETED
@@ -1,81 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Crowdin
|
4
|
-
module ApiResources
|
5
|
-
module Languages
|
6
|
-
def list_languages(query = {})
|
7
|
-
request = Web::Request.new(
|
8
|
-
self,
|
9
|
-
:get,
|
10
|
-
'/languages',
|
11
|
-
query
|
12
|
-
)
|
13
|
-
|
14
|
-
request.perform
|
15
|
-
end
|
16
|
-
|
17
|
-
# Add custom language.
|
18
|
-
#
|
19
|
-
# === Parameters
|
20
|
-
#
|
21
|
-
# * +:name+ [String] - Language name
|
22
|
-
# * +:code+ [String] - Custom language code
|
23
|
-
# * +:localeCode+ [String] - Custom language locale code
|
24
|
-
# * +:textDirection+ [String ltr/rtl] - Text direction in custom language
|
25
|
-
# * +:pluralCategoryNames+ [String] - Array with category names
|
26
|
-
# * +:threeLettersCode+ [String] - Custom language 3 letters code. Format: ISO 6393 code
|
27
|
-
#
|
28
|
-
# === Example
|
29
|
-
#
|
30
|
-
# crowdin.add_custom_language(name: 'your_name', code: 'your_code' ..)
|
31
|
-
#
|
32
|
-
def add_custom_language(query = {})
|
33
|
-
request = Web::Request.new(
|
34
|
-
self,
|
35
|
-
:post,
|
36
|
-
'/languages',
|
37
|
-
query
|
38
|
-
)
|
39
|
-
|
40
|
-
request.perform
|
41
|
-
end
|
42
|
-
|
43
|
-
def get_language(language_id = nil)
|
44
|
-
language_id || raise_parameter_is_required_error(:language_id)
|
45
|
-
|
46
|
-
request = Web::Request.new(
|
47
|
-
self,
|
48
|
-
:get,
|
49
|
-
"/languages/#{language_id}"
|
50
|
-
)
|
51
|
-
|
52
|
-
request.perform
|
53
|
-
end
|
54
|
-
|
55
|
-
def delete_custom_language(language_id = nil)
|
56
|
-
language_id || raise_parameter_is_required_error(:language_id)
|
57
|
-
|
58
|
-
request = Web::Request.new(
|
59
|
-
self,
|
60
|
-
:delete,
|
61
|
-
"/languages/#{language_id}"
|
62
|
-
)
|
63
|
-
|
64
|
-
request.perform
|
65
|
-
end
|
66
|
-
|
67
|
-
def edit_custom_language(language_id = nil)
|
68
|
-
language_id || raise_parameter_is_required_error(:language_id)
|
69
|
-
|
70
|
-
request = Web::Request.new(
|
71
|
-
self,
|
72
|
-
:patch,
|
73
|
-
"/languages/#{language_id}",
|
74
|
-
query
|
75
|
-
)
|
76
|
-
|
77
|
-
request.perform
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
@@ -1,134 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Crowdin
|
4
|
-
module ApiResources
|
5
|
-
module Projects
|
6
|
-
def list_projects(query = {})
|
7
|
-
request = Web::Request.new(
|
8
|
-
self,
|
9
|
-
:get,
|
10
|
-
'/projects',
|
11
|
-
query
|
12
|
-
)
|
13
|
-
|
14
|
-
request.perform
|
15
|
-
end
|
16
|
-
|
17
|
-
def add_project(query = {})
|
18
|
-
request = Web::Request.new(
|
19
|
-
self,
|
20
|
-
:post,
|
21
|
-
'/projects',
|
22
|
-
query
|
23
|
-
)
|
24
|
-
|
25
|
-
request.perform
|
26
|
-
end
|
27
|
-
|
28
|
-
def get_project(project_id = nil)
|
29
|
-
project_id || raise_parameter_is_required_error(:project_id)
|
30
|
-
|
31
|
-
request = Web::Request.new(
|
32
|
-
self,
|
33
|
-
:get,
|
34
|
-
"/projects/#{project_id}"
|
35
|
-
)
|
36
|
-
|
37
|
-
request.perform
|
38
|
-
end
|
39
|
-
|
40
|
-
def delete_project(project_id = nil)
|
41
|
-
project_id || raise_parameter_is_required_error(:project_id)
|
42
|
-
|
43
|
-
request = Web::Request.new(
|
44
|
-
self,
|
45
|
-
:delete,
|
46
|
-
"/projects/#{project_id}"
|
47
|
-
)
|
48
|
-
|
49
|
-
request.perform
|
50
|
-
end
|
51
|
-
|
52
|
-
def edit_project(project_id = nil, query = {})
|
53
|
-
project_id || raise_parameter_is_required_error(:project_id)
|
54
|
-
|
55
|
-
request = Web::Request.new(
|
56
|
-
self,
|
57
|
-
:patch,
|
58
|
-
"/projects/#{project_id}",
|
59
|
-
query
|
60
|
-
)
|
61
|
-
|
62
|
-
request.perform
|
63
|
-
end
|
64
|
-
|
65
|
-
# For Enterprise mode only
|
66
|
-
|
67
|
-
def list_groups(query = {})
|
68
|
-
config.enterprise_mode? || raise_only_for_enterprise_mode_error
|
69
|
-
|
70
|
-
request = Web::Request.new(
|
71
|
-
self,
|
72
|
-
:get,
|
73
|
-
'/groups',
|
74
|
-
query
|
75
|
-
)
|
76
|
-
|
77
|
-
request.perform
|
78
|
-
end
|
79
|
-
|
80
|
-
def add_group(query = {})
|
81
|
-
config.enterprise_mode? || raise_only_for_enterprise_mode_error
|
82
|
-
|
83
|
-
request = Web::Request.new(
|
84
|
-
self,
|
85
|
-
:post,
|
86
|
-
'/groups',
|
87
|
-
query
|
88
|
-
)
|
89
|
-
|
90
|
-
request.perform
|
91
|
-
end
|
92
|
-
|
93
|
-
def get_group(group_id = nil)
|
94
|
-
config.enterprise_mode? || raise_only_for_enterprise_mode_error
|
95
|
-
group_id || raise_parameter_is_required_error(:group_id)
|
96
|
-
|
97
|
-
request = Web::Request.new(
|
98
|
-
self,
|
99
|
-
:get,
|
100
|
-
"/groups/#{group_id}"
|
101
|
-
)
|
102
|
-
|
103
|
-
request.perform
|
104
|
-
end
|
105
|
-
|
106
|
-
def delete_group(group_id = nil)
|
107
|
-
config.enterprise_mode? || raise_only_for_enterprise_mode_error
|
108
|
-
group_id || raise_parameter_is_required_error(:group_id)
|
109
|
-
|
110
|
-
request = Web::Request.new(
|
111
|
-
self,
|
112
|
-
:delete,
|
113
|
-
"/groups/#{group_id}"
|
114
|
-
)
|
115
|
-
|
116
|
-
request.perform
|
117
|
-
end
|
118
|
-
|
119
|
-
def edit_group(group_id = nil, query = {})
|
120
|
-
config.enterprise_mode? || raise_only_for_enterprise_mode_error
|
121
|
-
group_id || raise_parameter_is_required_error(:group_id)
|
122
|
-
|
123
|
-
request = Web::Request.new(
|
124
|
-
self,
|
125
|
-
:patch,
|
126
|
-
"/groups/#{group_id}",
|
127
|
-
query
|
128
|
-
)
|
129
|
-
|
130
|
-
request.perform
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|
134
|
-
end
|
@@ -1,102 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Crowdin
|
4
|
-
module ApiResources
|
5
|
-
module Storages
|
6
|
-
# Get storages list.
|
7
|
-
#
|
8
|
-
# === Parameters
|
9
|
-
#
|
10
|
-
# Optional:
|
11
|
-
# * +:limit+ [Integer 1..500] - A maximum number of items to retrieve, default - 25
|
12
|
-
# * +:offset+ [Integer >= 0] - A starting offset in the collection, default - 0
|
13
|
-
#
|
14
|
-
# === Example
|
15
|
-
#
|
16
|
-
# crowdin.list_projects(limit: your_value)
|
17
|
-
#
|
18
|
-
def list_storages(query = {})
|
19
|
-
request = Web::Request.new(
|
20
|
-
self,
|
21
|
-
:get,
|
22
|
-
'/storages',
|
23
|
-
query
|
24
|
-
)
|
25
|
-
|
26
|
-
request.perform
|
27
|
-
end
|
28
|
-
|
29
|
-
# Add storage.
|
30
|
-
#
|
31
|
-
# === Parameters
|
32
|
-
#
|
33
|
-
# * +File+ - File class object or path to file
|
34
|
-
#
|
35
|
-
# === Example
|
36
|
-
#
|
37
|
-
# crowdin.add_storage(File.open('your_filename.extension', 'r'))
|
38
|
-
# or
|
39
|
-
# crowdin.add_storage('your_filename.extension')
|
40
|
-
#
|
41
|
-
def add_storage(file = nil)
|
42
|
-
file || raise_parameter_is_required_error(:file)
|
43
|
-
|
44
|
-
file = file.is_a?(File) ? file : File.open(file, 'r')
|
45
|
-
|
46
|
-
request = Web::Request.new(
|
47
|
-
self,
|
48
|
-
:post,
|
49
|
-
'/storages',
|
50
|
-
file,
|
51
|
-
{ 'Content-Type' => 'application/octet-stream', 'Crowdin-API-FileName' => File.basename(file) }
|
52
|
-
)
|
53
|
-
|
54
|
-
request.perform
|
55
|
-
end
|
56
|
-
|
57
|
-
# Get storage information.
|
58
|
-
#
|
59
|
-
# === Parameters
|
60
|
-
#
|
61
|
-
# * +:storage_id+ [Integer] - Storage Identifier. Get via list_storages
|
62
|
-
#
|
63
|
-
# === Example
|
64
|
-
#
|
65
|
-
# crowdin.get_storage(your_storage_id)
|
66
|
-
#
|
67
|
-
def get_storage(storage_id = nil)
|
68
|
-
storage_id || raise_parameter_is_required_error(:storage_id)
|
69
|
-
|
70
|
-
request = Web::Request.new(
|
71
|
-
self,
|
72
|
-
:get,
|
73
|
-
"/storages/#{storage_id}"
|
74
|
-
)
|
75
|
-
|
76
|
-
request.perform
|
77
|
-
end
|
78
|
-
|
79
|
-
# Delete storage.
|
80
|
-
#
|
81
|
-
# === Parameters
|
82
|
-
#
|
83
|
-
# * +:storage_id+ [Integer] - Storage Identifier. Get via list_storages
|
84
|
-
#
|
85
|
-
# === Example
|
86
|
-
#
|
87
|
-
# crowdin.delete_storage(your_storage_id)
|
88
|
-
#
|
89
|
-
def delete_storage(storage_id = nil)
|
90
|
-
storage_id || raise_parameter_is_required_error(:storage_id)
|
91
|
-
|
92
|
-
request = Web::Request.new(
|
93
|
-
self,
|
94
|
-
:delete,
|
95
|
-
"/storages/#{storage_id}"
|
96
|
-
)
|
97
|
-
|
98
|
-
request.perform
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
@@ -1,59 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Crowdin
|
4
|
-
module ApiResources
|
5
|
-
module Workflows
|
6
|
-
def list_workflow_steps(query = {}, project_id = config.project_id)
|
7
|
-
config.enterprise_mode? || raise_only_for_enterprise_mode_error
|
8
|
-
project_id || raise_project_id_is_required_error
|
9
|
-
|
10
|
-
request = Web::Request.new(
|
11
|
-
self,
|
12
|
-
:get,
|
13
|
-
"/projects/#{project_id}/workflow-steps",
|
14
|
-
query
|
15
|
-
)
|
16
|
-
|
17
|
-
request.perform
|
18
|
-
end
|
19
|
-
|
20
|
-
def get_workflow_step(step_id = nil, project_id = config.project_id)
|
21
|
-
config.enterprise_mode? || raise_only_for_enterprise_mode_error
|
22
|
-
step_id || raise_parameter_is_required_error(:step_id)
|
23
|
-
project_id || raise_project_id_is_required_error
|
24
|
-
|
25
|
-
request = Web::Request.new(
|
26
|
-
self,
|
27
|
-
:get,
|
28
|
-
"/projects/#{project_id}/workflow-steps/#{step_id}"
|
29
|
-
)
|
30
|
-
|
31
|
-
request.perform
|
32
|
-
end
|
33
|
-
|
34
|
-
def list_workflow_templates(query = {})
|
35
|
-
request = Web::Request.new(
|
36
|
-
self,
|
37
|
-
:get,
|
38
|
-
'/workflow-templates',
|
39
|
-
query
|
40
|
-
)
|
41
|
-
|
42
|
-
request.perform
|
43
|
-
end
|
44
|
-
|
45
|
-
def get_workflow_template(template_id = nil)
|
46
|
-
config.enterprise_mode? || raise_only_for_enterprise_mode_error
|
47
|
-
template_id || raise_parameter_is_required_error(:template_id)
|
48
|
-
|
49
|
-
request = Web::Request.new(
|
50
|
-
self,
|
51
|
-
:get,
|
52
|
-
"/workflow-templates/#{template_id}"
|
53
|
-
)
|
54
|
-
|
55
|
-
request.perform
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|