companies_house_hub 0.1.9 → 0.1.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 29c2c6ef2a7320dce0f29392bc87d82a6458c67eeb8637ecc4e3abf3b493e223
4
- data.tar.gz: 961885964947c2a58fc6ed08342af17cd0c113873f2484b4150580496573c71e
3
+ metadata.gz: 59d96e21bd09f95fcb72032639787449f6b98e32c834ea78f1a28595ae99633e
4
+ data.tar.gz: ce14faa74aca583e511da3982206768f816fe37f3b60268bcd81a6815739f34c
5
5
  SHA512:
6
- metadata.gz: d319f8a46e9d1187a34b5f69b04098b6de552013a549501598018f060f970faa10fd6cbc0098ec161f43cebe25f45e4bf7de099df75371b890b1f1b98ad6d98e
7
- data.tar.gz: bee69f4ce39a230a3a66399cbd4ef53787ebe2d77c1b0823d6d1c2e51c002f0e553b2471497f25dce7cce3ab11398c18524cbe7f8b6999ddb55667c35e363d66
6
+ metadata.gz: 06e7eda55b16f7bba6d604c871b3c4a1766fac003360e5fcc3bf36b6850568ec22711166144119b7cc9da77cb28219e50267544ebf3670745c8c37d5506db663
7
+ data.tar.gz: f181ec5c262037aef4b512757a77ad4a411f8e6946b57417af854b7aac5ec79ea8ff200869ad5ef077d176b14f1a6f1779bca45d4def5085dda66173869f1ca9
@@ -6,6 +6,8 @@ require 'companies_house_hub/configuration'
6
6
  require 'companies_house_hub/base_model'
7
7
  require 'companies_house_hub/errors'
8
8
  require 'companies_house_hub/models/company'
9
+ require 'companies_house_hub/models/person'
10
+ require 'companies_house_hub/models/officer'
9
11
 
10
12
  module CompaniesHouseHub
11
13
  API_URL = 'https://api.companieshouse.gov.uk'
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'companies_house_hub/models/address'
4
+
5
+ module CompaniesHouseHub
6
+ class Officer < BaseModel
7
+ FIND_PATH = "/company/:company_number/officers"
8
+ DEFAULT_PER_PAGE = 90
9
+
10
+ attr_reader :name, :country_of_residence, :appointed_on, :nationality, :occupation
11
+ attr_reader :officer_role, :address, :raw_json
12
+
13
+ def self.all(options = {})
14
+ options[:items_per_page] ||= DEFAULT_PER_PAGE
15
+
16
+ company_number = options.delete(:company_number)
17
+
18
+ result = get(format_url(FIND_PATH, company_number: company_number), options)
19
+
20
+ items = result.body.dig(:items) || []
21
+
22
+ return [] unless items.any?
23
+
24
+ items.map { |officer_json| new(officer_json) }
25
+ end
26
+
27
+ def initialize(json = {})
28
+ @name = json.dig(:name)
29
+ @country_of_residence = json.dig(:country_of_residence)
30
+ @appointed_on = json.dig(:appointed_on)
31
+ @nationality = json.dig(:nationality)
32
+ @occupation = json.dig(:occupation)
33
+ @officer_role = json.dig(:officer_role)
34
+ @address = Address.new(json.dig(:address))
35
+ @raw_json = json
36
+ end
37
+
38
+ # The name comes as a string, for example: "SANTOS, Ricardo", where the first actually comes
39
+ # last in the string.
40
+ def first_name
41
+ name = @name.split(',').last || ''
42
+ name.strip
43
+ end
44
+
45
+ def last_name
46
+ name = @name.split(',').first || ''
47
+ name.capitalize.strip
48
+ end
49
+ end
50
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CompaniesHouseHub
4
- VERSION = '0.1.9'
4
+ VERSION = '0.1.10'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: companies_house_hub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ricardo Otero
@@ -203,6 +203,7 @@ files:
203
203
  - lib/companies_house_hub/models/address.rb
204
204
  - lib/companies_house_hub/models/company.rb
205
205
  - lib/companies_house_hub/models/filing_history.rb
206
+ - lib/companies_house_hub/models/officer.rb
206
207
  - lib/companies_house_hub/models/person.rb
207
208
  - lib/companies_house_hub/version.rb
208
209
  homepage: https://github.com/rikas/companies_house_hub