Class: Frame::PaymentMethod

Inherits:
APIResource show all
Extended by:
APIOperations::Create, APIOperations::List
Includes:
APIOperations::Save
Defined in:
lib/frame/resources/payment_method.rb

Constant Summary collapse

OBJECT_NAME =
"payment_method"

Instance Attribute Summary

Attributes inherited from FrameObject

#id, #original_values

Class Method Summary collapse

Instance Method Summary collapse

Methods included from APIOperations::Create

create

Methods included from APIOperations::List

list

Methods included from APIOperations::Save

#serialize_params

Methods inherited from APIResource

class_name, #refresh, resource_url, #resource_url

Methods included from APIOperations::Request

included

Methods inherited from FrameObject

#[], #[]=, construct_from, #each, #initialize, #initialize_from, #inspect, #keys, #serialize_params, #to_hash, #to_s, #update_attributes, #values

Constructor Details

This class inherits a constructor from Frame::FrameObject

Class Method Details

.attach(id, customer_id, params = {}, opts = {}) ⇒ Object



79
80
81
82
83
84
85
86
# File 'lib/frame/resources/payment_method.rb', line 79

def self.attach(id, customer_id, params = {}, opts = {})
  request_object(
    :post,
    "/v1/payment_methods/#{CGI.escape(id)}/attach",
    {customer: customer_id}.merge(params),
    opts
  )
end

.block(id, params = {}, opts = {}) ⇒ Object



115
116
117
118
119
120
121
122
# File 'lib/frame/resources/payment_method.rb', line 115

def self.block(id, params = {}, opts = {})
  request_object(
    :post,
    "/v1/payment_methods/#{CGI.escape(id)}/block",
    params,
    opts
  )
end

.connect_plaid(params = {}, opts = {}) ⇒ Object



43
44
45
46
47
48
49
50
# File 'lib/frame/resources/payment_method.rb', line 43

def self.connect_plaid(params = {}, opts = {})
  request_object(
    :post,
    "/v1/payment_methods/connect_plaid",
    params,
    opts
  )
end

.create(params = {}, opts = {}) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/frame/resources/payment_method.rb', line 15

def self.create(params = {}, opts = {})
  request_object(
    :post,
    "/v1/payment_methods",
    params,
    opts
  )
end

.detach(id, params = {}, opts = {}) ⇒ Object



97
98
99
100
101
102
103
104
# File 'lib/frame/resources/payment_method.rb', line 97

def self.detach(id, params = {}, opts = {})
  request_object(
    :post,
    "/v1/payment_methods/#{CGI.escape(id)}/detach",
    params,
    opts
  )
end

.list(params = {}, opts = {}) ⇒ Object



24
25
26
27
28
29
30
31
# File 'lib/frame/resources/payment_method.rb', line 24

def self.list(params = {}, opts = {})
  request_object(
    :get,
    "/v1/payment_methods",
    params,
    opts
  )
end

.object_nameObject



11
12
13
# File 'lib/frame/resources/payment_method.rb', line 11

def self.object_name
  OBJECT_NAME
end

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



33
34
35
36
37
38
39
40
41
# File 'lib/frame/resources/payment_method.rb', line 33

def self.retrieve(id, opts = {})
  id = Util.normalize_id(id)
  request_object(
    :get,
    "/v1/payment_methods/#{CGI.escape(id)}",
    {},
    opts
  )
end

.unblock(id, params = {}, opts = {}) ⇒ Object



133
134
135
136
137
138
139
140
# File 'lib/frame/resources/payment_method.rb', line 133

def self.unblock(id, params = {}, opts = {})
  request_object(
    :post,
    "/v1/payment_methods/#{CGI.escape(id)}/unblock",
    params,
    opts
  )
end

Instance Method Details

#attach(customer_id, params = {}, opts = {}) ⇒ Object



70
71
72
73
74
75
76
77
# File 'lib/frame/resources/payment_method.rb', line 70

def attach(customer_id, params = {}, opts = {})
  request_object(
    :post,
    "/v1/payment_methods/#{CGI.escape(self["id"])}/attach",
    {customer: customer_id}.merge(params),
    opts
  )
end

#block(params = {}, opts = {}) ⇒ Object



106
107
108
109
110
111
112
113
# File 'lib/frame/resources/payment_method.rb', line 106

def block(params = {}, opts = {})
  request_object(
    :post,
    "/v1/payment_methods/#{CGI.escape(self["id"])}/block",
    params,
    opts
  )
end

#detach(params = {}, opts = {}) ⇒ Object



88
89
90
91
92
93
94
95
# File 'lib/frame/resources/payment_method.rb', line 88

def detach(params = {}, opts = {})
  request_object(
    :post,
    "/v1/payment_methods/#{CGI.escape(self["id"])}/detach",
    params,
    opts
  )
end

#save(params = {}, opts = {}) ⇒ Object



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/frame/resources/payment_method.rb', line 52

def save(params = {}, opts = {})
  values = serialize_params(self).merge(params)

  if values.empty?
    return self
  end

  updated = request_object(
    :patch,
    "/v1/payment_methods/#{CGI.escape(self["id"])}",
    values,
    opts
  )

  initialize_from(updated)
  self
end

#unblock(params = {}, opts = {}) ⇒ Object



124
125
126
127
128
129
130
131
# File 'lib/frame/resources/payment_method.rb', line 124

def unblock(params = {}, opts = {})
  request_object(
    :post,
    "/v1/payment_methods/#{CGI.escape(self["id"])}/unblock",
    params,
    opts
  )
end