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, #predicate?, #respond_to_missing?

Dynamic Method Handling

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

Class Method Details

.create(attributes = {}) ⇒ Object



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

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

.list(attributes = {}) ⇒ Object



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

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

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



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

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

.searchObject



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

def self.search
  SearchScope.new(:customer)
end

Instance Method Details

#cards(options = {}) ⇒ Object



54
55
56
57
58
59
60
61
# File 'lib/omise/customer.rb', line 54

def cards(options = {})
  if options.empty?
    list_attribute CardList, "cards"
  else
    response = collection.resource(location("cards")).get(options)
    CardList.new(response, parent: self)
  end
end

#charge(attributes = {}) ⇒ Object



42
43
44
45
46
47
48
# File 'lib/omise/customer.rb', line 42

def charge(attributes = {})
  if !defined?(Charge)
    require "omise/charge"
  end

  Charge.create(attributes.merge(customer: id))
end

#default_card(options = {}) ⇒ Object



50
51
52
# File 'lib/omise/customer.rb', line 50

def default_card(options = {})
  expand_attribute cards, "default_card", options
end

#destroy(attributes = {}) ⇒ Object



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

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

#reload(attributes = {}) ⇒ Object



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

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

#schedules(attributes = {}) ⇒ Object



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

def schedules(attributes = {})
  List.new nested_resource("schedules", attributes).get(attributes)
end

#update(attributes = {}) ⇒ Object



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

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