ruby-lokalise-api 6.2.0 → 7.1.0

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: 90b862c7994f5c977a2a3a71dac7877163d83c7051ea16b808a770f2b1c24f9e
4
- data.tar.gz: ca1cb74e869faae115c85d59011bd254bf0f06e6738d81297de4239d73c4c8d9
3
+ metadata.gz: 6f88c68ae7c24d90be54394259b2fc477eb52a485775be7292789ea743155556
4
+ data.tar.gz: 0ce8f2d8db252f4e7fa44cb87b68786adfacd86849b16d10c60ab58d3b9e51b8
5
5
  SHA512:
6
- metadata.gz: 98cba873be8c354d5de708493cbdf078bca3c1269b8587417044b3a7e5b2c8d235b83e09de84cb2d03279d3459074b1b150dc7b8a5e830be12332254d2f57cbf
7
- data.tar.gz: 5ef019ca07ac5e515f31805ebc63dd962832e42df1c10de46bc6a053de8639d92831763687d8cd80289ec8fb755da9c6b15f8272c0ec50c00c0ce722be4ed30c
6
+ metadata.gz: bb4469e28faafba3f0c81f4fb27b5b2747055da3d93cca81cf4244a38d0962ba896770a5fa8d81e859ad26f6f67cdf549ad288073bd5c946c5dacc58a812a1e7
7
+ data.tar.gz: fc41d966f5c55bbf900015ae3fa8f60f28cb9f1931b1f3172c247152e040dc0fab8b51eff7dcd107cd4423c73dca615b3db4f27e7e83acd963b37724d9251025
data/Rakefile CHANGED
@@ -1,6 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'rake'
4
+ require 'rake/clean'
5
+ require 'rspec/core/rake_task'
6
+ require 'rubocop/rake_task'
4
7
 
5
8
  begin
6
9
  require 'bundler/setup'
@@ -9,13 +12,33 @@ rescue LoadError
9
12
  puts 'although not required, bundler is recommened for running the tests'
10
13
  end
11
14
 
12
- task default: :spec
13
-
14
- require 'rspec/core/rake_task'
15
15
  RSpec::Core::RakeTask.new(:spec)
16
16
 
17
- require 'rubocop/rake_task'
18
17
  RuboCop::RakeTask.new do |task|
19
18
  task.requires << 'rubocop-performance'
20
19
  task.requires << 'rubocop-rspec'
20
+ task.requires << 'rubocop-rake'
21
+ end
22
+
23
+ CLOBBER.include(FileList['./*.gem'])
24
+
25
+ namespace :lokalise do
26
+ desc 'Updates RubyGems, installs dependencies'
27
+ task :install do
28
+ puts 'Running bundle install'
29
+ sh 'gem update --system'
30
+ sh 'bundle'
31
+ end
32
+
33
+ desc 'Builds the gem'
34
+ task :build do
35
+ puts 'Building'
36
+ sh 'gem build ruby-lokalise-api.gemspec'
37
+ end
21
38
  end
39
+
40
+ task rubospec: %w[rubocop spec]
41
+
42
+ task full_build: %w[clobber lokalise:install lokalise:build]
43
+
44
+ task default: :full_build
@@ -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
@@ -3,6 +3,47 @@
3
3
  module RubyLokaliseApi
4
4
  module BaseRequest
5
5
  include RubyLokaliseApi::JsonHandler
6
+ include RubyLokaliseApi::Connection
7
+
8
+ def get(path, client, params = {})
9
+ respond_with(
10
+ connection(client).get(prepare(path), params),
11
+ client
12
+ )
13
+ end
14
+
15
+ def post(path, client, params = {})
16
+ respond_with(
17
+ connection(client).post(prepare(path), custom_dump(params)),
18
+ client
19
+ )
20
+ end
21
+
22
+ def put(path, client, params = {})
23
+ respond_with(
24
+ connection(client).put(prepare(path), custom_dump(params)),
25
+ client
26
+ )
27
+ end
28
+
29
+ def patch(path, client, params = {})
30
+ respond_with(
31
+ connection(client).patch(prepare(path), params.any? ? custom_dump(params) : nil),
32
+ client
33
+ )
34
+ end
35
+
36
+ def delete(path, client, params = {})
37
+ respond_with(
38
+ # Rubocop tries to replace `delete` with `gsub` but that's a different method here!
39
+ # rubocop:disable Style/CollectionMethods
40
+ connection(client).delete(prepare(path)) do |req|
41
+ # rubocop:enable Style/CollectionMethods
42
+ req.body = custom_dump params
43
+ end,
44
+ client
45
+ )
46
+ end
6
47
 
