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.
Files changed (160) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ruby_lokalise_api/base_client.rb +2 -34
  3. data/lib/ruby_lokalise_api/client.rb +2 -31
  4. data/lib/ruby_lokalise_api/collections/base.rb +97 -70
  5. data/lib/ruby_lokalise_api/collections/branches.rb +11 -0
  6. data/lib/ruby_lokalise_api/collections/contributors.rb +10 -0
  7. data/lib/ruby_lokalise_api/collections/custom_translation_statuses.rb +10 -0
  8. data/lib/ruby_lokalise_api/collections/files.rb +10 -0
  9. data/lib/ruby_lokalise_api/collections/key_comments.rb +11 -0
  10. data/lib/ruby_lokalise_api/collections/keys.rb +10 -0
  11. data/lib/ruby_lokalise_api/collections/orders.rb +10 -0
  12. data/lib/ruby_lokalise_api/collections/payment_cards.rb +10 -0
  13. data/lib/ruby_lokalise_api/collections/project_comments.rb +12 -0
  14. data/lib/ruby_lokalise_api/collections/project_languages.rb +11 -0
  15. data/lib/ruby_lokalise_api/collections/projects.rb +10 -0
  16. data/lib/ruby_lokalise_api/collections/queued_processes.rb +11 -0
  17. data/lib/ruby_lokalise_api/collections/screenshots.rb +10 -0
  18. data/lib/ruby_lokalise_api/collections/segments.rb +10 -0
  19. data/lib/ruby_lokalise_api/collections/snapshots.rb +10 -0
  20. data/lib/ruby_lokalise_api/collections/system_languages.rb +11 -0
  21. data/lib/ruby_lokalise_api/collections/tasks.rb +10 -0
  22. data/lib/ruby_lokalise_api/collections/team_user_groups.rb +11 -0
  23. data/lib/ruby_lokalise_api/collections/team_users.rb +10 -0
  24. data/lib/ruby_lokalise_api/collections/teams.rb +10 -0
  25. data/lib/ruby_lokalise_api/collections/translation_providers.rb +10 -0
  26. data/lib/ruby_lokalise_api/collections/translations.rb +10 -0
  27. data/lib/ruby_lokalise_api/collections/webhooks.rb +10 -0
  28. data/lib/ruby_lokalise_api/concerns/attrs_loadable.rb +31 -0
  29. data/lib/ruby_lokalise_api/concerns/hash_accessible.rb +16 -0
  30. data/lib/ruby_lokalise_api/concerns/unsupportable.rb +16 -0
  31. data/lib/ruby_lokalise_api/connection.rb +18 -9
  32. data/lib/ruby_lokalise_api/data/collection_attributes.yml +52 -0
  33. data/lib/ruby_lokalise_api/data/{attributes.yml → resource_attributes.yml} +64 -6
  34. data/lib/ruby_lokalise_api/endpoints/base_endpoint.rb +66 -0
  35. data/lib/ruby_lokalise_api/endpoints/branches_endpoint.rb +16 -0
  36. data/lib/ruby_lokalise_api/endpoints/contributors_endpoint.rb +16 -0
  37. data/lib/ruby_lokalise_api/endpoints/custom_translation_statuses_endpoint.rb +16 -0
  38. data/lib/ruby_lokalise_api/endpoints/files_endpoint.rb +16 -0
  39. data/lib/ruby_lokalise_api/endpoints/jwts_endpoint.rb +15 -0
  40. data/lib/ruby_lokalise_api/endpoints/key_comments_endpoint.rb +17 -0
  41. data/lib/ruby_lokalise_api/endpoints/keys_endpoint.rb +16 -0
  42. data/lib/ruby_lokalise_api/endpoints/main_endpoint.rb +25 -0
  43. data/lib/ruby_lokalise_api/endpoints/oauth2/oauth2_endpoint.rb +33 -0
  44. data/lib/ruby_lokalise_api/endpoints/orders_endpoint.rb +16 -0
  45. data/lib/ruby_lokalise_api/endpoints/payment_cards_endpoint.rb +15 -0
  46. data/lib/ruby_lokalise_api/endpoints/project_comments_endpoint.rb +15 -0
  47. data/lib/ruby_lokalise_api/endpoints/project_languages_endpoint.rb +16 -0
  48. data/lib/ruby_lokalise_api/endpoints/projects_endpoint.rb +15 -0
  49. data/lib/ruby_lokalise_api/endpoints/queued_processes_endpoint.rb +16 -0
  50. data/lib/ruby_lokalise_api/endpoints/screenshots_endpoint.rb +16 -0
  51. data/lib/ruby_lokalise_api/endpoints/segments_endpoint.rb +17 -0
  52. data/lib/ruby_lokalise_api/endpoints/snapshots_endpoint.rb +16 -0
  53. data/lib/ruby_lokalise_api/endpoints/system_languages_endpoint.rb +15 -0
  54. data/lib/ruby_lokalise_api/endpoints/tasks_endpoint.rb +16 -0
  55. data/lib/ruby_lokalise_api/endpoints/team_user_billing_details_endpoint.rb +15 -0
  56. data/lib/ruby_lokalise_api/endpoints/team_user_groups_endpoint.rb +16 -0
  57. data/lib/ruby_lokalise_api/endpoints/team_users_endpoint.rb +16 -0
  58. data/lib/ruby_lokalise_api/endpoints/teams_endpoint.rb +13 -0
  59. data/lib/ruby_lokalise_api/endpoints/translation_providers_endpoint.rb +16 -0
  60. data/lib/ruby_lokalise_api/endpoints/translations_endpoint.rb +16 -0
  61. data/lib/ruby_lokalise_api/endpoints/webhooks_endpoint.rb +16 -0
  62. data/lib/ruby_lokalise_api/error.rb +1 -0
  63. data/lib/ruby_lokalise_api/generics.rb +25 -0
  64. data/lib/ruby_lokalise_api/json_handler.rb +1 -2
  65. data/lib/ruby_lokalise_api/oauth2/auth.rb +33 -39
  66. data/lib/ruby_lokalise_api/oauth2_client.rb +3 -0
  67. data/lib/ruby_lokalise_api/request.rb +66 -18
  68. data/lib/ruby_lokalise_api/resources/base.rb +41 -185
  69. data/lib/ruby_lokalise_api/resources/branch.rb +2 -21
  70. data/lib/ruby_lokalise_api/resources/comment.rb +11 -0
  71. data/lib/ruby_lokalise_api/resources/contributor.rb +1 -9
  72. data/lib/ruby_lokalise_api/resources/custom_translation_status.rb +1 -13
  73. data/lib/ruby_lokalise_api/resources/file.rb +2 -16
  74. data/lib/ruby_lokalise_api/resources/jwt.rb +2 -5
  75. data/lib/ruby_lokalise_api/resources/key.rb +5 -8
  76. data/lib/ruby_lokalise_api/resources/oauth2_refreshed_token.rb +9 -0
  77. data/lib/ruby_lokalise_api/resources/oauth2_token.rb +9 -0
  78. data/lib/ruby_lokalise_api/resources/order.rb +2 -9
  79. data/lib/ruby_lokalise_api/resources/payment_card.rb +2 -8
  80. data/lib/ruby_lokalise_api/resources/project.rb +85 -16
  81. data/lib/ruby_lokalise_api/resources/project_language.rb +2 -10
  82. data/lib/ruby_lokalise_api/resources/queued_process.rb +3 -10
  83. data/lib/ruby_lokalise_api/resources/screenshot.rb +1 -9
  84. data/lib/ruby_lokalise_api/resources/segment.rb +2 -11
  85. data/lib/ruby_lokalise_api/resources/snapshot.rb +3 -18
  86. data/lib/ruby_lokalise_api/resources/system_language.rb +2 -1
  87. data/lib/ruby_lokalise_api/resources/task.rb +1 -9
  88. data/lib/ruby_lokalise_api/resources/team.rb +2 -0
  89. data/lib/ruby_lokalise_api/resources/team_user.rb +1 -9
  90. data/lib/ruby_lokalise_api/resources/team_user_billing_details.rb +10 -5
  91. data/lib/ruby_lokalise_api/resources/team_user_group.rb +6 -14
  92. data/lib/ruby_lokalise_api/resources/translation.rb +2 -9
  93. data/lib/ruby_lokalise_api/resources/translation_provider.rb +2 -9
  94. data/lib/ruby_lokalise_api/resources/webhook.rb +2 -16
  95. data/lib/ruby_lokalise_api/response.rb +50 -0
  96. data/lib/ruby_lokalise_api/rest/branches.rb +52 -27
  97. data/lib/ruby_lokalise_api/rest/comments.rb +48 -23
  98. data/lib/ruby_lokalise_api/rest/contributors.rb +47 -23
  99. data/lib/ruby_lokalise_api/rest/custom_translation_statuses.rb +60 -36
  100. data/lib/ruby_lokalise_api/rest/files.rb +43 -24
  101. data/lib/ruby_lokalise_api/rest/jwts.rb +21 -0
  102. data/lib/ruby_lokalise_api/rest/keys.rb +67 -34
  103. data/lib/ruby_lokalise_api/rest/languages.rb +57 -28
  104. data/lib/ruby_lokalise_api/rest/orders.rb +36 -14
  105. data/lib/ruby_lokalise_api/rest/payment_cards.rb +29 -12
  106. data/lib/ruby_lokalise_api/rest/projects.rb +55 -32
  107. data/lib/ruby_lokalise_api/rest/queued_processes.rb +21 -13
  108. data/lib/ruby_lokalise_api/rest/screenshots.rb +45 -20
  109. data/lib/ruby_lokalise_api/rest/segments.rb +31 -18
  110. data/lib/ruby_lokalise_api/rest/snapshots.rb +34 -14
  111. data/lib/ruby_lokalise_api/rest/tasks.rb +41 -19
  112. data/lib/ruby_lokalise_api/rest/team_user_billing_details.rb +33 -12
  113. data/lib/ruby_lokalise_api/rest/team_user_groups.rb +82 -50
  114. data/lib/ruby_lokalise_api/rest/team_users.rb +35 -18
  115. data/lib/ruby_lokalise_api/rest/teams.rb +10 -5
  116. data/lib/ruby_lokalise_api/rest/translation_providers.rb +24 -9
  117. data/lib/ruby_lokalise_api/rest/translations.rb +28 -15
  118. data/lib/ruby_lokalise_api/rest/webhooks.rb +54 -30
  119. data/lib/ruby_lokalise_api/rest.rb +31 -0
  120. data/lib/ruby_lokalise_api/utils/attributes.rb +37 -0
  121. data/lib/ruby_lokalise_api/utils/classes.rb +24 -0
  122. data/lib/ruby_lokalise_api/utils/keys.rb +29 -0
  123. data/lib/ruby_lokalise_api/utils/loaders.rb +24 -0
  124. data/lib/ruby_lokalise_api/utils/strings.rb +20 -0
  125. data/lib/ruby_lokalise_api/version.rb +1 -1
  126. data/lib/ruby_lokalise_api.rb +6 -2
  127. data/ruby-lokalise-api.gemspec +2 -2
  128. metadata +76 -41
  129. data/lib/ruby_lokalise_api/base_request.rb +0 -73
  130. data/lib/ruby_lokalise_api/collections/branch.rb +0 -15
  131. data/lib/ruby_lokalise_api/collections/contributor.rb +0 -13
  132. data/lib/ruby_lokalise_api/collections/custom_translation_status.rb +0 -15
  133. data/lib/ruby_lokalise_api/collections/file.rb +0 -13
  134. data/lib/ruby_lokalise_api/collections/key.rb +0 -20
  135. data/lib/ruby_lokalise_api/collections/key_comment.rb +0 -14
  136. data/lib/ruby_lokalise_api/collections/order.rb +0 -13
  137. data/lib/ruby_lokalise_api/collections/payment_card.rb +0 -13
  138. data/lib/ruby_lokalise_api/collections/project.rb +0 -13
  139. data/lib/ruby_lokalise_api/collections/project_comment.rb +0 -13
  140. data/lib/ruby_lokalise_api/collections/project_language.rb +0 -13
  141. data/lib/ruby_lokalise_api/collections/queued_process.rb +0 -15
  142. data/lib/ruby_lokalise_api/collections/screenshot.rb +0 -13
  143. data/lib/ruby_lokalise_api/collections/segment.rb +0 -15
  144. data/lib/ruby_lokalise_api/collections/snapshot.rb +0 -13
  145. data/lib/ruby_lokalise_api/collections/system_language.rb +0 -13
  146. data/lib/ruby_lokalise_api/collections/task.rb +0 -13
  147. data/lib/ruby_lokalise_api/collections/team.rb +0 -13
  148. data/lib/ruby_lokalise_api/collections/team_user.rb +0 -13
  149. data/lib/ruby_lokalise_api/collections/team_user_group.rb +0 -15
  150. data/lib/ruby_lokalise_api/collections/translation.rb +0 -13
  151. data/lib/ruby_lokalise_api/collections/translation_provider.rb +0 -13
  152. data/lib/ruby_lokalise_api/collections/webhook.rb +0 -13
  153. data/lib/ruby_lokalise_api/oauth2/refresh.rb +0 -16
  154. data/lib/ruby_lokalise_api/oauth2/token.rb +0 -16
  155. data/lib/ruby_lokalise_api/resources/key_comment.rb +0 -19
  156. data/lib/ruby_lokalise_api/resources/project_comment.rb +0 -10
  157. data/lib/ruby_lokalise_api/rest/jwt.rb +0 -15
  158. data/lib/ruby_lokalise_api/utils/attribute_helpers.rb +0 -86
  159. data/lib/ruby_lokalise_api/utils/endpoint_helpers.rb +0 -14
  160. 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
