Class: Mercadopago::SDK

Inherits:
Object
  • Object
show all
Defined in:
lib/mercadopago/sdk.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(access_token, http_client: nil, request_options: nil) ⇒ SDK

Returns a new instance of SDK.



8
9
10
11
12
# File 'lib/mercadopago/sdk.rb', line 8

def initialize(access_token, http_client: nil, request_options: nil)
  self.access_token = access_token
  self.http_client = http_client.nil? ? HttpClient.new : http_client
  self.request_options = request_options.nil? ? RequestOptions.new(access_token: access_token) : request_options
end

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.



6
7
8
# File 'lib/mercadopago/sdk.rb', line 6

def access_token
  @access_token
end

#http_clientObject

Returns the value of attribute http_client.



6
7
8
# File 'lib/mercadopago/sdk.rb', line 6

def http_client
  @http_client
end

Instance Method Details

#advanced_paymentObject



14
15
16
# File 'lib/mercadopago/sdk.rb', line 14

def advanced_payment
  AdvancedPayment.new(request_options, http_client)
end

#cardObject



18
19
20
# File 'lib/mercadopago/sdk.rb', line 18

def card
  Card.new(request_options, http_client)
end

#card_tokenObject



22
23
24
# File 'lib/mercadopago/sdk.rb', line 22

def card_token
  CardToken.new(request_options, http_client)
end

#customerObject



26
27
28
# File 'lib/mercadopago/sdk.rb', line 26

def customer
  Customer.new(request_options, http_client)
end

#disbursement_refundObject



30
31
32
# File 'lib/mercadopago/sdk.rb', line 30

def disbursement_refund
  DisbursementRefund.new(request_options, http_client)
end

#identification_typeObject



38
39
40
# File 'lib/mercadopago/sdk.rb', line 38

def identification_type
  IdentificationType.new(request_options, http_client)
end

#merchant_orderObject



42
43
44
# File 'lib/mercadopago/sdk.rb', line 42

def merchant_order
  MerchantOrder.new(request_options, http_client)
end

#paymentObject



46
47
48
# File 'lib/mercadopago/sdk.rb', line 46

def payment
  Payment.new(request_options, http_client)
end

#payment_methodsObject



50
51
52
# File 'lib/mercadopago/sdk.rb', line 50

def payment_methods
  PaymentMethods.new(request_options, http_client)
end

#preferenceObject



54
55
56
# File 'lib/mercadopago/sdk.rb', line 54

def preference
  Preference.new(request_options, http_client)
end

#refundObject



58
59
60
# File 'lib/mercadopago/sdk.rb', line 58

def refund
  Refund.new(request_options, http_client)
end

#request_optionsObject



80
81
82
83
# File 'lib/mercadopago/sdk.rb', line 80

def request_options
  @request_options.access_token = @access_token if @request_options.access_token.nil?
  @request_options
end

#request_options=(value) ⇒ Object

Raises:

  • (TypeError)


74
75
76
77
78
# File 'lib/mercadopago/sdk.rb', line 74

def request_options=(value)
  raise TypeError, 'Param request_options must be a RequestOptions object' unless value.is_a?(RequestOptions)

  @request_options = value
end

#userObject



34
35
36
# File 'lib/mercadopago/sdk.rb', line 34

def user
  User.new(request_options, http_client)
end