ruby-lokalise-api 8.0.0 → 8.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/README.md +1 -0
 - data/lib/ruby_lokalise_api/base_client.rb +2 -0
 - data/lib/ruby_lokalise_api/client.rb +0 -2
 - data/lib/ruby_lokalise_api/connection.rb +12 -7
 - data/lib/ruby_lokalise_api/endpoints/base_endpoint.rb +8 -15
 - data/lib/ruby_lokalise_api/oauth2_client.rb +0 -2
 - data/lib/ruby_lokalise_api/request.rb +1 -1
 - data/lib/ruby_lokalise_api/version.rb +1 -1
 - metadata +3 -3
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: b9dd635ba92d1885a962876708929e92b3d4cf27da08281d37d001090b26059e
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 4360d59c199a2f166fc1ea0a7d6cbe767ff9fef1ad4915c7ea432fe96a5520a6
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: d5dc497254da7a8b9d887f449880a37c5d3ab71054a23d07aac90cdedb27896103b3ed907fda102c0785da068bc50dccce1b8f1723a0a71c78bb9c6896347fb7
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: de6153458925151cfd3ee5640d8dbea226877ba89698faf2e6320776340e5dafd37bb62e8297f04377e50918fdaa40c698020aa0f098466a488410f2fb3ffba3
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -2,6 +2,7 @@ 
     | 
|
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            
         
     | 
| 
       4 
4 
     | 
    
         
             
            
         
     | 
