# Deal Search API Ignoring Filter Groups (Ruby)

**URL:** <https://community.hubspot.com/t/deal-search-api-ignoring-filter-groups-ruby/41573>\
**Category:** APIs & Integrations\
**Tags:** python\
**Created:** [July 30, 2021, 3:29pm UTC](https://community.hubspot.com/t/deal-search-api-ignoring-filter-groups-ruby/41573 "2021-07-30T15:29:46Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![altjx](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/altjx/32/22074_2.png) [@altjx](https://community.hubspot.com/u/altjx)\
**Post date:** [August 5, 2021, 12:55am UTC](https://community.hubspot.com/t/deal-search-api-ignoring-filter-groups-ruby/41573/3 "2021-08-05T00:55:58Z")

</div>

Honestly I gave up on the HubSpot API Client gem for Ruby. I built my own wrapper around the types of calls that I would be making to HubSpot API through GET, POST, PATCH, and PUT requests.

For example, all of my HubSpot API calls get sent to one of these methods:

```lia-code-sample
 def get_request(url)
 url.gsub!('https://api.hubapi.com/crm/v3/', '') if url.include? 'https://api.hubapi.com/crm/v3/'
 response = @web.get_request("https://api.hubapi.com/crm/v3/#{url}&hapikey=#{@hubspot_api_key}")
 JSON(response.body)
 end

 def put_request(url)
 url.gsub!('https://api.hubapi.com/crm/v3/', '') if url.include? 'https://api.hubapi.com/crm/v3/'
 response = @web.put_request("https://api.hubapi.com/crm/v3/#{url}&hapikey=#{@hubspot_api_key}")
 JSON(response.body)
 end

 def post_request(url, body)
 url.gsub!('https://api.hubapi.com/crm/v3/', '') if url.include? 'https://api.hubapi.com/crm/v3/'
 response = @web.post_request("https://api.hubapi.com/crm/v3/#{url}&hapikey=#{@hubspot_api_key}", body)
 JSON(response.body)
 end

 def patch_request(url, body)
 url.gsub!('https://api.hubapi.com/crm/v3/', '') if url.include? 'https://api.hubapi.com/crm/v3/'
 response = @web.patch_request("https://api.hubapi.com/crm/v3/#{url}&hapikey=#{@hubspot_api_key}", body)
 JSON(response.body)
 end

```

so if I want to fetch the deals for a particular company, here’s what I call:

```lia-code-sample
 def find_existing_deal(company)
 response = {}
 deals = get_request("objects/companies/#{company.hubspot_id}/associations/deals?limit=500")
 unless deals['results'].empty?
 # Find the deal that has a DealType of XYZ
 deals['results'].each do |result|
 deal_id = result['id']

 # Retrieve deal details
 get_response = get_request("objects/deals/#{deal_id}?properties=dealtype")
 if get_response['properties']['dealtype'].blank?
 SlackBot.new.send_message(
 "Error updating HubSpot! #{company.name} does not have a dealType assigned to their deal. Please update this deal manually.", '#sales'
 )
 SlackBot.new.send_message(
 "You can access this deal at the following URL: https://app.hubspot.com/contacts/4512633/deal/#{deal_id}", '#sales'
 )
 exit(0)
 end
 next unless ['New Business','Existing Business'].any? do |a|
 a.include? get_response['properties']['dealtype']
 end

 response = get_response
 break
 end
 end

 response
 end

```

may not necessarily be the cleanest, but I’ve been able to get this implemented pretty much all over app avoiding the api-client and its limitations or confusions.

Hope this helps!

---

_[View the full topic](https://community.hubspot.com/t/deal-search-api-ignoring-filter-groups-ruby/41573)._
