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



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

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

.list(attributes = {}) ⇒ Object



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

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

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



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

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

Instance Method Details

#capture(options = {}) ⇒ Object



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

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

#capturedObject



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

def captured
  lookup_attribute_value :captured, :paid
end

#customer(options = {}) ⇒ Object



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

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

#dispute(options = {}) ⇒ Object



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

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


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

def paid
  lookup_attribute_value :paid, :captured
end

#refundsObject



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

def refunds
  list_attribute RefundList, "refunds"
end

#reload(attributes = {}) ⇒ Object



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

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

#transaction(options = {}) ⇒ Object



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

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

#update(attributes = {}) ⇒ Object



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

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