mercadolibre 1.3.2 → 1.3.3

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
  SHA1:
3
- metadata.gz: 0cfb9b21a37d853b60d8bf3ececbfdda1f93062a
4
- data.tar.gz: e0b6522495a46bdb08b748bfaf996d36852c6844
3
+ metadata.gz: a0a430d6e7ef717f9083cf28406c9a2abd73ad27
4
+ data.tar.gz: ae0d0dab36518f2b7a44674eb4bd2cb27f9606bd
5
5
  SHA512:
6
- metadata.gz: c7b536e9a9956417bf618de2935512258d0d94d3288dab2ae81263128d2c1eb89505062cc594f0d243121df9a898372a4fdcef5b90d6d3706f886fb74c8a8c22
7
- data.tar.gz: 4c5a6f289efa6be3b634a11f7c034ea5c752ac2a5c90569e40946cb74518c2b23cf2c9b1cedbd784608d520bd093664a2f02b6d822e357a3e353899bdf805440
6
+ metadata.gz: 3ab20cf112355ed308c0fccb9f897e8b6459173020bd697fcd3b83fda206fc5714959cf49b98fd7b92d1c07871f6676cf17e06f9c6f632d9ce88af113134d2b7
7
+ data.tar.gz: 6989e9929cc211678fef5f9fd1021b3c74004ef2572edc5e66cb74e44c1fd7eeb3e94133f53be86c40286b50a69fced0b3b50f6fffc905fcd97342793ec7ff73
@@ -257,3 +257,7 @@
257
257
  ## v1.3.2
258
258
 
259
259
  * Can set site with an accessor
260
+
261
+ ## v1.3.3
262
+
263
+ * Added extra methods to api and extra options on order message creation
data/README.md CHANGED
@@ -1,9 +1,9 @@
1
1
  Mercadolibre
2
2
  ==============
3
3
 
4
- Mercadolibre gem implements MELI API (Official API available to interact with Mercadolibre).
4
+ Mercadolibre gem implements MELI API (Official API available to interact with Mercadolibre) and MPAGO API (official API for Mercadopago).
5
5
 
6
- It implements most of the methods of the official API and it makes it very easy to interact with.
6
+ It implements all the methods of the official API and it makes it very easy to interact with.
7
7
 
8
8
  Requirements
9
9
  -----------------
@@ -19,7 +19,7 @@ Installation
19
19
  gem install mercadolibre
20
20
 
21
21
 
22
- Getting started
22
+ Getting started (MELI)
23
23
  -----------------
24
24
 
25
25
  MELI uses OAuth protocol for authentication, so you first need to get an access token.
@@ -27,6 +27,28 @@ module Mercadolibre
27
27
  @last_response
28
28
  end
29
29
 
30
+ def get_last_result
31
+ @last_result
32
+ end
33
+
34
+ def send_custom_request(http_method, action, params={}, headers={})
35
+ if http_method.to_s.downcase == 'get'
36
+ get_request(action, params, headers)
37
+ elsif http_method.to_s.downcase == 'post'
38
+ post_request(action, params, headers)
39
+ elsif http_method.to_s.downcase == 'put'
40
+ put_request(action, params, headers)
41
+ elsif http_method.to_s.downcase == 'patch'
42
+ patch_request(action, params, headers)
43
+ elsif http_method.to_s.downcase == 'head'
44
+ head_request(action, params, headers)
45
+ elsif http_method.to_s.downcase == 'delete'
46
+ delete_request(action, params, headers)
47
+ else
48
+ raise 'invalid http method!'
49
+ end
50
+ end
51
+
30
52
  private
31
53
 
32
54
  def get_request(action, params={}, headers={})
@@ -118,6 +140,8 @@ module Mercadolibre
118
140
  result.body = response.body
119
141
  end
120
142
 
143
+ @last_result = result
144
+
121
145
  result
122
146
  end
123
147
  end
@@ -132,7 +132,15 @@ module Mercadolibre
132
132
  get_request("/messages/#{message_id}", params).body
133
133
  end
134
134
 
135
- def create_order_message(order_id, user_from, user_to, message, attachments=[])
135
+ def create_order_message(order_id, user_from, user_to, content_type, message, attachments=[])
136
+ if content_type == 'plain'
137
+ message_data = { plain: message }
138
+ elsif content_type == 'html'
139
+ message_data = { html: message }
140
+ else
141
+ raise 'invalid content type! Allowed options: plain,html.'
142
+ end
143
+
136
144
  payload = {
137
145
  from: { user_id: user_from },
138
146
  to: [{
@@ -141,7 +149,7 @@ module Mercadolibre
141
149
  resource_id: order_id,
142
150
  site_id: @site
143
151
  }],
144
- text: { plain: message },
152
+ text: message_data,
145
153
  attachments: attachments
146
154
  }.to_json
147
155
 
@@ -1,3 +1,3 @@
1
1
  module Mercadolibre
2
- VERSION = '1.3.2'
2
+ VERSION = '1.3.3'
3
3
  end
@@ -9,6 +9,7 @@ module Mercadopago
9
9
  @access_token = args[:access_token]
10
10
  @endpoint_url = 'https://api.mercadopago.com'
11
11
  @auth_url = 'https://auth.mercadopago.com.ar'
12
+ @site = args[:site]
12
13
  end
13
14
 
14
15
  include Mercadopago::Core::Oauth
@@ -18,6 +19,28 @@ module Mercadopago
18
19
  @last_response
19
20
  end
20
21
 
22
+ def get_last_result
23
+ @last_result
24
+ end
25
+
26
+ def send_custom_request(http_method, action, params={}, headers={})
27
+ if http_method.to_s.downcase == 'get'
28
+ get_request(action, params, headers)
29
+ elsif http_method.to_s.downcase == 'post'
30
+ post_request(action, params, headers)
31
+ elsif http_method.to_s.downcase == 'put'
32
+ put_request(action, params, headers)
33
+ elsif http_method.to_s.downcase == 'patch'
34
+ patch_request(action, params, headers)
35
+ elsif http_method.to_s.downcase == 'head'
36
+ head_request(action, params, headers)
37
+ elsif http_method.to_s.downcase == 'delete'
38
+ delete_request(action, params, headers)
39
+ else
40
+ raise 'invalid http method!'
41
+ end
42
+ end
43
+
21
44
  private
22
45
 
23
46
  def get_request(action, params={}, headers={})
@@ -109,6 +132,8 @@ module Mercadopago
109
132
  result.body = response.body
110
133
  end
111
134
 
135
+ @last_result = result
136
+
112
137
  result
113
138
  end
114
139
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mercadolibre
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matias Hick
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-20 00:00:00.000000000 Z
11
+ date: 2016-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler