Class: FidorApi::Card
Instance Attribute Summary
#error_keys
Class Method Summary
collapse
Instance Method Summary
collapse
amount_attribute, attributes, extended
included, #method_missing, #respond_to_missing?
all, find, #initialize, model_name, #persisted?, #reload, #save, #update_attributes
Class Method Details
.required_attributes ⇒ Object
30
31
32
|
# File 'lib/fidor_api/card.rb', line 30
def self.required_attributes
%i(account_id type)
end
|
.writeable_attributes ⇒ Object
34
35
36
|
# File 'lib/fidor_api/card.rb', line 34
def self.writeable_attributes
required_attributes + %i(pin address)
end
|
Instance Method Details
#activate ⇒ Object
40
41
42
43
|
# File 'lib/fidor_api/card.rb', line 40
def activate
endpoint.for(self).put(action: 'activate')
true
end
|
#as_json ⇒ Object
67
68
69
|
# File 'lib/fidor_api/card.rb', line 67
def as_json
attributes.slice(*self.class.writeable_attributes)
end
|
#cancel(reason: 'lost') ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/fidor_api/card.rb', line 55
def cancel(reason: 'lost')
case reason
when 'lost'
endpoint.for(self).put(action: 'cancel')
when 'stolen'
endpoint.for(self).put(action: 'block')
else
fail ArgumentError, "Unknown reason: #{reason.inspect}"
end
true
end
|
#lock ⇒ Object
45
46
47
48
|
# File 'lib/fidor_api/card.rb', line 45
def lock
endpoint.for(self).put(action: 'lock')
true
end
|
#unlock ⇒ Object
50
51
52
53
|
# File 'lib/fidor_api/card.rb', line 50
def unlock
endpoint.for(self).put(action: 'unlock')
true
end
|