Class: FidorApi::Customer
Defined Under Namespace
Modules: ClientSupport, Gender
Instance Attribute Summary
#error_keys
Class Method Summary
collapse
Instance Method Summary
collapse
all, find, model_name, #persisted?, #reload, #save, #update_attributes
Constructor Details
#initialize(*args) ⇒ Customer
Returns a new instance of Customer.
77
78
79
80
|
# File 'lib/fidor_api/customer.rb', line 77
def initialize(*args)
super
self.affiliate_uid = FidorApi.configuration.affiliate_uid
end
|
Class Method Details
.first ⇒ Object
73
74
75
|
# File 'lib/fidor_api/customer.rb', line 73
def self.first
all(page: 1, per_page: 1).first
end
|
Instance Method Details
#as_json(options = nil) ⇒ Object
108
109
110
|
# File 'lib/fidor_api/customer.rb', line 108
def as_json(options = nil)
attributes.tap { |a| a[:birthday] = a[:birthday].try(:to_date) }
end
|
#confirm_update(attributes) ⇒ Object
91
92
93
94
|
# File 'lib/fidor_api/customer.rb', line 91
def confirm_update(attributes)
self.endpoint = Connectivity::Endpoint.new('/customers', :collection, version: '2')
endpoint.for(self).put(action: 'confirm_update', payload: {token: attributes['token']})
end
|
#gender ⇒ Object
96
97
98
|
# File 'lib/fidor_api/customer.rb', line 96
def gender
Gender.for_api_value(@gender)
end
|
#gender=(value) ⇒ Object
100
101
102
103
104
105
106
|
# File 'lib/fidor_api/customer.rb', line 100
def gender=(value)
@gender = if value.class == Class && value.instance.is_a?(FidorApi::Customer::Gender::Base)
Gender.object_to_string(value)
else
value
end
end
|
#request_update(attributes) ⇒ Object
82
83
84
85
86
87
88
89
|
# File 'lib/fidor_api/customer.rb', line 82
def request_update(attributes)
self.endpoint = Connectivity::Endpoint.new('/customers', :collection, version: '2')
endpoint.for(self).put(action: 'request_update', payload: attributes.as_json)
true
rescue ValidationError => e
map_errors(e.fields)
false
end
|