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

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseService

run

Instance Attribute Details

#company_statusObject (readonly)

Returns the value of attribute company_status.



46
47
48
# File 'app/services/defra_ruby_mocks/companies_house_service.rb', line 46

def company_status
  @company_status
end

#company_typeObject (readonly)

Returns the value of attribute company_type.



46
47
48
# File 'app/services/defra_ruby_mocks/companies_house_service.rb', line 46

def company_type
  @company_type
end

Class Method Details

.llp_company_numbersObject



32
33
34
# File 'app/services/defra_ruby_mocks/companies_house_service.rb', line 32

def self.llp_company_numbers
  %w[XX999999 YY999999]
end

.special_company_numbersObject



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

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:



36
37
38
39
40
41
42
43
44
# File 'app/services/defra_ruby_mocks/companies_house_service.rb', line 36

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

  @company_status = specials[company_number] || "active"
  @company_type = llps.include?(company_number) ? "llp" : "ltd"

  self
end