Class: CompaniesHouse::Request

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

Constant Summary collapse

BASE_URI =
'http://data.companieshouse.gov.uk/doc/company/'
ALLOWED_PREFIXES =

White list of allowed prefixes for companies house numbers. 1st line is English and Welsh prefixes 2nd line is Scottish prefixes 3rd line is Northen Irish prefixes dd is the default prefix in regex notation.

%w(AC BR FC GE IP LP OC RC SE ZC
SC SA SF SL SZ SP SO SR
NI NA NF NL NZ NP NO NR
\d\d)

Instance Method Summary collapse

Constructor Details

#initialize(registration_number) ⇒ Request

Don’t call this directly. Instead, use CompaniesHouse.lookup “01234567”



18
19
20
# File 'lib/companies_house/request.rb', line 18

def initialize(registration_number)
  @registration_number = validate(registration_number)
end

Instance Method Details

#performObject



22
23
24
25
26
# File 'lib/companies_house/request.rb', line 22

def perform
  url = BASE_URI + @registration_number + ".json"
  response = with_caching { Faraday.get(url) }
  Response.new(response)
end