Class: DefraRuby::Validators::CompaniesHouseService
- Inherits:
-
Object
- Object
- DefraRuby::Validators::CompaniesHouseService
- Defined in:
- lib/defra_ruby/validators/companies_house_service.rb
Instance Method Summary collapse
-
#initialize(company_no, company_type = nil) ⇒ CompaniesHouseService
constructor
A new instance of CompaniesHouseService.
- #json_response ⇒ Object
- #status ⇒ Object
Constructor Details
#initialize(company_no, company_type = nil) ⇒ CompaniesHouseService
Returns a new instance of CompaniesHouseService.
8 9 10 11 12 13 |
# File 'lib/defra_ruby/validators/companies_house_service.rb', line 8 def initialize(company_no, company_type = nil) @company_no = company_no @url = "#{DefraRuby::Validators.configuration.companies_house_host}#{@company_no}" @api_key = DefraRuby::Validators.configuration.companies_house_api_key @company_type = company_type end |
Instance Method Details
#json_response ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/defra_ruby/validators/companies_house_service.rb', line 23 def json_response @_json_response ||= JSON.parse( RestClient::Request.execute( method: :get, url: @url, user: @api_key, password: "" ) ) end |
#status ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/defra_ruby/validators/companies_house_service.rb', line 15 def status return :not_found unless company_type_is_allowed?(json_response) status_is_allowed?(json_response) ? :active : :inactive rescue RestClient::ResourceNotFound :not_found end |