companies_house_hub 0.1.4 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -4
- data/README.md +1 -1
- data/bin/console +2 -1
- data/companies_house_hub.gemspec +1 -1
- data/lib/companies_house_hub/models/address.rb +7 -1
- data/lib/companies_house_hub/models/company.rb +8 -1
- data/lib/companies_house_hub/models/filing_history.rb +6 -2
- data/lib/companies_house_hub/models/person.rb +45 -0
- data/lib/companies_house_hub/version.rb +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29c2c6ef2a7320dce0f29392bc87d82a6458c67eeb8637ecc4e3abf3b493e223
|
4
|
+
data.tar.gz: 961885964947c2a58fc6ed08342af17cd0c113873f2484b4150580496573c71e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d319f8a46e9d1187a34b5f69b04098b6de552013a549501598018f060f970faa10fd6cbc0098ec161f43cebe25f45e4bf7de099df75371b890b1f1b98ad6d98e
|
7
|
+
data.tar.gz: bee69f4ce39a230a3a66399cbd4ef53787ebe2d77c1b0823d6d1c2e51c002f0e553b2471497f25dce7cce3ab11398c18524cbe7f8b6999ddb55667c35e363d66
|
data/.rubocop.yml
CHANGED
data/README.md
CHANGED
data/bin/console
CHANGED
@@ -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
|
data/companies_house_hub.gemspec
CHANGED
@@ -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', '
|
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'
|
@@ -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
|
-
|
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 =
|
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)
|
@@ -50,6 +52,8 @@ module CompaniesHouseHub
|
|
50
52
|
end
|
51
53
|
|
52
54
|
def url(format = 'pdf')
|
55
|
+
return unless @links[:document_metadata]
|
56
|
+
|
53
57
|
file_path = @links[:self] || build_file_path
|
54
58
|
|
55
59
|
return unless file_path
|
@@ -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
|
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.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ricardo Otero
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
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:
|
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:
|
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,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/person.rb
|
206
207
|
- lib/companies_house_hub/version.rb
|
207
208
|
homepage: https://github.com/rikas/companies_house_hub
|
208
209
|
licenses:
|