ruby-lokalise-api 7.0.0 → 7.1.0
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 +49 -0
- data/lib/ruby_lokalise_api/client.rb +4 -37
- data/lib/ruby_lokalise_api/data/attributes.yml +2 -0
- data/lib/ruby_lokalise_api/oauth2/auth.rb +4 -4
- data/lib/ruby_lokalise_api/resources/jwt.rb +13 -0
- data/lib/ruby_lokalise_api/rest/jwt.rb +15 -0
- data/lib/ruby_lokalise_api/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f88c68ae7c24d90be54394259b2fc477eb52a485775be7292789ea743155556
|
4
|
+
data.tar.gz: 0ce8f2d8db252f4e7fa44cb87b68786adfacd86849b16d10c60ab58d3b9e51b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb4469e28faafba3f0c81f4fb27b5b2747055da3d93cca81cf4244a38d0962ba896770a5fa8d81e859ad26f6f67cdf549ad288073bd5c946c5dacc58a812a1e7
|
7
|
+
data.tar.gz: fc41d966f5c55bbf900015ae3fa8f60f28cb9f1931b1f3172c247152e040dc0fab8b51eff7dcd107cd4423c73dca615b3db4f27e7e83acd963b37724d9251025
|
@@ -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
|
-
|
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
|
-
|
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
|
@@ -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,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
|
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.
|
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-11-
|
11
|
+
date: 2022-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -266,6 +266,7 @@ files:
|
|
266
266
|
- README.md
|
267
267
|
- Rakefile
|
268
268
|
- lib/ruby_lokalise_api.rb
|
269
|
+
- lib/ruby_lokalise_api/base_client.rb
|
269
270
|
- lib/ruby_lokalise_api/base_request.rb
|
270
271
|
- lib/ruby_lokalise_api/client.rb
|
271
272
|
- lib/ruby_lokalise_api/collections/base.rb
|
@@ -306,6 +307,7 @@ files:
|
|
306
307
|
- lib/ruby_lokalise_api/resources/contributor.rb
|
307
308
|
- lib/ruby_lokalise_api/resources/custom_translation_status.rb
|
308
309
|
- lib/ruby_lokalise_api/resources/file.rb
|
310
|
+
- lib/ruby_lokalise_api/resources/jwt.rb
|
309
311
|
- lib/ruby_lokalise_api/resources/key.rb
|
310
312
|
- lib/ruby_lokalise_api/resources/key_comment.rb
|
311
313
|
- lib/ruby_lokalise_api/resources/order.rb
|
@@ -331,6 +333,7 @@ files:
|
|
331
333
|
- lib/ruby_lokalise_api/rest/contributors.rb
|
332
334
|
- lib/ruby_lokalise_api/rest/custom_translation_statuses.rb
|
333
335
|
- lib/ruby_lokalise_api/rest/files.rb
|
336
|
+
- lib/ruby_lokalise_api/rest/jwt.rb
|
334
337
|
- lib/ruby_lokalise_api/rest/keys.rb
|
335
338
|
- lib/ruby_lokalise_api/rest/languages.rb
|
336
339
|
- lib/ruby_lokalise_api/rest/orders.rb
|