Class: Omise::CardList

Inherits:
List show all
Defined in:
lib/omise/card_list.rb

Instance Method Summary collapse

Methods inherited from List

#each, #last, #reload, #to_a

Methods inherited from OmiseObject

location, resource

Methods included from Attributes

#[], #as_json, #assign_attributes, #attributes, #destroyed?, #key?, #location, #method_missing, #respond_to?

Constructor Details

#initialize(customer, attributes = {}) ⇒ CardList

Returns a new instance of CardList.



7
8
9
10
# File 'lib/omise/card_list.rb', line 7

def initialize(customer, attributes = {})
  super(attributes)
  @customer = customer
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Omise::Attributes

Instance Method Details

#create(attributes = {}) ⇒ Object



16
17
18
19
20
# File 'lib/omise/card_list.rb', line 16

def create(attributes = {})
  token = Token.create(card: attributes)
  @customer.update(card: token.id)
  retrieve(token.card.id)
end

#retrieve(id, attributes = {}) ⇒ Object



12
13
14
# File 'lib/omise/card_list.rb', line 12

def retrieve(id, attributes = {})
  Card.new self.class.resource(location(id), attributes).get
end