7
48
  private
8
49
 
@@ -11,8 +52,16 @@ module RubyLokaliseApi
11
52
  path.delete_prefix('/').gsub(%r{//}, '/').gsub(%r{/+\z}, '')
12
53
  end
13
54
 
14
- def raise_on_error!(status, body)
15
- respond_with_error(status, body) if status.between?(400, 599) || (body.respond_to?(:has_key?) && body.key?('error'))
55
+ def raise_on_error!(response, body)
56
+ return unless !response.success? || (body.respond_to?(:has_key?) && body.key?('error'))
57
+
58
+ respond_with_error(response.status, body)
59
+ end
60
+
61
+ def respond_with(response, _client)
62
+ body = custom_load response.body
63
+ raise_on_error! response, body
64
+ body
16
65
  end
17
66
 
18
67
  def respond_with_error(code, body)
@@ -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,43 +26,18 @@ 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)
30
+ super(token, params)
31
+
35
32
  @token_header = 'x-api-token'
36
33
  end
37
34
 
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. The base path is used for method chaining
46
- def construct_request(klass, method, endpoint_ids, params = {}, object_key = nil, initial_ids = nil)
47
- path = klass.endpoint(*endpoint_ids)
48
- formatted_params = format_params(params, object_key)
49
- formatted_params[:_initial_path] = klass.endpoint(*initial_ids) if initial_ids
50
- klass.send method, self, path, formatted_params
35
+ def base_url
36
+ 'https://api.lokalise.com/api2/'
51
37
  end
52
- # rubocop:enable Metrics/ParameterLists
53
38
 
54
- # Converts `params` to hash with arrays under the `object_key` key.
55
- # Used in bulk operations
56
- #
57
- # @return [Hash]
58
- def format_params(params, object_key)
59
- return params unless object_key
60
-
61
- params = [params] unless params.is_a?(Array)
62
- {object_key => params}
39
+ def compression?
40
+ true
63
41
  end
64
-
65
- alias c_r construct_request
66
42
  end
67
43
  end
@@ -2,26 +2,33 @@
2
2
 
3
3
  module RubyLokaliseApi
4
4
  module Connection
5
- BASE_URL = 'https://api.lokalise.com/api2/'
6
-
7
5
  def connection(client)
8
6
  Faraday.new(options(client), request_params_for(client)) do |faraday|
9
7
  faraday.adapter Faraday.default_adapter
10
- faraday.request :gzip
8
+ faraday.request(:gzip) if client.compression?
11
9
  end
12
10
  end
13
11
 
14
12
  private
15
13
 
16
14
  def options(client)
15
+ params = __base_options(client)
16
+
17
+ if client.respond_to?(:token) && client.respond_to?(:token_header)
18
+ params[:headers][client.token_header] = client.token
19
+ end
20
+ params[:headers][:accept_encoding] = 'gzip,deflate,br' if client.compression?
21
+
22
+ params
23
+ end
24
+
25
+ def __base_options(client)
17
26
  {
18
27
  headers: {
19
28
  accept: 'application/json',
20
- user_agent: "ruby-lokalise-api gem/#{RubyLokaliseApi::VERSION}",
21
- accept_encoding: 'gzip,deflate,br',
22
- client.token_header => client.token
29
+ user_agent: "ruby-lokalise-api gem/#{RubyLokaliseApi::VERSION}"
23
30
  },
24
- url: BASE_URL
31
+ url: client.base_url
25
32
  }
26
33
  end
27
34
 
@@ -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
@@ -3,13 +3,15 @@
3
3
  module RubyLokaliseApi
4
4
  module OAuth2
5
5
  class Auth
6
- include RubyLokaliseApi::OAuth2::Request
6
+ include RubyLokaliseApi::BaseRequest
7
7
 
8
- attr_reader :client_id, :client_secret
8
+ attr_reader :client_id, :client_secret, :timeout, :open_timeout
9
9
 
10
- def initialize(client_id, client_secret)
10
+ def initialize(client_id, client_secret, params = {})
11
11
  @client_id = client_id
12
12
  @client_secret = client_secret
13
+ @timeout = params[:timeout]
14
+ @open_timeout = params[:open_timeout]
13
15
  end
14
16
 
15
17
  def auth(scope:, redirect_uri: nil, state: nil)
@@ -30,7 +32,8 @@ module RubyLokaliseApi
30
32
  code: code,
31
33
  grant_type: 'authorization_code'
32
34
  })
