class CompaniesHouseHub::Company

Constants

FIND_PATH
SEARCH_PATH

Attributes

accounts[R]
address[R]
company_name[R]
company_number[R]
company_status[R]
confirmation_statement[R]
created_at[R]
date_of_creation[R]
full_address[R]
has_been_liquidated[R]
jurisdiction[R]
name[R]
number[R]
raw_json[R]
status[R]
type[R]

Public Class Methods

find(company_number, params = {}) click to toggle source
# File lib/companies_house_hub/models/company.rb, line 38
def self.find(company_number, params = {})
  url = format_url(FIND_PATH, company_number: company_number.to_s.strip)

  result = get(url, params)

  return if result.status == 404

  new(result.body)
end
new(json = {}) click to toggle source
# File lib/companies_house_hub/models/company.rb, line 48
def initialize(json = {})
  @raw_json = json
  @number = json.dig(:company_number)
  @has_been_liquidated = json.dig(:has_been_liquidated)
  @jurisdiction = json.dig(:jurisdiction)
  @name = json.dig(:company_name) || json.dig(:title)
  @created_at = json.dig(:date_of_creation)
  @address = Address.new(json.dig(:registered_office_address) || json.dig(:address) || {})
  @status = json.dig(:company_status)
  @type = json.dig(:type) || json.dig(:company_type)
  @accounts = json.dig(:accounts)
  @confirmation_statement = json.dig(:confirmation_statement)
  @full_address = json.fetch(:address_snippet, @address.full)
end

Public Instance Methods

active?() click to toggle source
# File lib/companies_house_hub/models/company.rb, line 71
def active?
  @status == 'active'
end
filing_histories() click to toggle source
# File lib/companies_house_hub/models/company.rb, line 63
def filing_histories
  FilingHistory.all(company_number: @number)
end
persons() click to toggle source
# File lib/companies_house_hub/models/company.rb, line 67
def persons
  Person.all(company_number: @number)
end