Class: Quickeebooks::Windows::Model::Customer
- Inherits:
-
IntuitType
- Object
- IntuitType
- Quickeebooks::Windows::Model::Customer
- Includes:
- ActiveModel::Validations
- Defined in:
- lib/quickeebooks/windows/model/customer.rb
Constant Summary collapse
- DEFAULT_TYPE_OF =
'Person'
- XML_COLLECTION_NODE =
'Customers'
- XML_NODE =
'Customer'
- REST_RESOURCE =
services.intuit.com/sb/customer/v2/<realmID>
"customer"
Instance Method Summary collapse
- #active? ⇒ Boolean
- #address=(address) ⇒ Object
- #billing_address ⇒ Object
- #email_address=(email_address) ⇒ Object
- #email_address_is_valid ⇒ Object
- #name_cannot_contain_invalid_characters ⇒ Object
- #require_an_address ⇒ Object
- #shipping_address ⇒ Object
- #to_xml_ns(options = {}) ⇒ Object
- #valid_for_create? ⇒ Boolean
-
#valid_for_deletion? ⇒ Boolean
To delete an account Intuit requires we provide Id and SyncToken fields.
- #valid_for_update? ⇒ Boolean
Instance Method Details
#active? ⇒ Boolean
80 81 82 |
# File 'lib/quickeebooks/windows/model/customer.rb', line 80 def active? active == 'true' end |
#address=(address) ⇒ Object
115 116 117 118 |
# File 'lib/quickeebooks/windows/model/customer.rb', line 115 def address=(address) self.addresses ||= [] self.addresses << address end |
#billing_address ⇒ Object
84 85 86 |
# File 'lib/quickeebooks/windows/model/customer.rb', line 84 def billing_address addresses.detect { |address| address.tag == "Billing" } end |
#email_address=(email_address) ⇒ Object
111 112 113 |
# File 'lib/quickeebooks/windows/model/customer.rb', line 111 def email_address=(email_address) self.email = Quickeebooks::Windows::Model::Email.new(email_address) end |
#email_address_is_valid ⇒ Object
132 133 134 135 136 137 138 139 |
# File 'lib/quickeebooks/windows/model/customer.rb', line 132 def email_address_is_valid if email address = email.address unless address.index('@') && address.index('.') errors.add(:email, "Email address must contain @ and . (dot)") end end end |
#name_cannot_contain_invalid_characters ⇒ Object
126 127 128 129 130 |
# File 'lib/quickeebooks/windows/model/customer.rb', line 126 def name_cannot_contain_invalid_characters if name.to_s.index(':') errors.add(:name, "Name cannot contain a colon (:)") end end |
#require_an_address ⇒ Object
141 142 143 144 145 |
# File 'lib/quickeebooks/windows/model/customer.rb', line 141 def require_an_address if addresses.nil? || (addresses.is_a?(Array) && addresses.empty?) errors.add(:addresses, "Must provide at least one address for this Customer.") end end |
#shipping_address ⇒ Object
88 89 90 |
# File 'lib/quickeebooks/windows/model/customer.rb', line 88 def shipping_address addresses.detect { |address| address.tag == "Shipping" } end |
#to_xml_ns(options = {}) ⇒ Object
107 108 109 |
# File 'lib/quickeebooks/windows/model/customer.rb', line 107 def to_xml_ns( = {}) to_xml end |
#valid_for_create? ⇒ Boolean
99 100 101 102 103 104 105 |
# File 'lib/quickeebooks/windows/model/customer.rb', line 99 def valid_for_create? valid? if type_of.nil? errors.add(:type_of, "Missing required attribute TypeOf for Create") end errors.empty? end |
#valid_for_deletion? ⇒ Boolean
To delete an account Intuit requires we provide Id and SyncToken fields
121 122 123 124 |
# File 'lib/quickeebooks/windows/model/customer.rb', line 121 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
92 93 94 95 96 97 |
# File 'lib/quickeebooks/windows/model/customer.rb', line 92 def valid_for_update? if sync_token.nil? errors.add(:sync_token, "Missing required attribute SyncToken for update") end errors.empty? end |