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
@@ -8,13 +8,12 @@ module Crowdin
|
|
8
8
|
project_id || raise_project_id_is_required_error
|
9
9
|
|
10
10
|
request = Web::Request.new(
|
11
|
-
|
11
|
+
connection,
|
12
12
|
:get,
|
13
|
-
"/projects/#{project_id}/branches/#{branch_id}/languages/progress",
|
14
|
-
query
|
13
|
+
"#{config.target_api_url}/projects/#{project_id}/branches/#{branch_id}/languages/progress",
|
14
|
+
{ params: query }
|
15
15
|
)
|
16
|
-
|
17
|
-
request.perform
|
16
|
+
Web::SendRequest.new(request).perform
|
18
17
|
end
|
19
18
|
|
20
19
|
def get_directory_progress(directory_id = nil, query = {}, project_id = config.project_id)
|
@@ -22,13 +21,12 @@ module Crowdin
|
|
22
21
|
project_id || raise_project_id_is_required_error
|
23
22
|
|
24
23
|
request = Web::Request.new(
|
25
|
-
|
24
|
+
connection,
|
26
25
|
:get,
|
27
|
-
"/projects/#{project_id}/directories/#{directory_id}/languages/progress",
|
28
|
-
query
|
26
|
+
"#{config.target_api_url}/projects/#{project_id}/directories/#{directory_id}/languages/progress",
|
27
|
+
{ params: query }
|
29
28
|
)
|
30
|
-
|
31
|
-
request.perform
|
29
|
+
Web::SendRequest.new(request).perform
|
32
30
|
end
|
33
31
|
|
34
32
|
def get_file_progress(file_id = nil, query = {}, project_id = config.project_id)
|
@@ -36,13 +34,12 @@ module Crowdin
|
|
36
34
|
project_id || raise_project_id_is_required_error
|
37
35
|
|
38
36
|
request = Web::Request.new(
|
39
|
-
|
37
|
+
connection,
|
40
38
|
:get,
|
41
|
-
"/projects/#{project_id}/files/#{file_id}/languages/progress",
|
42
|
-
query
|
39
|
+
"#{config.target_api_url}/projects/#{project_id}/files/#{file_id}/languages/progress",
|
40
|
+
{ params: query }
|
43
41
|
)
|
44
|
-
|
45
|
-
request.perform
|
42
|
+
Web::SendRequest.new(request).perform
|
46
43
|
end
|
47
44
|
|
48
45
|
def get_language_progress(language_id = nil, query = {}, project_id = config.project_id)
|
@@ -50,39 +47,36 @@ module Crowdin
|
|
50
47
|
project_id || raise_project_id_is_required_error
|
51
48
|
|
52
49
|
request = Web::Request.new(
|
53
|
-
|
50
|
+
connection,
|
54
51
|
:get,
|
55
|
-
"/projects/#{project_id}/languages/#{language_id}/progress",
|
56
|
-
query
|
52
|
+
"#{config.target_api_url}/projects/#{project_id}/languages/#{language_id}/progress",
|
53
|
+
{ params: query }
|
57
54
|
)
|
58
|
-
|
59
|
-
request.perform
|
55
|
+
Web::SendRequest.new(request).perform
|
60
56
|
end
|
61
57
|
|
62
58
|
def get_project_progress(query = {}, project_id = config.project_id)
|
63
59
|
project_id || raise_project_id_is_required_error
|
64
60
|
|
65
61
|
request = Web::Request.new(
|
66
|
-
|
62
|
+
connection,
|
67
63
|
:get,
|
68
|
-
"/projects/#{project_id}/languages/progress",
|
69
|
-
query
|
64
|
+
"#{config.target_api_url}/projects/#{project_id}/languages/progress",
|
65
|
+
{ params: query }
|
70
66
|
)
|
71
|
-
|
72
|
-
request.perform
|
67
|
+
Web::SendRequest.new(request).perform
|
73
68
|
end
|
74
69
|
|
75
70
|
def get_qa_progress(query = {}, project_id = config.project_id)
|
76
71
|
project_id || raise_project_id_is_required_error
|
77
72
|
|
78
73
|
request = Web::Request.new(
|
79
|
-
|
74
|
+
connection,
|
80
75
|
:get,
|
81
|
-
"/projects/#{project_id}/qa-checks",
|
82
|
-
query
|
76
|
+
"#{config.target_api_url}/projects/#{project_id}/qa-checks",
|
77
|
+
{ params: query }
|
83
78
|
)
|
84
|
-
|
85
|
-
request.perform
|
79
|
+
Web::SendRequest.new(request).perform
|
86
80
|
end
|
87
81
|
end
|
88
82
|
end
|
@@ -8,25 +8,23 @@ module Crowdin
|
|
8
8
|
project_id || raise_project_id_is_required_error
|
9
9
|
|
10
10
|
request = Web::Request.new(
|
11
|
-
|
11
|
+
connection,
|
12
12
|
:get,
|
13
|
-
"/projects/#{project_id}/pre-translations/#{pre_translation_id}"
|
13
|
+
"#{config.target_api_url}/projects/#{project_id}/pre-translations/#{pre_translation_id}"
|
14
14
|
)
|
15
|
-
|
16
|
-
request.perform
|
15
|
+
Web::SendRequest.new(request).perform
|
17
16
|
end
|
18
17
|
|
19
18
|
def apply_pre_translation(query = {}, project_id = config.project_id)
|
20
19
|
project_id || raise_project_id_is_required_error
|
21
20
|
|
22
21
|
request = Web::Request.new(
|
23
|
-
|
22
|
+
connection,
|
24
23
|
:post,
|
25
|
-
"/projects/#{project_id}/pre-translations",
|
26
|
-
query
|
24
|
+
"#{config.target_api_url}/projects/#{project_id}/pre-translations",
|
25
|
+
{ params: query }
|
27
26
|
)
|
28
|
-
|
29
|
-
request.perform
|
27
|
+
Web::SendRequest.new(request).perform
|
30
28
|
end
|
31
29
|
|
32
30
|
def build_project_directory_translation(directory_id = nil, query = {}, project_id = config.project_id)
|
@@ -34,56 +32,51 @@ module Crowdin
|
|
34
32
|
project_id || raise_project_id_is_required_error
|
35
33
|
|
36
34
|
request = Web::Request.new(
|
37
|
-
|
35
|
+
connection,
|
38
36
|
:post,
|
39
|
-
"/projects/#{project_id}/translations/builds/directories/#{directory_id}",
|
40
|
-
query
|
37
|
+
"#{config.target_api_url}/projects/#{project_id}/translations/builds/directories/#{directory_id}",
|
38
|
+
{ params: query }
|
41
39
|
)
|
42
|
-
|
43
|
-
request.perform
|
40
|
+
Web::SendRequest.new(request).perform
|
44
41
|
end
|
45
42
|
|
46
|
-
def build_project_file_translation(file_id = nil, query = {}, project_id = config.project_id)
|
43
|
+
def build_project_file_translation(file_id = nil, query = {}, destination = nil, project_id = config.project_id)
|
47
44
|
file_id || raise_parameter_is_required_error(:file_id)
|
48
45
|
project_id || raise_project_id_is_required_error
|
49
46
|
|
50
47
|
headers = query[:eTag] ? { 'If-None-Match' => query[:eTag] } : {}
|
51
48
|
|
52
49
|
request = Web::Request.new(
|
53
|
-
|
50
|
+
connection,
|
54
51
|
:post,
|
55
|
-
"/projects/#{project_id}/translations/builds/files/#{file_id}",
|
56
|
-
query,
|
57
|
-
headers
|
52
|
+
"#{config.target_api_url}/projects/#{project_id}/translations/builds/files/#{file_id}",
|
53
|
+
{ params: query, headers: headers }
|
58
54
|
)
|
59
|
-
|
60
|
-
request.perform
|
55
|
+
Web::SendRequest.new(request, destination).perform
|
61
56
|
end
|
62
57
|
|
63
58
|
def list_project_builds(query = {}, project_id = config.project_id)
|
64
59
|
project_id || raise_project_id_is_required_error
|
65
60
|
|
66
61
|
request = Web::Request.new(
|
67
|
-
|
62
|
+
connection,
|
68
63
|
:get,
|
69
|
-
"/projects/#{project_id}/translations/builds",
|
70
|
-
query
|
64
|
+
"#{config.target_api_url}/projects/#{project_id}/translations/builds",
|
65
|
+
{ params: query }
|
71
66
|
)
|
72
|
-
|
73
|
-
request.perform
|
67
|
+
Web::SendRequest.new(request).perform
|
74
68
|
end
|
75
69
|
|
76
70
|
def build_project_translation(query = {}, project_id = config.project_id)
|
77
71
|
project_id || raise_project_id_is_required_error
|
78
72
|
|
79
73
|
request = Web::Request.new(
|
80
|
-
|
74
|
+
connection,
|
81
75
|
:post,
|
82
|
-
"/projects/#{project_id}/translations/builds",
|
83
|
-
query
|
76
|
+
"#{config.target_api_url}/projects/#{project_id}/translations/builds",
|
77
|
+
{ params: query }
|
84
78
|
)
|
85
|
-
|
86
|
-
request.perform
|
79
|
+
Web::SendRequest.new(request).perform
|
87
80
|
end
|
88
81
|
|
89
82
|
def upload_translations(language_id = nil, query = {}, project_id = config.project_id)
|
@@ -91,30 +84,24 @@ module Crowdin
|
|
91
84
|
project_id || raise_project_id_is_required_error
|
92
85
|
|
93
86
|
request = Web::Request.new(
|
94
|
-
|
87
|
+
connection,
|
95
88
|
:post,
|
96
|
-
"/projects/#{project_id}/translations/#{language_id}",
|
97
|
-
query
|
89
|
+
"#{config.target_api_url}/projects/#{project_id}/translations/#{language_id}",
|
90
|
+
{ params: query }
|
98
91
|
)
|
99
|
-
|
100
|
-
request.perform
|
92
|
+
Web::SendRequest.new(request).perform
|
101
93
|
end
|
102
94
|
|
103
95
|
def download_project_translations(build_id = nil, destination = nil, project_id = config.project_id)
|
104
|
-
destination || raise_parameter_is_required_error(:destination)
|
105
96
|
build_id || raise_parameter_is_required_error(:build_id)
|
106
97
|
project_id || raise_project_id_is_required_error
|
107
98
|
|
108
99
|
request = Web::Request.new(
|
109
|
-
|
100
|
+
connection,
|
110
101
|
:get,
|
111
|
-
"/projects/#{project_id}/translations/builds/#{build_id}/download"
|
112
|
-
{},
|
113
|
-
{},
|
114
|
-
destination
|
102
|
+
"#{config.target_api_url}/projects/#{project_id}/translations/builds/#{build_id}/download"
|
115
103
|
)
|
116
|
-
|
117
|
-
request.perform
|
104
|
+
Web::SendRequest.new(request, destination).perform
|
118
105
|
end
|
119
106
|
|
120
107
|
def check_project_build_status(build_id = nil, project_id = config.project_id)
|
@@ -122,12 +109,11 @@ module Crowdin
|
|
122
109
|
project_id || raise_project_id_is_required_error
|
123
110
|
|
124
111
|
request = Web::Request.new(
|
125
|
-
|
112
|
+
connection,
|
126
113
|
:get,
|
127
|
-
"/projects/#{project_id}/translations/builds/#{build_id}"
|
114
|
+
"#{config.target_api_url}/projects/#{project_id}/translations/builds/#{build_id}"
|
128
115
|
)
|
129
|
-
|
130
|
-
request.perform
|
116
|
+
Web::SendRequest.new(request).perform
|
131
117
|
end
|
132
118
|
|
133
119
|
def cancel_build(build_id = nil, project_id = config.project_id)
|
@@ -135,27 +121,23 @@ module Crowdin
|
|
135
121
|
project_id || raise_project_id_is_required_error
|
136
122
|
|
137
123
|
request = Web::Request.new(
|
138
|
-
|
124
|
+
connection,
|
139
125
|
:delete,
|
140
|
-
"/projects/#{project_id}/translations/builds/#{build_id}"
|
126
|
+
"#{config.target_api_url}/projects/#{project_id}/translations/builds/#{build_id}"
|
141
127
|
)
|
142
|
-
|
143
|
-
request.perform
|
128
|
+
Web::SendRequest.new(request).perform
|
144
129
|
end
|
145
130
|
|
146
131
|
def export_project_translation(query = {}, destination = nil, project_id = config.project_id)
|
147
132
|
project_id || raise_project_id_is_required_error
|
148
133
|
|
149
134
|
request = Web::Request.new(
|
150
|
-
|
135
|
+
connection,
|
151
136
|
:post,
|
152
|
-
"/projects/#{project_id}/translations/exports",
|
153
|
-
query
|
154
|
-
{},
|
155
|
-
destination
|
137
|
+
"#{config.target_api_url}/projects/#{project_id}/translations/exports",
|
138
|
+
{ params: query }
|
156
139
|
)
|
157
|
-
|
158
|
-
request.perform
|
140
|
+
Web::SendRequest.new(request, destination).perform
|
159
141
|
end
|
160
142
|
end
|
161
143
|
end
|
@@ -0,0 +1,161 @@
|
|
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
|
+
connection,
|
9
|
+
:get,
|
10
|
+
"#{config.target_api_url}/user"
|
11
|
+
)
|
12
|
+
Web::SendRequest.new(request).perform
|
13
|
+
end
|
14
|
+
|
15
|
+
def list_project_members(query = {}, project_id = config.project_id)
|
16
|
+
project_id || raise_project_id_is_required_error
|
17
|
+
|
18
|
+
request = Web::Request.new(
|
19
|
+
connection,
|
20
|
+
:get,
|
21
|
+
"#{config.target_api_url}/projects/#{project_id}/members",
|
22
|
+
{ params: query }
|
23
|
+
)
|
24
|
+
Web::SendRequest.new(request).perform
|
25
|
+
end
|
26
|
+
|
27
|
+
def get_member_info(member_id = nil, project_id = config.project_id)
|
28
|
+
member_id || raise_parameter_is_required_error(:member_id)
|
29
|
+
project_id || raise_project_id_is_required_error
|
30
|
+
|
31
|
+
request = Web::Request.new(
|
32
|
+
connection,
|
33
|
+
:get,
|
34
|
+
"#{config.target_api_url}/projects/#{project_id}/members/#{member_id}"
|
35
|
+
)
|
36
|
+
Web::SendRequest.new(request).perform
|
37
|
+
end
|
38
|
+
|
39
|
+
# -- For Enterprise mode only --
|
40
|
+
|
41
|
+
def add_project_member(query = {}, project_id = config.project_id)
|
42
|
+
enterprise_mode? || raise_only_for_enterprise_mode_error
|
43
|
+
project_id || raise_project_id_is_required_error
|
44
|
+
|
45
|
+
request = Web::Request.new(
|
46
|
+
connection,
|
47
|
+
:post,
|
48
|
+
"#{config.target_api_url}/projects/#{project_id}/members",
|
49
|
+
{ params: query }
|
50
|
+
)
|
51
|
+
Web::SendRequest.new(request).perform
|
52
|
+
end
|
53
|
+
|
54
|
+
def get_project_member_permissions(member_id = nil, project_id = config.project_id)
|
55
|
+
enterprise_mode? || raise_only_for_enterprise_mode_error
|
56
|
+
member_id || raise_parameter_is_required_error(:member_id)
|
57
|
+
project_id || raise_project_id_is_required_error
|
58
|
+
|
59
|
+
request = Web::Request.new(
|
60
|
+
connection,
|
61
|
+
:get,
|
62
|
+
"#{config.target_api_url}/projects/#{project_id}/members/#{member_id}"
|
63
|
+
)
|
64
|
+
Web::SendRequest.new(request).perform
|
65
|
+
end
|
66
|
+
|
67
|
+
def replace_project_permissions(member_id = nil, query = {}, project_id = config.project_id)
|
68
|
+
enterprise_mode? || raise_only_for_enterprise_mode_error
|
69
|
+
member_id || raise_parameter_is_required_error(:member_id)
|
70
|
+
project_id || raise_project_id_is_required_error
|
71
|
+
|
72
|
+
request = Web::Request.new(
|
73
|
+
connection,
|
74
|
+
:put,
|
75
|
+
"#{config.target_api_url}/projects/#{project_id}/members/#{member_id}",
|
76
|
+
{ params: query }
|
77
|
+
)
|
78
|
+
Web::SendRequest.new(request).perform
|
79
|
+
end
|
80
|
+
|
81
|
+
def delete_member_from_project(member_id = nil, query = {}, project_id = config.project_id)
|
82
|
+
enterprise_mode? || raise_only_for_enterprise_mode_error
|
83
|
+
member_id || raise_parameter_is_required_error(:member_id)
|
84
|
+
project_id || raise_project_id_is_required_error
|
85
|
+
|
86
|
+
response = ::RestClient::Request.execute(
|
87
|
+
{
|
88
|
+
method: :delete,
|
89
|
+
url: config.base_url + config.target_api_url + "/projects/#{project_id}/members/#{member_id}",
|
90
|
+
payload: query.to_json
|
91
|
+
}.merge(@options)
|
92
|
+
)
|
93
|
+
|
94
|
+
response.body.empty? ? response.code : JSON.parse(response.body)
|
95
|
+
rescue StandardError => e
|
96
|
+
e.message
|
97
|
+
end
|
98
|
+
|
99
|
+
def list_users(query = {})
|
100
|
+
enterprise_mode? || raise_only_for_enterprise_mode_error
|
101
|
+
|
102
|
+
request = Web::Request.new(
|
103
|
+
connection,
|
104
|
+
:get,
|
105
|
+
"#{config.target_api_url}/users",
|
106
|
+
{ params: query }
|
107
|
+
)
|
108
|
+
Web::SendRequest.new(request).perform
|
109
|
+
end
|
110
|
+
|
111
|
+
def invite_user(query = {})
|
112
|
+
enterprise_mode? || raise_only_for_enterprise_mode_error
|
113
|
+
|
114
|
+
request = Web::Request.new(
|
115
|
+
connection,
|
116
|
+
:post,
|
117
|
+
"#{config.target_api_url}/users",
|
118
|
+
{ params: query }
|
119
|
+
)
|
120
|
+
Web::SendRequest.new(request).perform
|
121
|
+
end
|
122
|
+
|
123
|
+
def get_user(user_id = nil)
|
124
|
+
enterprise_mode? || raise_only_for_enterprise_mode_error
|
125
|
+
user_id || raise_parameter_is_required_error(:user_id)
|
126
|
+
|
127
|
+
request = Web::Request.new(
|
128
|
+
connection,
|
129
|
+
:get,
|
130
|
+
"#{config.target_api_url}/users/#{user_id}"
|
131
|
+
)
|
132
|
+
Web::SendRequest.new(request).perform
|
133
|
+
end
|
134
|
+
|
135
|
+
def delete_user(user_id = nil)
|
136
|
+
enterprise_mode? || raise_only_for_enterprise_mode_error
|
137
|
+
user_id || raise_parameter_is_required_error(:user_id)
|
138
|
+
|
139
|
+
request = Web::Request.new(
|
140
|
+
connection,
|
141
|
+
:delete,
|
142
|
+
"#{config.target_api_url}/users/#{user_id}"
|
143
|
+
)
|
144
|
+
Web::SendRequest.new(request).perform
|
145
|
+
end
|
146
|
+
|
147
|
+
def edit_user(user_id = nil, query = {})
|
148
|
+
enterprise_mode? || raise_only_for_enterprise_mode_error
|
149
|
+
user_id || raise_parameter_is_required_error(:user_id)
|
150
|
+
|
151
|
+
request = Web::Request.new(
|
152
|
+
connection,
|
153
|
+
:patch,
|
154
|
+
"#{config.target_api_url}/users/#{user_id}",
|
155
|
+
{ params: query }
|
156
|
+
)
|
157
|
+
Web::SendRequest.new(request).perform
|
158
|
+
end
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Crowdin
|
4
|
+
module ApiResources
|
5
|
+
module Vendors
|
6
|
+
# -- For Enterprise mode only --
|
7
|
+
|
8
|
+
def list_vendors(query = {})
|
9
|
+
enterprise_mode? || raise_only_for_enterprise_mode_error
|
10
|
+
|
11
|
+
request = Web::Request.new(
|
12
|
+
connection,
|
13
|
+
:get,
|
14
|
+
"#{config.target_api_url}/vendors",
|
15
|
+
{ params: query }
|
16
|
+
)
|
17
|
+
Web::SendRequest.new(request).perform
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Crowdin
|
4
|
+
module ApiResources
|
5
|
+
module Webhooks
|
6
|
+
def list_webhooks(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}/webhooks",
|
13
|
+
{ params: query }
|
14
|
+
)
|
15
|
+
Web::SendRequest.new(request).perform
|
16
|
+
end
|
17
|
+
|
18
|
+
def add_webhook(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}/webhooks",
|
25
|
+
{ params: query }
|
26
|
+
)
|
27
|
+
Web::SendRequest.new(request).perform
|
28
|
+
end
|
29
|
+
|
30
|
+
def get_webhook(webhook_id = nil, project_id = config.project_id)
|
31
|
+
webhook_id || raise_parameter_is_required_error(:webhook_id)
|
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}/webhooks/#{webhook_id}"
|
38
|
+
)
|
39
|
+
Web::SendRequest.new(request).perform
|
40
|
+
end
|
41
|
+
|
42
|
+
def delete_webhook(webhook_id = nil, project_id = config.project_id)
|
43
|
+
webhook_id || raise_parameter_is_required_error(:webhook_id)
|
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}/webhooks/#{webhook_id}"
|
50
|
+
)
|
51
|
+
Web::SendRequest.new(request).perform
|
52
|
+
end
|
53
|
+
|
54
|
+
def edit_webhook(webhook_id = nil, query = {}, project_id = config.project_id)
|
55
|
+
webhook_id || raise_parameter_is_required_error(:webhook_id)
|
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}/webhooks/#{webhook_id}",
|
62
|
+
{ params: query }
|
63
|
+
)
|
64
|
+
Web::SendRequest.new(request).perform
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Crowdin
|
4
|
+
module ApiResources
|
5
|
+
module Workflows
|
6
|
+
# -- For Enterprise mode only --
|
7
|
+
|
8
|
+
def list_workflow_steps(query = {}, project_id = config.project_id)
|
9
|
+
enterprise_mode? || raise_only_for_enterprise_mode_error
|
10
|
+
project_id || raise_project_id_is_required_error
|
11
|
+
|
12
|
+
request = Web::Request.new(
|
13
|
+
connection,
|
14
|
+
:get,
|
15
|
+
"#{config.target_api_url}/projects/#{project_id}/workflow-steps",
|
16
|
+
{ params: query }
|
17
|
+
)
|
18
|
+
Web::SendRequest.new(request).perform
|
19
|
+
end
|
20
|
+
|
21
|
+
def get_workflow_step(step_id = nil, project_id = config.project_id)
|
22
|
+
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
|
+
connection,
|
28
|
+
:get,
|
29
|
+
"#{config.target_api_url}/projects/#{project_id}/workflow-steps/#{step_id}"
|
30
|
+
)
|
31
|
+
Web::SendRequest.new(request).perform
|
32
|
+
end
|
33
|
+
|
34
|
+
def list_workflow_templates(query = {})
|
35
|
+
enterprise_mode? || raise_only_for_enterprise_mode_error
|
36
|
+
|
37
|
+
request = Web::Request.new(
|
38
|
+
connection,
|
39
|
+
:get,
|
40
|
+
"#{config.target_api_url}/workflow-templates",
|
41
|
+
{ params: query }
|
42
|
+
)
|
43
|
+
Web::SendRequest.new(request).perform
|
44
|
+
end
|
45
|
+
|
46
|
+
def get_workflow_template(template_id = nil)
|
47
|
+
enterprise_mode? || raise_only_for_enterprise_mode_error
|
48
|
+
template_id || raise_parameter_is_required_error(:template_id)
|
49
|
+
|
50
|
+
request = Web::Request.new(
|
51
|
+
connection,
|
52
|
+
:get,
|
53
|
+
"#{config.target_api_url}/workflow-templates/#{template_id}"
|
54
|
+
)
|
55
|
+
Web::SendRequest.new(request).perform
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|