Search code examples
ruby-on-railsrubyquickbooks

Why does quickbooks fail when trying to create/update certain attributes?


I am trying to create a new customer using the quickbooks API. If I only pass the name and active attributes it works fine. However, when I pass other attributes it fails.

ruby 1.9.3p194 - Rails 3.1.3

gem 'strong_parameters', '~> 0.2.3'

gem 'quickbooks-ruby'

gem 'quickbooks-ruby-base'

gem 'oauth-plugin'

base = Quickbooks::Base.new(@user, :customer)
customer = base.qr_model(:customer)
customer.given_name = patient.first_name
customer.family_name = patient.last_name
customer.active = true
customer.primary_phone = patient.home_phone
customer.primary_email_address = patient.email
customer.billing_address = patient.address1 + " " + patient.address2 + " " + patient.city + " " + patient.state + " " + patient.zip
base.service.create(customer)

ERROR: NoMethodError: undefined method `address' for "":String

It seems as if I am not saving the object correctly. Any ideas?

ANSWER(Thanks Manas Mukherjee):

address  = Quickbooks::Model::PhysicalAddress.new
address.line1 = "103 Fake St.
address.city = "Simsbury"
... 
customer.billing_address = address

Solution

  • I've not used the ruby-gem lib yet. It looks like, the error is not from the server rather from the client (ruby-gem).

    bill/ship address is not defined as 'String', it is a complex type called - 'physicaladdress'. Please check if you have correct setter method which takes a 'physicaladdres' type as argument.

    Java equivalent of this - customer.setBillAddr(PhysicalAddress val);

    https://developer.intuit.com/docs/api/accounting [ Ref - complex data type -> physicaladdress ].

    Customer Doc Ref - https://developer.intuit.com/docs/0025_quickbooksapi/0050_data_services/030_entity_services_reference/customer