ruby-lokalise-api 7.2.0 → 8.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ruby_lokalise_api/base_client.rb +2 -34
- data/lib/ruby_lokalise_api/client.rb +2 -31
- data/lib/ruby_lokalise_api/collections/base.rb +97 -70
- data/lib/ruby_lokalise_api/collections/branches.rb +11 -0
- data/lib/ruby_lokalise_api/collections/contributors.rb +10 -0
- data/lib/ruby_lokalise_api/collections/custom_translation_statuses.rb +10 -0
- data/lib/ruby_lokalise_api/collections/files.rb +10 -0
- data/lib/ruby_lokalise_api/collections/key_comments.rb +11 -0
- data/lib/ruby_lokalise_api/collections/keys.rb +10 -0
- data/lib/ruby_lokalise_api/collections/orders.rb +10 -0
- data/lib/ruby_lokalise_api/collections/payment_cards.rb +10 -0
- data/lib/ruby_lokalise_api/collections/project_comments.rb +12 -0
- data/lib/ruby_lokalise_api/collections/project_languages.rb +11 -0
- data/lib/ruby_lokalise_api/collections/projects.rb +10 -0
- data/lib/ruby_lokalise_api/collections/queued_processes.rb +11 -0
- data/lib/ruby_lokalise_api/collections/screenshots.rb +10 -0
- data/lib/ruby_lokalise_api/collections/segments.rb +10 -0
- data/lib/ruby_lokalise_api/collections/snapshots.rb +10 -0
- data/lib/ruby_lokalise_api/collections/system_languages.rb +11 -0
- data/lib/ruby_lokalise_api/collections/tasks.rb +10 -0
- data/lib/ruby_lokalise_api/collections/team_user_groups.rb +11 -0
- data/lib/ruby_lokalise_api/collections/team_users.rb +10 -0
- data/lib/ruby_lokalise_api/collections/teams.rb +10 -0
- data/lib/ruby_lokalise_api/collections/translation_providers.rb +10 -0
- data/lib/ruby_lokalise_api/collections/translations.rb +10 -0
- data/lib/ruby_lokalise_api/collections/webhooks.rb +10 -0
- data/lib/ruby_lokalise_api/concerns/attrs_loadable.rb +31 -0
- data/lib/ruby_lokalise_api/concerns/hash_accessible.rb +16 -0
- data/lib/ruby_lokalise_api/concerns/unsupportable.rb +16 -0
- data/lib/ruby_lokalise_api/connection.rb +18 -9
- data/lib/ruby_lokalise_api/data/collection_attributes.yml +52 -0
- data/lib/ruby_lokalise_api/data/{attributes.yml → resource_attributes.yml} +64 -6
- data/lib/ruby_lokalise_api/endpoints/base_endpoint.rb +66 -0
- data/lib/ruby_lokalise_api/endpoints/branches_endpoint.rb +16 -0
- data/lib/ruby_lokalise_api/endpoints/contributors_endpoint.rb +16 -0
- data/lib/ruby_lokalise_api/endpoints/custom_translation_statuses_endpoint.rb +16 -0
- data/lib/ruby_lokalise_api/endpoints/files_endpoint.rb +16 -0
- data/lib/ruby_lokalise_api/endpoints/jwts_endpoint.rb +15 -0
- data/lib/ruby_lokalise_api/endpoints/key_comments_endpoint.rb +17 -0
- data/lib/ruby_lokalise_api/endpoints/keys_endpoint.rb +16 -0
- data/lib/ruby_lokalise_api/endpoints/main_endpoint.rb +25 -0
- data/lib/ruby_lokalise_api/endpoints/oauth2/oauth2_endpoint.rb +33 -0
- data/lib/ruby_lokalise_api/endpoints/orders_endpoint.rb +16 -0
- data/lib/ruby_lokalise_api/endpoints/payment_cards_endpoint.rb +15 -0
- data/lib/ruby_lokalise_api/endpoints/project_comments_endpoint.rb +15 -0
- data/lib/ruby_lokalise_api/endpoints/project_languages_endpoint.rb +16 -0
- data/lib/ruby_lokalise_api/endpoints/projects_endpoint.rb +15 -0
- data/lib/ruby_lokalise_api/endpoints/queued_processes_endpoint.rb +16 -0
- data/lib/ruby_lokalise_api/endpoints/screenshots_endpoint.rb +16 -0
- data/lib/ruby_lokalise_api/endpoints/segments_endpoint.rb +17 -0
- data/lib/ruby_lokalise_api/endpoints/snapshots_endpoint.rb +16 -0
- data/lib/ruby_lokalise_api/endpoints/system_languages_endpoint.rb +15 -0
- data/lib/ruby_lokalise_api/endpoints/tasks_endpoint.rb +16 -0
- data/lib/ruby_lokalise_api/endpoints/team_user_billing_details_endpoint.rb +15 -0
- data/lib/ruby_lokalise_api/endpoints/team_user_groups_endpoint.rb +16 -0
- data/lib/ruby_lokalise_api/endpoints/team_users_endpoint.rb +16 -0
- data/lib/ruby_lokalise_api/endpoints/teams_endpoint.rb +13 -0
- data/lib/ruby_lokalise_api/endpoints/translation_providers_endpoint.rb +16 -0
- data/lib/ruby_lokalise_api/endpoints/translations_endpoint.rb +16 -0
- data/lib/ruby_lokalise_api/endpoints/webhooks_endpoint.rb +16 -0
- data/lib/ruby_lokalise_api/error.rb +1 -0
- data/lib/ruby_lokalise_api/generics.rb +25 -0
- data/lib/ruby_lokalise_api/json_handler.rb +1 -2
- data/lib/ruby_lokalise_api/oauth2/auth.rb +33 -39
- data/lib/ruby_lokalise_api/oauth2_client.rb +3 -0
- data/lib/ruby_lokalise_api/request.rb +66 -18
- data/lib/ruby_lokalise_api/resources/base.rb +41 -185
- data/lib/ruby_lokalise_api/resources/branch.rb +2 -21
- data/lib/ruby_lokalise_api/resources/comment.rb +11 -0
- data/lib/ruby_lokalise_api/resources/contributor.rb +1 -9
- data/lib/ruby_lokalise_api/resources/custom_translation_status.rb +1 -13
- data/lib/ruby_lokalise_api/resources/file.rb +2 -16
- data/lib/ruby_lokalise_api/resources/jwt.rb +2 -5
- data/lib/ruby_lokalise_api/resources/key.rb +5 -8
- data/lib/ruby_lokalise_api/resources/oauth2_refreshed_token.rb +9 -0
- data/lib/ruby_lokalise_api/resources/oauth2_token.rb +9 -0
- data/lib/ruby_lokalise_api/resources/order.rb +2 -9
- data/lib/ruby_lokalise_api/resources/payment_card.rb +2 -8
- data/lib/ruby_lokalise_api/resources/project.rb +85 -16
- data/lib/ruby_lokalise_api/resources/project_language.rb +2 -10
- data/lib/ruby_lokalise_api/resources/queued_process.rb +3 -10
- data/lib/ruby_lokalise_api/resources/screenshot.rb +1 -9
- data/lib/ruby_lokalise_api/resources/segment.rb +2 -11
- data/lib/ruby_lokalise_api/resources/snapshot.rb +3 -18
- data/lib/ruby_lokalise_api/resources/system_language.rb +2 -1
- data/lib/ruby_lokalise_api/resources/task.rb +1 -9
- data/lib/ruby_lokalise_api/resources/team.rb +2 -0
- data/lib/ruby_lokalise_api/resources/team_user.rb +1 -9
- data/lib/ruby_lokalise_api/resources/team_user_billing_details.rb +10 -5
- data/lib/ruby_lokalise_api/resources/team_user_group.rb +6 -14
- data/lib/ruby_lokalise_api/resources/translation.rb +2 -9
- data/lib/ruby_lokalise_api/resources/translation_provider.rb +2 -9
- data/lib/ruby_lokalise_api/resources/webhook.rb +2 -16
- data/lib/ruby_lokalise_api/response.rb +50 -0
- data/lib/ruby_lokalise_api/rest/branches.rb +52 -27
- data/lib/ruby_lokalise_api/rest/comments.rb +48 -23
- data/lib/ruby_lokalise_api/rest/contributors.rb +47 -23
- data/lib/ruby_lokalise_api/rest/custom_translation_statuses.rb +60 -36
- data/lib/ruby_lokalise_api/rest/files.rb +43 -24
- data/lib/ruby_lokalise_api/rest/jwts.rb +21 -0
- data/lib/ruby_lokalise_api/rest/keys.rb +67 -34
- data/lib/ruby_lokalise_api/rest/languages.rb +57 -28
- data/lib/ruby_lokalise_api/rest/orders.rb +36 -14
- data/lib/ruby_lokalise_api/rest/payment_cards.rb +29 -12
- data/lib/ruby_lokalise_api/rest/projects.rb +55 -32
- data/lib/ruby_lokalise_api/rest/queued_processes.rb +21 -13
- data/lib/ruby_lokalise_api/rest/screenshots.rb +45 -20
- data/lib/ruby_lokalise_api/rest/segments.rb +31 -18
- data/lib/ruby_lokalise_api/rest/snapshots.rb +34 -14
- data/lib/ruby_lokalise_api/rest/tasks.rb +41 -19
- data/lib/ruby_lokalise_api/rest/team_user_billing_details.rb +33 -12
- data/lib/ruby_lokalise_api/rest/team_user_groups.rb +82 -50
- data/lib/ruby_lokalise_api/rest/team_users.rb +35 -18
- data/lib/ruby_lokalise_api/rest/teams.rb +10 -5
- data/lib/ruby_lokalise_api/rest/translation_providers.rb +24 -9
- data/lib/ruby_lokalise_api/rest/translations.rb +28 -15
- data/lib/ruby_lokalise_api/rest/webhooks.rb +54 -30
- data/lib/ruby_lokalise_api/rest.rb +31 -0
- data/lib/ruby_lokalise_api/utils/attributes.rb +37 -0
- data/lib/ruby_lokalise_api/utils/classes.rb +24 -0
- data/lib/ruby_lokalise_api/utils/keys.rb +29 -0
- data/lib/ruby_lokalise_api/utils/loaders.rb +24 -0
- data/lib/ruby_lokalise_api/utils/strings.rb +20 -0
- data/lib/ruby_lokalise_api/version.rb +1 -1
- data/lib/ruby_lokalise_api.rb +6 -2
- data/ruby-lokalise-api.gemspec +2 -2
- metadata +76 -41
- data/lib/ruby_lokalise_api/base_request.rb +0 -73
- data/lib/ruby_lokalise_api/collections/branch.rb +0 -15
- data/lib/ruby_lokalise_api/collections/contributor.rb +0 -13
- data/lib/ruby_lokalise_api/collections/custom_translation_status.rb +0 -15
- data/lib/ruby_lokalise_api/collections/file.rb +0 -13
- data/lib/ruby_lokalise_api/collections/key.rb +0 -20
- data/lib/ruby_lokalise_api/collections/key_comment.rb +0 -14
- data/lib/ruby_lokalise_api/collections/order.rb +0 -13
- data/lib/ruby_lokalise_api/collections/payment_card.rb +0 -13
- data/lib/ruby_lokalise_api/collections/project.rb +0 -13
- data/lib/ruby_lokalise_api/collections/project_comment.rb +0 -13
- data/lib/ruby_lokalise_api/collections/project_language.rb +0 -13
- data/lib/ruby_lokalise_api/collections/queued_process.rb +0 -15
- data/lib/ruby_lokalise_api/collections/screenshot.rb +0 -13
- data/lib/ruby_lokalise_api/collections/segment.rb +0 -15
- data/lib/ruby_lokalise_api/collections/snapshot.rb +0 -13
- data/lib/ruby_lokalise_api/collections/system_language.rb +0 -13
- data/lib/ruby_lokalise_api/collections/task.rb +0 -13
- data/lib/ruby_lokalise_api/collections/team.rb +0 -13
- data/lib/ruby_lokalise_api/collections/team_user.rb +0 -13
- data/lib/ruby_lokalise_api/collections/team_user_group.rb +0 -15
- data/lib/ruby_lokalise_api/collections/translation.rb +0 -13
- data/lib/ruby_lokalise_api/collections/translation_provider.rb +0 -13
- data/lib/ruby_lokalise_api/collections/webhook.rb +0 -13
- data/lib/ruby_lokalise_api/oauth2/refresh.rb +0 -16
- data/lib/ruby_lokalise_api/oauth2/token.rb +0 -16
- data/lib/ruby_lokalise_api/resources/key_comment.rb +0 -19
- data/lib/ruby_lokalise_api/resources/project_comment.rb +0 -10
- data/lib/ruby_lokalise_api/rest/jwt.rb +0 -15
- data/lib/ruby_lokalise_api/utils/attribute_helpers.rb +0 -86
- data/lib/ruby_lokalise_api/utils/endpoint_helpers.rb +0 -14
- data/lib/ruby_lokalise_api/utils/string_utils.rb +0 -33
@@ -1,40 +1,49 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module RubyLokaliseApi
|
4
|
+
# Module to setup connection using Faraday
|
4
5
|
module Connection
|
5
|
-
|
6
|
-
|
6
|
+
|
7
|
+
# Creates a new Faraday object with specified params
|
8
|
+
def connection(endpoint)
|
9
|
+
Faraday.new(options(endpoint), request_params_for(endpoint.client)) do |faraday|
|
7
10
|
faraday.adapter Faraday.default_adapter
|
8
|
-
faraday.request(:gzip)
|
11
|
+
faraday.request(:gzip)
|
9
12
|
end
|
10
13
|
end
|
11
14
|
|
12
15
|
private
|
13
16
|
|
14
|
-
def options(
|
15
|
-
params = __base_options(
|
17
|
+
def options(endpoint)
|
18
|
+
params = __base_options(endpoint)
|
19
|
+
client = endpoint.client
|
16
20
|
|
17
21
|
if client.respond_to?(:token) && client.respond_to?(:token_header)
|
18
22
|
params[:headers][client.token_header] = client.token
|
19
23
|
end
|
20
|
-
params[:headers][:accept_encoding] = 'gzip,deflate,br'
|
24
|
+
params[:headers][:accept_encoding] = 'gzip,deflate,br'
|
21
25
|
|
22
26
|
params
|
23
27
|
end
|
24
28
|
|
25
|
-
def __base_options(
|
29
|
+
def __base_options(endpoint)
|
26
30
|
{
|
27
31
|
headers: {
|
28
32
|
accept: 'application/json',
|
29
33
|
user_agent: "ruby-lokalise-api gem/#{RubyLokaliseApi::VERSION}"
|
30
34
|
},
|
31
|
-
url:
|
35
|
+
url: endpoint.base_url
|
32
36
|
}
|
33
37
|
end
|
34
38
|
|
35
39
|
# Allows to customize request params per-client
|
36
40
|
def request_params_for(client)
|
37
|
-
{
|
41
|
+
{
|
42
|
+
request: {
|
43
|
+
timeout: client.timeout,
|
44
|
+
open_timeout: client.open_timeout
|
45
|
+
}
|
46
|
+
}
|
38
47
|
end
|
39
48
|
end
|
40
49
|
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
branches:
|
2
|
+
- project_id
|
3
|
+
- branch
|
4
|
+
contributors:
|
5
|
+
- project_id
|
6
|
+
- branch
|
7
|
+
comments:
|
8
|
+
- project_id
|
9
|
+
- branch
|
10
|
+
custom_translation_statuses:
|
11
|
+
- project_id
|
12
|
+
- branch
|
13
|
+
files:
|
14
|
+
- project_id
|
15
|
+
- branch
|
16
|
+
keys:
|
17
|
+
- project_id
|
18
|
+
- branch
|
19
|
+
- errors
|
20
|
+
orders:
|
21
|
+
- team_id
|
22
|
+
payment_cards:
|
23
|
+
- user_id
|
24
|
+
project_languages:
|
25
|
+
- project_id
|
26
|
+
- branch
|
27
|
+
queued_processes:
|
28
|
+
- project_id
|
29
|
+
- branch
|
30
|
+
segments:
|
31
|
+
- project_id
|
32
|
+
- key_id
|
33
|
+
- language_iso
|
34
|
+
screenshots:
|
35
|
+
- project_id
|
36
|
+
- branch
|
37
|
+
- errors
|
38
|
+
snapshots:
|
39
|
+
- project_id
|
40
|
+
- branch
|
41
|
+
tasks:
|
42
|
+
- project_id
|
43
|
+
- branch
|
44
|
+
team_users:
|
45
|
+
- team_id
|
46
|
+
team_user_groups:
|
47
|
+
- team_id
|
48
|
+
translations:
|
49
|
+
- project_id
|
50
|
+
- branch
|
51
|
+
webhooks:
|
52
|
+
- project_id
|
@@ -1,4 +1,5 @@
|
|
1
1
|
branch:
|
2
|
+
- project_id
|
2
3
|
- branch_id
|
3
4
|
- name
|
4
5
|
- created_at
|
@@ -6,6 +7,8 @@ branch:
|
|
6
7
|
- created_by
|
7
8
|
- created_by_email
|
8
9
|
comment:
|
10
|
+
- project_id
|
11
|
+
- branch
|
9
12
|
- comment_id
|
10
13
|
- key_id
|
11
14
|
- comment
|
@@ -14,6 +17,8 @@ comment:
|
|
14
17
|
- added_at
|
15
18
|
- added_at_timestamp
|
16
19
|
contributor:
|
20
|
+
- project_id
|
21
|
+
- branch
|
17
22
|
- user_id
|
18
23
|
- email
|
19
24
|
- fullname
|
@@ -24,15 +29,22 @@ contributor:
|
|
24
29
|
- languages
|
25
30
|
- admin_rights
|
26
31
|
custom_translation_status:
|
32
|
+
- project_id
|
33
|
+
- branch
|
27
34
|
- status_id
|
28
35
|
- title
|
29
36
|
- color
|
30
37
|
file:
|
38
|
+
- branch
|
39
|
+
- project_id
|
40
|
+
- file_id
|
31
41
|
- filename
|
32
42
|
- key_count
|
33
43
|
jwt:
|
34
44
|
- jwt
|
35
45
|
key:
|
46
|
+
- branch
|
47
|
+
- project_id
|
36
48
|
- key_id
|
37
49
|
- created_at
|
38
50
|
- created_at_timestamp
|
@@ -56,15 +68,21 @@ key:
|
|
56
68
|
- modified_at_timestamp
|
57
69
|
- translations_modified_at
|
58
70
|
- translations_modified_at_timestamp
|
59
|
-
|
60
|
-
-
|
61
|
-
-
|
62
|
-
-
|
63
|
-
-
|
64
|
-
|
71
|
+
o_auth2_token:
|
72
|
+
- access_token
|
73
|
+
- refresh_token
|
74
|
+
- expires_in
|
75
|
+
- token_type
|
76
|
+
o_auth2_refreshed_token:
|
77
|
+
- access_token
|
78
|
+
- scope
|
79
|
+
- expires_in
|
80
|
+
- token_type
|
65
81
|
order:
|
82
|
+
- team_id
|
66
83
|
- order_id
|
67
84
|
- project_id
|
85
|
+
- branch
|
68
86
|
- card_id
|
69
87
|
- status
|
70
88
|
- created_at
|
@@ -84,6 +102,7 @@ order:
|
|
84
102
|
- payment_method
|
85
103
|
- dry_run
|
86
104
|
payment_card:
|
105
|
+
- user_id
|
87
106
|
- card_id
|
88
107
|
- last4
|
89
108
|
- brand
|
@@ -91,6 +110,7 @@ payment_card:
|
|
91
110
|
- created_at_timestamp
|
92
111
|
project:
|
93
112
|
- project_id
|
113
|
+
- project_type
|
94
114
|
- name
|
95
115
|
- description
|
96
116
|
- created_at
|
@@ -102,7 +122,17 @@ project:
|
|
102
122
|
- base_language_iso
|
103
123
|
- settings
|
104
124
|
- statistics
|
125
|
+
project_language:
|
126
|
+
- project_id
|
127
|
+
- branch
|
128
|
+
- lang_id
|
129
|
+
- lang_iso
|
130
|
+
- lang_name
|
131
|
+
- is_rtl
|
132
|
+
- plural_forms
|
105
133
|
queued_process:
|
134
|
+
- project_id
|
135
|
+
- branch
|
106
136
|
- process_id
|
107
137
|
- type
|
108
138
|
- status
|
@@ -113,8 +143,11 @@ queued_process:
|
|
113
143
|
- created_at_timestamp
|
114
144
|
- details
|
115
145
|
screenshot:
|
146
|
+
- project_id
|
147
|
+
- branch
|
116
148
|
- screenshot_id
|
117
149
|
- key_ids
|
150
|
+
- keys
|
118
151
|
- url
|
119
152
|
- title
|
120
153
|
- description
|
@@ -124,6 +157,9 @@ screenshot:
|
|
124
157
|
- created_at
|
125
158
|
- created_at_timestamp
|
126
159
|
segment:
|
160
|
+
- project_id
|
161
|
+
- key_id
|
162
|
+
- language_iso
|
127
163
|
- segment_number
|
128
164
|
- language_iso
|
129
165
|
- modified_at
|
@@ -137,13 +173,23 @@ segment:
|
|
137
173
|
- words
|
138
174
|
- custom_translation_statuses
|
139
175
|
snapshot:
|
176
|
+
- project_id
|
177
|
+
- branch
|
140
178
|
- snapshot_id
|
141
179
|
- title
|
142
180
|
- created_at
|
143
181
|
- created_at_timestamp
|
144
182
|
- created_by
|
145
183
|
- created_by_email
|
184
|
+
system_language:
|
185
|
+
- lang_id
|
186
|
+
- lang_iso
|
187
|
+
- lang_name
|
188
|
+
- is_rtl
|
189
|
+
- plural_forms
|
146
190
|
task:
|
191
|
+
- branch
|
192
|
+
- project_id
|
147
193
|
- task_id
|
148
194
|
- title
|
149
195
|
- description
|
@@ -157,6 +203,7 @@ task:
|
|
157
203
|
- created_at_timestamp
|
158
204
|
- created_by
|
159
205
|
- created_by_email
|
206
|
+
- source_language_iso
|
160
207
|
- can_be_parent
|
161
208
|
- task_type
|
162
209
|
- parent_task_id
|
@@ -180,6 +227,7 @@ team:
|
|
180
227
|
- quota_usage
|
181
228
|
- quota_allowed
|
182
229
|
team_user:
|
230
|
+
- team_id
|
183
231
|
- user_id
|
184
232
|
- email
|
185
233
|
- fullname
|
@@ -187,6 +235,7 @@ team_user:
|
|
187
235
|
- created_at_timestamp
|
188
236
|
- role
|
189
237
|
team_user_billing_details:
|
238
|
+
- team_id
|
190
239
|
- billing_email
|
191
240
|
- country_code
|
192
241
|
- zip
|
@@ -198,6 +247,7 @@ team_user_billing_details:
|
|
198
247
|
- company
|
199
248
|
- vatnumber
|
200
249
|
team_user_group:
|
250
|
+
- team_id
|
201
251
|
- group_id
|
202
252
|
- name
|
203
253
|
- permissions
|
@@ -207,6 +257,10 @@ team_user_group:
|
|
207
257
|
- projects
|
208
258
|
- members
|
209
259
|
translation:
|
260
|
+
- project_id
|
261
|
+
- branch
|
262
|
+
- segment_number
|
263
|
+
- reviewed_by
|
210
264
|
- translation_id
|
211
265
|
- key_id
|
212
266
|
- language_iso
|
@@ -217,10 +271,12 @@ translation:
|
|
217
271
|
- translation
|
218
272
|
- is_fuzzy
|
219
273
|
- is_reviewed
|
274
|
+
- is_unverified
|
220
275
|
- words
|
221
276
|
- custom_translation_statuses
|
222
277
|
- task_id
|
223
278
|
translation_provider:
|
279
|
+
- team_id
|
224
280
|
- provider_id
|
225
281
|
- name
|
226
282
|
- slug
|
@@ -230,6 +286,8 @@ translation_provider:
|
|
230
286
|
- tiers
|
231
287
|
- pairs
|
232
288
|
webhook:
|
289
|
+
- project_id
|
290
|
+
- branch
|
233
291
|
- webhook_id
|
234
292
|
- url
|
235
293
|
- secret
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RubyLokaliseApi
|
4
|
+
module Endpoints
|
5
|
+
class BaseEndpoint
|
6
|
+
using RubyLokaliseApi::Utils::Classes
|
7
|
+
include RubyLokaliseApi::Request
|
8
|
+
|
9
|
+
attr_reader :client, :req_params, :uri
|
10
|
+
|
11
|
+
BASE_URL = ''
|
12
|
+
PARTIAL_URI_TEMPLATE = '{/segments*}'
|
13
|
+
|
14
|
+
def initialize(client, params = {})
|
15
|
+
@query_params = params[:query].to_array
|
16
|
+
@client = client
|
17
|
+
@req_params = params[:req]
|
18
|
+
@uri = nil
|
19
|
+
end
|
20
|
+
|
21
|
+
def reinitialize(query_params: nil, req_params: {})
|
22
|
+
@query_params = query_params || @query_params
|
23
|
+
@req_params = req_params || @req_params
|
24
|
+
@uri = partial_uri(base_query(*@query_params))
|
25
|
+
|
26
|
+
self
|
27
|
+
end
|
28
|
+
|
29
|
+
def base_url
|
30
|
+
self.class.const_get(:BASE_URL)
|
31
|
+
end
|
32
|
+
|
33
|
+
def full_uri
|
34
|
+
base_url + uri
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
HTTP_METHODS_REGEXP = /\Ado_(get|post|put|delete|patch)\z/.freeze
|
40
|
+
|
41
|
+
def respond_to_missing?(method, _include_all)
|
42
|
+
return true if HTTP_METHODS_REGEXP.match?(method.to_s)
|
43
|
+
|
44
|
+
super
|
45
|
+
end
|
46
|
+
|
47
|
+
def method_missing(method, *_args)
|
48
|
+
if method.to_s =~ HTTP_METHODS_REGEXP
|
49
|
+
send Regexp.last_match(1), self
|
50
|
+
else
|
51
|
+
super
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def base_query(*_args); end
|
56
|
+
|
57
|
+
def partial_uri(*_args)
|
58
|
+
Addressable::Template.new partial_uri_template
|
59
|
+
end
|
60
|
+
|
61
|
+
def partial_uri_template
|
62
|
+
self.class.const_get(:PARTIAL_URI_TEMPLATE)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RubyLokaliseApi
|
4
|
+
module Endpoints
|
5
|
+
class BranchesEndpoint < MainEndpoint
|
6
|
+
private
|
7
|
+
|
8
|
+
def base_query(project_id, branch_id = nil, action = nil)
|
9
|
+
{
|
10
|
+
projects: project_id,
|
11
|
+
branches: [branch_id, action]
|
12
|
+
}
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RubyLokaliseApi
|
4
|
+
module Endpoints
|
5
|
+
class ContributorsEndpoint < MainEndpoint
|
6
|
+
private
|
7
|
+
|
8
|
+
def base_query(project_id, contributor_id = nil)
|
9
|
+
{
|
10
|
+
projects: project_id,
|
11
|
+
contributors: contributor_id
|
12
|
+
}
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RubyLokaliseApi
|
4
|
+
module Endpoints
|
5
|
+
class CustomTranslationStatusesEndpoint < MainEndpoint
|
6
|
+
private
|
7
|
+
|
8
|
+
def base_query(project_id, status_id = nil)
|
9
|
+
{
|
10
|
+
projects: project_id,
|
11
|
+
custom_translation_statuses: status_id
|
12
|
+
}
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RubyLokaliseApi
|
4
|
+
module Endpoints
|
5
|
+
class KeyCommentsEndpoint < MainEndpoint
|
6
|
+
private
|
7
|
+
|
8
|
+
def base_query(project_id, key_id, comment_id = nil)
|
9
|
+
{
|
10
|
+
projects: project_id,
|
11
|
+
keys: key_id,
|
12
|
+
comments: comment_id
|
13
|
+
}
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RubyLokaliseApi
|
4
|
+
module Endpoints
|
5
|
+
class MainEndpoint < BaseEndpoint
|
6
|
+
BASE_URL = 'https://api.lokalise.com/api2'
|
7
|
+
|
8
|
+
def initialize(client, params = {})
|
9
|
+
super client, params
|
10
|
+
|
11
|
+
@uri = partial_uri(base_query(*@query_params))
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def partial_uri(segments, *_args)
|
17
|
+
template = super
|
18
|
+
|
19
|
+
template.expand(
|
20
|
+
segments: segments.to_a.flatten
|
21
|
+
).to_s
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RubyLokaliseApi
|
4
|
+
module Endpoints
|
5
|
+
module OAuth2
|
6
|
+
class OAuth2Endpoint < BaseEndpoint
|
7
|
+
BASE_URL = 'https://app.lokalise.com/oauth2'
|
8
|
+
PARTIAL_URI_TEMPLATE = '{/segments*}{?query*}'
|
9
|
+
|
10
|
+
def initialize(client, params = {})
|
11
|
+
super client, params
|
12
|
+
|
13
|
+
@uri = partial_uri(base_query(*@query_params), params.fetch(:get, []))
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def partial_uri(segments, query)
|
19
|
+
template = super
|
20
|
+
|
21
|
+
template.expand(
|
22
|
+
segments: segments.to_a.flatten,
|
23
|
+
query: query.filter { |_k, v| !v.nil? }
|
24
|
+
).to_s
|
25
|
+
end
|
26
|
+
|
27
|
+
def base_query(segment = nil)
|
28
|
+
[segment]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RubyLokaliseApi
|
4
|
+
module Endpoints
|
5
|
+
class ProjectLanguagesEndpoint < MainEndpoint
|
6
|
+
private
|
7
|
+
|
8
|
+
def base_query(project_id, language_id = nil)
|
9
|
+
{
|
10
|
+
projects: project_id,
|
11
|
+
languages: language_id
|
12
|
+
}
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RubyLokaliseApi
|
4
|
+
module Endpoints
|
5
|
+
class QueuedProcessesEndpoint < MainEndpoint
|
6
|
+
private
|
7
|
+
|
8
|
+
def base_query(project_id, process_id = nil)
|
9
|
+
{
|
10
|
+
projects: project_id,
|
11
|
+
processes: process_id
|
12
|
+
}
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module RubyLokaliseApi
|
4
|
+
module Endpoints
|
5
|
+
class ScreenshotsEndpoint < MainEndpoint
|
6
|
+
private
|
7
|
+
|
8
|
+
def base_query(project_id, screenshots_id = nil)
|
9
|
+
{
|
10
|
+
projects: project_id,
|
11
|
+
screenshots: screenshots_id
|
12
|
+
}
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|