1

I'm integrating infusionsoft with our rails app and we can create contacts using their API using this call, and passing the data through an array...

Infusionsoft.contact_add_with_dup_check({'Email' => contact.email, 'FirstName' => (contact.name if contact.name.present?)}, 'Email')

However, I want to be able to post additional contact info to their API if the contact in our rails app has more data. Such as if name or city is present. My attempt at checking if contact.name is present returns an error.

How can I do an if else statement within the array?

1
  • It can be like FirstName' => contact.name.present? ? contact.name : "" Commented May 16, 2015 at 19:49

1 Answer 1

1
contact_info = {'Email' => contact.email}
contact_info.merge!({'FirstName' => contact.name }) if contact.name.present?
Infusionsoft.contact_add_with_dup_check(contact_info, 'Email')

you can use a code same as in line#2 in case of city

Sign up to request clarification or add additional context in comments.

1 Comment

Brilliant idea! Learned something new too. Thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.