taylorbrooks / closeio

A Ruby wrapper for the Close.io API
http://developer.close.com
MIT License
45 stars 57 forks source link

updating custom fields for a lead #30

Closed aliw77 closed 8 years ago

aliw77 commented 8 years ago

Taylor - thank you for creating this very helpful gem and opensourcing it. I had a question about updating custom fields for an existing field, and creating a lead with custom fields. I have tried the following and it didn't work:

puts client.update_lead(lead.id, '{"custom.XXX": "Yes"}') I see a Hashie::Mash object returned which is the lead but the custom field does not seem to be updating. I tried it without the single quotes, as a JSON but same results, no update to the custom field and same Hashie::Mash object returned

Any thoughts on how to do this?

Also, is there a way to create custom fields during lead creation?

thanks again!

taylorbrooks commented 8 years ago

Try doing:

client.update_lead(lead.id, 'custom.field name' => "field value")

You should be able to create leads by doing something like:

client.create_lead(
    name: "Bluth Company",
    contacts: [{
      name: "Buster Bluth",
      emails: [{type: "office", email: "cartographer@bluthcompany.com"}]
    }],
   custom: {
     "Custom Car Type" => "Stair Car",
     car_color: "red, white and blue"
   }
)

Make sense?

aliw77 commented 8 years ago

works like a charm! thanks.