quickeebook gem:快速书中的PUSH postal_code,city,line1,line2字段?

时间:2013-08-13 07:19:27

标签: ruby-on-rails-3.2 rubygems quickbooks

我正在使用 rails 3.2和quickeebook gem 在线连接quickbooks。现在我的rails应用程序和quickbook之间的连接已经完成,但我正面临着新的问题。

当我尝试在quickbook中保存customer.name时,它通过我的控制器成功保存,但是如果我尝试传递customer.id,customer.email,customer.zipcode,customer.phone等字段。它正在生成错误。如何使用quickeebook gem

保存这些数据

哦,我忘了解释错误和代码

oauth_client = OAuth::AccessToken.new($qb_oauth_consumer, current_login.access_token, current_login.access_secret)


    #creating customer in quickbooks
    customer_service = Quickeebooks::Online::Service::Customer.new
    customer_service.access_token = oauth_client
    customer_service.realm_id = current_login.realm_id
    customer_service.list

    customer = Quickeebooks::Online::Model::Customer.new
    customer.name = "New Customer2"
    customer.email_address = "new_customer1@gmail.org"
    customer.given_name = "New"
    customer.middle_name = "H."
    customer.family_name = "Customer"
    customer.phone = "9845845854"
    customer.web_site = "www.google.com"
    customer.billing_address = "this is billing address"
    customer.city = "Bangalore"
    customer_service.create(customer)

假设,我想在线阅读这些字段。但这会产生如下错误:

undefined method `to_xml' for "9845845854":String

除了family_name之外的其他字段工作正常,但对于电话,地址,网站,城市等字段,每当我想将这些值推送到quickbooks错误时,如:

undefined method `to_xml' for "9845845854":String
undefined method `to_xml' for "www.google.com":string
undefined method `city=' for #<Quickeebooks::Online::Model::Customer:0xb5150e68>

正在降临。如何解决此错误?

1 个答案:

答案 0 :(得分:1)

最后,问题解决了......

postal_code,line1,line2,city等字段与地址字段相关。所以不要写

customer.city = "Bangalore"

我们必须首先继承地址模型,我们必须在客户中传递地址数组,如:

    address = Quickeebooks::Online::Model::Address.new
    address.line1 = "address 1"
    address.line2 = "my fake address"
    address.city = "awesome city"
    address.country_sub_division_code = "wooooooo..."
    address.postal_code = "12345"
    customer.addresses = [address]

同样,对于电话号码:

    phone1 = Quickeebooks::Online::Model::Phone.new
    phone1.device_type = "Primary"
    phone1.free_form_number = "973-855-0394"
    phone2 = Quickeebooks::Online::Model::Phone.new
    phone2.device_type = "Mobile"
    phone2.free_form_number = "5458565298"
    phone3 = Quickeebooks::Online::Model::Phone.new
    phone3.device_type = "Fax"
    phone3.free_form_number = "5458565298"
    customer.phones = [phone1, phone2, phone3]

依旧......