| 
      
 5 
     | 
    
         
            +
            [](https://coveralls.io/github/lokalise/ruby-lokalise-api?branch=master)
         
     | 
| 
       5 
6 
     | 
    
         
             
            
         
     | 
| 
       6 
7 
     | 
    
         | 
| 
       7 
8 
     | 
    
         
             
            Official opinionated Ruby interface for the [Lokalise API](https://developers.lokalise.com/reference/lokalise-rest-api) that represents returned data as Ruby objects.
         
     | 
| 
         @@ -4,6 +4,8 @@ module RubyLokaliseApi 
     | 
|
| 
       4 
4 
     | 
    
         
             
              # This class contains the base client. Inherited by Client (regular API client)
         
     | 
| 
       5 
5 
     | 
    
         
             
              # and OAuth2Client (used for OAuth-2 based authentication)
         
     | 
| 
       6 
6 
     | 
    
         
             
              class BaseClient
         
     | 
| 
      
 7 
     | 
    
         
            +
                include RubyLokaliseApi::Rest
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
       7 
9 
     | 
    
         
             
                attr_reader :token, :token_header
         
     | 
| 
       8 
10 
     | 
    
         
             
                attr_accessor :timeout, :open_timeout
         
     | 
| 
       9 
11 
     | 
    
         | 
| 
         @@ -4,8 +4,8 @@ module RubyLokaliseApi 
     | 
|
| 
       4 
4 
     | 
    
         
             
              # Module to setup connection using Faraday
         
     | 
| 
       5 
5 
     | 
    
         
             
              module Connection
         
     | 
| 
       6 
6 
     | 
    
         
             
                # Creates a new Faraday object with specified params
         
     | 
| 
       7 
     | 
    
         
            -
                def connection(endpoint)
         
     | 
| 
       8 
     | 
    
         
            -
                  Faraday.new(options(endpoint), request_params_for(endpoint.client)) do |faraday|
         
     | 
| 
      
 7 
     | 
    
         
            +
                def connection(endpoint, params = {})
         
     | 
| 
      
 8 
     | 
    
         
            +
                  Faraday.new(options(endpoint, params), request_params_for(endpoint.client)) do |faraday|
         
     | 
| 
       9 
9 
     | 
    
         
             
                    faraday.adapter Faraday.default_adapter
         
     | 
| 
       10 
10 
     | 
    
         
             
                    faraday.request(:gzip)
         
     | 
| 
       11 
11 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -13,16 +13,21 @@ module RubyLokaliseApi 
     | 
|
| 
       13 
13 
     | 
    
         | 
| 
       14 
14 
     | 
    
         
             
                private
         
     | 
| 
       15 
15 
     | 
    
         | 
| 
       16 
     | 
    
         
            -
                def options(endpoint)
         
     | 
| 
       17 
     | 
    
         
            -
                   
     | 
| 
      
 16 
     | 
    
         
            +
                def options(endpoint, params)
         
     | 
| 
      
 17 
     | 
    
         
            +
                  req_params = __base_options(endpoint)
         
     | 
| 
       18 
18 
     | 
    
         
             
                  client = endpoint.client
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
       20 
20 
     | 
    
         
             
                  if client.respond_to?(:token) && client.respond_to?(:token_header)
         
     | 
| 
       21 
     | 
    
         
            -
                     
     | 
| 
      
 21 
     | 
    
         
            +
                    req_params[:headers][client.token_header] = client.token
         
     | 
| 
       22 
22 
     | 
    
         
             
                  end
         
     | 
| 
       23 
     | 
    
         
            -
                  params[:headers][:accept_encoding] = 'gzip,deflate,br'
         
     | 
| 
       24 
23 
     | 
    
         | 
| 
       25 
     | 
    
         
            -
                   
     | 
| 
      
 24 
     | 
    
         
            +
                  # Sending content-type is needed only when the body is actually present
         
     | 
| 
      
 25 
     | 
    
         
            +
                  # Trying to send this header in other cases seems to result in error 500
         
     | 
| 
      
 26 
     | 
    
         
            +
                  req_params[:headers]['Content-type'] = 'application/json' if !params[:get_request] && endpoint.req_params
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                  req_params[:headers][:accept_encoding] = 'gzip,deflate,br'
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                  req_params
         
     | 
| 
       26 
31 
     | 
    
         
             
                end
         
     | 
| 
       27 
32 
     | 
    
         | 
| 
       28 
33 
     | 
    
         
             
                def __base_options(endpoint)
         
     | 
| 
         @@ -10,6 +10,7 @@ module RubyLokaliseApi 
     | 
|
| 
       10 
10 
     | 
    
         | 
| 
       11 
11 
     | 
    
         
             
                  BASE_URL = ''
         
     | 
| 
       12 
12 
     | 
    
         
             
                  PARTIAL_URI_TEMPLATE = '{/segments*}'
         
     | 
| 
      
 13 
     | 
    
         
            +
                  HTTP_METHODS = %i[get post put delete patch].freeze
         
     | 
| 
       13 
14 
     | 
    
         | 
| 
       14 
15 
     | 
    
         
             
                  def initialize(client, params = {})
         
     | 
| 
       15 
16 
     | 
    
         
             
                    @query_params = params[:query].to_array
         
     | 
| 
         @@ -34,24 +35,16 @@ module RubyLokaliseApi 
     | 
|
| 
       34 
35 
     | 
    
         
             
                    base_url + uri
         
     | 
| 
       35 
36 
     | 
    
         
             
                  end
         
     | 
| 
       36 
37 
     | 
    
         | 
| 
       37 
     | 
    
         
            -
                   
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
                   
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
                    return true if HTTP_METHODS_REGEXP.match?(method.to_s)
         
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
                    super
         
     | 
| 
       45 
     | 
    
         
            -
                  end
         
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
       47 
     | 
    
         
            -
                  def method_missing(method, *_args)
         
     | 
| 
       48 
     | 
    
         
            -
                    if method.to_s =~ HTTP_METHODS_REGEXP
         
     | 
| 
       49 
     | 
    
         
            -
                      send Regexp.last_match(1), self
         
     | 
| 
       50 
     | 
    
         
            -
                    else
         
     | 
| 
       51 
     | 
    
         
            -
                      super
         
     | 
| 
      
 38 
     | 
    
         
            +
                  # Creates methods like `do_post`, `do_get` that proxy calls to the
         
     | 
| 
      
 39 
     | 
    
         
            +
                  # corresponding methods in the `Request` module
         
     | 
| 
      
 40 
     | 
    
         
            +
                  HTTP_METHODS.each do |method_postfix|
         
     | 
| 
      
 41 
     | 
    
         
            +
                    define_method "do_#{method_postfix}" do
         
     | 
| 
      
 42 
     | 
    
         
            +
                      send method_postfix, self
         
     | 
| 
       52 
43 
     | 
    
         
             
                    end
         
     | 
| 
       53 
44 
     | 
    
         
             
                  end
         
     | 
| 
       54 
45 
     | 
    
         | 
| 
      
 46 
     | 
    
         
            +
                  private
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
       55 
48 
     | 
    
         
             
                  def base_query(*_args); end
         
     | 
| 
       56 
49 
     | 
    
         | 
| 
       57 
50 
     | 
    
         
             
                  def partial_uri(*_args)
         
     | 
| 
         @@ -9,7 +9,7 @@ module RubyLokaliseApi 
     | 
|
| 
       9 
9 
     | 
    
         
             
                # Sends a GET request
         
     | 
| 
       10 
10 
     | 
    
         
             
                def get(endpoint)
         
     | 
| 
       11 
11 
     | 
    
         
             
                  respond_with(
         
     | 
| 
       12 
     | 
    
         
            -
                    connection(endpoint).get(prepare(endpoint.uri), endpoint.req_params),
         
     | 
| 
      
 12 
     | 
    
         
            +
                    connection(endpoint, get_request: true).get(prepare(endpoint.uri), endpoint.req_params),
         
     | 
| 
       13 
13 
     | 
    
         
             
                    endpoint
         
     | 
| 
       14 
14 
     | 
    
         
             
                  )
         
     | 
| 
       15 
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: 8.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 8.0.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: 2023- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2023-08-24 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: addressable
         
     | 
| 
         @@ -397,7 +397,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       397 
397 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       398 
398 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       399 
399 
     | 
    
         
             
            requirements: []
         
     | 
| 
       400 
     | 
    
         
            -
            rubygems_version: 3.4. 
     | 
| 
      
 400 
     | 
    
         
            +
            rubygems_version: 3.4.18
         
     | 
| 
       401 
401 
     | 
    
         
             
            signing_key:
         
     | 
| 
       402 
402 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       403 
403 
     | 
    
         
             
            summary: Ruby interface to the Lokalise API
         
     |