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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d17badfe56ecab178ff6cb784e9d78bb8c0cd4ac9421e5ea356a52212622c76a
4
- data.tar.gz: 4f40821e57261ade83265e971ea8a45a85db038fff68b26744daeaedf80c87fd
3
+ metadata.gz: 89f477f8757f02eec3581b7336db18264543b27dd335b5eda3c532fcf1566cec
4
+ data.tar.gz: dc55656ac52fcbe17a58659ce619fd4f20e90a8334f7ab3a3956f13a3a61caf4
5
5
  SHA512:
6
- metadata.gz: 8b95637656926bd1b393ed569c136cb5f486b2c76ec46ef733eabb1746ef52a062d4f669c0b068ca93c2dd0dc52641483b9866304fa10a9e8c22847254971387
7
- data.tar.gz: 5c2310fbd9282c91f5777596d05f3504585cd394f3f31a59a1a514a41953593cd5422c87db971f4b3a5ce77b6989e8251676d7bd6257135fff79d24915ca3e30
6
+ metadata.gz: 276d56f9e9dbd6fe0f6d544220b7942442fdf372ed8d22c5d6e87c1901dec997d8c6e432041cda289d1e855df08f76b449483ceb0bfc932afe8436d97a23b3e0
7
+ data.tar.gz: '0588f3f0451f110057e54ade0e1a68bbaaf8180c4aaf8cdf92e26c9e7616c475c73961d6c5552327bc350620676ce899dc6b21d058a650e719a6442976c1b25e'
@@ -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
@@ -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
@@ -21,6 +21,7 @@ class EasyMeli::AuthorizationClient
21
21
  DO: 'https://auth.mercadolibre.com.do'
22
22
  }
23
23
 
24
+ headers EasyMeli::DEFAULT_HEADERS
24
25
  format :json
25
26
 
26
27
  attr_reader :logger
@@ -0,0 +1,8 @@
1
+ module EasyMeli
2
+ USER_AGENT = "EasyMeli-%s" % VERSION
3
+ DEFAULT_HEADERS = {
4
+ 'Content-Type' => 'application/json',
5
+ 'Accept' => 'application/json',
6
+ 'User-Agent' => USER_AGENT
7
+ }
8
+ end
@@ -1,3 +1,3 @@
1
1
  module EasyMeli
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
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.0
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-15 00:00:00.000000000 Z
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