companies_house_hub 0.1.5 → 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: 35fc481f5ebb3aa0af306168bc9c9fdbfd015c8dc450d2e6769835469d843ff6
4
- data.tar.gz: c10de118dc1766d712034abee82bf57420deba0dd307d90e1f056d984a1b2052
3
+ metadata.gz: 59d96e21bd09f95fcb72032639787449f6b98e32c834ea78f1a28595ae99633e
4
+ data.tar.gz: ce14faa74aca583e511da3982206768f816fe37f3b60268bcd81a6815739f34c
5
5
  SHA512:
6
- metadata.gz: fb3aafc06244cba5878e660e4b0d2d72f239ee8bec3ba4c37da6089037dad686097f00f4bde36678fd9cb8fe4435b87a5d7300b2f52e59939cf4b6f0293981ad
7
- data.tar.gz: 1f97195944a4f1c93ade95aaf9efbe872395a9fb8da4538dd6de0d2bd80ff685e3df972950fe2aec9c3808c71824250841ba995a3b08940bc79648f0f2149134
6
+ metadata.gz: 06e7eda55b16f7bba6d604c871b3c4a1766fac003360e5fcc3bf36b6850568ec22711166144119b7cc9da77cb28219e50267544ebf3670745c8c37d5506db663
7
+ data.tar.gz: f181ec5c262037aef4b512757a77ad4a411f8e6946b57417af854b7aac5ec79ea8ff200869ad5ef077d176b14f1a6f1779bca45d4def5085dda66173869f1ca9
@@ -3,9 +3,6 @@ require: rubocop-rspec
3
3
  Style/Documentation:
4
4
  Enabled: false
5
5
 
6
- Style/MixinUsage:
7
- Enabled: false
8
-
9
6
  Layout/LineLength:
10
7
  Max: 100
11
8
 
data/README.md CHANGED
@@ -23,7 +23,7 @@ Set up CompaniesHouseHub in a block:
23
23
 
24
24
  ```ruby
25
25
  CompaniesHouseHub.configure do |config|
26
- config.api_token = <YOUR_TOKEN>
26
+ config.api_key = <YOUR_TOKEN>
27
27
  end
28
28
  ```
29
29
 
@@ -14,10 +14,11 @@ Dotenv.load
14
14
 
15
15
  CompaniesHouseHub.configure do |config|
16
16
  config.api_key = ENV['API_KEY']
17
+ config.debug = true
17
18
  end
18
19
 
19
20
  # Allow direct access to CompaniesHouseHub classes
20
- include CompaniesHouseHub
21
+ send(:include, CompaniesHouseHub)
21
22
 
22
23
  require 'pry'
23
24
  Pry.start
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
30
30
  spec.add_development_dependency 'bundler', '~> 2.0'
31
31
  spec.add_development_dependency 'dotenv', '~> 2.4.0'
32
32
  spec.add_development_dependency 'pry-byebug'
33
- spec.add_development_dependency 'rake', '~> 10.0'
33
+ spec.add_development_dependency 'rake', '>= 12.3.3'
34
34
  spec.add_development_dependency 'rspec'
35
35
  spec.add_development_dependency 'rubocop'
36
36
  spec.add_development_dependency 'rubocop-rspec'
@@ -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'
@@ -4,7 +4,11 @@ require 'companies_house_hub/base_model'
4
4
 
5
5
  module CompaniesHouseHub
6
6
  class Address < BaseModel
7
- attr_reader :address_line1, :address_line2, :postal_code, :locality, :country
7
+ attr_reader :address_line1, :address_line2, :postal_code, :locality, :country, :care_of
8
+ attr_reader :premises
9
+
10
+ alias line1 address_line1
11
+ alias line2 address_line2
8
12
 
9
13
  def initialize(json = {})
10
14
  @address_line1 = json.dig(:address_line_1)
@@ -12,6 +16,8 @@ module CompaniesHouseHub
12
16
  @country = json.dig(:country)
13
17
  @postal_code = json.dig(:postal_code)
14
18
  @locality = json.dig(:locality)
19
+ @care_of = json.dig(:care_of)
20
+ @premises = json.dig(:premises)
15
21
  end
16
22
 
17
23
  def full
@@ -3,6 +3,7 @@
3
3
  require 'companies_house_hub/base_model'
4
4
  require 'companies_house_hub/models/address'
5
5
  require 'companies_house_hub/models/filing_history'
6
+ require 'companies_house_hub/models/person'
6
7
 
7
8
  module CompaniesHouseHub
8
9
  class Company < BaseModel
