Class: Quickeebooks::Online::Model::Item

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

Constant Summary collapse

XML_NODE =
"Item"
REST_RESOURCE =

<baseURL>/resource/items/v2/<realmID>

"item"

Instance Method Summary collapse

Methods inherited from IntuitType

resource_for_collection, resource_for_singular

Methods included from Logging

#log

Instance Method Details

#taxable?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/quickeebooks/online/model/item.rb', line 55

def taxable?
  taxable == "true"
end

#to_xml_ns(options = {}) ⇒ Object



37
38
39
# File 'lib/quickeebooks/online/model/item.rb', line 37

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

#valid_for_deletion?Boolean

To delete a record Intuit requires we provide Id and SyncToken fields

Returns:

  • (Boolean)


42
43
44
45
# File 'lib/quickeebooks/online/model/item.rb', line 42

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

Returns:

  • (Boolean)


47
48
49
50
51
52
53
# File 'lib/quickeebooks/online/model/item.rb', line 47

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