Class: KashflowApi::Customer

Inherits:
SoapObject show all
Defined in:
lib/kashflow_api/models/customer.rb

Constant Summary collapse

Keys =
[
  "Code", "Name", "Contact", "Telephone", "Mobile", "Fax", "Email", "Address1", "Address2", "Address3", "Address4", "Postcode",
  "Website", "Notes", "ExtraText1", "ExtraText2", "ExtraText3", "ExtraText4", "ExtraText5", "ExtraText6", "ExtraText7", "ExtraText8",
  "ExtraText9", "ExtraText10", "ExtraText11", "ExtraText12", "ExtraText13", "ExtraText14", "ExtraText15", "ExtraText16", "ExtraText17",
  "ExtraText18", "ExtraText19", "ExtraText20", "ContactTitle", "ContactFirstName", "ContactLastName", ["CustHasDeliveryAddresss", "0"],
  "DeliveryAddress1", "DeliveryAddress2", "DeliveryAddress3", "DeliveryAddress4", "DeliveryPostcode"
]
Finds =
[ "code", "id", "email", "postcode" ]
KFObject =
{ singular: "customer", plural: "customers" }
XMLKey =
"CustomerID"

Instance Attribute Summary

Attributes inherited from SoapObject

#hash

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from SoapObject

all, define_methods, find, find_method, inherited, #initialize, #to_xml

Constructor Details

This class inherits a constructor from KashflowApi::SoapObject

Class Method Details

.build_arguments(action, object, field, argument) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/kashflow_api/models/customer.rb', line 20

def self.build_arguments(action, object, field, argument)
  if action == "get"
    expects argument, String
    return "<Customer#{field}>#{argument}</Customer#{field}>" if object == "customer"
    return "<#{field}>#{argument}</#{field}>" if object == "customers"
  elsif action == "update" || action == "insert"
    expects argument, KashflowApi::Customer
    return "<custr>#{argument.to_xml}</custr>" if object == "customer"
  end
end

Instance Method Details

#balanceObject



39
40
41
# File 'lib/kashflow_api/models/customer.rb', line 39

def balance
  KashflowApi::CustomerBalance.new(self)
end

#saveObject



31
32
33
34
35
36
37
# File 'lib/kashflow_api/models/customer.rb', line 31

def save
  if @hash[:customer_id] == "0"
    insert_customer
  else
    update_customer
  end 
end