@@ -10,7 +11,7 @@ module CompaniesHouseHub
10
11
  FIND_PATH = '/company/:company_number'
11
12
 
12
13
  attr_reader :number, :name, :created_at, :address, :type, :jurisdiction, :has_been_liquidated
13
- attr_reader :status, :accounts, :full_address
14
+ attr_reader :status, :accounts, :confirmation_statement, :full_address, :raw_json
14
15
 
15
16
  alias company_number number
16
17
  alias company_name name
@@ -45,6 +46,7 @@ module CompaniesHouseHub
45
46
  end
46
47
 
47
48
  def initialize(json = {})
49
+ @raw_json = json
48
50
  @number = json.dig(:company_number)
49
51
  @has_been_liquidated = json.dig(:has_been_liquidated)
50
52
  @jurisdiction = json.dig(:jurisdiction)
@@ -54,6 +56,7 @@ module CompaniesHouseHub
54
56
  @status = json.dig(:company_status)
55
57
  @type = json.dig(:type) || json.dig(:company_type)
56
58
  @accounts = json.dig(:accounts)
59
+ @confirmation_statement = json.dig(:confirmation_statement)
57
60
  @full_address = json.fetch(:address_snippet, @address.full)
58
61
  end
59
62
 
@@ -61,6 +64,10 @@ module CompaniesHouseHub
61
64
  FilingHistory.all(company_number: @number)
62
65
  end
63
66
 
67
+ def persons
68
+ Person.all(company_number: @number)
69
+ end
70
+
64
71
  def active?
65
72
  @status == 'active'
66
73
  end
@@ -20,11 +20,13 @@ module CompaniesHouseHub
20
20
 
21
21
  result = get(format_url(FIND_PATH, company_number: company_number), options)
22
22
 
23
- return [] unless result.body[:items].any?
23
+ items = result.body.dig(:items) || []
24
+
25
+ return [] unless items.any?
24
26
 
25
27
  # Get all items and create a new history. If the description is 'legacy' then we can safely
26
28
  # ignore that document.
27
- filing_histories = result.body[:items].map do |filing_json|
29
+ filing_histories = items.map do |filing_json|
28
30
  next if filing_json.dig(:description) == LEGACY_DOC_DESCRIPTION
29
31
 
30
32
  new(filing_json, company_number)
@@ -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
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CompaniesHouseHub
4
+ class Person < BaseModel
5
+ FIND_PATH = "/company/:company_number/persons-with-significant-control"
6
+ DEFAULT_PER_PAGE = 90
7
+
8
+ attr_reader :name, :nationality, :kind, :country_of_residence, :forename, :middle_name, :title
9
+ attr_reader :surname, :address, :raw_json
10
+
11
+ def self.all(options = {})
12
+ options[:items_per_page] ||= DEFAULT_PER_PAGE
13
+
14
+ company_number = options.delete(:company_number)
15
+
16
+ result = get(format_url(FIND_PATH, company_number: company_number), options)
17
+
18
+ # For some companies, for some reason, this endpoint returns an error, like this:
19
+ # {
20
+ # "errors": [
21
+ # {
22
+ # "error": "company-psc-not-found",
23
+ # "type": "ch:service"
24
+ # }
25
+ # ]
26
+ # }
27
+ items = result.body.dig(:items) || []
28
+
29
+ return [] unless items.any?
30
+
31
+ items.map { |person_json| new(person_json) }
32
+ end
33
+
34
+ def initialize(json = {})
35
+ @raw_json = json
36
+ @name = json.dig(:name)
37
+ @nationality = json.dig(:nationality)
38
+ @address = Address.new(json.dig(:address))
39
+ @forename = json.dig(:name_elements, :forename)
40
+ @middle_name = json.dig(:name_elements, :middle_name)
41
+ @title = json.dig(:name_elements, :title)
42
+ @surname = json.dig(:name_elements, :surname)
43
+ end
44
+ end
45
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CompaniesHouseHub
4
- VERSION = '0.1.5'
4
+ VERSION = '0.1.10'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: companies_house_hub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ricardo Otero
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-13 00:00:00.000000000 Z
11
+ date: 2020-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -84,16 +84,16 @@ dependencies:
84
84
  name: rake
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: '10.0'
89
+ version: 12.3.3
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: '10.0'
96
+ version: 12.3.3
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rspec
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -203,6 +203,8 @@ 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
207
+ - lib/companies_house_hub/models/person.rb
206
208
  - lib/companies_house_hub/version.rb
207
209
  homepage: https://github.com/rikas/companies_house_hub
208
210
  licenses: