Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce Deal search #22

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

TSMMark
Copy link

@TSMMark TSMMark commented May 30, 2024

Hi, thanks for maintaining this awesome gem

I wanted to be able to search deals by name and pipeline, and this functionality was missing from the gem (AFAICT), even though it looked supported by the objects v3 search API

Originally found this discussion here: https://community.hubspot.com/t5/APIs-Integrations/How-can-I-do-a-search-for-all-deals-in-the-default-pipeline/m-p/793111 which led to the v3 search docs here: https://developers.hubspot.com/docs/api/crm/search

I've got this working, can be searched and filtered like so:

deals = Hubspot::Deal.find_by_search(
  properties: %w(dealname amount closedate dealstage),
  filters: [
    { propertyName: 'pipeline', 'operator': 'EQ', value: '12345' },
    { propertyName: 'dealname', 'operator': 'CONTAINS_TOKEN', value: 'MyDealName' },
  ],
)

Unfortunately the search API seems to return results in a very different format from the v1 API that was currently being used to fetch deals, so I had to strip out some of the associations from being required for deal init.

Let me know if you would accept a PR like this, what tests you would need, anything else you'd change about the way I'm doing this lmk

@fonji
Copy link

fonji commented May 31, 2024

Looks very cool, thank you!
Could you add tests for .find_by_search?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants