Class: Omise::Charge

Inherits:
OmiseObject show all
Defined in:
lib/omise/charge.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



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

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

.list(attributes = {}) ⇒ Object



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

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

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



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

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

.searchObject



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

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

Instance Method Details

#capture(options = {}) ⇒ Object



37
38
39
# File 'lib/omise/charge.rb', line 37

def capture(options = {})
  assign_attributes nested_resource("capture", options).post
end

#capturedObject



61
62
63
# File 'lib/omise/charge.rb', line 61

def captured
  lookup_attribute_value :captured, :paid
end

#customer(options = {}) ⇒ Object



45
46
47
# File 'lib/omise/charge.rb', line 45

def customer(options = {})
  expand_attribute Customer, "customer", options
end

#dispute(options = {}) ⇒ Object



49
50
51
# File 'lib/omise/charge.rb', line 49

def dispute(options = {})
  expand_attribute Dispute, "dispute", options
end


65
66
67
# File 'lib/omise/charge.rb', line 65

def paid
  lookup_attribute_value :paid, :captured
end

#refundsObject



57
58
59
# File 'lib/omise/charge.rb', line 57

def refunds
  list_attribute RefundList, "refunds"
end

#reload(attributes = {}) ⇒ Object



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

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

#reverse(options = {}) ⇒ Object



41
42
43
# File 'lib/omise/charge.rb', line 41

def reverse(options = {})
  assign_attributes nested_resource("reverse", options).post
end

#transaction(options = {}) ⇒ Object



53
54
55
# File 'lib/omise/charge.rb', line 53

def transaction(options = {})
  expand_attribute Transaction, "transaction", options
end

#update(attributes = {}) ⇒ Object



33
34
35
# File 'lib/omise/charge.rb', line 33

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