33
- post 'token', params
35
+
36
+ RubyLokaliseApi::OAuth2::Token.new post('token', self, params)
34
37
  end
35
38
 
36
39
  def refresh(token)
@@ -38,7 +41,16 @@ module RubyLokaliseApi
38
41
  refresh_token: token,
39
42
  grant_type: 'refresh_token'
40
43
  })
41
- post 'token', params
44
+
45
+ RubyLokaliseApi::OAuth2::Refresh.new post('token', self, params)
46
+ end
47
+
48
+ def base_url
49
+ URI('https://app.lokalise.com/oauth2/')
50
+ end
51
+
52
+ def compression?
53
+ false
42
54
  end
43
55
 
44
56
  private
@@ -52,8 +64,8 @@ module RubyLokaliseApi
52
64
 
53
65
  def _build_url_from(params)
54
66
  URI::HTTPS.build(
55
- host: BASE_URL.host,
56
- path: "#{BASE_URL.path}auth",
67
+ host: base_url.host,
68
+ path: "#{base_url.path}auth",
57
69
  query: URI.encode_www_form(params)
58
70
  ).to_s
59
71
  end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyLokaliseApi
4
+ module OAuth2
5
+ class Refresh
6
+ attr_reader :access_token, :expires_in, :scope, :token_type
7
+
8
+ def initialize(raw_params)
9
+ @access_token = raw_params['access_token']
10
+ @expires_in = raw_params['expires_in']
11
+ @scope = raw_params['scope']
12
+ @token_type = raw_params['token_type']
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyLokaliseApi
4
+ module OAuth2
5
+ class Token
6
+ attr_reader :access_token, :refresh_token, :expires_in, :token_type
7
+
8
+ def initialize(raw_params)
9
+ @access_token = raw_params['access_token']
10
+ @refresh_token = raw_params['refresh_token']
11
+ @expires_in = raw_params['expires_in']
12
+ @token_type = raw_params['token_type']
13
+ end
14
+ end
15
+ end
16
+ end
@@ -3,58 +3,17 @@
3
3
  module RubyLokaliseApi
4
4
  module Request
5
5
  include RubyLokaliseApi::BaseRequest
6
- include RubyLokaliseApi::Connection
7
6
 
8
7
  # Lokalise returns pagination info in special headers
9
- PAGINATION_HEADERS = %w[x-pagination-total-count x-pagination-page-count x-pagination-limit x-pagination-page].freeze
10
-
11
- def get(path, client, params = {})
12
- respond_with(
13
- connection(client).get(prepare(path), params),
14
- client
15
- )
16
- end
17
-
18
- def post(path, client, params = {})
19
- respond_with(
20
- connection(client).post(prepare(path), custom_dump(params)),
21
- client
22
- )
23
- end
24
-
25
- def put(path, client, params = {})
26
- respond_with(
27
- connection(client).put(prepare(path), custom_dump(params)),
28
- client
29
- )
30
- end
31
-
32
- def patch(path, client, params = {})
33
- respond_with(
34
- connection(client).patch(prepare(path), params.any? ? custom_dump(params) : nil),
35
- client
36
- )
37
- end
38
-
39
- def delete(path, client, params = {})
40
- respond_with(
41
- # Rubocop tries to replace `delete` with `gsub` but that's a different method here!
42
- # rubocop:disable Style/CollectionMethods
43
- connection(client).delete(prepare(path)) do |req|
44
- # rubocop:enable Style/CollectionMethods
45
- req.body = custom_dump params
46
- end,
47
- client
48
- )
49
- end
8
+ PAGINATION_HEADERS = %w[x-pagination-total-count x-pagination-page-count x-pagination-limit
9
+ x-pagination-page].freeze
50
10
 
51
11
  private
52
12
 
53
13
  def respond_with(response, client)
54
14
  body = custom_load response.body
55
15
  uri = Addressable::URI.parse response.env.url
56
- status = response.status
57
- raise_on_error! status, body
16
+ raise_on_error! response, body
58
17
  extract_headers_from(response).
