mercadolibre 1.1.1 → 1.2.0

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
  SHA1:
3
- metadata.gz: 3f3ee11b0f6bc728caeccce5f82f3f5479f2fbe2
4
- data.tar.gz: df0946ac60eed7712e0a565aa1b4edf76d51434f
3
+ metadata.gz: 4d590ea5ce185ae420280820a441df6a745ad367
4
+ data.tar.gz: 95ea25c832b36a77d9fdbc25186ee783e2f0d54a
5
5
  SHA512:
6
- metadata.gz: 506d8ff9137557835d5586a0fd1634198f916dddea7f6edb7b8ba1449d6a23114f12c6bc3f346d66acee3ee431df6c0f4127a18b2a783992613bde435f3251f5
7
- data.tar.gz: 461e80f6bffe9e1d6564292685dcf5ba9ef4779b619697bbced6719171183e0fc18e6aa49c02a015161073a9da1b99fc74efda930ddf426801a260a5a2ba7fb5
6
+ metadata.gz: 50cd4241e2d1d941fb7c13dbd1c0025000deae99106a29b3db5a3096079d3ac162fc1880fb67ed91bc36b48d8659fb1edcb7888fa334e96ef230cceb0a7d522f
7
+ data.tar.gz: d611737ce627fe623e017b66e38ef3f66326a3998fe689d5e41d7edaa4dd6a9604394a0b6bafd51ffdc673ece28ae95ce2700c16b10b8809303be627ab01e7a1
data/CHANGELOG.md CHANGED
@@ -241,3 +241,7 @@
241
241
  ## v1.1.1
242
242
 
243
243
  * Changed response for create/update order notes
244
+
245
+ ## v1.2.0
246
+
247
+ * Bugfix with json payload
@@ -30,8 +30,8 @@ module Mercadolibre
30
30
 
31
31
  def get_request(action, params={}, headers={})
32
32
  begin
33
- api_response_kind = params.delete('api_response_kind')
34
- api_response_kind = params.delete(:api_response_kind) if api_response_kind.nil?
33
+ api_response_kind = headers.delete('api_response_kind')
34
+ api_response_kind = headers.delete(:api_response_kind) if api_response_kind.nil?
35
35
  api_response_kind = 'object' if api_response_kind.nil?
36
36
 
37
37
  parse_response(api_response_kind, RestClient.get("#{@endpoint_url}#{action}", {params: params}.merge(headers)))
@@ -42,8 +42,8 @@ module Mercadolibre
42
42
 
43
43
  def post_request(action, params={}, headers={})
44
44
  begin
45
- api_response_kind = params.delete('api_response_kind')
46
- api_response_kind = params.delete(:api_response_kind) if api_response_kind.nil?
45
+ api_response_kind = headers.delete('api_response_kind')
46
+ api_response_kind = headers.delete(:api_response_kind) if api_response_kind.nil?
47
47
  api_response_kind = 'object' if api_response_kind.nil?
48
48
 
49
49
  parse_response(api_response_kind, RestClient.post("#{@endpoint_url}#{action}", params, headers))
@@ -54,8 +54,8 @@ module Mercadolibre
54
54
 
55
55
  def put_request(action, params={}, headers={})
56
56
  begin
57
- api_response_kind = params.delete('api_response_kind')
58
- api_response_kind = params.delete(:api_response_kind) if api_response_kind.nil?
57
+ api_response_kind = headers.delete('api_response_kind')
58
+ api_response_kind = headers.delete(:api_response_kind) if api_response_kind.nil?
59
59
  api_response_kind = 'object' if api_response_kind.nil?
60
60
 
61
61
  parse_response(api_response_kind, RestClient.put("#{@endpoint_url}#{action}", params, headers))
@@ -66,8 +66,8 @@ module Mercadolibre
66
66
 
67
67
  def patch_request(action, params={}, headers={})
68
68
  begin
69
- api_response_kind = params.delete('api_response_kind')
70
- api_response_kind = params.delete(:api_response_kind) if api_response_kind.nil?
69
+ api_response_kind = headers.delete('api_response_kind')
70
+ api_response_kind = headers.delete(:api_response_kind) if api_response_kind.nil?
71
71
  api_response_kind = 'object' if api_response_kind.nil?
72
72
 
73
73
  parse_response(api_response_kind, RestClient.patch("#{@endpoint_url}#{action}", params, headers))
