ruby-lokalise-api 4.2.0 → 4.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/.github/CONTRIBUTING.md +1 -1
  3. data/README.md +10 -2
  4. data/lib/ruby-lokalise-api/client.rb +6 -2
  5. data/lib/ruby-lokalise-api/collections/base.rb +19 -7
  6. data/lib/ruby-lokalise-api/collections/segment.rb +15 -0
  7. data/lib/ruby-lokalise-api/connection.rb +11 -5
  8. data/lib/ruby-lokalise-api/data/attributes.json +26 -0
  9. data/lib/ruby-lokalise-api/error.rb +2 -1
  10. data/lib/ruby-lokalise-api/oauth_client.rb +11 -0
  11. data/lib/ruby-lokalise-api/request.rb +3 -2
  12. data/lib/ruby-lokalise-api/resources/base.rb +18 -7
  13. data/lib/ruby-lokalise-api/resources/branch.rb +3 -1
  14. data/lib/ruby-lokalise-api/resources/contributor.rb +1 -1
  15. data/lib/ruby-lokalise-api/resources/custom_translation_status.rb +1 -1
  16. data/lib/ruby-lokalise-api/resources/key.rb +1 -0
  17. data/lib/ruby-lokalise-api/resources/key_comment.rb +1 -1
  18. data/lib/ruby-lokalise-api/resources/order.rb +1 -0
  19. data/lib/ruby-lokalise-api/resources/payment_card.rb +1 -0
  20. data/lib/ruby-lokalise-api/resources/project.rb +1 -0
  21. data/lib/ruby-lokalise-api/resources/project_comment.rb +1 -0
  22. data/lib/ruby-lokalise-api/resources/project_language.rb +1 -1
  23. data/lib/ruby-lokalise-api/resources/queued_process.rb +1 -1
  24. data/lib/ruby-lokalise-api/resources/screenshot.rb +1 -0
  25. data/lib/ruby-lokalise-api/resources/segment.rb +19 -0
  26. data/lib/ruby-lokalise-api/resources/snapshot.rb +1 -0
  27. data/lib/ruby-lokalise-api/resources/task.rb +1 -0
  28. data/lib/ruby-lokalise-api/resources/team_user.rb +1 -1
  29. data/lib/ruby-lokalise-api/resources/team_user_billing_details.rb +14 -0
  30. data/lib/ruby-lokalise-api/resources/team_user_group.rb +1 -1
  31. data/lib/ruby-lokalise-api/resources/translation.rb +1 -0
  32. data/lib/ruby-lokalise-api/resources/translation_provider.rb +1 -1
  33. data/lib/ruby-lokalise-api/resources/webhook.rb +1 -0
  34. data/lib/ruby-lokalise-api/rest/segments.rb +43 -0
  35. data/lib/ruby-lokalise-api/rest/team_user_billing_details.rb +34 -0
  36. data/lib/ruby-lokalise-api/utils/attribute_helpers.rb +3 -1
  37. data/lib/ruby-lokalise-api/utils/string_utils.rb +24 -18
  38. data/lib/ruby-lokalise-api/version.rb +1 -1
  39. data/lib/ruby-lokalise-api.rb +19 -0
  40. data/ruby-lokalise-api.gemspec +18 -14
  41. data/spec/lib/ruby-lokalise-api/connection_spec.rb +45 -1
  42. data/spec/lib/ruby-lokalise-api/error_spec.rb +8 -0
  43. data/spec/lib/ruby-lokalise-api/rest/segments_spec.rb +106 -0
  44. data/spec/lib/ruby-lokalise-api/rest/team_user_billing_details_spec.rb +48 -0
  45. data/spec/lib/ruby-lokalise-api_spec.rb +21 -0
  46. data/spec/support/test_client.rb +4 -0
  47. metadata +33 -10
  48. data/spec/lib/ruby-lokalise-api/utils/snakecase_spec.rb +0 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c0736dd816b0cc92d92a04277d86aaec283aa9d7f7be024c736e1a6b4c91531c
