Class: MercadoPago::API::Cards

Inherits:
Base
  • Object
show all
Defined in:
lib/mercadopago/api.rb,
lib/mercadopago/api/cards.rb

Instance Attribute Summary

Attributes inherited from Base

#access_token

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from MercadoPago::Base

Instance Method Details

#retrieve_customer_cards(customer_id) ⇒ Object

GET /v1/customers/:customer_id/cards It retrieves all cards from a customer



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/mercadopago/api/cards.rb', line 16

def retrieve_customer_cards(customer_id)
  response = connection.get customer_cards_endpoint(customer_id) do |req|
    req.params['access_token'] = access_token
  end
  response = process_response(response)
  OpenStruct.new(success?: true, body: response)
rescue Faraday::ClientError => exception
  OpenStruct.new(success?: false, message: 'Los datos no son correctos', details: exception.response[:body].to_s)
rescue Faraday::Error::TimeoutError, Faraday::ConnectionFailed, Timeout::Error => e
  OpenStruct.new(success?: false, message: 'El servidor de mercadopago se encuentra fuera de servicio. Intenta más tarde', details: 'Server timeout')
end

#service_urlObject

Override parent class method Place here main base URL



10
11
12
# File 'lib/mercadopago/api/cards.rb', line 10

def service_url
  'https://api.mercadopago.com'
end