companies_house_hub 0.1.8 → 0.1.9

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: d0674550a52a10c0f5cc3213fc68b1f2de77eb0c855c4dd461e4cb2ee5abaa90
4
- data.tar.gz: f10d683fde4a56667b020fe5eab40174d4eea7caccb609efe71d1c781b4cd648
3
+ metadata.gz: 29c2c6ef2a7320dce0f29392bc87d82a6458c67eeb8637ecc4e3abf3b493e223
4
+ data.tar.gz: 961885964947c2a58fc6ed08342af17cd0c113873f2484b4150580496573c71e
5
5
  SHA512:
6
- metadata.gz: c701167997705f15cfa20dd41110011aa17a8cc780e72b83d26127160e3d08a5d0484efb651f6c69b4416b2a3d2eadd3377a81691716a58d7efdc0d807ebc139
7
- data.tar.gz: af55ae20564e2abc7f2337fab7e7c83410f26fc49264be4e00298f15306771d68bd3aa6095cae27084a415bcc685e02ed3eb7c9b1e21d55f4d0721eb80103f5b
6
+ metadata.gz: d319f8a46e9d1187a34b5f69b04098b6de552013a549501598018f060f970faa10fd6cbc0098ec161f43cebe25f45e4bf7de099df75371b890b1f1b98ad6d98e
7
+ data.tar.gz: bee69f4ce39a230a3a66399cbd4ef53787ebe2d77c1b0823d6d1c2e51c002f0e553b2471497f25dce7cce3ab11398c18524cbe7f8b6999ddb55667c35e363d66
@@ -14,6 +14,7 @@ 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,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)
@@ -15,11 +15,20 @@ module CompaniesHouseHub
15
15
 
16
16
  result = get(format_url(FIND_PATH, company_number: company_number), options)
17
17
 
18
- return [] unless result.body[:items].any?
19
-
20
- result.body[:items].map do |person_json|
21
- new(person_json)
22
- end
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) }
23
32
  end
24
33
 
25
34
  def initialize(json = {})
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CompaniesHouseHub
4
- VERSION = '0.1.8'
4
+ VERSION = '0.1.9'
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.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ricardo Otero