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
@@ -5,78 +5,69 @@ module Crowdin
|
|
5
5
|
module Glossaries
|
6
6
|
def list_glossaries(query = {})
|
7
7
|
request = Web::Request.new(
|
8
|
-
|
8
|
+
connection,
|
9
9
|
:get,
|
10
|
-
|
11
|
-
query
|
10
|
+
"#{config.target_api_url}/glossaries",
|
11
|
+
{ params: query }
|
12
12
|
)
|
13
|
-
|
14
|
-
request.perform
|
13
|
+
Web::SendRequest.new(request).perform
|
15
14
|
end
|
16
15
|
|
17
16
|
def add_glossary(query = {})
|
18
17
|
request = Web::Request.new(
|
19
|
-
|
18
|
+
connection,
|
20
19
|
:post,
|
21
|
-
|
22
|
-
query
|
20
|
+
"#{config.target_api_url}/glossaries",
|
21
|
+
{ params: query }
|
23
22
|
)
|
24
|
-
|
25
|
-
request.perform
|
23
|
+
Web::SendRequest.new(request).perform
|
26
24
|
end
|
27
25
|
|
28
26
|
def get_glossary(glossary_id = nil, query = {})
|
29
27
|
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
30
28
|
|
31
29
|
request = Web::Request.new(
|
32
|
-
|
30
|
+
connection,
|
33
31
|
:get,
|
34
|
-
"/glossaries/#{glossary_id}",
|
35
|
-
query
|
32
|
+
"#{config.target_api_url}/glossaries/#{glossary_id}",
|
33
|
+
{ params: query }
|
36
34
|
)
|
37
|
-
|
38
|
-
request.perform
|
35
|
+
Web::SendRequest.new(request).perform
|
39
36
|
end
|
40
37
|
|
41
|
-
def delete_glossary(glossary_id = nil
|
38
|
+
def delete_glossary(glossary_id = nil)
|
42
39
|
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
43
40
|
|
44
41
|
request = Web::Request.new(
|
45
|
-
|
42
|
+
connection,
|
46
43
|
:delete,
|
47
|
-
"/glossaries/#{glossary_id}"
|
48
|
-
query
|
44
|
+
"#{config.target_api_url}/glossaries/#{glossary_id}"
|
49
45
|
)
|
50
|
-
|
51
|
-
request.perform
|
46
|
+
Web::SendRequest.new(request).perform
|
52
47
|
end
|
53
48
|
|
54
49
|
def edit_glossary(glossary_id = nil, query = {})
|
55
50
|
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
56
51
|
|
57
52
|
request = Web::Request.new(
|
58
|
-
|
53
|
+
connection,
|
59
54
|
:patch,
|
60
|
-
"/glossaries/#{glossary_id}",
|
61
|
-
query
|
55
|
+
"#{config.target_api_url}/glossaries/#{glossary_id}",
|
56
|
+
{ params: query }
|
62
57
|
)
|
63
|
-
|
64
|
-
request.perform
|
58
|
+
Web::SendRequest.new(request).perform
|
65
59
|
end
|
66
60
|
|
67
61
|
def export_glossary(query = {}, glossary_id = nil, destination = nil)
|
68
62
|
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
69
63
|
|
70
64
|
request = Web::Request.new(
|
71
|
-
|
65
|
+
connection,
|
72
66
|
:post,
|
73
|
-
"/glossaries/#{glossary_id}/exports",
|
74
|
-
query
|
75
|
-
{},
|
76
|
-
destination
|
67
|
+
"#{config.target_api_url}/glossaries/#{glossary_id}/exports",
|
68
|
+
{ params: query }
|
77
69
|
)
|
78
|
-
|
79
|
-
request.perform
|
70
|
+
Web::SendRequest.new(request, destination).perform
|
80
71
|
end
|
81
72
|
|
82
73
|
def check_glossary_export_status(glossary_id = nil, export_id = nil)
|
@@ -84,12 +75,11 @@ module Crowdin
|
|
84
75
|
export_id || raise_parameter_is_required_error(:export_id)
|
85
76
|
|
86
77
|
request = Web::Request.new(
|
87
|
-
|
78
|
+
connection,
|
88
79
|
:get,
|
89
|
-
"/glossaries/#{glossary_id}/exports/#{export_id}"
|
80
|
+
"#{config.target_api_url}/glossaries/#{glossary_id}/exports/#{export_id}"
|
90
81
|
)
|
91
|
-
|
92
|
-
request.perform
|
82
|
+
Web::SendRequest.new(request).perform
|
93
83
|
end
|
94
84
|
|
95
85
|
def download_glossary(glossary_id = nil, export_id = nil, destination = nil)
|
@@ -97,28 +87,23 @@ module Crowdin
|
|
97
87
|
export_id || raise_parameter_is_required_error(:export_id)
|
98
88
|
|
99
89
|
request = Web::Request.new(
|
100
|
-
|
90
|
+
connection,
|
101
91
|
:get,
|
102
|
-
"/glossaries/#{glossary_id}/exports/#{export_id}/download"
|
103
|
-
{},
|
104
|
-
{},
|
105
|
-
destination
|
92
|
+
"#{config.target_api_url}/glossaries/#{glossary_id}/exports/#{export_id}/download"
|
106
93
|
)
|
107
|
-
|
108
|
-
request.perform
|
94
|
+
Web::SendRequest.new(request, destination).perform
|
109
95
|
end
|
110
96
|
|
111
97
|
def import_glossary(glossary_id = nil, query = {})
|
112
98
|
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
113
99
|
|
114
100
|
request = Web::Request.new(
|
115
|
-
|
101
|
+
connection,
|
116
102
|
:post,
|
117
|
-
"/glossaries/#{glossary_id}/imports",
|
118
|
-
query
|
103
|
+
"#{config.target_api_url}/glossaries/#{glossary_id}/imports",
|
104
|
+
{ params: query }
|
119
105
|
)
|
120
|
-
|
121
|
-
request.perform
|
106
|
+
Web::SendRequest.new(request).perform
|
122
107
|
end
|
123
108
|
|
124
109
|
def check_glossary_import_status(glossary_id = nil, import_id = nil)
|
@@ -126,51 +111,51 @@ module Crowdin
|
|
126
111
|
import_id || raise_parameter_is_required_error(:import_id)
|
127
112
|
|
128
113
|
request = Web::Request.new(
|
129
|
-
|
114
|
+
connection,
|
130
115
|
:get,
|
131
|
-
"/glossaries/#{glossary_id}/imports/#{import_id}"
|
116
|
+
"#{config.target_api_url}/glossaries/#{glossary_id}/imports/#{import_id}"
|
132
117
|
)
|
133
|
-
|
134
|
-
request.perform
|
118
|
+
Web::SendRequest.new(request).perform
|
135
119
|
end
|
136
120
|
|
137
121
|
def list_terms(glossary_id = nil, query = {})
|
138
122
|
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
139
123
|
|
140
124
|
request = Web::Request.new(
|
141
|
-
|
125
|
+
connection,
|
142
126
|
:get,
|
143
|
-
"/glossaries/#{glossary_id}/terms",
|
144
|
-
query
|
127
|
+
"#{config.target_api_url}/glossaries/#{glossary_id}/terms",
|
128
|
+
{ params: query }
|
145
129
|
)
|
146
|
-
|
147
|
-
request.perform
|
130
|
+
Web::SendRequest.new(request).perform
|
148
131
|
end
|
149
132
|
|
150
133
|
def add_term(glossary_id = nil, query = {})
|
151
134
|
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
152
135
|
|
153
136
|
request = Web::Request.new(
|
154
|
-
|
137
|
+
connection,
|
155
138
|
:post,
|
156
|
-
"/glossaries/#{glossary_id}/terms",
|
157
|
-
query
|
139
|
+
"#{config.target_api_url}/glossaries/#{glossary_id}/terms",
|
140
|
+
{ params: query }
|
158
141
|
)
|
159
|
-
|
160
|
-
request.perform
|
142
|
+
Web::SendRequest.new(request).perform
|
161
143
|
end
|
162
144
|
|
163
145
|
def clear_glossary(glossary_id = nil, query = {})
|
164
146
|
glossary_id || raise_parameter_is_required_error(:glossary_id)
|
165
147
|
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
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)
|
171
154
|
)
|
172
155
|
|
173
|
-
|
156
|
+
response.body.empty? ? response.code : JSON.parse(response.body)
|
157
|
+
rescue StandardError => e
|
158
|
+
e.message
|
174
159
|
end
|
175
160
|
|
176
161
|
def get_term(glossary_id = nil, term_id = nil)
|
@@ -178,12 +163,11 @@ module Crowdin
|
|
178
163
|
term_id || raise_parameter_is_required_error(:term_id)
|
179
164
|
|
180
165
|
request = Web::Request.new(
|
181
|
-
|
166
|
+
connection,
|
182
167
|
:get,
|
183
|
-
"/glossaries/#{glossary_id}/terms/#{term_id}"
|
168
|
+
"#{config.target_api_url}/glossaries/#{glossary_id}/terms/#{term_id}"
|
184
169
|
)
|
185
|
-
|
186
|
-
request.perform
|
170
|
+
Web::SendRequest.new(request).perform
|
187
171
|
end
|
188
172
|
|
189
173
|
def delete_term(glossary_id = nil, term_id = nil)
|
@@ -191,12 +175,11 @@ module Crowdin
|
|
191
175
|
term_id || raise_parameter_is_required_error(:term_id)
|
192
176
|
|
193
177
|
request = Web::Request.new(
|
194
|
-
|
178
|
+
connection,
|
195
179
|
:delete,
|
196
|
-
"/glossaries/#{glossary_id}/terms/#{term_id}"
|
180
|
+
"#{config.target_api_url}/glossaries/#{glossary_id}/terms/#{term_id}"
|
197
181
|
)
|
198
|
-
|
199
|
-
request.perform
|
182
|
+
Web::SendRequest.new(request).perform
|
200
183
|
end
|
201
184
|
|
202
185
|
def edit_term(glossary_id = nil, term_id = nil, query = {})
|
@@ -204,13 +187,12 @@ module Crowdin
|
|
204
187
|
term_id || raise_parameter_is_required_error(:term_id)
|
205
188
|
|
206
189
|
request = Web::Request.new(
|
207
|
-
|
190
|
+
connection,
|
208
191
|
:patch,
|
209
|
-
"/glossaries/#{glossary_id}/terms/#{term_id}",
|
210
|
-
query
|
192
|
+
"#{config.target_api_url}/glossaries/#{glossary_id}/terms/#{term_id}",
|
193
|
+
{ params: query }
|
211
194
|
)
|
212
|
-
|
213
|
-
request.perform
|
195
|
+
Web::SendRequest.new(request).perform
|
214
196
|
end
|
215
197
|
end
|
216
198
|
end
|
@@ -3,30 +3,28 @@
|
|
3
3
|
module Crowdin
|
4
4
|
module ApiResources
|
5
5
|
module Labels
|
6
|
-
def
|
6
|
+
def list_labels(query = {}, project_id = config.project_id)
|
7
7
|
project_id || raise_project_id_is_required_error
|
8
8
|
|
9
9
|
request = Web::Request.new(
|
10
|
-
|
10
|
+
connection,
|
11
11
|
:get,
|
12
|
-
"/projects/#{project_id}/labels",
|
13
|
-
query
|
12
|
+
"#{config.target_api_url}/projects/#{project_id}/labels",
|
13
|
+
{ params: query }
|
14
14
|
)
|
15
|
-
|
16
|
-
request.perform
|
15
|
+
Web::SendRequest.new(request).perform
|
17
16
|
end
|
18
17
|
|
19
18
|
def add_label(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}/labels",
|
26
|
-
query
|
24
|
+
"#{config.target_api_url}/projects/#{project_id}/labels",
|
25
|
+
{ params: query }
|
27
26
|
)
|
28
|
-
|
29
|
-
request.perform
|
27
|
+
Web::SendRequest.new(request).perform
|
30
28
|
end
|
31
29
|
|
32
30
|
def get_label(label_id = nil, project_id = config.project_id)
|
@@ -34,12 +32,11 @@ 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
|
:get,
|
39
|
-
"/projects/#{project_id}/labels/#{label_id}"
|
37
|
+
"#{config.target_api_url}/projects/#{project_id}/labels/#{label_id}"
|
40
38
|
)
|
41
|
-
|
42
|
-
request.perform
|
39
|
+
Web::SendRequest.new(request).perform
|
43
40
|
end
|
44
41
|
|
45
42
|
def delete_label(label_id = nil, project_id = config.project_id)
|
@@ -47,12 +44,11 @@ module Crowdin
|
|
47
44
|
project_id || raise_project_id_is_required_error
|
48
45
|
|
49
46
|
request = Web::Request.new(
|
50
|
-
|
47
|
+
connection,
|
51
48
|
:delete,
|
52
|
-
"/projects/#{project_id}/labels/#{label_id}"
|
49
|
+
"#{config.target_api_url}/projects/#{project_id}/labels/#{label_id}"
|
53
50
|
)
|
54
|
-
|
55
|
-
request.perform
|
51
|
+
Web::SendRequest.new(request).perform
|
56
52
|
end
|
57
53
|
|
58
54
|
def edit_label(label_id = nil, query = {}, project_id = config.project_id)
|
@@ -60,13 +56,12 @@ module Crowdin
|
|
60
56
|
project_id || raise_project_id_is_required_error
|
61
57
|
|
62
58
|
request = Web::Request.new(
|
63
|
-
|
59
|
+
connection,
|
64
60
|
:patch,
|
65
|
-
"/projects/#{project_id}/labels/#{label_id}",
|
66
|
-
query
|
61
|
+
"#{config.target_api_url}/projects/#{project_id}/labels/#{label_id}",
|
62
|
+
{ params: query }
|
67
63
|
)
|
68
|
-
|
69
|
-
request.perform
|
64
|
+
Web::SendRequest.new(request).perform
|
70
65
|
end
|
71
66
|
|
72
67
|
def assign_label_to_strings(label_id = nil, query = {}, project_id = config.project_id)
|
@@ -74,29 +69,17 @@ module Crowdin
|
|
74
69
|
project_id || raise_project_id_is_required_error
|
75
70
|
|
76
71
|
request = Web::Request.new(
|
77
|
-
|
72
|
+
connection,
|
78
73
|
:post,
|
79
|
-
"/projects/#{project_id}/labels/#{label_id}/strings",
|
80
|
-
query
|
74
|
+
"#{config.target_api_url}/projects/#{project_id}/labels/#{label_id}/strings",
|
75
|
+
{ params: query }
|
81
76
|
)
|
82
|
-
|
83
|
-
request.perform
|
77
|
+
Web::SendRequest.new(request).perform
|
84
78
|
end
|
85
79
|
|
86
|
-
# For now Rest Client Resource aren't support payload for DELETE requests.
|
87
|
-
# So we have workaround through Rest Client Execute for this case
|
88
80
|
def unassign_label_from_strings(label_id = nil, query = {}, project_id = config.project_id)
|
89
|
-
|
90
|
-
|
91
|
-
#
|
92
|
-
# request = Web::Request.new(
|
93
|
-
# self,
|
94
|
-
# :delete,
|
95
|
-
# "/projects/#{project_id}/labels/#{label_id}",
|
96
|
-
# query
|
97
|
-
# )
|
98
|
-
#
|
99
|
-
# request.perform
|
81
|
+
label_id || raise_parameter_is_required_error(:label_id)
|
82
|
+
project_id || raise_project_id_is_required_error
|
100
83
|
|
101
84
|
response = ::RestClient::Request.execute(
|
102
85
|
{
|
@@ -106,11 +89,9 @@ module Crowdin
|
|
106
89
|
}.merge(@options)
|
107
90
|
)
|
108
91
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
{}
|
113
|
-
end
|
92
|
+
response.body.empty? ? response.code : JSON.parse(response.body)
|
93
|
+
rescue StandardError => e
|
94
|
+
e.message
|
114
95
|
end
|
115
96
|
end
|
116
97
|
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
|