companies_house_hub 0.1.3 → 0.1.8
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 -11
- data/.ruby-version +1 -1
- data/README.md +1 -1
- data/bin/console +1 -1
- data/companies_house_hub.gemspec +3 -3
- data/lib/companies_house_hub/models/address.rb +7 -1
- data/lib/companies_house_hub/models/company.rb +9 -2
- data/lib/companies_house_hub/models/filing_history.rb +16 -5
- data/lib/companies_house_hub/models/person.rb +36 -0
- data/lib/companies_house_hub/version.rb +1 -1
- metadata +14 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0674550a52a10c0f5cc3213fc68b1f2de77eb0c855c4dd461e4cb2ee5abaa90
|
4
|
+
data.tar.gz: f10d683fde4a56667b020fe5eab40174d4eea7caccb609efe71d1c781b4cd648
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c701167997705f15cfa20dd41110011aa17a8cc780e72b83d26127160e3d08a5d0484efb651f6c69b4416b2a3d2eadd3377a81691716a58d7efdc0d807ebc139
|
7
|
+
data.tar.gz: af55ae20564e2abc7f2337fab7e7c83410f26fc49264be4e00298f15306771d68bd3aa6095cae27084a415bcc685e02ed3eb7c9b1e21d55f4d0721eb80103f5b
|
data/.rubocop.yml
CHANGED
@@ -1,15 +1,9 @@
|
|
1
1
|
require: rubocop-rspec
|
2
2
|
|
3
|
-
Metrics/AbcSize:
|
4
|
-
Max: 30
|
5
|
-
|
6
3
|
Style/Documentation:
|
7
4
|
Enabled: false
|
8
5
|
|
9
|
-
|
10
|
-
Enabled: false
|
11
|
-
|
12
|
-
Metrics/LineLength:
|
6
|
+
Layout/LineLength:
|
13
7
|
Max: 100
|
14
8
|
|
15
9
|
Metrics/MethodLength:
|
@@ -31,9 +25,5 @@ Lint/UselessAssignment:
|
|
31
25
|
RSpec/ExampleLength:
|
32
26
|
Max: 100
|
33
27
|
|
34
|
-
# To be compatible with older versions of ruby
|
35
|
-
Performance/RegexpMatch:
|
36
|
-
Enabled: false
|
37
|
-
|
38
28
|
RSpec/MultipleExpectations:
|
39
29
|
Enabled: false
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.5
|
1
|
+
2.6.5
|
data/README.md
CHANGED
data/bin/console
CHANGED
data/companies_house_hub.gemspec
CHANGED
@@ -27,12 +27,12 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.add_dependency 'faraday'
|
28
28
|
spec.add_dependency 'faraday_middleware'
|
29
29
|
|
30
|
-
spec.add_development_dependency 'bundler', '~>
|
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
|
-
spec.add_development_dependency 'rubocop'
|
35
|
+
spec.add_development_dependency 'rubocop'
|
36
36
|
spec.add_development_dependency 'rubocop-rspec'
|
37
37
|
spec.add_development_dependency 'simplecov'
|
38
38
|
spec.add_development_dependency 'vcr'
|
@@ -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,13 +56,18 @@ 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)
|
57
|
-
@
|
59
|
+
@confirmation_statement = json.dig(:confirmation_statement)
|
60
|
+
@full_address = json.fetch(:address_snippet, @address.full)
|
58
61
|
end
|
59
62
|
|
60
63
|
def filing_histories
|
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
|
@@ -16,9 +16,9 @@ module CompaniesHouseHub
|
|
16
16
|
def self.all(options = {})
|
17
17
|
options[:items_per_page] ||= DEFAULT_PER_PAGE
|
18
18
|
|
19
|
-
|
19
|
+
company_number = options.delete(:company_number)
|
20
20
|
|
21
|
-
result = get(format_url(FIND_PATH, company_number:
|
21
|
+
result = get(format_url(FIND_PATH, company_number: company_number), options)
|
22
22
|
|
23
23
|
return [] unless result.body[:items].any?
|
24
24
|
|
@@ -27,13 +27,13 @@ module CompaniesHouseHub
|
|
27
27
|
filing_histories = result.body[:items].map do |filing_json|
|
28
28
|
next if filing_json.dig(:description) == LEGACY_DOC_DESCRIPTION
|
29
29
|
|
30
|
-
new(filing_json)
|
30
|
+
new(filing_json, company_number)
|
31
31
|
end
|
32
32
|
|
33
33
|
filing_histories.compact
|
34
34
|
end
|
35
35
|
|
36
|
-
def initialize(json = {})
|
36
|
+
def initialize(json = {}, company_number = nil)
|
37
37
|
@description = json.dig(:description)
|
38
38
|
@action_date = json.dig(:action_date)
|
39
39
|
@date = json.dig(:date)
|
@@ -42,6 +42,7 @@ module CompaniesHouseHub
|
|
42
42
|
@transaction_id = json.dig(:transaction_id) # helps on barcode generation
|
43
43
|
@barcode = json.dig(:barcode) || generate_barcode
|
44
44
|
@description_values = json.dig(:description_values)
|
45
|
+
@company_number = company_number
|
45
46
|
end
|
46
47
|
|
47
48
|
def formatted_name
|
@@ -49,7 +50,11 @@ module CompaniesHouseHub
|
|
49
50
|
end
|
50
51
|
|
51
52
|
def url(format = 'pdf')
|
52
|
-
|
53
|
+
return unless @links[:document_metadata]
|
54
|
+
|
55
|
+
file_path = @links[:self] || build_file_path
|
56
|
+
|
57
|
+
return unless file_path
|
53
58
|
|
54
59
|
document_path = "#{file_path}/document?format=#{format}"
|
55
60
|
|
@@ -66,5 +71,11 @@ module CompaniesHouseHub
|
|
66
71
|
|
67
72
|
Digest::SHA1.hexdigest(string)[0..6].upcase
|
68
73
|
end
|
74
|
+
|
75
|
+
def build_file_path
|
76
|
+
required = [@company_number, @transaction_id].all? { |val| val && !val.empty? }
|
77
|
+
|
78
|
+
"/company/#{@company_number}/filing-history/#{@transaction_id}" if required
|
79
|
+
end
|
69
80
|
end
|
70
81
|
end
|
@@ -0,0 +1,36 @@
|
|
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
|
+
return [] unless result.body[:items].any?
|
19
|
+
|
20
|
+
result.body[:items].map do |person_json|
|
21
|
+
new(person_json)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def initialize(json = {})
|
26
|
+
@raw_json = json
|
27
|
+
@name = json.dig(:name)
|
28
|
+
@nationality = json.dig(:nationality)
|
29
|
+
@address = Address.new(json.dig(:address))
|
30
|
+
@forename = json.dig(:name_elements, :forename)
|
31
|
+
@middle_name = json.dig(:name_elements, :middle_name)
|
32
|
+
@title = json.dig(:name_elements, :title)
|
33
|
+
@surname = json.dig(:name_elements, :surname)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
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.8
|
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
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '2.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '2.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: dotenv
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -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
|
@@ -112,16 +112,16 @@ dependencies:
|
|
112
112
|
name: rubocop
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- - "
|
115
|
+
- - ">="
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 0
|
117
|
+
version: '0'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- - "
|
122
|
+
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 0
|
124
|
+
version: '0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: rubocop-rspec
|
127
127
|
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:
|
@@ -223,8 +224,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
223
224
|
- !ruby/object:Gem::Version
|
224
225
|
version: '0'
|
225
226
|
requirements: []
|
226
|
-
|
227
|
-
rubygems_version: 2.7.3
|
227
|
+
rubygems_version: 3.0.3
|
228
228
|
signing_key:
|
229
229
|
specification_version: 4
|
230
230
|
summary: A REST client for the UK Companies House API
|