ruby-lokalise-api 6.1.0 → 7.0.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: 83ba3c3b7e6b33c712f31ef3e1d66daaed33604fd227b2fcef1cb8ed71fddd1c
4
- data.tar.gz: 78b7decbd94a6bdd45c5b684cb07a0ee50a21045a757b3b7e61ab5c10c8618c6
3
+ metadata.gz: a0df97ee1958c45138da225b66c6cc99797a9cf77c3f84435b3fff41e86317c9
4
+ data.tar.gz: a98e58642231426d959a49299d47154c1883d1fa89214693bf062642a89c4581
5
5
  SHA512:
6
- metadata.gz: a8cd7b58cf1c83534cc2faad45fd998ba200102db25a6a191483dd6d4ecb15809ca4563bd9965f052082fac93257daf53e4668fae7d3696bf90a886dd5fe1c11
7
- data.tar.gz: '008fe8a740c7a1d3d53229367df62082b83b1a5665f97b6a6d03ac29fe863b8b970c5fb77eb7196c26690234ff07e62abb58e7f014a85ec1fde78ca32adb51ea'
6
+ metadata.gz: 3b1760ad8acee33810dc905ceb9fe8ff3791b8ac42cda5affb031112c53b0981dc5a2ad714d5ee04352fd5c50856ec695c45abf1c3765e939ab8230f1ed78ff1
7
+ data.tar.gz: 947b22b36b74ebde8abeeb8edde48b701e9b4cfd2f4f7bbf5f1c2e35aa94408c1b4deb60b56ab03c65ae1f0f5405c0aef0a9a5cdbf15d0e8e094060d75aeea34
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  BSD 3 Clause
2
2
 