4
- data.tar.gz: 725e7262b0a226db6ae1d20d856eaac895ee11f5b39df15b3167a6b0db1984ec
3
+ metadata.gz: 1e1ed1ea503db64b5bf145288689885a365e35ba9520e692d65b51b311478fb5
4
+ data.tar.gz: b1636ef5cd3dafb7d1be6ca64ed6c6807c8f6f12f4383039d8312c4ce4f100b2
5
5
  SHA512:
6
- metadata.gz: 94f10e17e3290f76b95fef30acddc5ab448dd27c064ea6e306fe69af621e2e25e63ed51fa2f919c6421df1eeea6a230b414054c9ceb23fb120aaa7d587b1c192
7
- data.tar.gz: 31d41d8735f06151825eed3db874156ef78bec552e44cb8de8dcdd761878373ed5b6a3c745b918d6474262e681f9166c0e0d551d416254436464248e92821d8e
6
+ metadata.gz: 8141fe2f935cf0cc380f9824278235c5d6a0b12bd8daef9d6947556d0b73b9aa9d097f2c9e32833eb2c8261d84331ab476f7ef25b6c69965a2f8781bf3b284ff
7
+ data.tar.gz: 4bce32a0012e21830e45b12f58fb188395614a2dc64412c2c28fbd95bda4d8519565d0d38eebed1da9b6a2f7976bd0bc61ee28cb49fd466233b03d1843a90fb4
@@ -4,7 +4,7 @@
4
4
  2. [Create a topic branch.][branch]
5
5
  3. Implement your feature or bug fix.
6
6
  4. Don't forget to add specs and make sure they pass by running `rspec .`.
7
- 5. Make sure your code complies with the style guide by running `rubocop`. `rubocop -a` can automatically fix most issues for you.
7
+ 5. Make sure your code complies with the style guide by running `rubocop`. `rubocop -a` can automatically fix most issues for you. Run `rubocop -A` to make it more aggressive.
8
8
  6. If necessary, add documentation for your feature or bug fix.
9
9
  7. Commit and push your changes.
10
10
  8. [Submit a pull request.][pr]
