crowdin-api 0.6.0 → 1.2.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/build-and-publish.yml +30 -0
- data/.github/workflows/test-and-lint.yml +31 -0
- data/.gitignore +12 -0
- data/.rspec +2 -0
- data/.rubocop.yml +5 -0
- data/.rubocop_todo.yml +146 -0
- data/CODE_OF_CONDUCT.md +128 -0
- data/CONTRIBUTING.md +71 -0
- data/Gemfile +5 -0
- data/LICENSE +1 -1
- data/README.md +120 -280
- data/Rakefile +19 -0
- data/bin/crowdin-console +54 -0
- data/bin/setup +6 -0
- data/crowdin-api.gemspec +33 -0
- data/lib/crowdin-api/api-resources/dictionaries.rb +34 -0
- data/lib/crowdin-api/api-resources/distributions.rb +99 -0
- data/lib/crowdin-api/api-resources/glossaries.rb +217 -0
- data/lib/crowdin-api/api-resources/labels.rb +117 -0
- data/lib/crowdin-api/api-resources/languages.rb +82 -0
- data/lib/crowdin-api/api-resources/machine_translation_engines.rb +74 -0
- data/lib/crowdin-api/api-resources/projects.rb +148 -0
- data/lib/crowdin-api/api-resources/reports.rb +138 -0
- data/lib/crowdin-api/api-resources/screenshots.rb +186 -0
- data/lib/crowdin-api/api-resources/source_files.rb +304 -0
- data/lib/crowdin-api/api-resources/source_strings.rb +74 -0
- data/lib/crowdin-api/api-resources/storages.rb +106 -0
- data/lib/crowdin-api/api-resources/string_comments.rb +73 -0
- data/lib/crowdin-api/api-resources/string_translations.rb +220 -0
- data/lib/crowdin-api/api-resources/tasks.rb +113 -0
- data/lib/crowdin-api/api-resources/teams.rb +144 -0
- data/lib/crowdin-api/api-resources/translation_memory.rb +145 -0
- data/lib/crowdin-api/api-resources/translation_status.rb +89 -0
- data/lib/crowdin-api/api-resources/translations.rb +161 -0
- data/lib/crowdin-api/api-resources/users.rb +129 -0
- data/lib/crowdin-api/api-resources/vendors.rb +21 -0
- data/lib/crowdin-api/api-resources/webhooks.rb +73 -0
- data/lib/crowdin-api/api-resources/workflows.rb +62 -0
- data/lib/crowdin-api/client/client.rb +95 -0
- data/lib/crowdin-api/client/configuration.rb +48 -0
- data/lib/crowdin-api/client/version.rb +7 -0
- data/lib/crowdin-api/core/errors.rb +8 -0
- data/lib/crowdin-api/core/errors_raisers.rb +39 -0
- data/lib/crowdin-api/core/request.rb +118 -0
- data/lib/crowdin-api/core/utils.rb +10 -0
- data/lib/crowdin-api.rb +39 -126
- data/spec/client/client-instance_spec.rb +14 -0
- data/spec/client/configuration-instance_spec.rb +72 -0
- data/spec/spec_helper.rb +9 -0
- metadata +130 -47
- data/lib/crowdin-api/errors.rb +0 -23
- data/lib/crowdin-api/methods.rb +0 -452
- data/lib/crowdin-api/version.rb +0 -5
@@ -0,0 +1,148 @@
|
|
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
|
+
self,
|
9
|
+
:get,
|
10
|
+
'/projects',
|
11
|
+
query
|
12
|
+
)
|
13
|
+
|
14
|
+
request.perform
|
15
|
+
end
|
16
|
+
|
17
|
+
def add_project(query = {})
|
18
|
+
request = Web::Request.new(
|
19
|
+
self,
|
20
|
+
:post,
|
21
|
+
'/projects',
|
22
|
+
query
|
23
|
+
)
|
24
|
+
|
25
|
+
request.perform
|
26
|
+
end
|
27
|
+
|
28
|
+
def get_project(project_id = nil)
|
29
|
+
project_id || raise_parameter_is_required_error(:project_id)
|
30
|
+
|
31
|
+
request = Web::Request.new(
|
32
|
+
self,
|
33
|
+
:get,
|
34
|
+
"/projects/#{project_id}"
|
35
|
+
)
|
36
|
+
|
37
|
+
request.perform
|
38
|
+
end
|
39
|
+
|
40
|
+
def delete_project(project_id = nil)
|
41
|
+
project_id || raise_parameter_is_required_error(:project_id)
|
42
|
+
|
43
|
+
request = Web::Request.new(
|
44
|
+
self,
|
45
|
+
:delete,
|
46
|
+
"/projects/#{project_id}"
|
47
|
+
)
|
48
|
+
|
49
|
+
request.perform
|
50
|
+
end
|
51
|
+
|
52
|
+
#
|
53
|
+
# Edit project.
|
54
|
+
#
|
55
|
+
# === Parameters
|
56
|
+
#
|
57
|
+
# * +:projectId+ [Integer] - Project Identifier. Get via list_projects. Can be initialized with the Crowdin Client
|
58
|
+
# * +:value+ [String] - String or Array of strings.
|
59
|
+
# * +:op+ [String] - Path operation to perform.
|
60
|
+
# * +:projectId+ [String <json-pointer>] - Enum, for instance '/name'. Full list you can see on the developers site.
|
61
|
+
#
|
62
|
+
# === Example
|
63
|
+
#
|
64
|
+
# crowdin.edit_project(project_id, [{op: 'replace', path: '/name', value: 'your_new_project_name'}])
|
65
|
+
#
|
66
|
+
def edit_project(project_id = nil, query = {})
|
67
|
+
project_id || raise_parameter_is_required_error(:project_id)
|
68
|
+
|
69
|
+
request = Web::Request.new(
|
70
|
+
self,
|
71
|
+
:patch,
|
72
|
+
"/projects/#{project_id}",
|
73
|
+
query
|
74
|
+
)
|
75
|
+
|
76
|
+
request.perform
|
77
|
+
end
|
78
|
+
|
79
|
+
# -- For Enterprise mode only --
|
80
|
+
|
81
|
+
def list_groups(query = {})
|
82
|
+
config.enterprise_mode? || raise_only_for_enterprise_mode_error
|
83
|
+
|
84
|
+
request = Web::Request.new(
|
85
|
+
self,
|
86
|
+
:get,
|
87
|
+
'/groups',
|
88
|
+
query
|
89
|
+
)
|
90
|
+
|
91
|
+
request.perform
|
92
|
+
end
|
93
|
+
|
94
|
+
def add_group(query = {})
|
95
|
+
config.enterprise_mode? || raise_only_for_enterprise_mode_error
|
96
|
+
|
97
|
+
request = Web::Request.new(
|
98
|
+
self,
|
99
|
+
:post,
|
100
|
+
'/groups',
|
101
|
+
query
|
102
|
+
)
|
103
|
+
|
104
|
+
request.perform
|
105
|
+
end
|
106
|
+
|
107
|
+
def get_group(group_id = nil)
|
108
|
+
config.enterprise_mode? || raise_only_for_enterprise_mode_error
|
109
|
+
group_id || raise_parameter_is_required_error(:group_id)
|
110
|
+
|
111
|
+
request = Web::Request.new(
|
112
|
+
self,
|
113
|
+
:get,
|
114
|
+
"/groups/#{group_id}"
|
115
|
+
)
|
116
|
+
|
117
|
+
request.perform
|
118
|
+
end
|
119
|
+
|
120
|
+
def delete_group(group_id = nil)
|
121
|
+
config.enterprise_mode? || raise_only_for_enterprise_mode_error
|
122
|
+
group_id || raise_parameter_is_required_error(:group_id)
|
123
|
+
|
124
|
+
request = Web::Request.new(
|
125
|
+
self,
|
126
|
+
:delete,
|
127
|
+
"/groups/#{group_id}"
|
128
|
+
)
|
129
|
+
|
130
|
+
request.perform
|
131
|
+
end
|
132
|
+
|
133
|
+
def edit_group(group_id = nil, query = {})
|
134
|
+
config.enterprise_mode? || raise_only_for_enterprise_mode_error
|
135
|
+
group_id || raise_parameter_is_required_error(:group_id)
|
136
|
+
|
137
|
+
request = Web::Request.new(
|
138
|
+
self,
|
139
|
+
:patch,
|
140
|
+
"/groups/#{group_id}",
|
141
|
+
query
|
142
|
+
)
|
143
|
+
|
144
|
+
request.perform
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
@@ -0,0 +1,138 @@
|
|
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
|
+
self,
|
11
|
+
:post,
|
12
|
+
"/projects/#{project_id}/reports",
|
13
|
+
query
|
14
|
+
)
|
15
|
+
|
16
|
+
request.perform
|
17
|
+
end
|
18
|
+
|
19
|
+
def check_report_generation_status(report_id = nil, project_id = config.project_id)
|
20
|
+
report_id || raise_parameter_is_required_error(:report_id)
|
21
|
+
project_id || raise_project_id_is_required_error
|
22
|
+
|
23
|
+
request = Web::Request.new(
|
24
|
+
self,
|
25
|
+
:get,
|
26
|
+
"/projects/#{project_id}/reports/#{report_id}"
|
27
|
+
)
|
28
|
+
|
29
|
+
request.perform
|
30
|
+
end
|
31
|
+
|
32
|
+
def download_report(report_id = nil, destination = nil, project_id = config.project_id)
|
33
|
+
report_id || raise_parameter_is_required_error(:report_id)
|
34
|
+
project_id || raise_project_id_is_required_error
|
35
|
+
|
36
|
+
request = Web::Request.new(
|
37
|
+
self,
|
38
|
+
:get,
|
39
|
+
"/projects/#{project_id}/reports/#{report_id}/download",
|
40
|
+
{},
|
41
|
+
{},
|
42
|
+
destination
|
43
|
+
)
|
44
|
+
|
45
|
+
request.perform
|
46
|
+
end
|
47
|
+
|
48
|
+
# -- For Enterprise mode only --
|
49
|
+
|
50
|
+
def generate_group_report(group_id = nil, query = {})
|
51
|
+
config.enterprise_mode? || raise_only_for_enterprise_mode_error
|
52
|
+
group_id || raise_parameter_is_required_error(:group_id)
|
53
|
+
|
54
|
+
request = Web::Request.new(
|
55
|
+
self,
|
56
|
+
:post,
|
57
|
+
"/groups/#{group_id}/reports",
|
58
|
+
query
|
59
|
+
)
|
60
|
+
|
61
|
+
request.perform
|
62
|
+
end
|
63
|
+
|
64
|
+
def check_group_report_generation_status(group_id = nil, report_id = nil)
|
65
|
+
config.enterprise_mode? || raise_only_for_enterprise_mode_error
|
66
|
+
group_id || raise_parameter_is_required_error(:group_id)
|
67
|
+
report_id || raise_parameter_is_required_error(:report_id)
|
68
|
+
|
69
|
+
request = Web::Request.new(
|
70
|
+
self,
|
71
|
+
:get,
|
72
|
+
"/groups/#{group_id}/reports/#{report_id}"
|
73
|
+
)
|
74
|
+
|
75
|
+
request.perform
|
76
|
+
end
|
77
|
+
|
78
|
+
def download_group_report(group_id = nil, report_id = nil, destination = nil)
|
79
|
+
config.enterprise_mode? || raise_only_for_enterprise_mode_error
|
80
|
+
group_id || raise_parameter_is_required_error(:group_id)
|
81
|
+
report_id || raise_parameter_is_required_error(:report_id)
|
82
|
+
|
83
|
+
request = Web::Request.new(
|
84
|
+
self,
|
85
|
+
:get,
|
86
|
+
"/groups/#{group_id}/reports/#{report_id}/download",
|
87
|
+
{},
|
88
|
+
{},
|
89
|
+
destination
|
90
|
+
)
|
91
|
+
|
92
|
+
request.perform
|
93
|
+
end
|
94
|
+
|
95
|
+
def generate_organization_report(query = {})
|
96
|
+
config.enterprise_mode? || raise_only_for_enterprise_mode_error
|
97
|
+
|
98
|
+
request = Web::Request.new(
|
99
|
+
self,
|
100
|
+
:post,
|
101
|
+
'/reports',
|
102
|
+
query
|
103
|
+
)
|
104
|
+
|
105
|
+
request.perform
|
106
|
+
end
|
107
|
+
|
108
|
+
def check_organization_report_generation_status(report_id = nil)
|
109
|
+
config.enterprise_mode? || raise_only_for_enterprise_mode_error
|
110
|
+
report_id || raise_parameter_is_required_error(:report_id)
|
111
|
+
|
112
|
+
request = Web::Request.new(
|
113
|
+
self,
|
114
|
+
:get,
|
115
|
+
"/reports/#{report_id}"
|
116
|
+
)
|
117
|
+
|
118
|
+
request.perform
|
119
|
+
end
|
120
|
+
|
121
|
+
def download_organization_report(report_id = nil, destination = nil)
|
122
|
+
config.enterprise_mode? || raise_only_for_enterprise_mode_error
|
123
|
+
report_id || raise_parameter_is_required_error(:report_id)
|
124
|
+
|
125
|
+
request = Web::Request.new(
|
126
|
+
self,
|
127
|
+
:get,
|
128
|
+
"/reports/#{report_id}/download",
|
129
|
+
{},
|
130
|
+
{},
|
131
|
+
destination
|
132
|
+
)
|
133
|
+
|
134
|
+
request.perform
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
@@ -0,0 +1,186 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Crowdin
|
4
|
+
module ApiResources
|
5
|
+
module Screenshots
|
6
|
+
def list_screenshots(query = {}, project_id = config.project_id)
|
7
|
+
project_id || raise_project_id_is_required_error
|
8
|
+
|
9
|
+
request = Web::Request.new(
|
10
|
+
self,
|
11
|
+
:get,
|
12
|
+
"/projects/#{project_id}/screenshots",
|
13
|
+
query
|
14
|
+
)
|
15
|
+
|
16
|
+
request.perform
|
17
|
+
end
|
18
|
+
|
19
|
+
def add_screenshot(query = {}, project_id = config.project_id)
|
20
|
+
project_id || raise_project_id_is_required_error
|
21
|
+
|
22
|
+
request = Web::Request.new(
|
23
|
+
self,
|
24
|
+
:post,
|
25
|
+
"/projects/#{project_id}/screenshots",
|
26
|
+
query
|
27
|
+
)
|
28
|
+
|
29
|
+
request.perform
|
30
|
+
end
|
31
|
+
|
32
|
+
def get_screenshot(screenshot_id = nil, project_id = config.project_id)
|
33
|
+
screenshot_id || raise_parameter_is_required_error(:screenshot_id)
|
34
|
+
project_id || raise_project_id_is_required_error
|
35
|
+
|
36
|
+
request = Web::Request.new(
|
37
|
+
self,
|
38
|
+
:get,
|
39
|
+
"/projects/#{project_id}/screenshots/#{screenshot_id}"
|
40
|
+
)
|
41
|
+
|
42
|
+
request.perform
|
43
|
+
end
|
44
|
+
|
45
|
+
def update_screenshot(screenshot_id = nil, query = {}, project_id = config.project_id)
|
46
|
+
screenshot_id || raise_parameter_is_required_error(:screenshot_id)
|
47
|
+
project_id || raise_project_id_is_required_error
|
48
|
+
|
49
|
+
request = Web::Request.new(
|
50
|
+
self,
|
51
|
+
:put,
|
52
|
+
"/projects/#{project_id}/screenshots/#{screenshot_id}",
|
53
|
+
query
|
54
|
+
)
|
55
|
+
|
56
|
+
request.perform
|
57
|
+
end
|
58
|
+
|
59
|
+
def delete_screenshot(screenshot_id = nil, project_id = config.project_id)
|
60
|
+
screenshot_id || raise_parameter_is_required_error(:screenshot_id)
|
61
|
+
project_id || raise_project_id_is_required_error
|
62
|
+
|
63
|
+
request = Web::Request.new(
|
64
|
+
self,
|
65
|
+
:delete,
|
66
|
+
"/projects/#{project_id}/screenshots/#{screenshot_id}"
|
67
|
+
)
|
68
|
+
|
69
|
+
request.perform
|
70
|
+
end
|
71
|
+
|
72
|
+
def edit_screenshot(screenshot_id = nil, query = {}, project_id = config.project_id)
|
73
|
+
screenshot_id || raise_parameter_is_required_error(:screenshot_id)
|
74
|
+
project_id || raise_project_id_is_required_error
|
75
|
+
|
76
|
+
request = Web::Request.new(
|
77
|
+
self,
|
78
|
+
:patch,
|
79
|
+
"/projects/#{project_id}/screenshots/#{screenshot_id}",
|
80
|
+
query
|
81
|
+
)
|
82
|
+
|
83
|
+
request.perform
|
84
|
+
end
|
85
|
+
|
86
|
+
def list_tags(screenshot_id = nil, query = {}, project_id = config.project_id)
|
87
|
+
screenshot_id || raise_parameter_is_required_error(:screenshot_id)
|
88
|
+
project_id || raise_project_id_is_required_error
|
89
|
+
|
90
|
+
request = Web::Request.new(
|
91
|
+
self,
|
92
|
+
:get,
|
93
|
+
"/projects/#{project_id}/screenshots/#{screenshot_id}/tags",
|
94
|
+
query
|
95
|
+
)
|
96
|
+
|
97
|
+
request.perform
|
98
|
+
end
|
99
|
+
|
100
|
+
# Auto tag
|
101
|
+
def replace_tags(screenshot_id = nil, query = {}, project_id = config.project_id)
|
102
|
+
screenshot_id || raise_parameter_is_required_error(:screenshot_id)
|
103
|
+
project_id || raise_project_id_is_required_error
|
104
|
+
|
105
|
+
request = Web::Request.new(
|
106
|
+
self,
|
107
|
+
:put,
|
108
|
+
"/projects/#{project_id}/screenshots/#{screenshot_id}/tags",
|
109
|
+
query
|
110
|
+
)
|
111
|
+
|
112
|
+
request.perform
|
113
|
+
end
|
114
|
+
|
115
|
+
def add_tag(screenshot_id = nil, query = {}, project_id = config.project_id)
|
116
|
+
screenshot_id || raise_parameter_is_required_error(:screenshot_id)
|
117
|
+
project_id || raise_project_id_is_required_error
|
118
|
+
|
119
|
+
request = Web::Request.new(
|
120
|
+
self,
|
121
|
+
:post,
|
122
|
+
"/projects/#{project_id}/screenshots/#{screenshot_id}/tags",
|
123
|
+
query
|
124
|
+
)
|
125
|
+
|
126
|
+
request.perform
|
127
|
+
end
|
128
|
+
|
129
|
+
def clear_tags(screenshot_id = nil, project_id = config.project_id)
|
130
|
+
screenshot_id || raise_parameter_is_required_error(:screenshot_id)
|
131
|
+
project_id || raise_project_id_is_required_error
|
132
|
+
|
133
|
+
request = Web::Request.new(
|
134
|
+
self,
|
135
|
+
:delete,
|
136
|
+
"/projects/#{project_id}/screenshots/#{screenshot_id}/tags"
|
137
|
+
)
|
138
|
+
|
139
|
+
request.perform
|
140
|
+
end
|
141
|
+
|
142
|
+
def get_tag(screenshot_id = nil, tag_id = nil, project_id = config.project_id)
|
143
|
+
screenshot_id || raise_parameter_is_required_error(:screenshot_id)
|
144
|
+
tag_id || raise_parameter_is_required_error(:tag_id)
|
145
|
+
project_id || raise_project_id_is_required_error
|
146
|
+
|
147
|
+
request = Web::Request.new(
|
148
|
+
self,
|
149
|
+
:get,
|
150
|
+
"/projects/#{project_id}/screenshots/#{screenshot_id}/tags/#{tag_id}"
|
151
|
+
)
|
152
|
+
|
153
|
+
request.perform
|
154
|
+
end
|
155
|
+
|
156
|
+
def delete_tag(screenshot_id = nil, tag_id = nil, project_id = config.project_id)
|
157
|
+
screenshot_id || raise_parameter_is_required_error(:screenshot_id)
|
158
|
+
tag_id || raise_parameter_is_required_error(:tag_id)
|
159
|
+
project_id || raise_project_id_is_required_error
|
160
|
+
|
161
|
+
request = Web::Request.new(
|
162
|
+
self,
|
163
|
+
:delete,
|
164
|
+
"/projects/#{project_id}/screenshots/#{screenshot_id}/tags/#{tag_id}"
|
165
|
+
)
|
166
|
+
|
167
|
+
request.perform
|
168
|
+
end
|
169
|
+
|
170
|
+
def edit_tag(screenshot_id = nil, tag_id = nil, query = {}, project_id = config.project_id)
|
171
|
+
screenshot_id || raise_parameter_is_required_error(:screenshot_id)
|
172
|
+
tag_id || raise_parameter_is_required_error(:tag_id)
|
173
|
+
project_id || raise_project_id_is_required_error
|
174
|
+
|
175
|
+
request = Web::Request.new(
|
176
|
+
self,
|
177
|
+
:patch,
|
178
|
+
"/projects/#{project_id}/screenshots/#{screenshot_id}/tags/#{tag_id}",
|
179
|
+
query
|
180
|
+
)
|
181
|
+
|
182
|
+
request.perform
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|