- def connection(client)
6
- Faraday.new(options(client), request_params_for(client)) do |faraday|
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) if client.compression?
11
+ faraday.request(:gzip)
9
12
  end
10
13
  end
11
14
 
12
15
  private
13
16
 
14
- def options(client)
15
- params = __base_options(client)
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' if client.compression?
24
+ params[:headers][:accept_encoding] = 'gzip,deflate,br'
21
25
 
22
26
  params
23
27
  end
24
28
 
25
- def __base_options(client)
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: client.base_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
- {request: {timeout: client.timeout, open_timeout: client.open_timeout}}
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
- language:
60
- - lang_id
61
- - lang_iso
62
- - lang_name
63
- - is_rtl
64
- - plural_forms
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,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyLokaliseApi
4
+ module Endpoints
5
+ class FilesEndpoint < MainEndpoint
6
+ private
7
+
8
+ def base_query(project_id, action = nil)
9
+ {
10
+ projects: project_id,
11
+ files: action
12
+ }
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyLokaliseApi
4
+ module Endpoints
5
+ class JwtsEndpoint < MainEndpoint
6
+ private
7
+
8
+ def base_query(project_id)
9
+ {
10
+ projects: [project_id, :tokens]
11
+ }
12
+ end
13
+ end
14
+ end
15
+ 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,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyLokaliseApi
4
+ module Endpoints
5
+ class KeysEndpoint < MainEndpoint
6
+ private
7
+
8
+ def base_query(project_id, key_id = nil)
9
+ {
10
+ projects: project_id,
11
+ keys: key_id
12
+ }
13
+ end
14
+ end
15
+ end
16
+ 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 OrdersEndpoint < MainEndpoint
6
+ private
7
+
8
+ def base_query(team_id, order_id = nil)
9
+ {
10
+ teams: team_id,
11
+ orders: order_id
12
+ }
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyLokaliseApi
4
+ module Endpoints
5
+ class PaymentCardsEndpoint < MainEndpoint
6
+ private
7
+
8
+ def base_query(card_id = nil, *_args)
9
+ {
10
+ payment_cards: card_id
11
+ }
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyLokaliseApi
4
+ module Endpoints
5
+ class ProjectCommentsEndpoint < MainEndpoint
6
+ private
7
+
8
+ def base_query(project_id)
9
+ {
10
+ projects: [project_id, :comments]
11
+ }
12
+ end
13
+ end
14
+ end
15
+ 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,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyLokaliseApi
4
+ module Endpoints
5
+ class ProjectsEndpoint < MainEndpoint
6
+ private
7
+
8
+ def base_query(project_id = nil, action = nil)
9
+ {
10
+ projects: [project_id, action]
11
+ }
12
+ end
13
+ end
14
+ end
15
+ 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