mercadopago 2.3.1 → 3.1.0

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
- SHA1:
3
- metadata.gz: 915ad943d6fa17a084ca5591addde311f150f643
4
- data.tar.gz: bb2accde1c3a562d02fa4ea44ecd5ea044080447
2
+ SHA256:
3
+ metadata.gz: 649f78d3dbe6b0e7211edebf9377deb5c0bb20d95f9fe6aa4ea2040c79bb85c2
4
+ data.tar.gz: 4cfc927afb3ac884e3e6473f4b96a902e1f25885b2a9bf5830e079f837962f14
5
5
  SHA512:
6
- metadata.gz: bc66543f4efec94a04dbf1d4496ff9f4aac31bcabe8b1d22f56de389deca6a21850e0a70f3f39a0ea2dd43fca4eea6c975ec83c829b850b3483d309141890f70
7
- data.tar.gz: 1cbb0ba8446f5121c3efc669512f8540328f29d7b6d526234b0cadc7dc4b75a96b0830c10b9b744c63bafde61d21839d1f303b0c4677a07aab832bfaa1f055c4
6
+ metadata.gz: 584dbba43aee5eb9f0a25fe1d21a9f1e03e8f6cb53e48ea752ecbff8d37d8bfe2476821f2d2a664e26c2effe4637bc3625a72d26a9cb4e9f9febcb5deb9c716f
7
+ data.tar.gz: 6544033782bf9c5cb39d92c83b7b6a7fb87e232c553d225735c36755c321d834b8738c8607704a5329f00c37d87922314bd39827e0d21470ccde2e0965df5d64
@@ -0,0 +1,30 @@
1
+ name: Tests
2
+ on:
3
+ push:
4
+ branches: [ "master" ]
5
+ pull_request:
6
+ branches: [ "master" ]
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ jobs:
12
+ test:
13
+ runs-on: ubuntu-latest
14
+ strategy:
15
+ matrix:
16
+ ruby-version: ['2.6', '2.7']
17
+
18
+ steps:
19
+ - uses: actions/checkout@v3
20
+ - name: Set up Ruby
21
+ # To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
22
+ # change this to (see https://github.com/ruby/setup-ruby#versioning):
23
+ # uses: ruby/setup-ruby@v1
24
+ uses: ruby/setup-ruby@55283cc23133118229fd3f97f9336ee23a179fcf # v1.146.0
25
+ with:
26
+ ruby-version: ${{ matrix.ruby-version }}
27
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
28
+
29
+ - name: Run Tests
30
+ run: bundle exec rake
data/CHANGELOG.md ADDED
@@ -0,0 +1,15 @@
1
+ # CHANGELOG
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## main [(unreleased)](https://github.com/ombulabs/mercadopago/compare/v3.1.0...HEAD)
9
+
10
+ * <INSERT YOUR FEATURE OR BUGFIX HERE>
11
+
12
+ ## v3.1.0 / 2024-12-02 [(commits)](https://github.com/ombulabs/mercadopago/compare/v3.0.0...v3.1.0)
13
+
14
+ * [BUGFIX: Bump JSON dependency](https://github.com/ombulabs/mercadopago/pull/47)
15
+ * [CHORE: CI with GitHub Actions](https://github.com/ombulabs/mercadopago/pull/48)
data/README.md CHANGED
@@ -16,7 +16,8 @@ You can read the documentation of the MercadoPago API here:
16
16
  Installation
17
17
  ------------
18
18
 
19
- mercadopago 2.3.0 needs Ruby >= 2.0.0. For Ruby 1.9 support, use mercadopago ~> 2.2.0.
19
+ mercadopago 2.3.0 needs Ruby >= 2.0.0. Ruby 1.9.3 does not support TLS v1.2,
20
+ which is required by MercadoPago starting June 30th 2018.
20
21
 
21
22
  To install the last version of the gem:
22
23
 
@@ -287,6 +288,19 @@ And the parameters that could be used in the search hash are:
287
288
  recurring_payment: Active subscription recurring payment.
288
289
  subscription_payment: Subscription fee.
289
290
 
291
+ ### Auto Pagination
292
+
293
+ It is also possible to inform if whether or not the result should be automatically paginated to return all payments. By default MercadoPago return only 30 payments on each request and if you setting up `auto_paginate` to true, will be made as many requests as needed to return all payments that matches with your search.
294
+
295
+ # Create a hash to search for
296
+ search_hash = { external_reference: 'OPERATION-ID-1234' }
297
+
298
+ # setup the auto_paginate to true
299
+ mp_client.auto_paginate = true
300
+
301
+ # do the desired search
302
+ search = mp_client.search(search_hash)
303
+
290
304
  ### Sandbox mode
291
305
 
292
306
  The sandbox mode can be enabled/disabled as follows:
@@ -21,25 +21,23 @@ http_interactions:
21
21
  message: OK
22
22
  headers:
23
23
  Date:
24
- - Mon, 25 Apr 2016 18:27:43 GMT
24
+ - Thu, 12 Oct 2017 21:05:06 GMT
25
25
  Content-Type:
26
26
  - application/json;charset=UTF-8
27
- Transfer-Encoding:
28
- - chunked
29
27
  Connection:
30
28
  - keep-alive
31
29
  Vary:
32
- - Accept,Accept-Encoding
30
+ - Accept,Accept-Encoding, User-Agent
33
31
  Cache-Control:
34
32
  - max-age=0
35
33
  Etag:
36
- - ea81c1fa59f6b789c1d7811bb3497072
34
+ - 117072c3d17a4c57ec53e81a49ccc340
37
35
  X-Content-Type-Options:
38
36
  - nosniff
39
37
  X-Frame-Options:
40
38
  - DENY
41
39
  X-Request-Id:
42
- - 29adeddd-6421-45c5-a855-0d3bfbb05878
40
+ - 5ee09a80-8c79-4b93-a2b9-e084de782f0b
43
41
  X-Xss-Protection:
44
42
  - 1; mode=block
45
43
  Strict-Transport-Security:
@@ -52,12 +50,15 @@ http_interactions:
52
50
  - PUT, GET, POST, DELETE, OPTIONS
53
51
  Access-Control-Max-Age:
54
52
  - '86400'
55
- X-Libra-Upstreamhost:
56
- - 172.16.161.224
53
+ Set-Cookie:
54
+ - TS016da221=0119b547a2e0a66296bbde4156a3367a684adbaa1543cf074a81cb09f5a7c4c51f64000f8eea85ae721c61a0c2dc9c5edea90f95a8;
55
+ Path=/; Secure; HTTPOnly
56
+ Transfer-Encoding:
57
+ - chunked
57
58
  body:
58
- encoding: UTF-8
59
- string: '{"access_token":"APP_USR-<CLIENT-ID>-1234567","refresh_token":"TG-2345e6rtyughj7city8d3-1234567","live_mode":true,"user_id":1234567,"token_type":"bearer","expires_in":21600,"scope":"offline_access
59
+ encoding: ASCII-8BIT
60
+ string: '{"access_token":"APP_USR-<CLIENT-ID>-101217-d6e629925b4a85db8fd187bf6634a763__E_G__-64475662","refresh_token":"TG-59dfd902e4b00c9296aab2da-64475662","live_mode":true,"user_id":64475662,"token_type":"bearer","expires_in":21600,"scope":"offline_access
60
61
  read write"}'
61
62
  http_version:
62
- recorded_at: Mon, 25 Apr 2016 18:27:43 GMT
63
- recorded_with: VCR 3.0.1
63
+ recorded_at: Thu, 12 Oct 2017 21:05:06 GMT
64
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,183 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.mercadopago.com/collections/search?access_token=APP_USR-<CLIENT-ID>-101217-d6e629925b4a85db8fd187bf6634a763__E_G__-64475662&status=refunded
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Date:
22
+ - Thu, 12 Oct 2017 21:05:09 GMT
23
+ Content-Type:
24
+ - application/json;charset=UTF-8
25
+ Connection:
26
+ - keep-alive
27
+ X-Api-Version:
28
+ - '1'
29
+ Vary:
30
+ - Accept,Accept-Encoding, User-Agent
31
+ Cache-Control:
32
+ - max-age=0
33
+ Etag:
34
+ - 8fdbad2ea576655d1aa99aa1f992a518
35
+ X-Content-Type-Options:
36
+ - nosniff
37
+ X-Frame-Options:
38
+ - DENY
39
+ X-Request-Id:
40
+ - d6dca1a4-f713-459f-b286-74d8c3e8f6ec
41
+ X-Xss-Protection:
42
+ - 1; mode=block
43
+ Strict-Transport-Security:
44
+ - max-age=15724800
45
+ Access-Control-Allow-Origin:
46
+ - "*"
47
+ Access-Control-Allow-Headers:
48
+ - Content-Type
49
+ Access-Control-Allow-Methods:
50
+ - PUT, GET, POST, DELETE, OPTIONS
51
+ Access-Control-Max-Age:
52
+ - '86400'
53
+ Set-Cookie:
54
+ - TS01e25bc7=015d800523a1540d53d21bfe200f32d4f643ceeec8dacb5463365acdde0d05b7293969368b6b0f746720df9e793599556d51d36723;
55
+ Path=/; Secure; HTTPOnly
56
+ Transfer-Encoding:
57
+ - chunked
58
+ body:
59
+ encoding: ASCII-8BIT
60
+ string: '{"paging":{"total":73,"limit":30,"offset":0},"results":[{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}},{"collection":{"id":2759844123}}]}'
61
+ http_version:
62
+ recorded_at: Thu, 12 Oct 2017 21:05:09 GMT
63
+ - request:
64
+ method: get
65
+ uri: https://api.mercadopago.com/collections/search?access_token=APP_USR-<CLIENT-ID>-101217-d6e629925b4a85db8fd187bf6634a763__E_G__-64475662&offset=30&status=refunded
66
+ body:
67
+ encoding: US-ASCII
68
+ string: ''
69
+ headers:
70
+ Accept:
71
+ - application/json
72
+ Accept-Encoding:
73
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
74
+ User-Agent:
75
+ - Ruby
76
+ response:
77
+ status:
78
+ code: 200
79
+ message: OK
80
+ headers:
81
+ Date:
82
+ - Thu, 12 Oct 2017 21:05:10 GMT
83
+ Content-Type:
84
+ - application/json;charset=UTF-8
85
+ Connection:
86
+ - keep-alive
87
+ X-Api-Version:
88
+ - '1'
89
+ Vary:
90
+ - Accept,Accept-Encoding, User-Agent
91
+ Cache-Control:
92
+ - max-age=0
93
+ Etag:
94
+ - c6ebb80caabfdae48fb601167fd27098
95
+ X-Content-Type-Options:
96
+ - nosniff
97
+ X-Frame-Options:
98
+ - DENY
99
+ X-Request-Id:
100
+ - 28fc5782-2324-4a50-9f94-e12e4869ecd6
101
+ X-Xss-Protection:
102
+ - 1; mode=block
103
+ Strict-Transport-Security:
104
+ - max-age=15724800
105
+ Access-Control-Allow-Origin:
106
+ - "*"
107
+ Access-Control-Allow-Headers:
108
+ - Content-Type
109
+ Access-Control-Allow-Methods:
110
+ - PUT, GET, POST, DELETE, OPTIONS
111
+ Access-Control-Max-Age:
112
+ - '86400'
113
+ Set-Cookie:
114
+ - TS01e25bc7=015d800523bfac2e652c09b83ec2b5dba4c3184c5747f4cc744d5a989152643dcca8c4e1e50ae567f1fa6eee94954b164c32f09686;
115
+ Path=/; Secure; HTTPOnly
116
+ Transfer-Encoding:
117
+ - chunked
118
+ body:
119
+ encoding: ASCII-8BIT
120
+ string: '{"paging":{"total":3,"limit":30,"offset":30},"results":[]}'
121
+ http_version:
122
+ recorded_at: Thu, 12 Oct 2017 21:05:09 GMT
123
+ - request:
124
+ method: get
125
+ uri: https://api.mercadopago.com/collections/search?access_token=APP_USR-<CLIENT-ID>-101217-d6e629925b4a85db8fd187bf6634a763__E_G__-64475662&offset=60&status=refunded
126
+ body:
127
+ encoding: US-ASCII
128
+ string: ''
129
+ headers:
130
+ Accept:
131
+ - application/json
132
+ Accept-Encoding:
133
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
134
+ User-Agent:
135
+ - Ruby
136
+ response:
137
+ status:
138
+ code: 200
139
+ message: OK
140
+ headers:
141
+ Date:
142
+ - Thu, 12 Oct 2017 21:05:11 GMT
143
+ Content-Type:
144
+ - application/json;charset=UTF-8
145
+ Connection:
146
+ - keep-alive
147
+ X-Api-Version:
148
+ - '1'
149
+ Vary:
150
+ - Accept,Accept-Encoding, User-Agent
151
+ Cache-Control:
152
+ - max-age=0
153
+ Etag:
154
+ - c36602d9bcd21ce1521315dd36c054be
155
+ X-Content-Type-Options:
156
+ - nosniff
157
+ X-Frame-Options:
158
+ - DENY
159
+ X-Request-Id:
160
+ - ebbecc76-94ff-4b17-95b2-f383b60b1651
161
+ X-Xss-Protection:
162
+ - 1; mode=block
163
+ Strict-Transport-Security:
164
+ - max-age=15724800
165
+ Access-Control-Allow-Origin:
166
+ - "*"
167
+ Access-Control-Allow-Headers:
168
+ - Content-Type
169
+ Access-Control-Allow-Methods:
170
+ - PUT, GET, POST, DELETE, OPTIONS
171
+ Access-Control-Max-Age:
172
+ - '86400'
173
+ Set-Cookie:
174
+ - TS01e25bc7=015d800523d3b04a83b4be92e13925a96ffefa2f6850ea5973905c65cc69ac93f9b00ab012adf095c026384b720ca1d6e67bbc1cf0;
175
+ Path=/; Secure; HTTPOnly
176
+ Transfer-Encoding:
177
+ - chunked
178
+ body:
179
+ encoding: ASCII-8BIT
180
+ string: '{"paging":{"total":3,"limit":30,"offset":60},"results":[]}'
181
+ http_version:
182
+ recorded_at: Thu, 12 Oct 2017 21:05:10 GMT
183
+ recorded_with: VCR 3.0.3
@@ -0,0 +1,58 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.mercadopago.com/collections/search?access_token=APP_USR-<CLIENT-ID>-101217-d6e629925b4a85db8fd187bf6634a763__E_G__-64475662&status=refunded
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept:
11
+ - application/json
12
+ Accept-Encoding:
13
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 400
19
+ message: Bad Request
20
+ headers:
21
+ Date:
22
+ - Thu, 24 Oct 2019 23:50:42 GMT
23
+ Content-Type:
24
+ - application/json;charset=ISO-8859-1
25
+ Content-Length:
26
+ - '157'
27
+ Connection:
28
+ - keep-alive
29
+ Cache-Control:
30
+ - max-age=60,stale-while-revalidate=30, stale-if-error=120
31
+ X-Newrelic-App-Data:
32
+ - PxQOWV9WAAUTVVFaBwkHVVQJFB9AMQYAZBBZDEtZV0ZaCldOdg4cBQ1CXxQETVtcXUsMB0VSVgILXV9REANMA0UWUE9ZW1dXQBYUFV4KVgxJV0cISRBKUB8FEQsYUlgIEENZXw4DEREeJl0BV1xRc1AGXBJCNVwJAVgVTVZPCB0AVFFQDgEBX10dGwJORAdVVVRaWwEKUQZWAFgCUwMRTgJXWxIDPg==
33
+ X-Content-Type-Options:
34
+ - nosniff
35
+ X-Request-Id:
36
+ - f23ce7c1-8246-4b2e-bb99-c5fd125447b4
37
+ X-Frame-Options:
38
+ - DENY
39
+ X-Xss-Protection:
40
+ - 1; mode=block
41
+ Access-Control-Allow-Origin:
42
+ - "*"
43
+ Access-Control-Allow-Headers:
44
+ - Content-Type
45
+ Access-Control-Allow-Methods:
46
+ - PUT, GET, POST, DELETE, OPTIONS
47
+ Access-Control-Max-Age:
48
+ - '86400'
49
+ Strict-Transport-Security:
50
+ - max-age=16070400; includeSubDomains; preload
51
+ Timing-Allow-Origin:
52
+ - "*"
53
+ body:
54
+ encoding: UTF-8
55
+ string: '{"message":"Malformed access_token: APP_USR-<CLIENT-ID>-101217-d6e629925b4a85db8fd187bf6634a763__E_G__-64475662","error":"bad_request","status":400,"cause":[]}'
56
+ http_version:
57
+ recorded_at: Thu, 24 Oct 2019 23:50:41 GMT
58
+ recorded_with: VCR 5.0.0
@@ -28,6 +28,7 @@ module MercadoPago
28
28
  class Client
29
29
 
30
30
  attr_reader :access_token, :refresh_token, :sandbox
31
+ attr_accessor :auto_paginate
31
32
 
32
33
  #
33
34
  # Creates an instance and stores the access_token to make calls to the
@@ -151,7 +152,7 @@ module MercadoPago
151
152
  # - search_hash: the search hash to find collections.
152
153
  #
153
154
  def search(search_hash)
154
- MercadoPago::Collection.search(@access_token, search_hash, @sandbox)
155
+ MercadoPago::Collection.search(@access_token, search_hash, @sandbox, auto_paginate)
155
156
  end
156
157
 
157
158
  #
@@ -193,7 +194,7 @@ module MercadoPago
193
194
 
194
195
  if (auth.keys & mandatory_keys) == mandatory_keys
195
196
  @access_token = auth['access_token']
196
- @refresh_token = auth['refresh_token'] # Sometimes refresh_token is not received
197
+ @refresh_token = auth['refresh_token']
197
198
  else
198
199
  raise AccessError, auth['message']
199
200
  end
@@ -2,6 +2,7 @@
2
2
  module MercadoPago
3
3
 
4
4
  module Collection
5
+ RESULTS_PER_PAGE = 30
5
6
 
6
7
  #
7
8
  # Receives an access_token and a payment id and retrieves information of the payment.
@@ -10,10 +11,11 @@ module MercadoPago
10
11
  # - access_token: an access_token of the MercadoPago account associated with the payment to be checked.
11
12
  # - payment_id: the id of the payment to be checked.
12
13
  # - sandbox: whether or not the sandbox mode should be activated.
14
+ # - auto_paginate: whether or not the result should be automaticaly paginated to return all payments
13
15
  #
14
16
  def self.notification(access_token, payment_id, sandbox = false)
15
17
  uri_prefix = sandbox ? '/sandbox' : ''
16
- MercadoPago::Request.wrap_get("#{uri_prefix}/collections/notifications/#{payment_id}?access_token=#{access_token}", { accept: 'application/json' })
18
+ MercadoPago::Request.wrap_get("#{uri_prefix}/v1/payments/#{payment_id}?access_token=#{access_token}", { accept: 'application/json' })
17
19
  end
18
20
 
19
21
  #
@@ -100,14 +102,41 @@ module MercadoPago
100
102
  # Active subscription recurring payment.
101
103
  # subscription_payment::
102
104
  # Subscription fee.
103
- #
104
- def self.search(access_token, search_hash = {}, sandbox = false)
105
+
106
+ def self.search(access_token, search_hash = {}, sandbox = false, auto_paginate = false)
105
107
  query = search_hash.map { |e| e.join('=') }.join('&')
106
108
 
107
109
  uri_prefix = sandbox ? '/sandbox' : ''
108
- MercadoPago::Request.wrap_get("#{uri_prefix}/collections/search?access_token=#{access_token}&#{query}", { accept: 'application/json' })
110
+
111
+ result = []
112
+
113
+ if auto_paginate
114
+ response = get_collection(access_token, query, uri_prefix)
115
+
116
+ if response
117
+ total_items = response.fetch("paging", {}).fetch("total", nil)
118
+ pages = total_items ? (total_items / RESULTS_PER_PAGE.to_f).ceil : 1
119
+
120
+ pages.times do |page|
121
+ offset = page * RESULTS_PER_PAGE
122
+ query = search_hash.map { |e| e.join('=') }.join('&')
123
+ query += "&offset=#{offset}" if offset > 0
124
+
125
+ response = get_collection(access_token, query, uri_prefix) if offset > 0
126
+
127
+ result << response["results"]
128
+ result = [result] unless result.is_a? Array
129
+ end
130
+ end
131
+ else
132
+ result << get_collection(access_token, query, uri_prefix)
133
+ end
134
+
135
+ result.flatten
109
136
  end
110
137
 
138
+ def self.get_collection(access_token, query, uri_prefix)
139
+ MercadoPago::Request.wrap_get("#{uri_prefix}/collections/search?access_token=#{access_token}&#{query}", { accept: 'application/json' })
140
+ end
111
141
  end
112
-
113
142
  end
@@ -65,7 +65,7 @@ module MercadoPago
65
65
  def self.make_request(type, path, payload = nil, headers = {})
66
66
  args = [type, MERCADOPAGO_URL, path, payload, headers].compact
67
67
 
68
- connection = Faraday.new(MERCADOPAGO_URL)
68
+ connection = Faraday.new(MERCADOPAGO_URL, ssl: { version: :TLSv1_2 })
69
69
 
70
70
  response = connection.send(type) do |req|
71
71
  req.url path
@@ -1,3 +1,3 @@
1
1
  module MercadoPago
2
- VERSION = "2.3.1".freeze
2
+ VERSION = "3.1.0".freeze
3
3
  end
data/mercadopago.gemspec CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
8
8
  s.licenses = ['MIT']
9
9
  s.authors = ["Kauplus Social Commerce", "Ombu Shop, Tu Tienda Online"]
10
10
  s.email = ["suporte@kauplus.com.br", "hola@ombushop.com"]
11
- s.homepage = "https://github.com/kauplus/mercadopago"
11
+ s.homepage = "https://github.com/ombulabs/mercadopago"
12
12
  s.summary = %q{Client for the MercadoPago API}
13
13
  s.description = %q{This gem allows developers to use the services available in the MercadoPago API (http://www.mercadopago.com)}
14
14
 
@@ -20,11 +20,11 @@ Gem::Specification.new do |s|
20
20
  s.require_paths = ["lib"]
21
21
 
22
22
  # specify any dependencies here:
23
- s.add_dependency 'json', '~> 1.4'
24
- s.add_dependency 'faraday', '~> 0.9.0'
23
+ s.add_dependency 'json', '~> 2.3'
24
+ s.add_dependency 'faraday', '~> 0.9'
25
25
  s.add_development_dependency 'pry', '~> 0.11.1'
26
26
  s.add_development_dependency 'rake', '~> 12.1'
27
- s.add_development_dependency 'byebug', '~> 9.1'
27
+ s.add_development_dependency 'byebug', '~> 11.1'
28
28
  s.add_development_dependency 'test-unit', '~> 3.2'
29
29
  s.add_development_dependency 'vcr', '~> 3.0'
30
30
  s.add_development_dependency 'webmock', '~> 3.0'
@@ -221,26 +221,29 @@ class TestMercadoPago < Test::Unit::TestCase
221
221
  # assert_equal payment_id, @response['id']
222
222
  # end
223
223
 
224
- # TODO: make test work again
225
- # def test_that_client_can_search
226
- # VCR.use_cassette("login", match_requests_on: [:path]) do
227
- # @mp_client = MercadoPago::Client.new(CREDENTIALS[:client_id], CREDENTIALS[:client_secret])
228
- # end
229
- #
230
- # VCR.use_cassette("search status") do
231
- # @response = @mp_client.search(status: :refunded)
232
- # end
233
- #
234
- # assert @response.has_key?('results')
235
- #
236
- # external_reference = '55723'
237
- #
238
- # VCR.use_cassette("search external reference") do
239
- # @response = @mp_client.search(external_reference: external_reference)
240
- # end
241
- # results = @response['results']
242
- #
243
- # assert_equal 1, results.length
244
- # assert_equal external_reference, results[0]['collection']['external_reference']
245
- # end
224
+ def test_that_client_can_search
225
+ VCR.use_cassette("login", match_requests_on: [:path]) do
226
+ @mp_client = MercadoPago::Client.new(CREDENTIALS[:client_id], CREDENTIALS[:client_secret])
227
+ end
228
+
229
+ VCR.use_cassette("search status") do
230
+ @response = @mp_client.search(status: :refunded)
231
+ end
232
+
233
+ assert_equal 1, @response.length
234
+ end
235
+
236
+ def test_that_search_can_be_paginated
237
+ VCR.use_cassette("login", match_requests_on: [:path]) do
238
+ @mp_client = MercadoPago::Client.new(CREDENTIALS[:client_id], CREDENTIALS[:client_secret])
239
+ end
240
+
241
+ @mp_client.auto_paginate = true
242
+
243
+ VCR.use_cassette("paginated search") do
244
+ @response = @mp_client.search(status: :refunded)
245
+ end
246
+
247
+ assert_equal 73, @response.length
248
+ end
246
249
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mercadopago
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.1
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kauplus Social Commerce
8
8
  - Ombu Shop, Tu Tienda Online
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-05-07 00:00:00.000000000 Z
12
+ date: 2024-12-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
@@ -17,28 +17,28 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: '1.4'
20
+ version: '2.3'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: '1.4'
27
+ version: '2.3'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: faraday
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: 0.9.0
34
+ version: '0.9'
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: 0.9.0
41
+ version: '0.9'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: pry
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -73,14 +73,14 @@ dependencies:
73
73
  requirements:
74
74
  - - "~>"
75
75
  - !ruby/object:Gem::Version
76
- version: '9.1'
76
+ version: '11.1'
77
77
  type: :development
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
81
  - - "~>"
82
82
  - !ruby/object:Gem::Version
83
- version: '9.1'
83
+ version: '11.1'
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: test-unit
86
86
  requirement: !ruby/object:Gem::Requirement
@@ -132,8 +132,9 @@ executables: []
132
132
  extensions: []
133
133
  extra_rdoc_files: []
134
134
  files:
135
+ - ".github/workflows/tests.yml"
135
136
  - ".gitignore"
136
- - ".travis.yml"
137
+ - CHANGELOG.md
137
138
  - Gemfile
138
139
  - README.md
139
140
  - Rakefile
@@ -142,6 +143,8 @@ files:
142
143
  - fixtures/vcr_cassettes/create_preference.yml
143
144
  - fixtures/vcr_cassettes/get_preference.yml
144
145
  - fixtures/vcr_cassettes/login.yml
146
+ - fixtures/vcr_cassettes/paginated_search.yml
147
+ - fixtures/vcr_cassettes/search_status.yml
145
148
  - fixtures/vcr_cassettes/wrong_login.yml
146
149
  - fixtures/vcr_cassettes/wrong_token.yml
147
150
  - lib/mercadopago.rb
@@ -154,11 +157,11 @@ files:
154
157
  - lib/mercadopago/version.rb
155
158
  - mercadopago.gemspec
156
159
  - test/test_mercado_pago.rb
157
- homepage: https://github.com/kauplus/mercadopago
160
+ homepage: https://github.com/ombulabs/mercadopago
158
161
  licenses:
159
162
  - MIT
160
163
  metadata: {}
161
- post_install_message:
164
+ post_install_message:
162
165
  rdoc_options: []
163
166
  require_paths:
164
167
  - lib
@@ -173,9 +176,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
173
176
  - !ruby/object:Gem::Version
174
177
  version: '0'
175
178
  requirements: []
176
- rubyforge_project: mercadopago
177
- rubygems_version: 2.6.14
178
- signing_key:
179
+ rubygems_version: 3.5.10
180
+ signing_key:
179
181
  specification_version: 4
180
182
  summary: Client for the MercadoPago API
181
183
  test_files:
data/.travis.yml DELETED
@@ -1,8 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 2.2.4
4
- script: "rake test"
5
- gemfile:
6
- - Gemfile
7
- before_install:
8
- - gem update bundler