amalc / rubyzoho

Abstracting Zoho’s API into a set of Ruby classes, with reflection of Zoho’s fields using a more familiar ActiveRecord lifecycle, but without ActiveRecord. Works with Rails and Devise.
MIT License
62 stars 57 forks source link

Can't save fields with _ #29

Open brenes opened 10 years ago

brenes commented 10 years ago

Hi,

We have created some utm custom fields (utm_campaign, utm_term...) in our zoho but we are not being able to populate them from the API.

We noticed that when the XML to be sent to the API is generated those fields have changed to a capitalized version (Utm Source, Utm Term...) due to the ApiUtils#symbol_to_string method, so although they are sent to Zoho they are not saved (it doesn't trigger any error either).

I was thinking that could be useful creating some kind of "memory" for translations. This way, the string_to_method_name could save that utm_source translates as utm_source, and the symbol_to_string method could recover that translation and send utm_source.

This memory could be created at the RubyZoho::Crm::Lead level.

What do you think?

amalc commented 10 years ago

It's a good idea. I'd started on a "map" to manage this and other issues, like non ruby legal field names. But haven't got a chance to finish it.

The thought was to cache the Zoho name inbound, and create a legal Ruby name and convert it back on the way out.

I think its at the "api" level in the source.

On Tue, Aug 19, 2014 at 2:06 PM, brenes notifications@github.com wrote:

Hi,

We have created some utm custom fields (utm_campaign, urm_term...) in our zoho but we are not being able to populate them from the API.

We noticed that when the XML to be sent to the API is generated those fields have changed to a capitalized version (Utm Source, Utm Term...) due to the ApiUtils#symbol_to_string method, so although they are sent to Zoho they are not saved (it doesn't trigger any error either).

I was thinking that could be useful creating some kind of "memory" for translations. This way, the string_to_method_name could save that utm_source translates as utm_source, and the symbol_to_string method could recover that translation and send utm_source.

This memory could be created at the RubyZoho::Crm::Lead level.

What do you think?

— Reply to this email directly or view it on GitHub https://github.com/amalc/rubyzoho/issues/29.

brenes commented 10 years ago

Browing in the code I'm seeing that maybe the right place to touch would be the ZohoApiFieldUtils#extract_field method. This way the translation could be stored at a module level.

Then we could check for the translation in the ZohoApiFieldUtils#add_field method and rewrite it properly in the XML.

I think I will give it a try and let you know (hopefully with a PR if everything goes fine ).

amalc commented 10 years ago

Yup, exactly!

On Tue, Aug 19, 2014 at 2:26 PM, brenes notifications@github.com wrote:

Browing in the code I'm seeing that maybe the right place to touch would be the ZohoApiFieldUtils#extract_field method. This way the translation could be stored at a module level.

Then we could check for the translation in the ZohoApiFieldUtils#add_field method and rewrite it properly in the XML.

I think I will give it a try and let you know (hopefully with a PR if everything goes fine ).

— Reply to this email directly or view it on GitHub https://github.com/amalc/rubyzoho/issues/29#issuecomment-52677432.

brenes commented 10 years ago

I published a PR right now. As I comment in the PR I couldn't find a way to properly test this translation as I can't use my Zoho API Key with testing purposes.

Is there any test API Key that could be used? Should I mock all the API calls?

Thanks!

amalc commented 9 years ago

Sorry I didn't see this. We have a test Zoho account for testing. And we're very careful about API usage.