crowdin-api 1.2.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +102 -43
- data/README.md +37 -6
- data/bin/crowdin-console +1 -1
- data/crowdin-api.gemspec +1 -2
- data/lib/crowdin-api/api_resources/bundles.rb +81 -0
- data/lib/crowdin-api/{api-resources → api_resources}/dictionaries.rb +8 -10
- data/lib/crowdin-api/{api-resources → api_resources}/distributions.rb +25 -32
- data/lib/crowdin-api/{api-resources → api_resources}/glossaries.rb +64 -82
- data/lib/crowdin-api/{api-resources → api_resources}/labels.rb +28 -47
- 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 → api_resources}/screenshots.rb +47 -61
- data/lib/crowdin-api/{api-resources → api_resources}/source_files.rb +68 -131
- 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 → api_resources}/string_comments.rb +18 -23
- data/lib/crowdin-api/{api-resources → api_resources}/string_translations.rb +64 -91
- data/lib/crowdin-api/{api-resources → api_resources}/tasks.rb +30 -41
- data/lib/crowdin-api/api_resources/teams.rb +135 -0
- data/lib/crowdin-api/{api-resources → api_resources}/translation_memory.rb +38 -52
- data/lib/crowdin-api/{api-resources → api_resources}/translation_status.rb +24 -30
- data/lib/crowdin-api/{api-resources → api_resources}/translations.rb +41 -58
- 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 → api_resources}/webhooks.rb +19 -24
- data/lib/crowdin-api/api_resources/workflows.rb +59 -0
- data/lib/crowdin-api/client/client.rb +134 -39
- data/lib/crowdin-api/client/configuration.rb +12 -12
- data/lib/crowdin-api/client/version.rb +1 -1
- data/lib/crowdin-api/core/errors.rb +1 -0
- data/lib/crowdin-api/core/errors_raisers.rb +1 -1
- data/lib/crowdin-api/core/fetch_all_extensions.rb +14 -0
- data/lib/crowdin-api/core/request.rb +50 -90
- data/lib/crowdin-api/core/send_request.rb +67 -0
- data/lib/crowdin-api.rb +18 -24
- data/spec/api_resources/bundles_spec.rb +61 -0
- 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 +184 -0
- data/spec/api_resources/source_strings_spec.rb +51 -0
- data/spec/api_resources/storages_spec.rb +41 -0
- data/spec/api_resources/string_comments_spec.rb +51 -0
- data/spec/api_resources/string_translations_spec.rb +141 -0
- data/spec/api_resources/tasks_spec.rb +79 -0
- data/spec/api_resources/teams_spec.rb +100 -0
- data/spec/api_resources/translation_memory_spec.rb +114 -0
- data/spec/api_resources/translation_status_spec.rb +61 -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 +23 -2
- data/spec/unit/client_spec.rb +85 -0
- metadata +67 -43
- data/bin/setup +0 -6
- data/lib/crowdin-api/api-resources/languages.rb +0 -82
- data/lib/crowdin-api/api-resources/machine_translation_engines.rb +0 -74
- data/lib/crowdin-api/api-resources/projects.rb +0 -148
- data/lib/crowdin-api/api-resources/reports.rb +0 -138
- data/lib/crowdin-api/api-resources/storages.rb +0 -106
- data/lib/crowdin-api/api-resources/teams.rb +0 -144
- data/lib/crowdin-api/api-resources/users.rb +0 -129
- data/lib/crowdin-api/api-resources/vendors.rb +0 -21
- data/lib/crowdin-api/api-resources/workflows.rb +0 -62
- data/lib/crowdin-api/core/utils.rb +0 -10
- data/spec/client/client-instance_spec.rb +0 -14
- data/spec/client/configuration-instance_spec.rb +0 -72
@@ -1,129 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Crowdin
|
4
|
-
module ApiResources
|
5
|
-
module Users
|
6
|
-
def get_authenticated_user
|
7
|
-
request = Web::Request.new(
|
8
|
-
self,
|
9
|
-
:get,
|
10
|
-
'/user'
|
11
|
-
)
|
12
|
-
|
13
|
-
request.perform
|
14
|
-
end
|
15
|
-
|
16
|
-
def list_project_members(query = {}, project_id = config.project_id)
|
17
|
-
project_id || raise_project_id_is_required_error
|
18
|
-
|
19
|
-
request = Web::Request.new(
|
20
|
-
self,
|
21
|
-
:get,
|
22
|
-
"/projects/#{project_id}/members",
|
23
|
-
query
|
24
|
-
)
|
25
|
-
|
26
|
-
request.perform
|
27
|
-
end
|
28
|
-
|
29
|
-
def get_member_info(member_id = nil, project_id = config.project_id)
|
30
|
-
member_id || raise_parameter_is_required_error(:member_id)
|
31
|
-
project_id || raise_project_id_is_required_error
|
32
|
-
|
33
|
-
request = Web::Request.new(
|
34
|
-
self,
|
35
|
-
:get,
|
36
|
-
"/projects/#{project_id}/members/#{member_id}"
|
37
|
-
)
|
38
|
-
|
39
|
-
request.perform
|
40
|
-
end
|
41
|
-
|
42
|
-
# -- For Enterprise mode only --
|
43
|
-
|
44
|
-
def add_project_member(query = {}, project_id = config.project_id)
|
45
|
-
config.enterprise_mode? || raise_only_for_enterprise_mode_error
|
46
|
-
project_id || raise_project_id_is_required_error
|
47
|
-
|
48
|
-
request = Web::Request.new(
|
49
|
-
self,
|
50
|
-
:post,
|
51
|
-
"/projects/#{project_id}/members",
|
52
|
-
query
|
53
|
-
)
|
54
|
-
|
55
|
-
request.perform
|
56
|
-
end
|
57
|
-
|
58
|
-
def get_project_member_permissions(member_id = nil, project_id = config.project_id)
|
59
|
-
config.enterprise_mode? || raise_only_for_enterprise_mode_error
|
60
|
-
member_id || raise_parameter_is_required_error(:member_id)
|
61
|
-
project_id || raise_project_id_is_required_error
|
62
|
-
|
63
|
-
request = Web::Request.new(
|
64
|
-
self,
|
65
|
-
:get,
|
66
|
-
"/projects/#{project_id}/members/#{member_id}"
|
67
|
-
)
|
68
|
-
|
69
|
-
request.perform
|
70
|
-
end
|
71
|
-
|
72
|
-
def replace_project_permissions(member_id = nil, query = {}, project_id = config.project_id)
|
73
|
-
config.enterprise_mode? || raise_only_for_enterprise_mode_error
|
74
|
-
member_id || raise_parameter_is_required_error(:member_id)
|
75
|
-
project_id || raise_project_id_is_required_error
|
76
|
-
|
77
|
-
request = Web::Request.new(
|
78
|
-
self,
|
79
|
-
:put,
|
80
|
-
"/projects/#{project_id}/members/#{member_id}",
|
81
|
-
query
|
82
|
-
)
|
83
|
-
|
84
|
-
request.perform
|
85
|
-
end
|
86
|
-
|
87
|
-
def delete_member_from_project(member_id = nil, query = {}, project_id = config.project_id)
|
88
|
-
config.enterprise_mode? || raise_only_for_enterprise_mode_error
|
89
|
-
member_id || raise_parameter_is_required_error(:member_id)
|
90
|
-
project_id || raise_project_id_is_required_error
|
91
|
-
|
92
|
-
request = Web::Request.new(
|
93
|
-
self,
|
94
|
-
:delete,
|
95
|
-
"/projects/#{project_id}/members/#{member_id}",
|
96
|
-
query
|
97
|
-
)
|
98
|
-
|
99
|
-
request.perform
|
100
|
-
end
|
101
|
-
|
102
|
-
def list_users(query = {})
|
103
|
-
config.enterprise_mode? || raise_only_for_enterprise_mode_error
|
104
|
-
|
105
|
-
request = Web::Request.new(
|
106
|
-
self,
|
107
|
-
:get,
|
108
|
-
'/users',
|
109
|
-
query
|
110
|
-
)
|
111
|
-
|
112
|
-
request.perform
|
113
|
-
end
|
114
|
-
|
115
|
-
def get_user(user_id = nil)
|
116
|
-
config.enterprise_mode? || raise_only_for_enterprise_mode_error
|
117
|
-
user_id || raise_parameter_is_required_error(:user_id)
|
118
|
-
|
119
|
-
request = Web::Request.new(
|
120
|
-
self,
|
121
|
-
:get,
|
122
|
-
"/users/#{user_id}"
|
123
|
-
)
|
124
|
-
|
125
|
-
request.perform
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Crowdin
|
4
|
-
module ApiResources
|
5
|
-
# -- For Enterprise mode only --
|
6
|
-
module Vendors
|
7
|
-
def list_vendors(query = {})
|
8
|
-
config.enterprise_mode? || raise_only_for_enterprise_mode_error
|
9
|
-
|
10
|
-
request = Web::Request.new(
|
11
|
-
self,
|
12
|
-
:get,
|
13
|
-
'/vendors',
|
14
|
-
query
|
15
|
-
)
|
16
|
-
|
17
|
-
request.perform
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Crowdin
|
4
|
-
module ApiResources
|
5
|
-
# -- For Enterprise mode only --
|
6
|
-
module Workflows
|
7
|
-
def list_workflow_steps(query = {}, project_id = config.project_id)
|
8
|
-
config.enterprise_mode? || raise_only_for_enterprise_mode_error
|
9
|
-
project_id || raise_project_id_is_required_error
|
10
|
-
|
11
|
-
request = Web::Request.new(
|
12
|
-
self,
|
13
|
-
:get,
|
14
|
-
"/projects/#{project_id}/workflow-steps",
|
15
|
-
query
|
16
|
-
)
|
17
|
-
|
18
|
-
request.perform
|
19
|
-
end
|
20
|
-
|
21
|
-
def get_workflow_step(step_id = nil, project_id = config.project_id)
|
22
|
-
config.enterprise_mode? || raise_only_for_enterprise_mode_error
|
23
|
-
step_id || raise_parameter_is_required_error(:step_id)
|
24
|
-
project_id || raise_project_id_is_required_error
|
25
|
-
|
26
|
-
request = Web::Request.new(
|
27
|
-
self,
|
28
|
-
:get,
|
29
|
-
"/projects/#{project_id}/workflow-steps/#{step_id}"
|
30
|
-
)
|
31
|
-
|
32
|
-
request.perform
|
33
|
-
end
|
34
|
-
|
35
|
-
def list_workflow_templates(query = {})
|
36
|
-
config.enterprise_mode? || raise_only_for_enterprise_mode_error
|
37
|
-
|
38
|
-
request = Web::Request.new(
|
39
|
-
self,
|
40
|
-
:get,
|
41
|
-
'/workflow-templates',
|
42
|
-
query
|
43
|
-
)
|
44
|
-
|
45
|
-
request.perform
|
46
|
-
end
|
47
|
-
|
48
|
-
def get_workflow_template(template_id = nil)
|
49
|
-
config.enterprise_mode? || raise_only_for_enterprise_mode_error
|
50
|
-
template_id || raise_parameter_is_required_error(:template_id)
|
51
|
-
|
52
|
-
request = Web::Request.new(
|
53
|
-
self,
|
54
|
-
:get,
|
55
|
-
"/workflow-templates/#{template_id}"
|
56
|
-
)
|
57
|
-
|
58
|
-
request.perform
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe 'Config instance' do
|
4
|
-
before do
|
5
|
-
@crowdin = Crowdin::Client.new do |config|
|
6
|
-
config.api_token = 'api_token'
|
7
|
-
config.project_id = 1
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'should have a version' do
|
12
|
-
expect(Crowdin::Client::VERSION).to_not be_nil
|
13
|
-
end
|
14
|
-
end
|
@@ -1,72 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
describe 'Config instance' do
|
4
|
-
before do
|
5
|
-
@crowdin = Crowdin::Client.new do |config|
|
6
|
-
config.api_token = 'api_token'
|
7
|
-
config.project_id = 1
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'should have a #project_id' do
|
12
|
-
expect(@crowdin.config.project_id).to_not be_nil
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'should have a #api_token' do
|
16
|
-
expect(@crowdin.config.api_token).to_not be_nil
|
17
|
-
end
|
18
|
-
|
19
|
-
it '#target_api_url should equal \'api/v2\' by default' do
|
20
|
-
expect(@crowdin.config.target_api_url).to eq('/api/v2')
|
21
|
-
end
|
22
|
-
|
23
|
-
describe '#logger_enabled?' do
|
24
|
-
it 'should equal false by default' do
|
25
|
-
expect(@crowdin.config.logger_enabled?).to be_falsey
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'should equal specified argument' do
|
29
|
-
@crowdin = Crowdin::Client.new do |config|
|
30
|
-
config.enable_logger = true
|
31
|
-
end
|
32
|
-
|
33
|
-
expect(@crowdin.config.logger_enabled?).to be_truthy
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
describe '#enterprise_mode?' do
|
38
|
-
it 'should equal false by default' do
|
39
|
-
expect(@crowdin.config.enterprise_mode?).to be_falsey
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'should equal true if user specify organization domain' do
|
43
|
-
@crowdin = Crowdin::Client.new do |config|
|
44
|
-
config.organization_domain = 'organization_domain'
|
45
|
-
end
|
46
|
-
|
47
|
-
expect(@crowdin.config.enterprise_mode?).to be_truthy
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
describe '#base_url' do
|
52
|
-
it 'should equal \'https://api.crowdin.com\' by default' do
|
53
|
-
expect(@crowdin.config.base_url).to eq('https://api.crowdin.com')
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'should equal specified organization domain' do
|
57
|
-
@crowdin = Crowdin::Client.new do |config|
|
58
|
-
config.organization_domain = 'organization_domain'
|
59
|
-
end
|
60
|
-
|
61
|
-
expect(@crowdin.config.base_url).to eq('https://organization_domain.api.crowdin.com')
|
62
|
-
end
|
63
|
-
|
64
|
-
it 'should equal full specified organization domain when user specify full url (with \'.com\')' do
|
65
|
-
@crowdin = Crowdin::Client.new do |config|
|
66
|
-
config.organization_domain = 'organization_domain.com'
|
67
|
-
end
|
68
|
-
|
69
|
-
expect(@crowdin.config.base_url).to eq('organization_domain.com')
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|