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,199 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Crowdin
|
4
|
+
module ApiResources
|
5
|
+
module Glossaries
|
6
|
+
def list_glossaries(query = {})
|
7
|
+
request = Web::Request.new(
|
8
|
+
connection,
|
9
|
+
:get,
|
10
|
+
"#{config.target_api_url}/glossaries",
|
11
|
+
{ params: query }
|
12
|
+
)
|
13
|
+
Web::SendRequest.new(request).perform
|
14
|
+
end
|
15
|
+
|
16
|
+
def add_glossary(query = {})
|
17
|
+
request = Web::Request.new(
|
18
|
+
connection,
|
19
|
+
:post,
|
20
|
+
"#{config.target_api_url}/glossaries",
|
21
|
+
{ params: query }
|
22
|
+
)
|
23
|
+
Web::SendRequest.new(request).perform
|
24
|
+
end
|
25
|
+
|
26
|
+
def get_glossary(glossary_id = nil, query = {})
|
27
|
+
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
28
|
+
|
29
|
+
request = Web::Request.new(
|
30
|
+
connection,
|
31
|
+
:get,
|
32
|
+
"#{config.target_api_url}/glossaries/#{glossary_id}",
|
33
|
+
{ params: query }
|
34
|
+
)
|
35
|
+
Web::SendRequest.new(request).perform
|
36
|
+
end
|
37
|
+
|
38
|
+
def delete_glossary(glossary_id = nil)
|
39
|
+
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
40
|
+
|
41
|
+
request = Web::Request.new(
|
42
|
+
connection,
|
43
|
+
:delete,
|
44
|
+
"#{config.target_api_url}/glossaries/#{glossary_id}"
|
45
|
+
)
|
46
|
+
Web::SendRequest.new(request).perform
|
47
|
+
end
|
48
|
+
|
49
|
+
def edit_glossary(glossary_id = nil, query = {})
|
50
|
+
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
51
|
+
|
52
|
+
request = Web::Request.new(
|
53
|
+
connection,
|
54
|
+
:patch,
|
55
|
+
"#{config.target_api_url}/glossaries/#{glossary_id}",
|
56
|
+
{ params: query }
|
57
|
+
)
|
58
|
+
Web::SendRequest.new(request).perform
|
59
|
+
end
|
60
|
+
|
61
|
+
def export_glossary(query = {}, glossary_id = nil, destination = nil)
|
62
|
+
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
63
|
+
|
64
|
+
request = Web::Request.new(
|
65
|
+
connection,
|
66
|
+
:post,
|
67
|
+
"#{config.target_api_url}/glossaries/#{glossary_id}/exports",
|
68
|
+
{ params: query }
|
69
|
+
)
|
70
|
+
Web::SendRequest.new(request, destination).perform
|
71
|
+
end
|
72
|
+
|
73
|
+
def check_glossary_export_status(glossary_id = nil, export_id = nil)
|
74
|
+
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
75
|
+
export_id || raise_parameter_is_required_error(:export_id)
|
76
|
+
|
77
|
+
request = Web::Request.new(
|
78
|
+
connection,
|
79
|
+
:get,
|
80
|
+
"#{config.target_api_url}/glossaries/#{glossary_id}/exports/#{export_id}"
|
81
|
+
)
|
82
|
+
Web::SendRequest.new(request).perform
|
83
|
+
end
|
84
|
+
|
85
|
+
def download_glossary(glossary_id = nil, export_id = nil, destination = nil)
|
86
|
+
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
87
|
+
export_id || raise_parameter_is_required_error(:export_id)
|
88
|
+
|
89
|
+
request = Web::Request.new(
|
90
|
+
connection,
|
91
|
+
:get,
|
92
|
+
"#{config.target_api_url}/glossaries/#{glossary_id}/exports/#{export_id}/download"
|
93
|
+
)
|
94
|
+
Web::SendRequest.new(request, destination).perform
|
95
|
+
end
|
96
|
+
|
97
|
+
def import_glossary(glossary_id = nil, query = {})
|
98
|
+
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
99
|
+
|
100
|
+
request = Web::Request.new(
|
101
|
+
connection,
|
102
|
+
:post,
|
103
|
+
"#{config.target_api_url}/glossaries/#{glossary_id}/imports",
|
104
|
+
{ params: query }
|
105
|
+
)
|
106
|
+
Web::SendRequest.new(request).perform
|
107
|
+
end
|
108
|
+
|
109
|
+
def check_glossary_import_status(glossary_id = nil, import_id = nil)
|
110
|
+
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
111
|
+
import_id || raise_parameter_is_required_error(:import_id)
|
112
|
+
|
113
|
+
request = Web::Request.new(
|
114
|
+
connection,
|
115
|
+
:get,
|
116
|
+
"#{config.target_api_url}/glossaries/#{glossary_id}/imports/#{import_id}"
|
117
|
+
)
|
118
|
+
Web::SendRequest.new(request).perform
|
119
|
+
end
|
120
|
+
|
121
|
+
def list_terms(glossary_id = nil, query = {})
|
122
|
+
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
123
|
+
|
124
|
+
request = Web::Request.new(
|
125
|
+
connection,
|
126
|
+
:get,
|
127
|
+
"#{config.target_api_url}/glossaries/#{glossary_id}/terms",
|
128
|
+
{ params: query }
|
129
|
+
)
|
130
|
+
Web::SendRequest.new(request).perform
|
131
|
+
end
|
132
|
+
|
133
|
+
def add_term(glossary_id = nil, query = {})
|
134
|
+
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
135
|
+
|
136
|
+
request = Web::Request.new(
|
137
|
+
connection,
|
138
|
+
:post,
|
139
|
+
"#{config.target_api_url}/glossaries/#{glossary_id}/terms",
|
140
|
+
{ params: query }
|
141
|
+
)
|
142
|
+
Web::SendRequest.new(request).perform
|
143
|
+
end
|
144
|
+
|
145
|
+
def clear_glossary(glossary_id = nil, query = {})
|
146
|
+
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
147
|
+
|
148
|
+
response = ::RestClient::Request.execute(
|
149
|
+
{
|
150
|
+
method: :delete,
|
151
|
+
url: config.base_url + config.target_api_url + "/glossaries/#{glossary_id}/terms",
|
152
|
+
payload: query.to_json
|
153
|
+
}.merge(@options)
|
154
|
+
)
|
155
|
+
|
156
|
+
response.body.empty? ? response.code : JSON.parse(response.body)
|
157
|
+
rescue StandardError => e
|
158
|
+
e.message
|
159
|
+
end
|
160
|
+
|
161
|
+
def get_term(glossary_id = nil, term_id = nil)
|
162
|
+
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
163
|
+
term_id || raise_parameter_is_required_error(:term_id)
|
164
|
+
|
165
|
+
request = Web::Request.new(
|
166
|
+
connection,
|
167
|
+
:get,
|
168
|
+
"#{config.target_api_url}/glossaries/#{glossary_id}/terms/#{term_id}"
|
169
|
+
)
|
170
|
+
Web::SendRequest.new(request).perform
|
171
|
+
end
|
172
|
+
|
173
|
+
def delete_term(glossary_id = nil, term_id = nil)
|
174
|
+
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
175
|
+
term_id || raise_parameter_is_required_error(:term_id)
|
176
|
+
|
177
|
+
request = Web::Request.new(
|
178
|
+
connection,
|
179
|
+
:delete,
|
180
|
+
"#{config.target_api_url}/glossaries/#{glossary_id}/terms/#{term_id}"
|
181
|
+
)
|
182
|
+
Web::SendRequest.new(request).perform
|
183
|
+
end
|
184
|
+
|
185
|
+
def edit_term(glossary_id = nil, term_id = nil, query = {})
|
186
|
+
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
187
|
+
term_id || raise_parameter_is_required_error(:term_id)
|
188
|
+
|
189
|
+
request = Web::Request.new(
|
190
|
+
connection,
|
191
|
+
:patch,
|
192
|
+
"#{config.target_api_url}/glossaries/#{glossary_id}/terms/#{term_id}",
|
193
|
+
{ params: query }
|
194
|
+
)
|
195
|
+
Web::SendRequest.new(request).perform
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Crowdin
|
4
|
+
module ApiResources
|
5
|
+
module Labels
|
6
|
+
def list_labels(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}/labels",
|
13
|
+
{ params: query }
|
14
|
+
)
|
15
|
+
Web::SendRequest.new(request).perform
|
16
|
+
end
|
17
|
+
|
18
|
+
def add_label(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}/labels",
|
25
|
+
{ params: query }
|
26
|
+
)
|
27
|
+
Web::SendRequest.new(request).perform
|
28
|
+
end
|
29
|
+
|
30
|
+
def get_label(label_id = nil, project_id = config.project_id)
|
31
|
+
label_id || raise_parameter_is_required_error(:label_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}/labels/#{label_id}"
|
38
|
+
)
|
39
|
+
Web::SendRequest.new(request).perform
|
40
|
+
end
|
41
|
+
|
42
|
+
def delete_label(label_id = nil, project_id = config.project_id)
|
43
|
+
label_id || raise_parameter_is_required_error(:label_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}/labels/#{label_id}"
|
50
|
+
)
|
51
|
+
Web::SendRequest.new(request).perform
|
52
|
+
end
|
53
|
+
|
54
|
+
def edit_label(label_id = nil, query = {}, project_id = config.project_id)
|
55
|
+
label_id || raise_parameter_is_required_error(:label_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}/labels/#{label_id}",
|
62
|
+
{ params: query }
|
63
|
+
)
|
64
|
+
Web::SendRequest.new(request).perform
|
65
|
+
end
|
66
|
+
|
67
|
+
def assign_label_to_strings(label_id = nil, query = {}, project_id = config.project_id)
|
68
|
+
label_id || raise_parameter_is_required_error(:label_id)
|
69
|
+
project_id || raise_project_id_is_required_error
|
70
|
+
|
71
|
+
request = Web::Request.new(
|
72
|
+
connection,
|
73
|
+
:post,
|
74
|
+
"#{config.target_api_url}/projects/#{project_id}/labels/#{label_id}/strings",
|
75
|
+
{ params: query }
|
76
|
+
)
|
77
|
+
Web::SendRequest.new(request).perform
|
78
|
+
end
|
79
|
+
|
80
|
+
def unassign_label_from_strings(label_id = nil, query = {}, project_id = config.project_id)
|
81
|
+
label_id || raise_parameter_is_required_error(:label_id)
|
82
|
+
project_id || raise_project_id_is_required_error
|
83
|
+
|
84
|
+
response = ::RestClient::Request.execute(
|
85
|
+
{
|
86
|
+
method: :delete,
|
87
|
+
url: config.base_url + config.target_api_url + "/projects/#{project_id}/labels/#{label_id}",
|
88
|
+
payload: query.to_json
|
89
|
+
}.merge(@options)
|
90
|
+
)
|
91
|
+
|
92
|
+
response.body.empty? ? response.code : JSON.parse(response.body)
|
93
|
+
rescue StandardError => e
|
94
|
+
e.message
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,61 @@
|
|
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
|
+
connection,
|
9
|
+
:get,
|
10
|
+
"#{config.target_api_url}/languages",
|
11
|
+
{ params: query }
|
12
|
+
)
|
13
|
+
Web::SendRequest.new(request).perform
|
14
|
+
end
|
15
|
+
|
16
|
+
def add_custom_language(query = {})
|
17
|
+
request = Web::Request.new(
|
18
|
+
connection,
|
19
|
+
:post,
|
20
|
+
"#{config.target_api_url}/languages",
|
21
|
+
{ params: query }
|
22
|
+
)
|
23
|
+
Web::SendRequest.new(request).perform
|
24
|
+
end
|
25
|
+
|
26
|
+
def get_language(language_id = nil)
|
27
|
+
language_id || raise_parameter_is_required_error(:language_id)
|
28
|
+
|
29
|
+
request = Web::Request.new(
|
30
|
+
connection,
|
31
|
+
:get,
|
32
|
+
"#{config.target_api_url}/languages/#{language_id}"
|
33
|
+
)
|
34
|
+
Web::SendRequest.new(request).perform
|
35
|
+
end
|
36
|
+
|
37
|
+
def delete_custom_language(language_id = nil)
|
38
|
+
language_id || raise_parameter_is_required_error(:language_id)
|
39
|
+
|
40
|
+
request = Web::Request.new(
|
41
|
+
connection,
|
42
|
+
:delete,
|
43
|
+
"#{config.target_api_url}/languages/#{language_id}"
|
44
|
+
)
|
45
|
+
Web::SendRequest.new(request).perform
|
46
|
+
end
|
47
|
+
|
48
|
+
def edit_custom_language(language_id = nil, query = {})
|
49
|
+
language_id || raise_parameter_is_required_error(:language_id)
|
50
|
+
|
51
|
+
request = Web::Request.new(
|
52
|
+
connection,
|
53
|
+
:patch,
|
54
|
+
"#{config.target_api_url}/languages/#{language_id}",
|
55
|
+
{ params: query }
|
56
|
+
)
|
57
|
+
Web::SendRequest.new(request).perform
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Crowdin
|
4
|
+
module ApiResources
|
5
|
+
module MachineTranslationEngines
|
6
|
+
def list_mts(query = {})
|
7
|
+
request = Web::Request.new(
|
8
|
+
connection,
|
9
|
+
:get,
|
10
|
+
"#{config.target_api_url}/mts",
|
11
|
+
{ params: query }
|
12
|
+
)
|
13
|
+
Web::SendRequest.new(request).perform
|
14
|
+
end
|
15
|
+
|
16
|
+
def get_mt(mt_id = nil)
|
17
|
+
mt_id || raise_parameter_is_required_error(:mt_id)
|
18
|
+
|
19
|
+
request = Web::Request.new(
|
20
|
+
connection,
|
21
|
+
:get,
|
22
|
+
"#{config.target_api_url}/mts/#{mt_id}"
|
23
|
+
)
|
24
|
+
Web::SendRequest.new(request).perform
|
25
|
+
end
|
26
|
+
|
27
|
+
def translate_via_mt(mt_id = nil, query = {})
|
28
|
+
mt_id || raise_parameter_is_required_error(:mt_id)
|
29
|
+
|
30
|
+
request = Web::Request.new(
|
31
|
+
connection,
|
32
|
+
:post,
|
33
|
+
"#{config.target_api_url}/mts/#{mt_id}/translations",
|
34
|
+
{ params: query }
|
35
|
+
)
|
36
|
+
Web::SendRequest.new(request).perform
|
37
|
+
end
|
38
|
+
|
39
|
+
# -- For Enterprise mode only --
|
40
|
+
|
41
|
+
def edit_mt(mt_id = nil, query = {})
|
42
|
+
enterprise_mode? || raise_only_for_enterprise_mode_error
|
43
|
+
mt_id || raise_parameter_is_required_error(:mt_id)
|
44
|
+
|
45
|
+
request = Web::Request.new(
|
46
|
+
connection,
|
47
|
+
:patch,
|
48
|
+
"#{config.target_api_url}/mts/#{mt_id}",
|
49
|
+
{ params: query }
|
50
|
+
)
|
51
|
+
Web::SendRequest.new(request).perform
|
52
|
+
end
|
53
|
+
|
54
|
+
def add_mt(query = {})
|
55
|
+
enterprise_mode? || raise_only_for_enterprise_mode_error
|
56
|
+
|
57
|
+
request = Web::Request.new(
|
58
|
+
connection,
|
59
|
+
:post,
|
60
|
+
"#{config.target_api_url}/mts",
|
61
|
+
{ params: query }
|
62
|
+
)
|
63
|
+
Web::SendRequest.new(request).perform
|
64
|
+
end
|
65
|
+
|
66
|
+
def delete_mt(mt_id = nil)
|
67
|
+
enterprise_mode? || raise_only_for_enterprise_mode_error
|
68
|
+
mt_id || raise_parameter_is_required_error(:mt_id)
|
69
|
+
|
70
|
+
request = Web::Request.new(
|
71
|
+
connection,
|
72
|
+
:delete,
|
73
|
+
"#{config.target_api_url}/mts/#{mt_id}"
|
74
|
+
)
|
75
|
+
Web::SendRequest.new(request).perform
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,124 @@
|
|
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
|
+
connection,
|
9
|
+
:get,
|
10
|
+
"#{config.target_api_url}/projects",
|
11
|
+
{ params: query }
|
12
|
+
)
|
13
|
+
Web::SendRequest.new(request).perform
|
14
|
+
end
|
15
|
+
|
16
|
+
def add_project(query = {})
|
17
|
+
request = Web::Request.new(
|
18
|
+
connection,
|
19
|
+
:post,
|
20
|
+
"#{config.target_api_url}/projects",
|
21
|
+
{ params: query }
|
22
|
+
)
|
23
|
+
Web::SendRequest.new(request).perform
|
24
|
+
end
|
25
|
+
|
26
|
+
def get_project(project_id = nil)
|
27
|
+
project_id || raise_parameter_is_required_error(:project_id)
|
28
|
+
|
29
|
+
request = Web::Request.new(
|
30
|
+
connection,
|
31
|
+
:get,
|
32
|
+
"#{config.target_api_url}/projects/#{project_id}"
|
33
|
+
)
|
34
|
+
Web::SendRequest.new(request).perform
|
35
|
+
end
|
36
|
+
|
37
|
+
def delete_project(project_id = nil)
|
38
|
+
project_id || raise_parameter_is_required_error(:project_id)
|
39
|
+
|
40
|
+
request = Web::Request.new(
|
41
|
+
connection,
|
42
|
+
:delete,
|
43
|
+
"#{config.target_api_url}/projects/#{project_id}"
|
44
|
+
)
|
45
|
+
Web::SendRequest.new(request).perform
|
46
|
+
end
|
47
|
+
|
48
|
+
def edit_project(project_id = nil, query = {})
|
49
|
+
project_id || raise_parameter_is_required_error(:project_id)
|
50
|
+
|
51
|
+
request = Web::Request.new(
|
52
|
+
connection,
|
53
|
+
:patch,
|
54
|
+
"#{config.target_api_url}/projects/#{project_id}",
|
55
|
+
{ params: query }
|
56
|
+
)
|
57
|
+
Web::SendRequest.new(request).perform
|
58
|
+
end
|
59
|
+
|
60
|
+
# -- For Enterprise mode only --
|
61
|
+
|
62
|
+
def list_groups(query = {})
|
63
|
+
enterprise_mode? || raise_only_for_enterprise_mode_error
|
64
|
+
|
65
|
+
request = Web::Request.new(
|
66
|
+
connection,
|
67
|
+
:get,
|
68
|
+
"#{config.target_api_url}/groups",
|
69
|
+
{ params: query }
|
70
|
+
)
|
71
|
+
Web::SendRequest.new(request).perform
|
72
|
+
end
|
73
|
+
|
74
|
+
def add_group(query = {})
|
75
|
+
enterprise_mode? || raise_only_for_enterprise_mode_error
|
76
|
+
|
77
|
+
request = Web::Request.new(
|
78
|
+
connection,
|
79
|
+
:post,
|
80
|
+
"#{config.target_api_url}/groups",
|
81
|
+
{ params: query }
|
82
|
+
)
|
83
|
+
Web::SendRequest.new(request).perform
|
84
|
+
end
|
85
|
+
|
86
|
+
def get_group(group_id = nil)
|
87
|
+
enterprise_mode? || raise_only_for_enterprise_mode_error
|
88
|
+
group_id || raise_parameter_is_required_error(:group_id)
|
89
|
+
|
90
|
+
request = Web::Request.new(
|
91
|
+
connection,
|
92
|
+
:get,
|
93
|
+
"#{config.target_api_url}/groups/#{group_id}"
|
94
|
+
)
|
95
|
+
Web::SendRequest.new(request).perform
|
96
|
+
end
|
97
|
+
|
98
|
+
def delete_group(group_id = nil)
|
99
|
+
enterprise_mode? || raise_only_for_enterprise_mode_error
|
100
|
+
group_id || raise_parameter_is_required_error(:group_id)
|
101
|
+
|
102
|
+
request = Web::Request.new(
|
103
|
+
connection,
|
104
|
+
:delete,
|
105
|
+
"#{config.target_api_url}/groups/#{group_id}"
|
106
|
+
)
|
107
|
+
Web::SendRequest.new(request).perform
|
108
|
+
end
|
109
|
+
|
110
|
+
def edit_group(group_id = nil, query = {})
|
111
|
+
enterprise_mode? || raise_only_for_enterprise_mode_error
|
112
|
+
group_id || raise_parameter_is_required_error(:group_id)
|
113
|
+
|
114
|
+
request = Web::Request.new(
|
115
|
+
connection,
|
116
|
+
:patch,
|
117
|
+
"#{config.target_api_url}/groups/#{group_id}",
|
118
|
+
{ params: query }
|
119
|
+
)
|
120
|
+
Web::SendRequest.new(request).perform
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Crowdin
|
4
|
+
module ApiResources
|
5
|
+
module Reports
|
6
|
+
def generate_report(query = {}, project_id = config.project_id)
|
7
|
+
project_id || raise_project_id_is_required_error
|
8
|
+
|
9
|
+
request = Web::Request.new(
|
10
|
+
connection,
|
11
|
+
:post,
|
12
|
+
"#{config.target_api_url}/projects/#{project_id}/reports",
|
13
|
+
{ params: query }
|
14
|
+
)
|
15
|
+
Web::SendRequest.new(request).perform
|
16
|
+
end
|
17
|
+
|
18
|
+
def check_report_generation_status(report_id = nil, project_id = config.project_id)
|
19
|
+
report_id || raise_parameter_is_required_error(:report_id)
|
20
|
+
project_id || raise_project_id_is_required_error
|
21
|
+
|
22
|
+
request = Web::Request.new(
|
23
|
+
connection,
|
24
|
+
:get,
|
25
|
+
"#{config.target_api_url}/projects/#{project_id}/reports/#{report_id}"
|
26
|
+
)
|
27
|
+
Web::SendRequest.new(request).perform
|
28
|
+
end
|
29
|
+
|
30
|
+
def download_report(report_id = nil, destination = nil, project_id = config.project_id)
|
31
|
+
report_id || raise_parameter_is_required_error(:report_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}/reports/#{report_id}/download"
|
38
|
+
)
|
39
|
+
Web::SendRequest.new(request, destination).perform
|
40
|
+
end
|
41
|
+
|
42
|
+
# -- For Enterprise mode only --
|
43
|
+
|
44
|
+
def generate_group_report(group_id = nil, query = {})
|
45
|
+
enterprise_mode? || raise_only_for_enterprise_mode_error
|
46
|
+
group_id || raise_parameter_is_required_error(:group_id)
|
47
|
+
|
48
|
+
request = Web::Request.new(
|
49
|
+
connection,
|
50
|
+
:post,
|
51
|
+
"#{config.target_api_url}/groups/#{group_id}/reports",
|
52
|
+
{ params: query }
|
53
|
+
)
|
54
|
+
Web::SendRequest.new(request).perform
|
55
|
+
end
|
56
|
+
|
57
|
+
def check_group_report_generation_status(group_id = nil, report_id = nil)
|
58
|
+
enterprise_mode? || raise_only_for_enterprise_mode_error
|
59
|
+
group_id || raise_parameter_is_required_error(:group_id)
|
60
|
+
report_id || raise_parameter_is_required_error(:report_id)
|
61
|
+
|
62
|
+
request = Web::Request.new(
|
63
|
+
connection,
|
64
|
+
:get,
|
65
|
+
"#{config.target_api_url}/groups/#{group_id}/reports/#{report_id}"
|
66
|
+
)
|
67
|
+
Web::SendRequest.new(request).perform
|
68
|
+
end
|
69
|
+
|
70
|
+
def download_group_report(group_id = nil, report_id = nil, destination = nil)
|
71
|
+
enterprise_mode? || raise_only_for_enterprise_mode_error
|
72
|
+
group_id || raise_parameter_is_required_error(:group_id)
|
73
|
+
report_id || raise_parameter_is_required_error(:report_id)
|
74
|
+
|
75
|
+
request = Web::Request.new(
|
76
|
+
connection,
|
77
|
+
:get,
|
78
|
+
"#{config.target_api_url}/groups/#{group_id}/reports/#{report_id}/download"
|
79
|
+
)
|
80
|
+
Web::SendRequest.new(request, destination).perform
|
81
|
+
end
|
82
|
+
|
83
|
+
def generate_organization_report(query = {})
|
84
|
+
enterprise_mode? || raise_only_for_enterprise_mode_error
|
85
|
+
|
86
|
+
request = Web::Request.new(
|
87
|
+
connection,
|
88
|
+
:post,
|
89
|
+
"#{config.target_api_url}/reports",
|
90
|
+
{ params: query }
|
91
|
+
)
|
92
|
+
Web::SendRequest.new(request).perform
|
93
|
+
end
|
94
|
+
|
95
|
+
def check_organization_report_generation_status(report_id = nil)
|
96
|
+
enterprise_mode? || raise_only_for_enterprise_mode_error
|
97
|
+
report_id || raise_parameter_is_required_error(:report_id)
|
98
|
+
|
99
|
+
request = Web::Request.new(
|
100
|
+
connection,
|
101
|
+
:get,
|
102
|
+
"#{config.target_api_url}/reports/#{report_id}"
|
103
|
+
)
|
104
|
+
Web::SendRequest.new(request).perform
|
105
|
+
end
|
106
|
+
|
107
|
+
def download_organization_report(report_id = nil, destination = nil)
|
108
|
+
enterprise_mode? || raise_only_for_enterprise_mode_error
|
109
|
+
report_id || raise_parameter_is_required_error(:report_id)
|
110
|
+
|
111
|
+
request = Web::Request.new(
|
112
|
+
connection,
|
113
|
+
:get,
|
114
|
+
"#{config.target_api_url}/reports/#{report_id}/download"
|
115
|
+
)
|
116
|
+
Web::SendRequest.new(request, destination).perform
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|