Class: Quickbooks::Model::Customer
Constant Summary
collapse
- XML_COLLECTION_NODE =
"Customer"
- XML_NODE =
"Customer"
- REST_RESOURCE =
'customer'
Instance Method Summary
collapse
Methods inherited from BaseModel
reference_setters, resource_for_collection, resource_for_singular, #to_xml_inject_ns, #to_xml_ns
Instance Method Details
#active? ⇒ Boolean
59
60
61
|
# File 'lib/quickbooks/model/customer.rb', line 59
def active?
active.to_s == 'true'
end
|
#bill_with_parent? ⇒ Boolean
67
68
69
|
# File 'lib/quickbooks/model/customer.rb', line 67
def bill_with_parent?
bill_with_parent.to_s == 'true'
end
|
#email_address ⇒ Object
91
92
93
|
# File 'lib/quickbooks/model/customer.rb', line 91
def email_address
primary_email_address
end
|
#email_address=(email_address) ⇒ Object
87
88
89
|
# File 'lib/quickbooks/model/customer.rb', line 87
def email_address=(email_address)
self.primary_email_address = EmailAddress.new(email_address)
end
|
#email_address_is_valid ⇒ Object
110
111
112
113
114
115
116
117
|
# File 'lib/quickbooks/model/customer.rb', line 110
def email_address_is_valid
if primary_email_address
address = primary_email_address.address
unless address.index('@') && address.index('.')
errors.add(:primary_email_address, "Email address must contain @ and . (dot)")
end
end
end
|
#job? ⇒ Boolean
63
64
65
|
# File 'lib/quickbooks/model/customer.rb', line 63
def job?
job.to_s == 'true'
end
|
#names_cannot_contain_invalid_characters ⇒ Object
101
102
103
104
105
106
107
108
|
# File 'lib/quickbooks/model/customer.rb', line 101
def names_cannot_contain_invalid_characters
[:display_name, :given_name, :middle_name, :family_name, :print_on_check_name].each do |property|
value = send(property).to_s
if value.index(':')
errors.add(property, ":#{property} cannot contain a colon (:).")
end
end
end
|
#taxable? ⇒ Boolean
71
72
73
|
# File 'lib/quickbooks/model/customer.rb', line 71
def taxable?
taxable.to_s == 'true'
end
|
#valid_for_create? ⇒ Boolean
82
83
84
85
|
# File 'lib/quickbooks/model/customer.rb', line 82
def valid_for_create?
valid?
errors.empty?
end
|
#valid_for_deletion? ⇒ Boolean
To delete an account Intuit requires we provide Id and SyncToken fields
96
97
98
99
|
# File 'lib/quickbooks/model/customer.rb', line 96
def valid_for_deletion?
return false if(id.nil? || sync_token.nil?)
id.to_i > 0 && !sync_token.to_s.empty? && sync_token.to_i >= 0
end
|
#valid_for_update? ⇒ Boolean
75
76
77
78
79
80
|
# File 'lib/quickbooks/model/customer.rb', line 75
def valid_for_update?
if sync_token.nil?
errors.add(:sync_token, "Missing required attribute SyncToken for update")
end
errors.empty?
end
|