Class: DefraRubyMocks::CompaniesHouseService

Inherits:
BaseService
  • Object
show all
Defined in:
app/services/defra_ruby_mocks/companies_house_service.rb

Constant Summary collapse

VALID_COMPANIES_HOUSE_REGISTRATION_NUMBER_REGEX =

Examples we need to validate are 10997904, 09764739 SC534714, CE000958 IP00141R, IP27702R, SP02252R assets.publishing.service.gov.uk/government/uploads/system/uploads/attachment_data/file/426891/uniformResourceIdentifiersCustomerGuide.pdf

Regexp.new(
  /\A(\d{8,8}$)|([a-zA-Z]{2}\d{6}$)|([a-zA-Z]{2}\d{5}[a-zA-Z]{1}$)\z/i
).freeze
NOT_FOUND =
"99999999"

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseService

run

Class Method Details

.special_company_numbersObject



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/services/defra_ruby_mocks/companies_house_service.rb', line 20

def self.special_company_numbers
  {
    "05868270" => "dissolved",
    "04270505" => "administration",
    "88888888" => "liquidation",
    "77777777" => "receivership",
    "66666666" => "converted-closed",
    "55555555" => "voluntary-arrangement",
    "44444444" => "insolvency-proceedings",
    "33333333" => "open",
    "22222222" => "closed"
  }
end

Instance Method Details

#run(company_number) ⇒ Object

Raises:



34
35
36
37
38
39
40
41
# File 'app/services/defra_ruby_mocks/companies_house_service.rb', line 34

def run(company_number)
  raise NotFoundError unless valid_company_number?(company_number)
  raise NotFoundError if company_number == NOT_FOUND

  return specials[company_number] if specials.key?(company_number)

  "active"
end