Class: Omise::Customer

Inherits:
OmiseObject show all
Defined in:
lib/omise/customer.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from OmiseObject

location, resource

Methods included from Attributes

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

Dynamic Method Handling

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

Class Method Details

.create(attributes = {}) ⇒ Object



17
18
19
# File 'lib/omise/customer.rb', line 17

def self.create(attributes = {})
  new resource(location, attributes).post(attributes)
end

.list(attributes = {}) ⇒ Object



13
14
15
# File 'lib/omise/customer.rb', line 13

def self.list(attributes = {})
  List.new resource(location, attributes).get
end

.retrieve(id = nil, attributes = {}) ⇒ Object



9
10
11
# File 'lib/omise/customer.rb', line 9

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

Instance Method Details

#cardsObject



39
40
41
# File 'lib/omise/customer.rb', line 39

def cards
  @cards ||= CardList.new(self, @attributes["cards"])
end

#default_card(options = {}) ⇒ Object



33
34
35
36
37
# File 'lib/omise/customer.rb', line 33

def default_card(options = {})
  if @attributes["default_card"]
    @default_card ||= cards.retrieve(@attributes["default_card"], options)
  end
end

#destroy(attributes = {}) ⇒ Object



29
30
31
# File 'lib/omise/customer.rb', line 29

def destroy(attributes = {})
  assign_attributes resource(attributes).delete
end

#reload(attributes = {}) ⇒ Object



21
22
23
# File 'lib/omise/customer.rb', line 21

def reload(attributes = {})
  assign_attributes resource(attributes).get
end

#update(attributes = {}) ⇒ Object



25
26
27
# File 'lib/omise/customer.rb', line 25

def update(attributes = {})
  assign_attributes resource(attributes).patch(attributes)
end