Class: Quickeebooks::Online::Model::Customer

Inherits:
IntuitType
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
lib/quickeebooks/online/model/customer.rb

Constant Summary collapse

XML_NODE =
"Customer"
REST_RESOURCE =
"customer"

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from IntuitType

resource_for_singular

Class Method Details

.resource_for_collectionObject

Class methods



67
68
69
# File 'lib/quickeebooks/online/model/customer.rb', line 67

def self.resource_for_collection
  "#{self::REST_RESOURCE}s"
end

Instance Method Details

#email_address=(email_address) ⇒ Object



56
57
58
# File 'lib/quickeebooks/online/model/customer.rb', line 56

def email_address=(email_address)
  self.email = Quickeebooks::Online::Model::Email.new(email_address)
end

#to_xml_ns(options = {}) ⇒ Object



52
53
54
# File 'lib/quickeebooks/online/model/customer.rb', line 52

def to_xml_ns(options = {})
  to_xml_inject_ns('Customer', options)
end

#valid_for_deletion?Boolean

To delete an account Intuit requires we provide Id and SyncToken fields

Returns:

  • (Boolean)


61
62
63
64
# File 'lib/quickeebooks/online/model/customer.rb', line 61

def valid_for_deletion?
  return false if(id.nil? || sync_token.nil?)
  id.value.to_i > 0 && !sync_token.to_s.empty? && sync_token.to_i >= 0
end

#valid_for_update?Boolean

Returns:

  • (Boolean)


45
46
47
48
49
50
# File 'lib/quickeebooks/online/model/customer.rb', line 45

def valid_for_update?
  if sync_token.nil?
    errors.add(:sync_token, "Missing required attribute SyncToken for update")
  end
  errors.empty?
end