3
- Copyright 2021 Lokalise Group, Ilya Bodrov
3
+ Copyright 2021 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
@@ -5,7 +5,7 @@
5
5
  [![Test Coverage](https://codecov.io/gh/lokalise/ruby-lokalise-api/graph/badge.svg)](https://codecov.io/gh/lokalise/ruby-lokalise-api)
6
6
  ![Downloads total](https://img.shields.io/gem/dt/ruby-lokalise-api)
7
7
 
8
- Official opinionated Ruby interface for the [Lokalise API](https://app.lokalise.com/api2docs/curl/) that represents returned data as Ruby objects.
8
+ Official opinionated Ruby interface for the [Lokalise API](https://developers.lokalise.com/reference/lokalise-rest-api) that represents returned data as Ruby objects.
9
9
 
10
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
 
@@ -57,4 +57,4 @@ You can also check [this repo containing some usage examples](https://github.com
57
57
 
58
58
  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.
59
59
 
60
- Copyright (c) [Lokalise team](http://lokalise.co) and [Ilya Bodrov](http://bodrovis.tech)
60
+ Copyright (c) [Lokalise team](http://lokalise.co) and [Ilya Krukowski](http://bodrovis.tech)
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
@@ -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)
@@ -42,7 +42,8 @@ module RubyLokaliseApi
42
42
  # @param endpoint_ids [Array, Hash] IDs that are used to generate the proper path to the endpoint
43
43
  # @param params [Array, Hash] Request parameters
44
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
45
+ # @param initial_ids [Array] IDs that should be used to generate base endpoint path.
46
+ # The base path is used for method chaining
46
47
  def construct_request(klass, method, endpoint_ids, params = {}, object_key = nil, initial_ids = nil)
47
48
  path = klass.endpoint(*endpoint_ids)
48
49
  formatted_params = format_params(params, object_key)
@@ -62,6 +63,14 @@ module RubyLokaliseApi
62
63
  {object_key => params}
63
64
  end
64
65
 
66
+ def base_url
67
+ 'https://api.lokalise.com/api2/'
68
+ end
69
+
70
+ def compression?
71
+ true
72
+ end
73
+
65
74
  alias c_r construct_request
66
75
  end
67
76
  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
 
@@ -3,13 +3,19 @@
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]
15
+ end
16
+
17
+ def base_url
18
+ URI('https://app.lokalise.com/oauth2/')
13
19
  end
14
20
 
15
21
  def auth(scope:, redirect_uri: nil, state: nil)
@@ -30,7 +36,8 @@ module RubyLokaliseApi
30
36
  code: code,
31
37
  grant_type: 'authorization_code'
32
38
  })
33
- post 'token', params
39
+
40
+ RubyLokaliseApi::OAuth2::Token.new post('token', self, params)
34
41
  end
35
42
 
36
43
  def refresh(token)
@@ -38,7 +45,12 @@ module RubyLokaliseApi
38
45
  refresh_token: token,
39
46
  grant_type: 'refresh_token'
40
47
  })
41
- post 'token', params
48
+
49
+ RubyLokaliseApi::OAuth2::Refresh.new post('token', self, params)
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,6 +27,19 @@ 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]
35
+ def [](raw_key_attr)
36
+ key_attr = raw_key_attr.to_s.to_sym
37
+
38
+ return nil unless instance_variables.include?(:"@#{key_attr}")
39
+
40
+ send key_attr
41
+ end
42
+
30
43
  class << self
31
44
  # Dynamically adds attribute readers for each inherited class.
32
45
  # Attributes are defined in the `data/attributes.json` file.
@@ -5,7 +5,7 @@ module RubyLokaliseApi
5
5
  module Branches
6
6
  # Returns all branches for the given project
7
7
  #
8
- # @see https://lokalise.com/api2docs/curl/#transition-list-all-branches-get
8
+ # @see https://developers.lokalise.com/reference/list-all-branches
9
9
  # @return [RubyLokaliseApi::Collection::Branch<RubyLokaliseApi::Resources::Branch>]
10
10
  # @param project_id [String]
11
11
  # @param params [Hash]
@@ -15,7 +15,7 @@ module RubyLokaliseApi
15
15
 
16
16
  # Creates a new branch inside the given project
17
17
  #
18
- # @see https://lokalise.com/api2docs/curl/#transition-create-a-branch-post
18
+ # @see https://developers.lokalise.com/reference/create-a-branch
19
19
  # @return [RubyLokaliseApi::Resources::Branch]
20
20
  # @param project_id [String]
21
21
  # @param params [Hash]
@@ -25,7 +25,7 @@ module RubyLokaliseApi
25
25
 
26
26
  # Returns a single branch for the given project
27
27
  #
28
- # @see https://lokalise.com/api2docs/curl/#transition-retrieve-a-branch-get
28
+ # @see https://developers.lokalise.com/reference/retrieve-a-branch
29
29
  # @return [RubyLokaliseApi::Resources::Branch]
30
30
  # @param project_id [String]
31
31
  # @param branch_id [String, Integer]
@@ -35,7 +35,7 @@ module RubyLokaliseApi
35
35
 
36
36
  # Updates the given branch inside the given project
37
37
  #
38
- # @see https://lokalise.com/api2docs/curl/#transition-update-a-branch-put
38
+ # @see https://developers.lokalise.com/reference/update-a-branch
39
39
  # @return [RubyLokaliseApi::Resources::Branch]
40
40
  # @param project_id [String]
41
41
  # @param branch_id [String, Integer]
@@ -46,7 +46,7 @@ module RubyLokaliseApi
46
46
 
47
47
  # Deletes branch inside the given project
48
48
  #
49
- # @see https://lokalise.com/api2docs/curl/#transition-delete-a-branch-delete
49
+ # @see https://developers.lokalise.com/reference/delete-a-branch
50
50
  # @return [Hash]
51
51
  # @param project_id [String]
52
52
  # @param branch_id [String, Integer]
@@ -56,7 +56,7 @@ module RubyLokaliseApi
56
56
 
57
57
  # Merges a branch in the project
58
58
  #
59
- # @see https://lokalise.com/api2docs/curl/#transition-merge-a-branch-post
59
+ # @see https://developers.lokalise.com/reference/merge-a-branch
60
60
  # @return [Hash]
61
61
  # @param project_id [String]
62
62
  # @param branch_id [String, Integer]
@@ -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]
@@ -5,7 +5,7 @@ module RubyLokaliseApi
5
5
  module Orders
6
6
  # Returns all orders for the given team
7
7
  #
8
- # @see https://lokalise.co/api2docs/curl/#transition-list-all-orders-get
8
+ # @see https://developers.lokalise.com/reference/list-all-orders
9
9
  # @return [RubyLokaliseApi::Collection::Order<RubyLokaliseApi::Resources::Order>]
10
10
  # @param team_id [String]
11
11
  # @param params [Hash]
@@ -15,7 +15,7 @@ module RubyLokaliseApi
15
15
 
16
16
  # Returns a single order for the given team
17
17
  #
18
- # @see https://lokalise.co/api2docs/curl/#transition-retrieve-an-order-get
18
+ # @see https://developers.lokalise.com/reference/retrieve-an-order
19
19
  # @return [RubyLokaliseApi::Resources::Order]
20
20
  # @param team_id [String]
21
21
  # @param order_id [String, Integer]
@@ -25,7 +25,7 @@ module RubyLokaliseApi
25
25
 
26
26
  # Creates an order for the given team
27
27
  #
28
- # @see https://lokalise.co/api2docs/curl/#transition-create-an-order-post
28
+ # @see https://developers.lokalise.com/reference/create-an-order
29
29
  # @return [RubyLokaliseApi::Resources::Order]
30
30
  # @param team_id [String]
31
31
  # @param params [Hash]
@@ -23,7 +23,7 @@ module RubyLokaliseApi
23
23
 
24
24
  # Creates a payment card
25
25
  #
26
- # @see https://lokalise.co/api2docs/curl/#transition-create-a-card-post
26
+ # @see https://developers.lokalise.com/reference/create-a-card
27
27
  # @return [RubyLokaliseApi::Resources::PaymentCard]
28
28
  # @param params [Hash]
29
29
  def create_payment_card(params)
@@ -5,7 +5,7 @@ module RubyLokaliseApi
5
5
  module TeamUserGroups
6
6
  # Returns all team user groups for the given team
7
7
  #
8
- # @see https://lokalise.co/api2docs/curl/#transition-list-all-groups-get
8
+ # @see https://developers.lokalise.com/reference/list-all-team-users
9
9
  # @return [RubyLokaliseApi::Collection::TeamUserGroup<RubyLokaliseApi::Resources::TeamUserGroup>]
10
10
  # @param team_id [String]
11
11
  # @param params [Hash]
@@ -15,7 +15,7 @@ module RubyLokaliseApi
15
15
 
16
16
  # Returns team user from the given team
17
17
  #
18
- # @see https://lokalise.co/api2docs/curl/#transition-retrieve-a-group-get
18
+ # @see https://developers.lokalise.com/reference/retrieve-a-team-user
19
19
  # @return [RubyLokaliseApi::Resources::TeamUserGroup]
20
20
  # @param team_id [String]
21
21
  # @param group_id [String, Integer]
@@ -25,7 +25,7 @@ module RubyLokaliseApi
25
25
 
26
26
  # Creates team user group
27
27
  #
28
- # @see https://lokalise.co/api2docs/curl/#resource-team-user-groups
28
+ # @see https://developers.lokalise.com/reference/create-a-group
29
29
  # @return [RubyLokaliseApi::Resources::TeamUserGroup]
30
30
  # @param params [Hash]
31
31
  def create_team_user_group(team_id, params)
@@ -34,7 +34,7 @@ module RubyLokaliseApi
34
34
 
35
35
  # Updates team user group for the given team
36
36
  #
37
- # @see https://lokalise.co/api2docs/curl/#transition-update-a-group-put
37
+ # @see https://developers.lokalise.com/reference/update-a-group
38
38
  # @return [RubyLokaliseApi::Resources::TeamUserGroup]
39
39
  # @param team_id [String]
40
40
  # @param group_id [String, Integer]
@@ -45,7 +45,7 @@ module RubyLokaliseApi
45
45
 
46
46
  # Deletes team user group from the given team
47
47
  #
48
- # @see https://lokalise.co/api2docs/curl/#transition-delete-a-group-delete
48
+ # @see https://developers.lokalise.com/reference/delete-a-group
49
49
  # @return [RubyLokaliseApi::Resources::TeamUserGroup]
50
50
  # @param team_id [String]
51
51
  # @param group_id [String, Integer]
@@ -55,7 +55,7 @@ module RubyLokaliseApi
55
55
 
56
56
  # Adds projects to the given group
57
57
  #
58
- # @see https://lokalise.co/api2docs/curl/#transition-add-projects-to-group-put
58
+ # @see https://developers.lokalise.com/reference/add-projects-to-group
59
59
  # @return [RubyLokaliseApi::Resources::TeamUserGroup]
60
60
  # @param team_id [String]
61
61
  # @param group_id [String, Integer]
@@ -68,7 +68,7 @@ module RubyLokaliseApi
68
68
 
69
69
  # Removes projects from the given group
70
70
  #
71
- # @see https://lokalise.co/api2docs/curl/#transition-remove-projects-from-group-put
71
+ # @see https://developers.lokalise.com/reference/remove-projects-from-group
72
72
  # @return [RubyLokaliseApi::Resources::TeamUserGroup]
73
73
  # @param team_id [String]
74
74
  # @param group_id [String, Integer]
@@ -81,7 +81,7 @@ module RubyLokaliseApi
81
81
 
82
82
  # Adds users to the given group
83
83
  #
84
- # @see https://lokalise.co/api2docs/curl/#transition-add-members-to-group-put
84
+ # @see https://developers.lokalise.com/reference/add-members-to-group
85
85
  # @return [RubyLokaliseApi::Resources::TeamUserGroup]
86
86
  # @param team_id [String]
87
87
  # @param group_id [String, Integer]
@@ -94,7 +94,7 @@ module RubyLokaliseApi
94
94
 
95
95
  # Removes users from the given group
96
96
  #
97
- # @see https://lokalise.co/api2docs/curl/#transition-remove-members-from-group-put
97
+ # @see https://developers.lokalise.com/reference/remove-members-from-group
98
98
  # @return [RubyLokaliseApi::Resources::TeamUserGroup]
99
99
  # @param team_id [String]
100
100
  # @param group_id [String, Integer]
@@ -56,7 +56,7 @@ module RubyLokaliseApi
56
56
 
57
57
  # Regenerates secret for the given webhook
58
58
  #
59
- # @see https://lokalise.com/api2docs/curl/#transition-regenerate-a-webhook-secret-patch
59
+ # @see https://developers.lokalise.com/reference/regenerate-a-webhook-secret
60
60
  # @return [Hash]
61
61
  # @param project_id [String]
62
62
  # @param webhook_id [String, Integer]
@@ -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.1.0'
4
+ VERSION = '7.0.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
@@ -5,7 +5,7 @@ require File.expand_path('lib/ruby_lokalise_api/version', __dir__)
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'ruby-lokalise-api'
7
7
  spec.version = RubyLokaliseApi::VERSION
8
- spec.authors = ['Ilya Bodrov-Krukowski']
8
+ spec.authors = ['Ilya Krukowski']
9
9
  spec.email = ['golosizpru@gmail.com']
10
10
  spec.summary = 'Ruby interface to the Lokalise API'
11
11
  spec.description = 'Opinionated Ruby client for the Lokalise platform API allowing to work with translations, projects, users and other resources as with Ruby objects.'
@@ -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.1.0
4
+ version: 7.0.0
5
5
  platform: ruby
6
6
  authors:
7
- - Ilya Bodrov-Krukowski
7
+ - Ilya Krukowski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-27 00:00:00.000000000 Z
11
+ date: 2022-11-18 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
@@ -283,8 +297,8 @@ files:
283
297
  - lib/ruby_lokalise_api/error.rb
284
298
  - lib/ruby_lokalise_api/json_handler.rb
285
299
  - lib/ruby_lokalise_api/oauth2/auth.rb
286
- - lib/ruby_lokalise_api/oauth2/connection.rb
287
- - lib/ruby_lokalise_api/oauth2/request.rb
300
+ - lib/ruby_lokalise_api/oauth2/refresh.rb
301
+ - lib/ruby_lokalise_api/oauth2/token.rb
288
302
  - lib/ruby_lokalise_api/oauth2_client.rb
289
303
  - lib/ruby_lokalise_api/request.rb
290
304
  - lib/ruby_lokalise_api/resources/base.rb
@@ -359,7 +373,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
359
373
  - !ruby/object:Gem::Version
360
374
  version: '0'
361
375
  requirements: []
362
- rubygems_version: 3.3.17
376
+ rubygems_version: 3.3.26
363
377
  signing_key:
364
378
  specification_version: 4
365
379
  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