easy_meli 0.3.0 → 0.3.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/lib/easy_meli.rb +2 -0
- data/lib/easy_meli/api_client.rb +5 -3
- data/lib/easy_meli/authorization_client.rb +1 -0
- data/lib/easy_meli/constants.rb +8 -0
- data/lib/easy_meli/version.rb +1 -1
- metadata +3 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 89f477f8757f02eec3581b7336db18264543b27dd335b5eda3c532fcf1566cec
         | 
| 4 | 
            +
              data.tar.gz: dc55656ac52fcbe17a58659ce619fd4f20e90a8334f7ab3a3956f13a3a61caf4
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 276d56f9e9dbd6fe0f6d544220b7942442fdf372ed8d22c5d6e87c1901dec997d8c6e432041cda289d1e855df08f76b449483ceb0bfc932afe8436d97a23b3e0
         | 
| 7 | 
            +
              data.tar.gz: '0588f3f0451f110057e54ade0e1a68bbaaf8180c4aaf8cdf92e26c9e7616c475c73961d6c5552327bc350620676ce899dc6b21d058a650e719a6442976c1b25e'
         | 
    
        data/lib/easy_meli.rb
    CHANGED
    
    | @@ -1,12 +1,14 @@ | |
| 1 1 | 
             
            require 'httparty'
         | 
| 2 2 |  | 
| 3 3 | 
             
            require 'easy_meli/version'
         | 
| 4 | 
            +
            require 'easy_meli/constants'
         | 
| 4 5 | 
             
            require 'easy_meli/errors'
         | 
| 5 6 | 
             
            require 'easy_meli/configuration'
         | 
| 6 7 | 
             
            require 'easy_meli/authorization_client'
         | 
| 7 8 | 
             
            require 'easy_meli/api_client'
         | 
| 8 9 |  | 
| 9 10 | 
             
            module EasyMeli
         | 
| 11 | 
            +
             | 
| 10 12 | 
             
              def self.configuration
         | 
| 11 13 | 
             
                @configuration ||= Configuration.new
         | 
| 12 14 | 
             
              end
         | 
    
        data/lib/easy_meli/api_client.rb
    CHANGED
    
    | @@ -12,6 +12,7 @@ class EasyMeli::ApiClient | |
| 12 12 | 
             
              }
         | 
| 13 13 |  | 
| 14 14 | 
             
              base_uri API_ROOT_URL 
         | 
| 15 | 
            +
              headers EasyMeli::DEFAULT_HEADERS
         | 
| 15 16 | 
             
              format :json
         | 
| 16 17 |  | 
| 17 18 | 
             
              attr_reader :logger, :access_token
         | 
| @@ -42,6 +43,7 @@ class EasyMeli::ApiClient | |
| 42 43 | 
             
              def send_request(verb, path = '', params = {})
         | 
| 43 44 | 
             
                query = params[:query] || params['query'] || {}
         | 
| 44 45 | 
             
                query[:access_token] = access_token
         | 
| 46 | 
            +
             | 
| 45 47 | 
             
                self.class.send(verb, path, params.merge(query)).tap do |response|
         | 
| 46 48 | 
             
                  logger&.log response
         | 
| 47 49 | 
             
                  check_authentication(response)
         | 
| @@ -49,9 +51,9 @@ class EasyMeli::ApiClient | |
| 49 51 | 
             
              end
         | 
| 50 52 |  | 
| 51 53 | 
             
              def check_authentication(response)
         | 
| 52 | 
            -
                response_message = error_message_from_body(response.to_h)
         | 
| 54 | 
            +
                response_message = error_message_from_body(response.to_h) if response.parsed_response.is_a? Hash
         | 
| 53 55 | 
             
                return if response_message.to_s.empty?
         | 
| 54 | 
            -
             | 
| 56 | 
            +
             | 
| 55 57 | 
             
                TOKEN_ERRORS.keys.each do |key|
         | 
| 56 58 | 
             
                  if response_message.include?(key)
         | 
| 57 59 | 
             
                    raise EasyMeli::AuthenticationError.new(TOKEN_ERRORS[key], response)
         | 
| @@ -63,4 +65,4 @@ class EasyMeli::ApiClient | |
| 63 65 | 
             
                return if body.nil?
         | 
| 64 66 | 
             
                body['error'].to_s.empty? ? body['message'] : body['error']
         | 
| 65 67 | 
             
              end
         | 
| 66 | 
            -
            end
         | 
| 68 | 
            +
            end
         | 
    
        data/lib/easy_meli/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: easy_meli
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.3. | 
| 4 | 
            +
              version: 0.3.1
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Eric Northam
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2020-05- | 
| 11 | 
            +
            date: 2020-05-18 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: httparty
         | 
| @@ -127,6 +127,7 @@ files: | |
| 127 127 | 
             
            - lib/easy_meli/api_client.rb
         | 
| 128 128 | 
             
            - lib/easy_meli/authorization_client.rb
         | 
| 129 129 | 
             
            - lib/easy_meli/configuration.rb
         | 
| 130 | 
            +
            - lib/easy_meli/constants.rb
         | 
| 130 131 | 
             
            - lib/easy_meli/errors.rb
         | 
| 131 132 | 
             
            - lib/easy_meli/version.rb
         | 
| 132 133 | 
             
            homepage: https://github.com/easybroker/easy_meli
         |