data/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
  Official opinionated Ruby interface for the [Lokalise API](https://app.lokalise.com/api2docs/curl/) that represents returned data as Ruby objects.
9
9
 
10
- Looking for a Rails integration? Try the new [lokalise_rails gem](https://github.com/bodrovis/lokalise_rails).
10
+ Looking for a Rails integration? Try the [lokalise_rails gem](https://github.com/bodrovis/lokalise_rails). Also you can use a [lokalise_manager gem](https://github.com/bodrovis/lokalise_manager) which allows to exchange translation files between Lokalise and *any* Ruby script.
11
11
 
12
12
  ## Quickstart
13
13
 
@@ -39,12 +39,20 @@ process = @client.upload_file project_id,
39
39
  process.status
40
40
  ```
41
41
 
42
+ Alternatively instantiate your client with an [OAuth2 token](http://docs.lokalise.com/en/articles/5574713-oauth-2):
43
+
44
+ ```ruby
45
+ @client = Lokalise.oauth_client 'YOUR_OAUTH_TOKEN_HERE'
46
+ ```
47
+
42
48
  ## Usage
43
49
 
44
50
  Detailed documentation can be found at [lokalise.github.io/ruby-lokalise-api](https://lokalise.github.io/ruby-lokalise-api/).
45
51
 
52
+ You can also check [this repo containing some usage examples](https://github.com/bodrovis-learning/Lokalise-APIv2-Samples) and [this blog post with explanations](https://lokalise.com/blog/lokalise-apiv2-in-practice).
53
+
46
54
  ## License
47
55
 
48
56
  This gem is licensed under the [BSD 3 Clause license](https://github.com/lokalise/ruby-lokalise-api/blob/master/LICENSE). Prior to version 4 the license type was MIT.
49
57
 
50
- Copyright (c) [Lokalise team](http://lokalise.co), [Ilya Bodrov](http://bodrovis.tech)
58
+ Copyright (c) [Lokalise team](http://lokalise.co) and [Ilya Bodrov](http://bodrovis.tech)
@@ -20,16 +20,20 @@ require 'ruby-lokalise-api/rest/translation_providers'
20
20
  require 'ruby-lokalise-api/rest/team_user_group'
21
21
  require 'ruby-lokalise-api/rest/custom_translation_statuses'
22
22
  require 'ruby-lokalise-api/rest/webhooks'
23
+ require 'ruby-lokalise-api/rest/segments'
24
+ require 'ruby-lokalise-api/rest/team_user_billing_details'
23
25
 
24
26
  module Lokalise
25
27
  class Client
26
- attr_reader :token
27
- attr_accessor :timeout, :open_timeout
28
+ attr_reader :token, :token_header
29
+ attr_accessor :timeout, :open_timeout, :enable_compression
28
30
 
29
31
  def initialize(token, params = {})
30
32
  @token = token
31
33
  @timeout = params.fetch(:timeout, nil)
32
34
  @open_timeout = params.fetch(:open_timeout, nil)
35
+ @enable_compression = params.fetch(:enable_compression, false)
36
+ @token_header = 'x-api-token'
33
37
  end
34
38
 
35
39
  # rubocop:disable Metrics/ParameterLists
@@ -3,6 +3,8 @@
3
3
  module Lokalise
4
4
  module Collections
5
5
  class Base
6
+ using Lokalise::Utils::StringUtils
7
+
6
8
  extend Lokalise::Request
7
9
  extend Lokalise::Utils::AttributeHelpers
8
10
  include Lokalise::Utils::AttributeHelpers
@@ -19,14 +21,8 @@ module Lokalise
19
21
  def initialize(response, params = {})
20
22
  produce_collection_for response
21
23
  populate_pagination_data_for response
22
- # Project, team id, user id, and branch may not be present in some cases
23
- @project_id = response['content']['project_id']
24
- @team_id = response['content']['team_id']
25
- @user_id = response['content']['user_id']
26
- @branch = response['content']['branch']
27
24
  @request_params = params
28
- @client = response['client']
29
- @path = response['path']
25
+ popular_common_attrs response
30
26
  end
31
27
 
32
28
  class << self
@@ -90,6 +86,8 @@ module Lokalise
90
86
  # Dynamically produces collection of resources based on the given response
91
87
  # Collection example: `{ "content": {"comments": [ ... ]} }`
92
88
  def produce_collection_for(response)
89
+ return unless response['content']
90
+
93
91
  model_class = self.class.name.base_class_name
94
92
  data_key_plural = data_key_for model_class: model_class, plural: true, collection: true
95
93
 
@@ -101,6 +99,20 @@ module Lokalise
101
99
  'base_path' => response['path']
102
100
  end
103
101
  end
102
+
103
+ def popular_common_attrs(response)
104
+ @client = response['client']
105
+ @path = response['path']
106
+
107
+ return unless response['content']
108
+
109
+ content = response['content']
110
+ # Project, team id, user id, and branch may not be present in some cases
111
+ @project_id = content['project_id']
112
+ @team_id = content['team_id']
113
+ @user_id = content['user_id']
114
+ @branch = content['branch']
115
+ end
104
116
  end
105
117
  end
106
118
  end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lokalise
4
+ module Collections
5
+ class Segment < Base
6
+ class << self
7
+ def endpoint(project_id, key_id, lang_iso, *_args)
8
+ path_from projects: project_id,
9
+ keys: key_id,
10
+ segments: lang_iso
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -5,19 +5,25 @@ module Lokalise
5
5
  BASE_URL = 'https://api.lokalise.com/api2/'
6
6
 
7
7
  def connection(client)
8
- options = {
8
+ Faraday.new(options(client), request_params_for(client)) do |faraday|
9
+ faraday.use(:gzip) if client.enable_compression
10
+ faraday.adapter Faraday.default_adapter
11
+ end
12
+ end
13
+
14
+ private
15
+
16
+ def options(client)
17
+ {
9
18
  headers: {
10
19
  accept: 'application/json',
11
20
  user_agent: "ruby-lokalise-api gem/#{Lokalise::VERSION}",
12
- 'x-api-token': client.token
21
+ client.token_header => client.token
13
22
  },
14
23
  url: BASE_URL
15
24
  }
16
- Faraday.new(options, request_params_for(client)) { |faraday| faraday.adapter Faraday.default_adapter }
17
25
  end
18
26
 
19
- private
20
-
21
27
  # Allows to customize request params per-client
22
28
  def request_params_for(client)
23
29
  {request: {timeout: client.timeout, open_timeout: client.open_timeout}}
@@ -134,6 +134,20 @@
134
134
  "created_at",
135
135
  "created_at_timestamp"
136
136
  ],
137
+ "segment": [
138
+ "segment_number",
139
+ "language_iso",
140
+ "modified_at",
141
+ "modified_at_timestamp",
142
+ "modified_by",
143
+ "modified_by_email",
144
+ "value",
145
+ "is_fuzzy",
146
+ "is_reviewed",
147
+ "reviewed_by",
148
+ "words",
149
+ "custom_translation_statuses"
150
+ ],
137
151
  "snapshot": [
138
152
  "snapshot_id",
139
153
  "title",
@@ -188,6 +202,18 @@
188
202
  "created_at_timestamp",
189
203
  "role"
190
204
  ],
205
+ "team_user_billing_details": [
206
+ "billing_email",
207
+ "country_code",
208
+ "zip",
209
+ "state_code",
210
+ "address1",
211
+ "address2",
212
+ "city",
213
+ "phone",
214
+ "company",
215
+ "vatnumber"
216
+ ],
191
217
  "team_user_group": [
192
218
  "group_id",
193
219
  "name",
@@ -39,7 +39,8 @@ module Lokalise
39
39
  class << self
40
40
  # Create a new error from an HTTP response
41
41
  def from_response(body)
42
- new body['error']['message'].to_s
42
+ msg = body.key?('error') ? body['error']['message'] : body['message']
43
+ new msg.to_s
43
44
  end
44
45
  end
45
46
 
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lokalise
4
+ class OAuthClient < Client
5
+ def initialize(token, params = {})
6
+ super(token, params)
7
+ @token_header = 'Authorization'
8
+ @token = "Bearer #{@token}"
9
+ end
10
+ end
11
+ end
@@ -58,7 +58,8 @@ module Lokalise
58
58
  def respond_with(response, client)
59
59
  body = custom_load response.body
60
60
  uri = Addressable::URI.parse response.env.url
61
- respond_with_error(response.status, body) if body.respond_to?(:has_key?) && body.key?('error')
61
+ status = response.status
62
+ respond_with_error status, body if status.between?(400, 599) || (body.respond_to?(:has_key?) && body.key?('error'))
62
63
  extract_headers_from(response).
63
64
  merge('content' => body,
64
65
  'client' => client,
@@ -74,7 +75,7 @@ module Lokalise
74
75
  end
75
76
 
76
77
  def respond_with_error(code, body)
77
- raise(Lokalise::Error, body['error']) unless Lokalise::Error::ERRORS.key? code
78
+ raise(Lokalise::Error, body['error'] || body) unless Lokalise::Error::ERRORS.key? code
78
79
 
79
80
  raise Lokalise::Error::ERRORS[code].from_response(body)
80
81
  end
@@ -3,12 +3,14 @@
3
3
  module Lokalise
4
4
  module Resources
5
5
  class Base
6
+ using Lokalise::Utils::StringUtils
7
+
6
8
  extend Lokalise::Request
7
9
  extend Lokalise::Utils::AttributeHelpers
8
10
  include Lokalise::Utils::AttributeHelpers
9
11
  extend Lokalise::Utils::EndpointHelpers
10
12
 
11
- attr_reader :raw_data, :project_id, :client, :path, :branch, :user_id, :team_id
13
+ attr_reader :raw_data, :project_id, :client, :path, :branch, :user_id, :team_id, :key_id
12
14
 
13
15
  # Initializes a new resource based on the response.
14
16
  # `endpoint_generator` is used in cases when a new instance is generated
@@ -107,10 +109,11 @@ module Lokalise
107
109
  end
108
110
 
109
111
  def produce_resource(model_class, response)
112
+ content = response['content']
110
113
  data_key_singular = data_key_for model_class: model_class
111
- if response['content'].key? data_key_singular
112
- data = response['content'].delete data_key_singular
113
- response['content'].merge! data
114
+ if content.key? data_key_singular
115
+ data = content.delete data_key_singular
116
+ content.merge! data
114
117
  end
115
118
 
116
119
  new response
@@ -131,7 +134,7 @@ module Lokalise
131
134
 
132
135
  def path_with_id(response, id_key, data_key, endpoint_generator = nil)
133
136
  # Some resources do not have ids at all
134
- return nil unless response['content'].key?(id_key) || response['content'].key?(data_key)
137
+ return unless response['content'] && (response['content'].key?(id_key) || response['content'].key?(data_key))
135
138
 
136
139
  # ID of the resource
137
140
  id = id_from response, id_key, data_key
@@ -155,15 +158,20 @@ module Lokalise
155
158
  # Content may be `{"project_id": '123', ...}` or {"snapshot": {"snapshot_id": '123', ...}}
156
159
  # Sometimes there is an `id_key` but it has a value of `null`
157
160
  # (for example when we do not place the actual order but only check its price).
161
+ # In rare cases the actual identifier does not have an "_id" suffix
162
+ # (for segments that have "segment_number" field instead)
158
163
  # Therefore we must explicitly check if the key is present
159
- return response['content'][id_key] if response['content'].key?(id_key)
164
+ content = response['content']
165
+ return content[id_key] if content.respond_to?(:key?) && content&.key?(id_key)
160
166
 
161
- response['content'][data_key][id_key]
167
+ content[data_key][id_key]
162
168
  end
163
169
 
164
170
  # Store all resources attributes under the corresponding instance variables.
165
171
  # `ATTRIBUTES` is defined inside resource-specific classes
166
172
  def populate_attributes_for(content)
173
+ return unless content
174
+
167
175
  data_key = data_key_for model_class: self.class.name.base_class_name
168
176
 
169
177
  self.class.const_get(:ATTRIBUTES).each do |attr|
@@ -181,10 +189,13 @@ module Lokalise
181
189
  # Some of them may be absent in certain cases.
182
190
  # rubocop:disable Naming/MemoizedInstanceVariableName
183
191
  def extract_common_attributes_for(content)
192
+ return unless content
193
+
184
194
  @raw_data = content
185
195
  @project_id ||= content['project_id']
186
196
  @user_id ||= content['user_id']
187
197
  @team_id ||= content['team_id']
198
+ @key_id ||= content['key_id']
188
199
  @branch ||= content['branch']
189
200
  end
190
201
  # rubocop:enable Naming/MemoizedInstanceVariableName
@@ -3,10 +3,12 @@
3
3
  module Lokalise
4
4
  module Resources
5
5
  class Branch < Base
6
+ ID_KEY = 'branch_id'
6
7
  supports :update, :destroy, [:reload_data, '', :find]
7
8
 
8
9
  def merge(params = {})
9
- self.class.merge @client, self.class.endpoint(project_id, branch_id, :merge), params
10
+ klass = self.class
11
+ klass.merge @client, klass.endpoint(project_id, branch_id, :merge), params
10
12
  end
11
13
 
12
14
  class << self
@@ -3,7 +3,7 @@
3
3
  module Lokalise
4
4
  module Resources
5
5
  class Contributor < Base
6
- ID_KEY = 'user'
6
+ ID_KEY = 'user_id'
7
7
  supports :update, :destroy, [:reload_data, '', :find]
8
8
 
9
9
  class << self
@@ -3,7 +3,7 @@
3
3
  module Lokalise
4
4
  module Resources
5
5
  class CustomTranslationStatus < Base
6
- ID_KEY = 'status'
6
+ ID_KEY = 'status_id'
7
7
  supports :update, :destroy, [:reload_data, '', :find]
8
8
 
9
9
  class << self
@@ -3,6 +3,7 @@
3
3
  module Lokalise
4
4
  module Resources
5
5
  class Key < Base
6
+ ID_KEY = 'key_id'
6
7
  supports :update, :destroy, [:reload_data, '', :find]
7
8
 
8
9
  class << self
@@ -4,7 +4,7 @@ module Lokalise
4
4
  module Resources
5
5
  class KeyComment < Base
6
6
  DATA_KEY = 'Comment'
7
- ID_KEY = 'comment'
7
+ ID_KEY = 'comment_id'
8
8
  supports :destroy, [:reload_data, '', :find]
9
9
 
10
10
  class << self
@@ -3,6 +3,7 @@
3
3
  module Lokalise
4
4
  module Resources
5
5
  class Order < Base
6
+ ID_KEY = 'order_id'
6
7
  supports [:reload_data, '', :find]
7
8
 
8
9
  class << self
@@ -3,6 +3,7 @@
3
3
  module Lokalise
4
4
  module Resources
5
5
  class PaymentCard < Base
6
+ ID_KEY = 'card_id'
6
7
  supports :destroy, [:reload_data, '', :find]
7
8
 
8
9
  class << self
@@ -3,6 +3,7 @@
3
3
  module Lokalise
4
4
  module Resources
5
5
  class Project < Base
6
+ ID_KEY = 'project_id'
6
7
  supports :update, :destroy, [:reload_data, '', :find]
7
8
 
8
9
  def empty
@@ -3,6 +3,7 @@
3
3
  module Lokalise
4
4
  module Resources
5
5
  class ProjectComment < Base
6
+ ID_KEY = 'comment_id'
6
7
  DATA_KEY = 'Comment'
7
8
  end
8
9
  end
@@ -4,7 +4,7 @@ module Lokalise
4
4
  module Resources
5
5
  class ProjectLanguage < Base
6
6
  DATA_KEY = 'Language'
7
- ID_KEY = 'lang'
7
+ ID_KEY = 'lang_id'
8
8
  supports :update, :destroy, [:reload_data, '', :find]
9
9
 
10
10
  class << self
@@ -4,7 +4,7 @@ module Lokalise
4
4
  module Resources
5
5
  class QueuedProcess < Base
6
6
  DATA_KEY = 'Process'
7
- ID_KEY = 'process'
7
+ ID_KEY = 'process_id'
8
8
  supports [:reload_data, '', :find]
9
9
 
10
10
  class << self
@@ -3,6 +3,7 @@
3
3
  module Lokalise
4
4
  module Resources
5
5
  class Screenshot < Base
6
+ ID_KEY = 'screenshot_id'
6
7
  supports :update, :destroy, [:reload_data, '', :find]
7
8
 
8
9
  class << self
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lokalise
4
+ module Resources
5
+ class Segment < Base
6
+ DATA_KEY = 'Segment'
7
+ ID_KEY = 'segment_number'
8
+ supports :update, [:reload_data, '', :find]
9
+
10
+ class << self
11
+ def endpoint(project_id, key_id, lang_iso, segment_number = nil)
12
+ path_from projects: project_id,
13
+ keys: key_id,
14
+ segments: [lang_iso, segment_number]
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -3,6 +3,7 @@
3
3
  module Lokalise
4
4
  module Resources
5
5
  class Snapshot < Base
6
+ ID_KEY = 'snapshot_id'
6
7
  supports :destroy
7
8
 
8
9
  def restore
@@ -3,6 +3,7 @@
3
3
  module Lokalise
4
4
  module Resources
5
5
  class Task < Base
6
+ ID_KEY = 'task_id'
6
7
  supports :update, :destroy, [:reload_data, '', :find]
7
8
 
8
9
  class << self
@@ -3,7 +3,7 @@
3
3
  module Lokalise
4
4
  module Resources
5
5
  class TeamUser < Base
6
- ID_KEY = 'user'
6
+ ID_KEY = 'user_id'
7
7
  supports :update, :destroy, [:reload_data, '', :find]
8
8
 
9
9
  class << self
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lokalise
4
+ module Resources
5
+ class TeamUserBillingDetails < Base
6
+ class << self
7
+ def endpoint(team_id)
8
+ path_from teams: team_id,
9
+ billing_details: ''
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -4,7 +4,7 @@ module Lokalise
4
4
  module Resources
5
5
  class TeamUserGroup < Base
6
6
  DATA_KEY = 'Group'
7
- ID_KEY = 'group'
7
+ ID_KEY = 'group_id'
8
8
  supports :update, :destroy,
9
9
  [:add_projects, '/projects/add', :update],
10
10
  [:remove_projects, '/projects/remove', :update],
@@ -3,6 +3,7 @@
3
3
  module Lokalise
4
4
  module Resources
5
5
  class Translation < Base
6
+ ID_KEY = 'translation_id'
6
7
  supports :update, [:reload_data, '', :find]
7
8
 
8
9
  class << self
@@ -4,7 +4,7 @@ module Lokalise
4
4
  module Resources
5
5
  class TranslationProvider < Base
6
6
  supports [:reload_data, '', :find]
7
- ID_KEY = 'provider'
7
+ ID_KEY = 'provider_id'
8
8
 
9
9
  class << self
10
10
  def endpoint(team_id, provider_id = nil)
@@ -3,6 +3,7 @@
3
3
  module Lokalise
4
4
  module Resources
5
5
  class Webhook < Base
6
+ ID_KEY = 'webhook_id'
6
7
  supports :update, :destroy, [:reload_data, '', :find]
7
8
 
8
9
  def regenerate_secret
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lokalise
4
+ class Client
5
+ # Returns all segments for the given key and language ISO code
6
+ #
7
+ # @see https://app.lokalise.com/api2docs/curl/#transition-list-all-segments-for-key-language-get
8
+ # @return [Lokalise::Collection::Segments<Lokalise::Resources::Segment>]
9
+ # @param project_id [String]
10
+ # @param key_id [String, Integer]
11
+ # @param lang_iso [String]
12
+ # @param params [Hash]
13
+ def segments(project_id, key_id, lang_iso, params = {})
14
+ c_r Lokalise::Collections::Segment, :all, [project_id, key_id, lang_iso], params
15
+ end
16
+
17
+ # Returns a segment under a given number for the given key and language ISO code
18
+ #
19
+ # @see https://app.lokalise.com/api2docs/curl/#transition-retrieve-a-segment-for-key-language-get
20
+ # @return [Lokalise::Resources::Segment]
21
+ # @param project_id [String]
22
+ # @param key_id [String, Integer]
23
+ # @param lang_iso [String]
24
+ # @params segment_number [Integer, String]
25
+ # @param params [Hash]
26
+ def segment(project_id, key_id, lang_iso, segment_number, params = {})
27
+ c_r Lokalise::Resources::Segment, :find, [project_id, key_id, lang_iso, segment_number], params
28
+ end
29
+
30
+ # Updates a segment under a given number for the given key and language ISO code
31
+ #
32
+ # @see https://app.lokalise.com/api2docs/curl/#transition-update-a-segment-post
33
+ # @return [Lokalise::Resources::Segment]
34
+ # @param project_id [String]
35
+ # @param key_id [String, Integer]
36
+ # @param lang_iso [String]
37
+ # @params segment_number [Integer, String]
38
+ # @param params [Hash]
39
+ def update_segment(project_id, key_id, lang_iso, segment_number, params = {})
40
+ c_r Lokalise::Resources::Segment, :update, [project_id, key_id, lang_iso, segment_number], params
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Lokalise
4
+ class Client
5
+ # Returns team user billing details
6
+ #
7
+ # @see https://app.lokalise.com/api2docs/curl/#transition-retrieve-team-user-billing-details-get
8
+ # @return [Lokalise::Resources::TeamUserBillingDetails]
9
+ # @param team_id [String]
10
+ def team_user_billing_details(team_id)
11
+ c_r Lokalise::Resources::TeamUserBillingDetails, :find, team_id
12
+ end
13
+
14
+ # Creates team user billing details
15
+ #
16
+ # @see https://app.lokalise.com/api2docs/curl/#transition-create-team-user-billing-details-post
17
+ # @return [Lokalise::Resources::TeamUserBillingDetails]
18
+ # @param team_id [String]
19
+ # @param params [Hash]
20
+ def create_team_user_billing_details(team_id, params)
21
+ c_r Lokalise::Resources::TeamUserBillingDetails, :create, team_id, params
22
+ end
23
+
24
+ # Updates team user billing details
25
+ #
26
+ # @see https://app.lokalise.com/api2docs/curl/#transition-create-team-user-billing-details-post
27
+ # @return [Lokalise::Resources::TeamUserBillingDetails]
28
+ # @param team_id [String]
29
+ # @param params [Hash]
30
+ def update_team_user_billing_details(team_id, params)
31
+ c_r Lokalise::Resources::TeamUserBillingDetails, :update, team_id, params
32
+ end
33
+ end
34
+ end