Class: CDDS::DisqualifiedPersons

Inherits:
Object
  • Object
show all
Defined in:
lib/cdds.rb

Constant Summary collapse

API_VERSION =
"v2"

Class Method Summary collapse

Class Method Details

.search(search_term, page_size) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/cdds.rb', line 13

def self.search(search_term, page_size)
  page_size = 50 if page_size.blank?
  response = RestClient.get("https://api.business.govt.nz/services/#{API_VERSION}/companies-office/disqualified-directors/search?name=#{search_term}&page-size=#{page_size}",
                            { authorization: "Bearer #{access_token}", accept: 'application/json' })
  begin
    JSON.parse(response.body).with_indifferent_access
  rescue JSON::ParserError
    raise CDDS::DataError, "CDDS API returned bad data"
  end
end