0

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

当我尝试将 customer.name 保存在 quickbook 中时,它会通过我的控制器成功保存,但如果我尝试传递 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 的其他字段都运行良好,但是对于电话、地址、网站、城市等字段,每当我想将这些值推送到快速簿错误时,例如:

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>

来了。如何修复此错误?

4

1 回答 1

1

终于,问题解决了......

postal_code、line1、line2、city等字段与addresses字段相关。所以而不是写

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]

等等....

于 2013-08-14T09:13:42.617 回答