59
18
  merge('content' => body,
60
19
  'client' => client,
@@ -27,12 +27,17 @@ module RubyLokaliseApi
27
27
  @path = infer_path_from response, endpoint_generator
28
28
  end
29
29
 
30
+ # Returns object attribute with [] notation by calling
31
+ # the corresponding method on the object if the
32
+ # instance variable named after the requested key exists
33
+ #
34
+ # @param raw_key_attr [String or Hash]
30
35
  def [](raw_key_attr)
31
36
  key_attr = raw_key_attr.to_s.to_sym
32
37
 
33
- return nil unless self.instance_variables.include?(:"@#{key_attr}")
38
+ return nil unless instance_variables.include?(:"@#{key_attr}")
34
39
 
35
- self.send key_attr
40
+ send key_attr
36
41
  end
37
42
 
38
43
  class << self
@@ -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
@@ -6,7 +6,8 @@ module RubyLokaliseApi
6
6
  # Returns all translation statuses for the given project
7
7
  #
8
8
  # @see https://developers.lokalise.com/reference/list-all-custom-translation-statuses
9
- # @return [RubyLokaliseApi::Collection::CustomTranslationStatus<RubyLokaliseApi::Resources::CustomTranslationStatus>]
9
+ # @return [RubyLokaliseApi::Collection::CustomTranslationStatus
10
+ # <RubyLokaliseApi::Resources::CustomTranslationStatus>]
10
11
  # @param project_id [String]
11
12
  # @param params [Hash]
12
13
  def translation_statuses(project_id, params = {})
@@ -13,7 +13,8 @@ module RubyLokaliseApi
13
13
  c_r RubyLokaliseApi::Collections::File, :all, project_id, params
14
14
  end
15
15
 
16
- # Exports translation files as .zip bundle, uploads them to Amazon S3 and returns a URL to the generated bundle. The URL is valid for a year
16
+ # Exports translation files as .zip bundle, uploads them to Amazon S3 and
17
+ # returns a URL to the generated bundle. The URL is valid for a year
17
18
  #
18
19
  # @see https://developers.lokalise.com/reference/download-files
19
20
  # @return [Hash]
@@ -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
@@ -70,7 +70,8 @@ module RubyLokaliseApi
70
70
  key ? key.snakecase : key
71
71
  end
72
72
 
73
- # Unify some resources' names (eg, `ProjectComment` and `KeyComment` have the same attributes which are stored under `comment`)
73
+ # Unify some resources' names (eg, `ProjectComment` and `KeyComment` have the same
74
+ # attributes which are stored under `comment`)
74
75
  #
75
76
  # @return [String]
76
77
  def unify(name)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyLokaliseApi
4
- VERSION = '6.2.0'
4
+ VERSION = '7.1.0'
5
5
  end
@@ -43,8 +43,14 @@ module RubyLokaliseApi
43
43
  @oauth2_client = nil
44
44
  end
45
45
 
46
- def auth_client(client_id, client_secret)
47
- RubyLokaliseApi::OAuth2::Auth.new client_id, client_secret
46
+ # Initializes a new Auth client to request OAuth 2 tokens
47
+ #
48
+ # @return [RubyLokaliseApi::OAuth2::Auth]
49
+ # @param client_id [String]
50
+ # @param client_secret [String]
51
+ # @param params [Hash]
52
+ def auth_client(client_id, client_secret, params = {})
53
+ RubyLokaliseApi::OAuth2::Auth.new client_id, client_secret, params
48
54
  end
49
55
  end
50
56
  end
@@ -34,6 +34,7 @@ Gem::Specification.new do |spec|
34
34
  spec.add_development_dependency 'rspec', '~> 3.6'
35
35
  spec.add_development_dependency 'rubocop', '~> 1.6'
36
36
  spec.add_development_dependency 'rubocop-performance', '~> 1.5'
37
+ spec.add_development_dependency 'rubocop-rake', '~> 0.6'
37
38
  spec.add_development_dependency 'rubocop-rspec', '~> 2.0'
38
39
  spec.add_development_dependency 'simplecov', '~> 0.16'
39
40
  spec.add_development_dependency 'vcr', '~> 6.0'
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: 6.2.0
4
+ version: 7.1.0
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-08-02 00:00:00.000000000 Z
11
+ date: 2022-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -178,6 +178,20 @@ dependencies:
178
178
  - - "~>"
179
179
  - !ruby/object:Gem::Version
180
180
  version: '1.5'
181
+ - !ruby/object:Gem::Dependency
182
+ name: rubocop-rake
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - "~>"
186
+ - !ruby/object:Gem::Version
187
+ version: '0.6'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - "~>"
193
+ - !ruby/object:Gem::Version
194
+ version: '0.6'
181
195
  - !ruby/object:Gem::Dependency
182
196
  name: rubocop-rspec
183
197
  requirement: !ruby/object:Gem::Requirement
@@ -252,6 +266,7 @@ files:
252
266
  - README.md
253
267
  - Rakefile
254
268
  - lib/ruby_lokalise_api.rb
269
+ - lib/ruby_lokalise_api/base_client.rb
255
270
  - lib/ruby_lokalise_api/base_request.rb
256
271
  - lib/ruby_lokalise_api/client.rb
257
272
  - lib/ruby_lokalise_api/collections/base.rb
@@ -283,8 +298,8 @@ files:
283
298
  - lib/ruby_lokalise_api/error.rb
284
299
  - lib/ruby_lokalise_api/json_handler.rb
285
300
  - lib/ruby_lokalise_api/oauth2/auth.rb
286
- - lib/ruby_lokalise_api/oauth2/connection.rb
287
- - lib/ruby_lokalise_api/oauth2/request.rb
301
+ - lib/ruby_lokalise_api/oauth2/refresh.rb
302
+ - lib/ruby_lokalise_api/oauth2/token.rb
288
303
  - lib/ruby_lokalise_api/oauth2_client.rb
289
304
  - lib/ruby_lokalise_api/request.rb
290
305
  - lib/ruby_lokalise_api/resources/base.rb
@@ -292,6 +307,7 @@ files:
292
307
  - lib/ruby_lokalise_api/resources/contributor.rb
293
308
  - lib/ruby_lokalise_api/resources/custom_translation_status.rb
294
309
  - lib/ruby_lokalise_api/resources/file.rb
310
+ - lib/ruby_lokalise_api/resources/jwt.rb
295
311
  - lib/ruby_lokalise_api/resources/key.rb
296
312
  - lib/ruby_lokalise_api/resources/key_comment.rb
297
313
  - lib/ruby_lokalise_api/resources/order.rb
@@ -317,6 +333,7 @@ files:
317
333
  - lib/ruby_lokalise_api/rest/contributors.rb
318
334
  - lib/ruby_lokalise_api/rest/custom_translation_statuses.rb
319
335
  - lib/ruby_lokalise_api/rest/files.rb
336
+ - lib/ruby_lokalise_api/rest/jwt.rb
320
337
  - lib/ruby_lokalise_api/rest/keys.rb
321
338
  - lib/ruby_lokalise_api/rest/languages.rb
322
339
  - lib/ruby_lokalise_api/rest/orders.rb
@@ -359,7 +376,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
359
376
  - !ruby/object:Gem::Version
360
377
  version: '0'
361
378
  requirements: []
362
- rubygems_version: 3.3.19
379
+ rubygems_version: 3.3.26
363
380
  signing_key:
364
381
  specification_version: 4
365
382
  summary: Ruby interface to the Lokalise API
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RubyLokaliseApi
4
- module OAuth2
5
- module Connection
6
- BASE_URL = URI('https://app.lokalise.com/oauth2/')
7
-
8
- def connection
9
- Faraday.new(options) { |f| f.adapter Faraday.default_adapter }
10
- end
11
-
12
- private
13
-
14
- def options
15
- {
16
- headers: {
17
- accept: 'application/json',
18
- user_agent: "ruby-lokalise-api gem/#{RubyLokaliseApi::VERSION}"
19
- },
20
- url: BASE_URL.to_s
21
- }
22
- end
23
- end
24
- end
25
- end
@@ -1,23 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RubyLokaliseApi
4
- module OAuth2
5
- module Request
6
- include RubyLokaliseApi::BaseRequest
7
- include RubyLokaliseApi::OAuth2::Connection
8
-
9
- def post(path, params = {})
10
- respond_with connection.post(prepare(path), custom_dump(params))
11
- end
12
-
13
- private
14
-
15
- def respond_with(response)
16
- body = custom_load response.body
17
- status = response.status
18
- raise_on_error! status, body
19
- body
20
- end
21
- end
22
- end
23
- end