@@ -76,10 +76,10 @@ module Mercadolibre
76
76
  end
77
77
  end
78
78
 
79
- def head_request(action, params={})
79
+ def head_request(action, params={}, headers={})
80
80
  begin
81
- api_response_kind = params.delete('api_response_kind')
82
- api_response_kind = params.delete(:api_response_kind) if api_response_kind.nil?
81
+ api_response_kind = headers.delete('api_response_kind')
82
+ api_response_kind = headers.delete(:api_response_kind) if api_response_kind.nil?
83
83
  api_response_kind = 'object' if api_response_kind.nil?
84
84
 
85
85
  parse_response(api_response_kind, RestClient.head("#{@endpoint_url}#{action}", params))
@@ -88,10 +88,10 @@ module Mercadolibre
88
88
  end
89
89
  end
90
90
 
91
- def delete_request(action, params={})
91
+ def delete_request(action, params={}, headers={})
92
92
  begin
93
- api_response_kind = params.delete('api_response_kind')
94
- api_response_kind = params.delete(:api_response_kind) if api_response_kind.nil?
93
+ api_response_kind = headers.delete('api_response_kind')
94
+ api_response_kind = headers.delete(:api_response_kind) if api_response_kind.nil?
95
95
  api_response_kind = 'object' if api_response_kind.nil?
96
96
 
97
97
  parse_response(api_response_kind, RestClient.delete("#{@endpoint_url}#{action}", params))
@@ -26,14 +26,14 @@ module Mercadolibre
26
26
  result = { }
27
27
 
28
28
  item_ids.each_slice(50) do |ids_group|
29
- filters = { ids: ids_group.join(','), api_response_kind: 'hash' }
30
- result.merge!(get_request('/visits/items', filters).body)
29
+ filters = { ids: ids_group.join(',') }
30
+ result.merge!(get_request('/visits/items', filters, { api_response_kind: 'hash' }).body)
31
31
  end
32
32
 
33
33
  result
34
34
  else
35
- filters = { ids: ids_group.join(','), api_response_kind: 'hash' }
36
- get_request('/visits/items', filters).body[item_ids]
35
+ filters = { ids: ids_group.join(',') }
36
+ get_request('/visits/items', filters, { api_response_kind: 'hash' }).body[item_ids]
37
37
  end
38
38
  end
39
39
 
@@ -44,7 +44,7 @@ module Mercadolibre
44
44
  headers = { content_type: :json, accept: :json }
45
45
 
46
46
  result = post_request("/orders/#{order_id}/notes?access_token=#{@access_token}", payload, headers)
47
- result.body
47
+ result.body.note
48
48
  end
49
49
 
50
50
  def update_order_note(order_id, note_id, text)
@@ -53,7 +53,7 @@ module Mercadolibre
53
53
  headers = { content_type: :json, accept: :json }
54
54
 
55
55
  result = put_request("/orders/#{order_id}/notes/#{note_id}?access_token=#{@access_token}", payload, headers)
56
- result.body
56
+ result.body.note
57
57
  end
58
58
 
59
59
  def delete_order_note(order_id, note_id)
@@ -156,8 +156,8 @@ module Mercadolibre
156
156
  end
157
157
 
158
158
  def get_attachment(attachment_id)
159
- params = { access_token: @access_token, api_response_kind: 'raw' }
160
- get_request("/messages/attachments/#{attachment_id}", params).body
159
+ params = { access_token: @access_token }
160
+ get_request("/messages/attachments/#{attachment_id}", params, { api_response_kind: 'raw' }).body
161
161
  end
162
162
 
163
163
  def get_site_payment_methods(site_id)
@@ -48,20 +48,18 @@ module Mercadolibre
48
48
  end
49
49
 
50
50
  def get_shipment_labels(shipment_ids, attrs={})
51
- filters = {
52
- access_token: @access_token,
53
- api_response_kind: 'raw'
54
- }.merge(attrs)
55
-
56
51
  if shipment_ids.is_a?(Array)
57
52
  shipment_ids_data = shipment_ids.join(',')
58
53
  else
59
54
  shipment_ids_data = shipment_ids
60
55
  end
61
56
 
62
- filters[:shipment_ids] = shipment_ids_data
57
+ filters = attrs.merge({
58
+ access_token: @access_token,
59
+ shipment_ids: shipment_ids_data
60
+ })
63
61
 
