crowdin-api 1.2.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/.rubocop_todo.yml +96 -31
- data/README.md +8 -6
- data/bin/crowdin-console +1 -1
- data/crowdin-api.gemspec +1 -2
- 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 +63 -90
- 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 +40 -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 +51 -42
- data/lib/crowdin-api/client/configuration.rb +12 -12
- data/lib/crowdin-api/client/version.rb +1 -1
- data/lib/crowdin-api/core/errors_raisers.rb +1 -1
- data/lib/crowdin-api/core/request.rb +53 -88
- data/lib/crowdin-api/core/send_request.rb +67 -0
- data/lib/crowdin-api.rb +17 -24
- 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 +64 -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
@@ -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
|
@@ -7,26 +7,24 @@ module Crowdin
|
|
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}/screenshots",
|
13
|
-
query
|
12
|
+
"#{config.target_api_url}/projects/#{project_id}/screenshots",
|
13
|
+
{ params: query }
|
14
14
|
)
|
15
|
-
|
16
|
-
request.perform
|
15
|
+
Web::SendRequest.new(request).perform
|
17
16
|
end
|
18
17
|
|
19
18
|
def add_screenshot(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}/screenshots",
|
26
|
-
query
|
24
|
+
"#{config.target_api_url}/projects/#{project_id}/screenshots",
|
25
|
+
{ params: query }
|
27
26
|
)
|
28
|
-
|
29
|
-
request.perform
|
27
|
+
Web::SendRequest.new(request).perform
|
30
28
|
end
|
31
29
|
|
32
30
|
def get_screenshot(screenshot_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}/screenshots/#{screenshot_id}"
|
37
|
+
"#{config.target_api_url}/projects/#{project_id}/screenshots/#{screenshot_id}"
|
40
38
|
)
|
41
|
-
|
42
|
-
request.perform
|
39
|
+
Web::SendRequest.new(request).perform
|
43
40
|
end
|
44
41
|
|
45
42
|
def update_screenshot(screenshot_id = nil, query = {}, project_id = config.project_id)
|
@@ -47,13 +44,12 @@ 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
|
:put,
|
52
|
-
"/projects/#{project_id}/screenshots/#{screenshot_id}",
|
53
|
-
query
|
49
|
+
"#{config.target_api_url}/projects/#{project_id}/screenshots/#{screenshot_id}",
|
50
|
+
{ params: query }
|
54
51
|
)
|
55
|
-
|
56
|
-
request.perform
|
52
|
+
Web::SendRequest.new(request).perform
|
57
53
|
end
|
58
54
|
|
59
55
|
def delete_screenshot(screenshot_id = nil, project_id = config.project_id)
|
@@ -61,12 +57,11 @@ module Crowdin
|
|
61
57
|
project_id || raise_project_id_is_required_error
|
62
58
|
|
63
59
|
request = Web::Request.new(
|
64
|
-
|
60
|
+
connection,
|
65
61
|
:delete,
|
66
|
-
"/projects/#{project_id}/screenshots/#{screenshot_id}"
|
62
|
+
"#{config.target_api_url}/projects/#{project_id}/screenshots/#{screenshot_id}"
|
67
63
|
)
|
68
|
-
|
69
|
-
request.perform
|
64
|
+
Web::SendRequest.new(request).perform
|
70
65
|
end
|
71
66
|
|
72
67
|
def edit_screenshot(screenshot_id = nil, query = {}, project_id = config.project_id)
|
@@ -74,13 +69,12 @@ 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
|
:patch,
|
79
|
-
"/projects/#{project_id}/screenshots/#{screenshot_id}",
|
80
|
-
query
|
74
|
+
"#{config.target_api_url}/projects/#{project_id}/screenshots/#{screenshot_id}",
|
75
|
+
{ params: query }
|
81
76
|
)
|
82
|
-
|
83
|
-
request.perform
|
77
|
+
Web::SendRequest.new(request).perform
|
84
78
|
end
|
85
79
|
|
86
80
|
def list_tags(screenshot_id = nil, query = {}, project_id = config.project_id)
|
@@ -88,28 +82,25 @@ module Crowdin
|
|
88
82
|
project_id || raise_project_id_is_required_error
|
89
83
|
|
90
84
|
request = Web::Request.new(
|
91
|
-
|
85
|
+
connection,
|
92
86
|
:get,
|
93
|
-
"/projects/#{project_id}/screenshots/#{screenshot_id}/tags",
|
94
|
-
query
|
87
|
+
"#{config.target_api_url}/projects/#{project_id}/screenshots/#{screenshot_id}/tags",
|
88
|
+
{ params: query }
|
95
89
|
)
|
96
|
-
|
97
|
-
request.perform
|
90
|
+
Web::SendRequest.new(request).perform
|
98
91
|
end
|
99
92
|
|
100
|
-
# Auto tag
|
101
93
|
def replace_tags(screenshot_id = nil, query = {}, project_id = config.project_id)
|
102
94
|
screenshot_id || raise_parameter_is_required_error(:screenshot_id)
|
103
95
|
project_id || raise_project_id_is_required_error
|
104
96
|
|
105
97
|
request = Web::Request.new(
|
106
|
-
|
98
|
+
connection,
|
107
99
|
:put,
|
108
|
-
"/projects/#{project_id}/screenshots/#{screenshot_id}/tags",
|
109
|
-
query
|
100
|
+
"#{config.target_api_url}/projects/#{project_id}/screenshots/#{screenshot_id}/tags",
|
101
|
+
{ params: query }
|
110
102
|
)
|
111
|
-
|
112
|
-
request.perform
|
103
|
+
Web::SendRequest.new(request).perform
|
113
104
|
end
|
114
105
|
|
115
106
|
def add_tag(screenshot_id = nil, query = {}, project_id = config.project_id)
|
@@ -117,13 +108,12 @@ module Crowdin
|
|
117
108
|
project_id || raise_project_id_is_required_error
|
118
109
|
|
119
110
|
request = Web::Request.new(
|
120
|
-
|
111
|
+
connection,
|
121
112
|
:post,
|
122
|
-
"/projects/#{project_id}/screenshots/#{screenshot_id}/tags",
|
123
|
-
query
|
113
|
+
"#{config.target_api_url}/projects/#{project_id}/screenshots/#{screenshot_id}/tags",
|
114
|
+
{ params: query }
|
124
115
|
)
|
125
|
-
|
126
|
-
request.perform
|
116
|
+
Web::SendRequest.new(request).perform
|
127
117
|
end
|
128
118
|
|
129
119
|
def clear_tags(screenshot_id = nil, project_id = config.project_id)
|
@@ -131,12 +121,11 @@ module Crowdin
|
|
131
121
|
project_id || raise_project_id_is_required_error
|
132
122
|
|
133
123
|
request = Web::Request.new(
|
134
|
-
|
124
|
+
connection,
|
135
125
|
:delete,
|
136
|
-
"/projects/#{project_id}/screenshots/#{screenshot_id}/tags"
|
126
|
+
"#{config.target_api_url}/projects/#{project_id}/screenshots/#{screenshot_id}/tags"
|
137
127
|
)
|
138
|
-
|
139
|
-
request.perform
|
128
|
+
Web::SendRequest.new(request).perform
|
140
129
|
end
|
141
130
|
|
142
131
|
def get_tag(screenshot_id = nil, tag_id = nil, project_id = config.project_id)
|
@@ -145,12 +134,11 @@ module Crowdin
|
|
145
134
|
project_id || raise_project_id_is_required_error
|
146
135
|
|
147
136
|
request = Web::Request.new(
|
148
|
-
|
137
|
+
connection,
|
149
138
|
:get,
|
150
|
-
"/projects/#{project_id}/screenshots/#{screenshot_id}/tags/#{tag_id}"
|
139
|
+
"#{config.target_api_url}/projects/#{project_id}/screenshots/#{screenshot_id}/tags/#{tag_id}"
|
151
140
|
)
|
152
|
-
|
153
|
-
request.perform
|
141
|
+
Web::SendRequest.new(request).perform
|
154
142
|
end
|
155
143
|
|
156
144
|
def delete_tag(screenshot_id = nil, tag_id = nil, project_id = config.project_id)
|
@@ -159,12 +147,11 @@ module Crowdin
|
|
159
147
|
project_id || raise_project_id_is_required_error
|
160
148
|
|
161
149
|
request = Web::Request.new(
|
162
|
-
|
150
|
+
connection,
|
163
151
|
:delete,
|
164
|
-
"/projects/#{project_id}/screenshots/#{screenshot_id}/tags/#{tag_id}"
|
152
|
+
"#{config.target_api_url}/projects/#{project_id}/screenshots/#{screenshot_id}/tags/#{tag_id}"
|
165
153
|
)
|
166
|
-
|
167
|
-
request.perform
|
154
|
+
Web::SendRequest.new(request).perform
|
168
155
|
end
|
169
156
|
|
170
157
|
def edit_tag(screenshot_id = nil, tag_id = nil, query = {}, project_id = config.project_id)
|
@@ -173,13 +160,12 @@ module Crowdin
|
|
173
160
|
project_id || raise_project_id_is_required_error
|
174
161
|
|
175
162
|
request = Web::Request.new(
|
176
|
-
|
163
|
+
connection,
|
177
164
|
:patch,
|
178
|
-
"/projects/#{project_id}/screenshots/#{screenshot_id}/tags/#{tag_id}",
|
179
|
-
query
|
165
|
+
"#{config.target_api_url}/projects/#{project_id}/screenshots/#{screenshot_id}/tags/#{tag_id}",
|
166
|
+
{ params: query }
|
180
167
|
)
|
181
|
-
|
182
|
-
request.perform
|
168
|
+
Web::SendRequest.new(request).perform
|
183
169
|
end
|
184
170
|
end
|
185
171
|
end
|