Class: Omise::CardList

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

Instance Method Summary collapse

Methods inherited from List

#each, #first_page?, #initialize, #jump_to_page, #last, #last_page?, #next_page, #page, #parent, #previous_page, #reload, #to_a, #total_pages

Methods inherited from OmiseObject

location, resource

Methods included from Attributes

#[], #as_json, #assign_attributes, #attributes, #destroyed?, #initialize, #key?, #location, #method_missing, #predicate?, #respond_to_missing?

Constructor Details

This class inherits a constructor from Omise::List

Dynamic Method Handling

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

Instance Method Details

#create(attributes = {}) ⇒ Object



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

def create(attributes = {})
  if !defined?(Token)
    require "omise/token"
  end

  token = Token.create(card: attributes)
  parent.update(card: token.id)
  retrieve(token.card.id)
end

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



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

def retrieve(id, attributes = {})
  if !defined?(Card)
    require "omise/card"
  end

  Card.new self.class.resource(location(id), attributes).get(attributes)
end