Class: Zoop::Token
Constant Summary
Constants inherited
from ZoopObject
ZoopObject::RESOURCES
Instance Attribute Summary
Attributes inherited from ZoopObject
#attributes
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Model
class_name, create, find_by_id, #save, underscored_class_name, #update, #url
Methods inherited from ZoopObject
#==, #[]=, convert, #empty?, #initialize, #respond_to?, #to_hash, #to_s, #unsaved_attributes
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Zoop::ZoopObject
Class Method Details
.url(*params) ⇒ Object
24
25
26
27
28
29
30
|
# File 'lib/zoop/resources/token.rb', line 24
def url(*params)
case params.first
when TrueClass then '/cards/tokens'
when FalseClass then '/bank_accounts/tokens'
else super(*params)
end
end
|
Instance Method Details
#associate(customer_id) ⇒ Object
13
14
15
16
|
# File 'lib/zoop/resources/token.rb', line 13
def associate(customer_id)
raise RequestError.new('Invalid Token ID') unless id.present?
payment_method.class.associate(customer: customer_id.to_s, token: id.to_s)
end
|
4
5
6
7
|
# File 'lib/zoop/resources/token.rb', line 4
def create
@custom_url = self.class.url(self.card_number.present?)
super
end
|
9
10
11
|
# File 'lib/zoop/resources/token.rb', line 9
def destroy
raise NotImplementedError
end
|
#payment_method ⇒ Object
18
19
20
|
# File 'lib/zoop/resources/token.rb', line 18
def payment_method
self.card || self.bank_account
end
|