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, #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



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

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

.list(attributes = {}) ⇒ Object



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

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

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



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

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

.schedule(attributes = {}) ⇒ Object



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

def self.schedule(attributes = {})
  Scheduler.new(:charge, attributes)
end

.searchObject



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

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

Instance Method Details

#capture(options = {}) ⇒ Object



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

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

#capturedObject



75
76
77
# File 'lib/omise/charge.rb', line 75

def captured
  lookup_attribute_value :captured, :paid
end

#customer(options = {}) ⇒ Object



47
48
49
50
51
52
53
# File 'lib/omise/charge.rb', line 47

def customer(options = {})
  if !defined?(Customer)
    require "omise/customer"
  end

  expand_attribute Customer, "customer", options
end

#dispute(options = {}) ⇒ Object



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

def dispute(options = {})
  if !defined?(Dispute)
    require "omise/dispute"
  end

  expand_attribute Dispute, "dispute", options
end


79
80
81
# File 'lib/omise/charge.rb', line 79

def paid
  lookup_attribute_value :paid, :captured
end

#refundsObject



71
72
73
# File 'lib/omise/charge.rb', line 71

def refunds
  list_attribute RefundList, "refunds"
end

#reload(attributes = {}) ⇒ Object



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

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

#reverse(options = {}) ⇒ Object



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

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

#transaction(options = {}) ⇒ Object



63
64
65
66
67
68
69
# File 'lib/omise/charge.rb', line 63

def transaction(options = {})
  if !defined?(Transaction)
    require "omise/transaction"
  end

  expand_attribute Transaction, "transaction", options
end

#update(attributes = {}) ⇒ Object



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

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