mercadolibre 0.11.2 → 0.11.3

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: 7ba0e4c91a688e38b5522169023c32df1e182b00
4
- data.tar.gz: 84c9f8850b2ef9afec9d62e59d5a6b0cb53f2163
3
+ metadata.gz: e8ddaf39f8b392547db9cfd377295de6920e7ff9
4
+ data.tar.gz: d9c5ea6a8b7dd6919f5027eb463f66b5f2646f7e
5
5
  SHA512:
6
- metadata.gz: 99368e18499a9e3e6d3168e092a2f40371c5959954a0f50348f22d34d2895576f974d44ad330b0c7ba150a81affb3495270b734df92ee2d754c6127031ae8ae3
7
- data.tar.gz: e2c890893430894381d5cc9b9864c8748d47a4a6d8ec6635cd5373cb9fb4adac964d61ee7d6fc31daed2957eef29a351f0b13ea2153e52a2e5261633d6699f2a
6
+ metadata.gz: 858e0d426fe52b8b340727a5aab4bcab201603da94c73e56d572a4f8bcf3645926586aeb9ebae6068a25a101b5dbf4a0d520679f8aea632003298e67b19fa1aa
7
+ data.tar.gz: 31902a605ae8b0c125de41ae4c67fd73e3c60cc89e968bee918fcdc5ffe4ba4a415796f5ad1cfb956e9de64546c7fc0cfab38878eb16d72df4382ef5b0519024
data/CHANGELOG.md CHANGED
@@ -205,3 +205,7 @@
205
205
  ## v0.11.2
206
206
 
207
207
  * Bugfix mercadopago module mistype
208
+
209
+ ## v0.11.3
210
+
211
+ * Bugfix mercadopago auth url, added payment entities
data/lib/mercadolibre.rb CHANGED
@@ -71,14 +71,24 @@ require "mercadolibre/core/order_management"
71
71
  require "mercadolibre/core/shippings"
72
72
  require "mercadolibre/core/questions"
73
73
  require "mercadolibre/core/users"
74
+
75
+ # mercadolibre -> api
74
76
  require "mercadolibre/api"
75
77
 
76
- # mercadopago -< entities
78
+ # mercadopago -> entities
77
79
  require "mercadopago/entity/auth"
80
+ require "mercadopago/entity/identification"
81
+ require "mercadopago/entity/money_request"
82
+ require "mercadopago/entity/payer"
83
+ require "mercadopago/entity/payment"
84
+ require "mercadopago/entity/phone"
85
+ require "mercadopago/entity/transaction_details"
78
86
 
79
- # mercadopago -< core
87
+ # mercadopago -> core
80
88
  require "mercadopago/core/auth"
81
89
  require "mercadopago/core/payments"
90
+
91
+ # mercadopago -> api
82
92
  require "mercadopago/api"
83
93
 
84
94
  # dependencies
@@ -1,3 +1,3 @@
1
1
  module Mercadolibre
2
- VERSION = "0.11.2"
2
+ VERSION = "0.11.3"
3
3
  end
@@ -8,7 +8,7 @@ module Mercadopago
8
8
  @callback_url = args[:callback_url]
9
9
  @access_token = args[:access_token]
10
10
  @endpoint_url = 'https://api.mercadopago.com'
11
- @auth_url = 'https://auth.mercadolibre.com.ar'
11
+ @auth_url = 'https://auth.mercadopago.com.ar'
12
12
  @debug = args[:debug]
13
13
  end
14
14
 
@@ -2,12 +2,25 @@ module Mercadopago
2
2
  module Core
3
3
  module Payments
4
4
  def get_payment(payment_id)
5
- raise 'not implemented!'
5
+ filters = { access_token: @access_token }
6
+ r = get_request("/v1/paymetns/#{payment_id}", filters)
7
+
8
+ Mercadolibre::Entity::Payment.new(r[:body])
6
9
  end
7
10
 
8
11
  def search_payments(filters={})
9
12
  raise 'not implemented!'
10
13
  end
14
+
15
+ def request_payment(attrs={})
16
+ payload = attrs.to_json
17
+
18
+ headers = { content_type: :json }
19
+
20
+ result = post_request("/money_requests?access_token=#{@access_token}", payload, headers)
21
+
22
+ Mercadopago::Entity::MoneyRequest.new(result[:body])
23
+ end
11
24
  end
12
25
  end
13
26
  end
@@ -0,0 +1,21 @@
1
+ module Mercadolibre
2
+ module Entity
3
+ class Identification
4
+ def self.attr_list
5
+ [:type, :number]
6
+ end
7
+
8
+ attr_reader *attr_list
9
+
10
+ def initialize(attributes={})
11
+ attributes.each do |k, v|
12
+ self.send("#{k}=", v) if self.respond_to?(k)
13
+ end
14
+ end
15
+
16
+ private
17
+
18
+ attr_writer *attr_list
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,32 @@
1
+ module Mercadopago
2
+ module Entity
3
+ class MoneyRequest
4
+ def self.attr_list
5
+ [:id, :status, :site_id, :currency_id, :amount, :collector_id, :collector_email, :payer_id, :payer_email,
6
+ :description, :concept_type, :init_point, :external_reference, :pref_id, :date_created, :last_updated]
7
+ end
8
+
9
+ attr_reader *attr_list
10
+
11
+ def initialize(attributes={})
12
+ attributes.each do |k, v|
13
+ if ['date_created', 'last_updated'].include?(k.to_s)
14
+ self.send("#{k}=", Time.parse(v)) unless v.nil?
15
+ else
16
+ self.send("#{k}=", v) if self.respond_to?(k)
17
+ end
18
+ end
19
+ end
20
+
21
+ private
22
+
23
+ attr_writer *attr_list
24
+ end
25
+ end
26
+ end
27
+
28
+
29
+
30
+ {
31
+
32
+ }
@@ -0,0 +1,29 @@
1
+ module Mercadolibre
2
+ module Entity
3
+ class Payer
4
+ def self.attr_list
5
+ [:type, :id, :email, :identification, :phone, :first_name, :last_name, :entity_type]
6
+ end
7
+
8
+ attr_reader *attr_list
9
+
10
+ def initialize(attributes={})
11
+ attributes.each do |k, v|
12
+ if k.to_s == 'identification'
13
+ self.identification = Identification.new(v) unless v.nil?
14
+ elsif k.to_s == 'phone'
15
+ self.phone = Phone.new(v) unless v.nil?
16
+ else
17
+ self.send("#{k}=", v) if self.respond_to?(k)
18
+ end
19
+ end
20
+ end
21
+
22
+ private
23
+
24
+ attr_writer *attr_list
25
+ end
26
+ end
27
+ end
28
+
29
+
@@ -0,0 +1,70 @@
1
+ module Mercadopago
2
+ module Payment
3
+ class Auth
4
+ def self.attr_list
5
+ [
6
+ :id,
7
+ :date_created,
8
+ :date_approved,
9
+ :date_last_updated,
10
+ :money_release_date,
11
+ :operation_type,
12
+ :issuer_id,
13
+ :payment_method_id,
14
+ :payment_type_id,
15
+ :status,
16
+ :status_detail,
17
+ :currency_id,
18
+ :description,
19
+ :live_mode,
20
+ :sponsor_id,
21
+ :authorization_code,
22
+ :collector_id,
23
+ :payer,
24
+ :metadata,
25
+ :order,
26
+ :external_reference,
27
+ :transaction_amount,
28
+ :transaction_amount_refunded,
29
+ :coupon_amount,
30
+ :differential_pricing_id,
31
+ :deduction_schema,
32
+ :transaction_details,
33
+ :fee_details,
34
+ :captured,
35
+ :binary_mode,
36
+ :call_for_authorize_id,
37
+ :statement_descriptor,
38
+ :installments,
39
+ :card,
40
+ :notification_url,
41
+ :refunds,
42
+ :payer,
43
+ :transaction_details
44
+ ]
45
+ end
46
+
47
+ attr_reader *attr_list
48
+
49
+ def initialize(attributes={})
50
+ time_fields = ['date_created', 'date_approved', 'date_last_updated', 'money_release_date']
51
+
52
+ attributes.each do |k, v|
53
+ if time_fields.include?(k.to_s)
54
+ self.send("#{k}=", Time.parse(v)) unless v.nil?
55
+ elsif k.to_s == 'payer'
56
+ self.payer = Payer.new(v)
57
+ elsif k.to_s == 'transaction_details'
58
+ self.transaction_details = TransactionDetails.new(v)
59
+ else
60
+ self.send("#{k}=", v) if self.respond_to?(k)
61
+ end
62
+ end
63
+ end
64
+
65
+ private
66
+
67
+ attr_writer *attr_list
68
+ end
69
+ end
70
+ end
@@ -0,0 +1,21 @@
1
+ module Mercadolibre
2
+ module Entity
3
+ class Phone
4
+ def self.attr_list
5
+ [:area_code, :number, :extension]
6
+ end
7
+
8
+ attr_reader *attr_list
9
+
10
+ def initialize(attributes={})
11
+ attributes.each do |k, v|
12
+ self.send("#{k}=", v) if self.respond_to?(k)
13
+ end
14
+ end
15
+
16
+ private
17
+
18
+ attr_writer *attr_list
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,27 @@
1
+ module Mercadopago
2
+ module Entity
3
+ class TransactionDetails
4
+ def self.attr_list
5
+ [:net_received_amount,
6
+ :total_paid_amount,
7
+ :overpaid_amount,
8
+ :external_resource_url,
9
+ :installment_amount,
10
+ :financial_institution,
11
+ :payment_method_reference_id]
12
+ end
13
+
14
+ attr_reader *attr_list
15
+
16
+ def initialize(attributes={})
17
+ attributes.each do |k, v|
18
+ self.send("#{k}=", v) if self.respond_to?(k)
19
+ end
20
+ end
21
+
22
+ private
23
+
24
+ attr_writer *attr_list
25
+ end
26
+ end
27
+ 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: 0.11.2
4
+ version: 0.11.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-11-24 00:00:00.000000000 Z
11
+ date: 2016-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -137,6 +137,12 @@ files:
137
137
  - lib/mercadopago/core/auth.rb
138
138
  - lib/mercadopago/core/payments.rb
139
139
  - lib/mercadopago/entity/auth.rb
140
+ - lib/mercadopago/entity/identification.rb
141
+ - lib/mercadopago/entity/money_request.rb
142
+ - lib/mercadopago/entity/payer.rb
143
+ - lib/mercadopago/entity/payment.rb
144
+ - lib/mercadopago/entity/phone.rb
145
+ - lib/mercadopago/entity/transaction_details.rb
140
146
  homepage: https://github.com/unformattmh/mercadolibre
141
147
  licenses:
142
148
  - MIT