ruby-lokalise-api 7.0.0 → 7.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a0df97ee1958c45138da225b66c6cc99797a9cf77c3f84435b3fff41e86317c9
4
- data.tar.gz: a98e58642231426d959a49299d47154c1883d1fa89214693bf062642a89c4581
3
+ metadata.gz: 9f195975b35421d2d4be87df71c5167fe34fc7143b580a1b79368a30d386e5cf
4
+ data.tar.gz: f461a8e2069ad81f3dd618cfa7f46641bdd020dbf893eb639e1cb04a83e35221
5
5
  SHA512:
6
- metadata.gz: 3b1760ad8acee33810dc905ceb9fe8ff3791b8ac42cda5affb031112c53b0981dc5a2ad714d5ee04352fd5c50856ec695c45abf1c3765e939ab8230f1ed78ff1
7
- data.tar.gz: 947b22b36b74ebde8abeeb8edde48b701e9b4cfd2f4f7bbf5f1c2e35aa94408c1b4deb60b56ab03c65ae1f0f5405c0aef0a9a5cdbf15d0e8e094060d75aeea34
6
+ metadata.gz: 01d5ef8819e3cdba05c651049a7c8fb4876d0e1b59b6fc3a87442ef3ec178c2ca2799ebbf145a94cba9cae37faac9fa0f8e4e6297023e88fab6aa5df19d6f627
7
+ data.tar.gz: 57bd17227380725a5b0e7898f23714584e354ace578b7e09f9c7fb87ce973594d07954d6cfcad3f42fc4a28b1d07ce2e9c681570f8fbc4f0b5d675bea75a1e6a
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  BSD 3 Clause
2
2
 
3
- Copyright 2021 Lokalise Group, Ilya Krukowski
3
+ Copyright 2023 Lokalise Group, Ilya Krukowski
4
4
 
5
5
  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6
6
 
data/README.md CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  ![Gem](https://img.shields.io/gem/v/ruby-lokalise-api)
4
4
  ![CI](https://github.com/lokalise/ruby-lokalise-api/actions/workflows/ci.yml/badge.svg)
5
- [![Test Coverage](https://codecov.io/gh/lokalise/ruby-lokalise-api/graph/badge.svg)](https://codecov.io/gh/lokalise/ruby-lokalise-api)
6
5
  ![Downloads total](https://img.shields.io/gem/dt/ruby-lokalise-api)
7
6
 
8
7
  Official opinionated Ruby interface for the [Lokalise API](https://developers.lokalise.com/reference/lokalise-rest-api) that represents returned data as Ruby objects.
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyLokaliseApi
4
+ class BaseClient
5
+ attr_reader :token, :token_header
6
+ attr_accessor :timeout, :open_timeout
7
+
8
+ def initialize(token, params = {})
9
+ @token = token
10
+ @timeout = params.fetch(:timeout, nil)
11
+ @open_timeout = params.fetch(:open_timeout, nil)
12
+ @token_header = ''
13
+ end
14
+
15
+ # rubocop:disable Metrics/ParameterLists
16
+ # Constructs request to perform the specified action
17
+ # @param klass The actual class to call the method upon
18
+ # @param method [Symbol] The method to call (:new, :update, :create etc)
19
+ # @param endpoint_ids [Array, Hash] IDs that are used to generate the proper path to the endpoint
20
+ # @param params [Array, Hash] Request parameters
21
+ # @param object_key [String, Symbol] Key that should be used to wrap parameters into
22
+ # @param initial_ids [Array] IDs that should be used to generate base endpoint path.
23
+ # The base path is used for method chaining
24
+ def construct_request(klass, method, endpoint_ids, params = {}, object_key = nil, initial_ids = nil)
25
+ path = klass.endpoint(*endpoint_ids)
26
+ formatted_params = format_params(params, object_key)
27
+ formatted_params[:_initial_path] = klass.endpoint(*initial_ids) if initial_ids
28
+ klass.send method, self, path, formatted_params
29
+ end
30
+ # rubocop:enable Metrics/ParameterLists
31
+
32
+ # Converts `params` to hash with arrays under the `object_key` key.
33
+ # Used in bulk operations
34
+ #
35
+ # @return [Hash]
36
+ def format_params(params, object_key)
37
+ return params unless object_key
38
+
39
+ params = [params] unless params.is_a?(Array)
40
+ {object_key => params}
41
+ end
42
+
43
+ def base_url; end
44
+
45
+ def compression?; end
46
+
47
+ alias c_r construct_request
48
+ end
49
+ end
@@ -1,12 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyLokaliseApi
4
- class Client
4
+ class Client < BaseClient
5
5
  include RubyLokaliseApi::Rest::Branches
6
6
  include RubyLokaliseApi::Rest::Comments
7
7
  include RubyLokaliseApi::Rest::Contributors
8
8
  include RubyLokaliseApi::Rest::CustomTranslationStatuses
9
9
  include RubyLokaliseApi::Rest::Files
10
+ include RubyLokaliseApi::Rest::Jwt
10
11
  include RubyLokaliseApi::Rest::Keys
11
12
  include RubyLokaliseApi::Rest::Languages
12
13
  include RubyLokaliseApi::Rest::Orders
@@ -25,42 +26,10 @@ module RubyLokaliseApi
25
26
  include RubyLokaliseApi::Rest::Translations
26
27
  include RubyLokaliseApi::Rest::Webhooks
27
28
 
28
- attr_reader :token, :token_header
29
- attr_accessor :timeout, :open_timeout
30
-
31
29
  def initialize(token, params = {})
32
- @token = token
33
- @timeout = params.fetch(:timeout, nil)
34
- @open_timeout = params.fetch(:open_timeout, nil)
35
- @token_header = 'x-api-token'
36
- end
37
-
38
- # rubocop:disable Metrics/ParameterLists
39
- # Constructs request to perform the specified action
40
- # @param klass The actual class to call the method upon
41
- # @param method [Symbol] The method to call (:new, :update, :create etc)
42
- # @param endpoint_ids [Array, Hash] IDs that are used to generate the proper path to the endpoint
43
- # @param params [Array, Hash] Request parameters
44
- # @param object_key [String, Symbol] Key that should be used to wrap parameters into
45
- # @param initial_ids [Array] IDs that should be used to generate base endpoint path.
46
- # The base path is used for method chaining
47
- def construct_request(klass, method, endpoint_ids, params = {}, object_key = nil, initial_ids = nil)
48
- path = klass.endpoint(*endpoint_ids)
49
- formatted_params = format_params(params, object_key)
50
- formatted_params[:_initial_path] = klass.endpoint(*initial_ids) if initial_ids
51
- klass.send method, self, path, formatted_params
52
- end
53
- # rubocop:enable Metrics/ParameterLists
54
-
55
- # Converts `params` to hash with arrays under the `object_key` key.
56
- # Used in bulk operations
57
- #
58
- # @return [Hash]
59
- def format_params(params, object_key)
60
- return params unless object_key
30
+ super(token, params)
61
31
 
62
- params = [params] unless params.is_a?(Array)
63
- {object_key => params}
32
+ @token_header = 'x-api-token'
64
33
  end
65
34
 
66
35
  def base_url
@@ -70,7 +39,5 @@ module RubyLokaliseApi
70
39
  def compression?
71
40
  true
72
41
  end
73
-
74
- alias c_r construct_request
75
42
  end
76
43
  end
@@ -30,6 +30,8 @@ custom_translation_status:
30
30
  file:
31
31
  - filename
32
32
  - key_count
33
+ jwt:
34
+ - jwt
33
35
  key:
34
36
  - key_id
35
37
  - created_at
@@ -14,10 +14,6 @@ module RubyLokaliseApi
14
14
  @open_timeout = params[:open_timeout]
15
15
  end
16
16
 
17
- def base_url
18
- URI('https://app.lokalise.com/oauth2/')
19
- end
20
-
21
17
  def auth(scope:, redirect_uri: nil, state: nil)
22
18
  scope = scope.join(' ') if scope.is_a?(Array)
23
19
 
@@ -49,6 +45,10 @@ module RubyLokaliseApi
49
45
  RubyLokaliseApi::OAuth2::Refresh.new post('token', self, params)
50
46
  end
51
47
 
48
+ def base_url
49
+ URI('https://app.lokalise.com/oauth2/')
50
+ end
51
+
52
52
  def compression?
53
53
  false
54
54
  end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyLokaliseApi
4
+ module Resources
5
+ class Jwt < Base
6
+ class << self
7
+ def endpoint(*_args)
8
+ path_from 'jwt-tokens': 'ota'
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyLokaliseApi
4
+ module Rest
5
+ module Jwt
6
+ # Returns a JWT that can be used to work with OTA
7
+ #
8
+ # @see https://developers.lokalise.com/reference/get-ota-jwt
9
+ # @return [RubyLokaliseApi::Resources::Jwt]
10
+ def jwt
11
+ c_r RubyLokaliseApi::Resources::Jwt, :find, nil, {}
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyLokaliseApi
4
- VERSION = '7.0.0'
4
+ VERSION = '7.1.1'
5
5
  end
@@ -23,11 +23,10 @@ Gem::Specification.new do |spec|
23
23
 
24
24
  spec.add_dependency 'addressable', '~> 2.5'
25
25
  spec.add_dependency 'faraday', '~> 2.0'
26
- spec.add_dependency 'faraday-gzip', '~> 0.1'
26
+ spec.add_dependency 'faraday-gzip', '>= 0.1', '< 2.0'
27
27
  spec.add_dependency 'json', '~> 2'
28
28
  spec.add_dependency 'zeitwerk', '~> 2.4'
29
29
 
30
- spec.add_development_dependency 'codecov', '~> 0.1'
31
30
  spec.add_development_dependency 'dotenv', '~> 2.5'
32
31
  spec.add_development_dependency 'oj', '~> 3.10'
33
32
  spec.add_development_dependency 'rake', '~> 13.0'
@@ -36,7 +35,7 @@ Gem::Specification.new do |spec|
36
35
  spec.add_development_dependency 'rubocop-performance', '~> 1.5'
37
36
  spec.add_development_dependency 'rubocop-rake', '~> 0.6'
38
37
  spec.add_development_dependency 'rubocop-rspec', '~> 2.0'
39
- spec.add_development_dependency 'simplecov', '~> 0.16'
38
+ spec.add_development_dependency 'simplecov', '~> 0.21'
40
39
  spec.add_development_dependency 'vcr', '~> 6.0'
41
40
  spec.add_development_dependency 'webmock', '~> 3.14'
42
41
  spec.metadata = {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-lokalise-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.0
4
+ version: 7.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilya Krukowski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-11-18 00:00:00.000000000 Z
11
+ date: 2023-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -42,16 +42,22 @@ dependencies:
42
42
  name: faraday-gzip
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0.1'
48
+ - - "<"
49
+ - !ruby/object:Gem::Version
50
+ version: '2.0'
48
51
  type: :runtime
49
52
  prerelease: false
50
53
  version_requirements: !ruby/object:Gem::Requirement
51
54
  requirements:
52
- - - "~>"
55
+ - - ">="
53
56
  - !ruby/object:Gem::Version
54
57
  version: '0.1'
58
+ - - "<"
59
+ - !ruby/object:Gem::Version
60
+ version: '2.0'
55
61
  - !ruby/object:Gem::Dependency
56
62
  name: json
57
63
  requirement: !ruby/object:Gem::Requirement
@@ -80,20 +86,6 @@ dependencies:
80
86
  - - "~>"
81
87
  - !ruby/object:Gem::Version
82
88
  version: '2.4'
83
- - !ruby/object:Gem::Dependency
84
- name: codecov
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: '0.1'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: '0.1'
97
89
  - !ruby/object:Gem::Dependency
98
90
  name: dotenv
99
91
  requirement: !ruby/object:Gem::Requirement
@@ -212,14 +204,14 @@ dependencies:
212
204
  requirements:
213
205
  - - "~>"
214
206
  - !ruby/object:Gem::Version
215
- version: '0.16'
207
+ version: '0.21'
216
208
  type: :development
217
209
  prerelease: false
218
210
  version_requirements: !ruby/object:Gem::Requirement
219
211
  requirements:
220
212
  - - "~>"
221
213
  - !ruby/object:Gem::Version
222
- version: '0.16'
214
+ version: '0.21'
223
215
  - !ruby/object:Gem::Dependency
224
216
  name: vcr
225
217
  requirement: !ruby/object:Gem::Requirement
@@ -266,6 +258,7 @@ files:
266
258
  - README.md
267
259
  - Rakefile
268
260
  - lib/ruby_lokalise_api.rb
261
+ - lib/ruby_lokalise_api/base_client.rb
269
262
  - lib/ruby_lokalise_api/base_request.rb
270
263
  - lib/ruby_lokalise_api/client.rb
271
264
  - lib/ruby_lokalise_api/collections/base.rb
@@ -306,6 +299,7 @@ files:
306
299
  - lib/ruby_lokalise_api/resources/contributor.rb
307
300
  - lib/ruby_lokalise_api/resources/custom_translation_status.rb
308
301
  - lib/ruby_lokalise_api/resources/file.rb
302
+ - lib/ruby_lokalise_api/resources/jwt.rb
309
303
  - lib/ruby_lokalise_api/resources/key.rb
310
304
  - lib/ruby_lokalise_api/resources/key_comment.rb
311
305
  - lib/ruby_lokalise_api/resources/order.rb
@@ -331,6 +325,7 @@ files:
331
325
  - lib/ruby_lokalise_api/rest/contributors.rb
332
326
  - lib/ruby_lokalise_api/rest/custom_translation_statuses.rb
333
327
  - lib/ruby_lokalise_api/rest/files.rb
328
+ - lib/ruby_lokalise_api/rest/jwt.rb
334
329
  - lib/ruby_lokalise_api/rest/keys.rb
335
330
  - lib/ruby_lokalise_api/rest/languages.rb
336
331
  - lib/ruby_lokalise_api/rest/orders.rb
@@ -373,7 +368,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
373
368
  - !ruby/object:Gem::Version
374
369
  version: '0'
375
370
  requirements: []
376
- rubygems_version: 3.3.26
371
+ rubygems_version: 3.4.2
377
372
  signing_key:
378
373
  specification_version: 4
379
374
  summary: Ruby interface to the Lokalise API