class CompaniesHouseHub::Officer
Constants
- DEFAULT_PER_PAGE
- FIND_PATH
Attributes
address[R]
appointed_on[R]
country_of_residence[R]
name[R]
nationality[R]
occupation[R]
officer_role[R]
raw_json[R]
Public Class Methods
all(options = {})
click to toggle source
# File lib/companies_house_hub/models/officer.rb, line 13 def self.all(options = {}) options[:items_per_page] ||= DEFAULT_PER_PAGE company_number = options.delete(:company_number) result = get(format_url(FIND_PATH, company_number: company_number), options) items = result.body.dig(:items) || [] return [] unless items.any? items.map { |officer_json| new(officer_json) } end
new(json = {})
click to toggle source
# File lib/companies_house_hub/models/officer.rb, line 27 def initialize(json = {}) @name = json.dig(:name) @country_of_residence = json.dig(:country_of_residence) @appointed_on = json.dig(:appointed_on) @nationality = json.dig(:nationality) @occupation = json.dig(:occupation) @officer_role = json.dig(:officer_role) @address = Address.new(json.dig(:address)) @raw_json = json end
Public Instance Methods
first_name()
click to toggle source
The name comes as a string, for example: “SANTOS, Ricardo”, where the first actually comes last in the string.
# File lib/companies_house_hub/models/officer.rb, line 40 def first_name name = @name.split(',').last || '' name.strip end
last_name()
click to toggle source
# File lib/companies_house_hub/models/officer.rb, line 45 def last_name name = @name.split(',').first || '' name.capitalize.strip end