64
- get_request('/shipment_labels', filters).body
62
+ get_request('/shipment_labels', filters, { api_response_kind: 'raw' }).body
65
63
  end
66
64
  end
67
65
  end
@@ -1,3 +1,3 @@
1
1
  module Mercadolibre
2
- VERSION = '1.1.1'
2
+ VERSION = '1.2.0'
3
3
  end
@@ -22,8 +22,8 @@ module Mercadopago
22
22
 
23
23
  def get_request(action, params={}, headers={})
24
24
  begin
25
- api_response_kind = params.delete('api_response_kind')
26
- api_response_kind = params.delete(:api_response_kind) if api_response_kind.nil?
25
+ api_response_kind = headers.delete('api_response_kind')
26
+ api_response_kind = headers.delete(:api_response_kind) if api_response_kind.nil?
27
27
  api_response_kind = 'object' if api_response_kind.nil?
28
28
 
29
29
  parse_response(api_response_kind, RestClient.get("#{@endpoint_url}#{action}", {params: params}.merge(headers)))
@@ -34,8 +34,8 @@ module Mercadopago
34
34
 
35
35
  def post_request(action, params={}, headers={})
36
36
  begin
37
- api_response_kind = params.delete('api_response_kind')
38
- api_response_kind = params.delete(:api_response_kind) if api_response_kind.nil?
37
+ api_response_kind = headers.delete('api_response_kind')
38
+ api_response_kind = headers.delete(:api_response_kind) if api_response_kind.nil?
39
39
  api_response_kind = 'object' if api_response_kind.nil?
40
40
 
41
41
  parse_response(api_response_kind, RestClient.post("#{@endpoint_url}#{action}", params, headers))
@@ -46,8 +46,8 @@ module Mercadopago
46
46
 
47
47
  def put_request(action, params={}, headers={})
48
48
  begin
49
- api_response_kind = params.delete('api_response_kind')
50
- api_response_kind = params.delete(:api_response_kind) if api_response_kind.nil?
49
+ api_response_kind = headers.delete('api_response_kind')
50
+ api_response_kind = headers.delete(:api_response_kind) if api_response_kind.nil?
51
51
  api_response_kind = 'object' if api_response_kind.nil?
52
52
 
53
53
  parse_response(api_response_kind, RestClient.put("#{@endpoint_url}#{action}", params, headers))
@@ -58,8 +58,8 @@ module Mercadopago
58
58
 
59
59
  def patch_request(action, params={}, headers={})
60
60
  begin
61
- api_response_kind = params.delete('api_response_kind')
62
- api_response_kind = params.delete(:api_response_kind) if api_response_kind.nil?
61
+ api_response_kind = headers.delete('api_response_kind')
62
+ api_response_kind = headers.delete(:api_response_kind) if api_response_kind.nil?
63
63
  api_response_kind = 'object' if api_response_kind.nil?
64
64
 
65
65
  parse_response(api_response_kind, RestClient.patch("#{@endpoint_url}#{action}", params, headers))
@@ -68,10 +68,10 @@ module Mercadopago
68
68
  end
69
69
  end
70
70
 
71
- def head_request(action, params={})
71
+ def head_request(action, params={}, headers={})
72
72
  begin
73
- api_response_kind = params.delete('api_response_kind')
74
- api_response_kind = params.delete(:api_response_kind) if api_response_kind.nil?
73
+ api_response_kind = headers.delete('api_response_kind')
74
+ api_response_kind = headers.delete(:api_response_kind) if api_response_kind.nil?
75
75
  api_response_kind = 'object' if api_response_kind.nil?
76
76
 
77
77
  parse_response(api_response_kind, RestClient.head("#{@endpoint_url}#{action}", params))
@@ -80,10 +80,10 @@ module Mercadopago
80
80
  end
81
81
  end
82
82
 
83
- def delete_request(action, params={})
83
+ def delete_request(action, params={}, headers={})
84
84
  begin
85
- api_response_kind = params.delete('api_response_kind')
86
- api_response_kind = params.delete(:api_response_kind) if api_response_kind.nil?
85
+ api_response_kind = headers.delete('api_response_kind')
86
+ api_response_kind = headers.delete(:api_response_kind) if api_response_kind.nil?
87
87
  api_response_kind = 'object' if api_response_kind.nil?
88
88
 
89
89
  parse_response(api_response_kind, RestClient.delete("#{@endpoint_url}#{action}", params))
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mercadolibre
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matias Hick