taylorbrooks / closeio

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

Find leads by custom field with space #27

Closed migu0 closed 8 years ago

migu0 commented 8 years ago

Hey Taylor,

We have custom fields with white spaces and I can't query by them.

Example:

client.list_leads("custom.Paused:false") # works
client.list_leads("custom.Multiple once off:false") # doesn't work

I wonder whether this node wrapper had the same issue: https://github.com/closeio/closeio-node/issues/4?

taylorbrooks commented 8 years ago

Interesting. Lemme take a look into this.

migu0 commented 8 years ago

Thx. The second line returns 0 results even though there are matches.

taylorbrooks commented 8 years ago

What if you do this?

client.list_leads('"custom.Multiple once off":false')
migu0 commented 8 years ago

Bingo! Thanks!

migu0 commented 8 years ago

Is there any way to make this work with string interpolation?

client.list_leads('"custom.Global ID":#{user.id}')
taylorbrooks commented 8 years ago

Will it work if you flip the quotes?

client.list_leads("'custom.Global ID':#{user.id}")
migu0 commented 8 years ago

No =(

taylorbrooks commented 8 years ago

What if you change your custom field keys by "dasherize-ing" them? That way you wouldn't have to do this single/double quote dance...

client.list_leads("'custom.Global ID':#{user.id}") # vs.
client.list_leads("custom.Global-ID:#{user.id}")
migu0 commented 8 years ago

That's definitely what I would recommend to someone setting up Close for the first time. We have quite a bit of code and reports where these custom fields are hard coded so I'd have to change that.

I found a way to make it work

backend.list_leads('"custom.Global ID":'+user.id.to_s)

Thanks for your help!