From a582392a400b4fae9d455f851302aa76c606e84e Mon Sep 17 00:00:00 2001 From: Tomislav Simnett Date: Mon, 9 Dec 2024 15:39:23 +0000 Subject: [PATCH] Add company search restrictions parameter --- lib/companies_house/client.rb | 5 +++-- spec/companies_house/client_spec.rb | 5 ++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/companies_house/client.rb b/lib/companies_house/client.rb index 708a2a5..6dc1d25 100644 --- a/lib/companies_house/client.rb +++ b/lib/companies_house/client.rb @@ -80,12 +80,13 @@ def filing_history_item(id, transaction_id) ) end - def company_search(query, items_per_page: nil, start_index: nil) + def company_search(query, items_per_page: nil, start_index: nil, restrictions: nil) request( resource: :company_search, path: "search/companies", params: { - q: query, items_per_page: items_per_page, start_index: start_index + q: query, items_per_page: items_per_page, start_index: start_index, + restrictions: restrictions, }.compact, ) end diff --git a/spec/companies_house/client_spec.rb b/spec/companies_house/client_spec.rb index 9c2b65d..72a5fb5 100644 --- a/spec/companies_house/client_spec.rb +++ b/spec/companies_house/client_spec.rb @@ -410,6 +410,7 @@ query, items_per_page: items_per_page, start_index: start_index, + restrictions: restrictions, ) end @@ -418,16 +419,18 @@ q: query, items_per_page: items_per_page, start_index: start_index, + restrictions: restrictions, } end let(:items_per_page) { 5 } let(:start_index) { 3 } + let(:restrictions) { "active-companies"} before do stub_request( :get, "#{example_endpoint}/#{rest_path}?items_per_page=#{items_per_page}\ -&q=#{query}&start_index=#{start_index}", +&q=#{query}&start_index=#{start_index}&restrictions=#{restrictions}", ). with(basic_auth: [api_key, ""]). to_return(body: '{"companies": "data"}', status: status)