companies-house-rest 0.4.2 → 0.4.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +20 -20
- data/README.md +154 -154
- data/companies-house-rest.gemspec +34 -34
- data/lib/companies_house.rb +11 -11
- data/lib/companies_house/api_error.rb +18 -18
- data/lib/companies_house/authentication_error.rb +10 -10
- data/lib/companies_house/client.rb +104 -104
- data/lib/companies_house/not_found_error.rb +14 -14
- data/lib/companies_house/rate_limit_error.rb +10 -10
- data/lib/companies_house/request.rb +96 -96
- data/lib/companies_house/timeout_error.rb +10 -10
- data/lib/companies_house/version.rb +5 -5
- metadata +10 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c10c7c1f7ca78088d0591f617d45313363cf90d4
|
4
|
+
data.tar.gz: acaea65ec921f948c136602bccd8e78021113602
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '086b4c67ac3620af41f88def0274db7878be9203bc964eb27694dfb6db75220311ba46f29f7fbc7ee8e3679d71451654359a55130f5b66746b2ce615eea4dd22'
|
7
|
+
data.tar.gz: 2109f0235146ed2eeafa79b1e46ab371221d03c026afb36540b7f414f8ec360ead19e0e09be8e8d8b3cbb069a0f7e84f7b1018d49a9a0f9726c374c54a4bddbe
|
data/LICENSE
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
Copyright (c) 2016 GOCARDLESS LTD
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
1
|
+
Copyright (c) 2016 GOCARDLESS LTD
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,154 +1,154 @@
|
|
1
|
-
# CompaniesHouse::Client
|
2
|
-
|
3
|
-
[![CircleCI](https://circleci.com/gh/gocardless/companies-house-rest.svg?style=svg)](https://circleci.com/gh/gocardless/companies-house-rest)
|
4
|
-
|
5
|
-
This Gem implements an API client for the Companies House REST API. It can be
|
6
|
-
used to look up information about companies registered in the United Kingdom.
|
7
|
-
As of July 2016, this API is described by Companies House as a "beta service."
|
8
|
-
More information about this free API can be found
|
9
|
-
[on the Companies House API website](https://developer.companieshouse.gov.uk/api/docs/index.html).
|
10
|
-
|
11
|
-
To interact the older [CompaniesHouse XML-based API](http://xmlgw.companieshouse.gov.uk/),
|
12
|
-
see the gem [companies-house-gateway](https://github.com/gocardless/companies-house-gateway-ruby).
|
13
|
-
(Monthly subscription [fees](http://xmlgw.companieshouse.gov.uk/CHDpriceList.shtml), and other fees, may apply.)
|
14
|
-
|
15
|
-
Quick start:
|
16
|
-
* Register an account via the `Sign In / Register` link
|
17
|
-
[on the CompaniesHouse Developers website](https://developer.companieshouse.gov.uk/api/docs/)
|
18
|
-
* Register an API key at [Your Applications](https://developer.companieshouse.gov.uk/developer/applications)
|
19
|
-
* Put your API key in an environment variable (not in your code):
|
20
|
-
|
21
|
-
``` shell
|
22
|
-
export COMPANIES_HOUSE_API_KEY=YOUR_API_KEY_HERE
|
23
|
-
|
24
|
-
```
|
25
|
-
* Install `companies-house-rest` through [RubyGems](https://rubygems.org/gems/companies-house-rest)
|
26
|
-
* Create and use a client:
|
27
|
-
|
28
|
-
``` ruby
|
29
|
-
require 'companies_house/client'
|
30
|
-
client = CompaniesHouse::Client.new(api_key: ENV['COMPANIES_HOUSE_API_KEY'])
|
31
|
-
profile = client.company('07495895')
|
32
|
-
```
|
33
|
-
|
34
|
-
|
35
|
-
## Overview
|
36
|
-
This gem is meant to provide a simple synchronous API to look up company profile
|
37
|
-
information and company officers. The data returned is parsed JSON.
|
38
|
-
|
39
|
-
This gem provides information on companies by their Companies House company
|
40
|
-
number. This "company number" is actually a string and should be treated as such.
|
41
|
-
The string may consist solely of digits (including leading 0s) or begin with
|
42
|
-
alphabetic characters such as `NI` or `SC`.
|
43
|
-
|
44
|
-
## Authentication
|
45
|
-
|
46
|
-
Using the Companies House REST API requires you to register an account
|
47
|
-
[on the CompaniesHouse Developers website](https://developer.companieshouse.gov.uk/api/docs/)
|
48
|
-
and [configure an API key](https://developer.companieshouse.gov.uk/developer/applications).
|
49
|
-
Developers should read
|
50
|
-
[the Companies House developer guidelines](https://developer.companieshouse.gov.uk/api/docs/index/gettingStarted/developerGuidelines.html)
|
51
|
-
before using this API, and will note that these guidelines contain several
|
52
|
-
instructions regarding API keys:
|
53
|
-
|
54
|
-
* Do not embed API keys in your code
|
55
|
-
* Do not store API keys in your source tree
|
56
|
-
* Restrict API key use by IP address and domain
|
57
|
-
* **Regenerate your API keys regularly**
|
58
|
-
* Delete API keys when no longer required
|
59
|
-
|
60
|
-
## Client Initialization
|
61
|
-
|
62
|
-
All requests to the API are made through a client object:
|
63
|
-
|
64
|
-
```ruby
|
65
|
-
require 'companies_house/client'
|
66
|
-
client = CompaniesHouse::Client.new(config)
|
67
|
-
```
|
68
|
-
|
69
|
-
The client is configured by passing a hash to the constructor. The supported keys for this
|
70
|
-
hash are:
|
71
|
-
|
72
|
-
| Key | Description |
|
73
|
-
| ----------- | ----------- |
|
74
|
-
| `:api_key` | Required. The API key received after registration. |
|
75
|
-
| `:endpoint` | Optional. Specifies the base URI for the API (e.g. if using a self-hosted version) |
|
76
|
-
|
77
|
-
## Requests
|
78
|
-
|
79
|
-
Once a client has been initialised, requests can be made to the API.
|
80
|
-
Details of the available fields in the response are in the Companies House
|
81
|
-
[documentation](https://developer.companieshouse.gov.uk/api/docs/index.html).
|
82
|
-
The endpoints currently implemented by the gem are:
|
83
|
-
|
84
|
-
| Client Method | Endpoint | Description |
|
85
|
-
| --------------------------------------------------------------- | --------------------------------------- | ----------- |
|
86
|
-
| `.company(company_number)` | `GET /company/:company_number` | Retrieves a company profile. |
|
87
|
-
| `.officers(company_number)` | `GET /company/:company_number/officers` | Retrieves a list of company officers. |
|
88
|
-
| `.company_search(query, items_per_page: nil, start_index: nil)` | `GET /search/companies` | Retrieves a list of companies that match the given query. |
|
89
|
-
|
90
|
-
### .company
|
91
|
-
This method implements the [readCompanyProfile](https://developer.companieshouse.gov.uk/api/docs/company/company_number/readCompanyProfile.html)
|
92
|
-
API and returns the full [companyProfile](https://developer.companieshouse.gov.uk/api/docs/company/company_number/companyProfile-resource.html)
|
93
|
-
resource.
|
94
|
-
|
95
|
-
### .officers
|
96
|
-
This method implements the [officersList](https://developer.companieshouse.gov.uk/api/docs/company/company_number/officers/officerList.html)
|
97
|
-
API. It will make one or more requests against this API, as necessary, to obtain
|
98
|
-
the full list of company officers. It returns only the values under the `items`
|
99
|
-
key from the
|
100
|
-
[officerList](https://developer.companieshouse.gov.uk/api/docs/company/company_number/officers/officerList-resource.html)
|
101
|
-
resource(s) which it reads.
|
102
|
-
|
103
|
-
### .company_search
|
104
|
-
This method implements the [searchCompanies](https://developer.companieshouse.gov.uk/api/docs/search/companies/companysearch.html)
|
105
|
-
API and returns the list of [companySearch](https://developer.companieshouse.gov.uk/api/docs/search-overview/CompanySearch-resource.html)
|
106
|
-
resources that match the given query. The `items_per_page` and `start_index` parameters are optional.
|
107
|
-
|
108
|
-
### Other API Methods
|
109
|
-
While there are other resources exposed by the
|
110
|
-
[Companies House API](https://developer.companieshouse.gov.uk/api/docs/index.html),
|
111
|
-
this gem does not implement access to these resources at this time.
|
112
|
-
|
113
|
-
## Error Handling
|
114
|
-
If a request to the Companies House API encounters an HTTP status other than
|
115
|
-
`200 OK`, it will raise an instance of `CompaniesHouse::APIError` instead of
|
116
|
-
returning response data. The error will have the following fields:
|
117
|
-
|
118
|
-
| Field | Description |
|
119
|
-
| ---------- | ----------- |
|
120
|
-
| `response` | The Net::HTTP response object from the failed API call. |
|
121
|
-
| `status` | A string containing the response status code. |
|
122
|
-
|
123
|
-
|
124
|
-
Certain API responses will raise an instance of a more specific subclass of
|
125
|
-
`CompaniesHouse::APIError`:
|
126
|
-
|
127
|
-
| Status | Error | Description |
|
128
|
-
| ------ | ------------------------------------- | ----------- |
|
129
|
-
| 401 | `CompaniesHouse::AuthenticationError` | Authentication error (invalid API key) |
|
130
|
-
| 404 | `CompaniesHouse::NotFoundError` | Not Found. (No record of the company is available.) |
|
131
|
-
| 429 | `CompaniesHouse::RateLimitError` | Application is being [rate limited](https://developer.companieshouse.gov.uk/api/docs/index/gettingStarted/rateLimiting.html) |
|
132
|
-
|
133
|
-
The client will not catch any other errors which may occur, such as
|
134
|
-
errors involving network connections (e.g. `Errno::ECONNRESET`).
|
135
|
-
|
136
|
-
## Development
|
137
|
-
|
138
|
-
This gem is configured for development using a `bundler` workflow.
|
139
|
-
Tests are written using RSpec, and Rubocop is used to provide linting.
|
140
|
-
Bug reports and pull requests are welcome on this project's
|
141
|
-
[GitHub repository](https://github.com/gocardless/companies-house-rest).
|
142
|
-
|
143
|
-
To get started:
|
144
|
-
|
145
|
-
``` shell
|
146
|
-
bundle install --path vendor
|
147
|
-
```
|
148
|
-
|
149
|
-
|
150
|
-
To run all tests and Rubocop:
|
151
|
-
|
152
|
-
```shell
|
153
|
-
bundle exec rake
|
154
|
-
```
|
1
|
+
# CompaniesHouse::Client
|
2
|
+
|
3
|
+
[![CircleCI](https://circleci.com/gh/gocardless/companies-house-rest.svg?style=svg)](https://circleci.com/gh/gocardless/companies-house-rest)
|
4
|
+
|
5
|
+
This Gem implements an API client for the Companies House REST API. It can be
|
6
|
+
used to look up information about companies registered in the United Kingdom.
|
7
|
+
As of July 2016, this API is described by Companies House as a "beta service."
|
8
|
+
More information about this free API can be found
|
9
|
+
[on the Companies House API website](https://developer.companieshouse.gov.uk/api/docs/index.html).
|
10
|
+
|
11
|
+
To interact the older [CompaniesHouse XML-based API](http://xmlgw.companieshouse.gov.uk/),
|
12
|
+
see the gem [companies-house-gateway](https://github.com/gocardless/companies-house-gateway-ruby).
|
13
|
+
(Monthly subscription [fees](http://xmlgw.companieshouse.gov.uk/CHDpriceList.shtml), and other fees, may apply.)
|
14
|
+
|
15
|
+
Quick start:
|
16
|
+
* Register an account via the `Sign In / Register` link
|
17
|
+
[on the CompaniesHouse Developers website](https://developer.companieshouse.gov.uk/api/docs/)
|
18
|
+
* Register an API key at [Your Applications](https://developer.companieshouse.gov.uk/developer/applications)
|
19
|
+
* Put your API key in an environment variable (not in your code):
|
20
|
+
|
21
|
+
``` shell
|
22
|
+
export COMPANIES_HOUSE_API_KEY=YOUR_API_KEY_HERE
|
23
|
+
|
24
|
+
```
|
25
|
+
* Install `companies-house-rest` through [RubyGems](https://rubygems.org/gems/companies-house-rest)
|
26
|
+
* Create and use a client:
|
27
|
+
|
28
|
+
``` ruby
|
29
|
+
require 'companies_house/client'
|
30
|
+
client = CompaniesHouse::Client.new(api_key: ENV['COMPANIES_HOUSE_API_KEY'])
|
31
|
+
profile = client.company('07495895')
|
32
|
+
```
|
33
|
+
|
34
|
+
|
35
|
+
## Overview
|
36
|
+
This gem is meant to provide a simple synchronous API to look up company profile
|
37
|
+
information and company officers. The data returned is parsed JSON.
|
38
|
+
|
39
|
+
This gem provides information on companies by their Companies House company
|
40
|
+
number. This "company number" is actually a string and should be treated as such.
|
41
|
+
The string may consist solely of digits (including leading 0s) or begin with
|
42
|
+
alphabetic characters such as `NI` or `SC`.
|
43
|
+
|
44
|
+
## Authentication
|
45
|
+
|
46
|
+
Using the Companies House REST API requires you to register an account
|
47
|
+
[on the CompaniesHouse Developers website](https://developer.companieshouse.gov.uk/api/docs/)
|
48
|
+
and [configure an API key](https://developer.companieshouse.gov.uk/developer/applications).
|
49
|
+
Developers should read
|
50
|
+
[the Companies House developer guidelines](https://developer.companieshouse.gov.uk/api/docs/index/gettingStarted/developerGuidelines.html)
|
51
|
+
before using this API, and will note that these guidelines contain several
|
52
|
+
instructions regarding API keys:
|
53
|
+
|
54
|
+
* Do not embed API keys in your code
|
55
|
+
* Do not store API keys in your source tree
|
56
|
+
* Restrict API key use by IP address and domain
|
57
|
+
* **Regenerate your API keys regularly**
|
58
|
+
* Delete API keys when no longer required
|
59
|
+
|
60
|
+
## Client Initialization
|
61
|
+
|
62
|
+
All requests to the API are made through a client object:
|
63
|
+
|
64
|
+
```ruby
|
65
|
+
require 'companies_house/client'
|
66
|
+
client = CompaniesHouse::Client.new(config)
|
67
|
+
```
|
68
|
+
|
69
|
+
The client is configured by passing a hash to the constructor. The supported keys for this
|
70
|
+
hash are:
|
71
|
+
|
72
|
+
| Key | Description |
|
73
|
+
| ----------- | ----------- |
|
74
|
+
| `:api_key` | Required. The API key received after registration. |
|
75
|
+
| `:endpoint` | Optional. Specifies the base URI for the API (e.g. if using a self-hosted version) |
|
76
|
+
|
77
|
+
## Requests
|
78
|
+
|
79
|
+
Once a client has been initialised, requests can be made to the API.
|
80
|
+
Details of the available fields in the response are in the Companies House
|
81
|
+
[documentation](https://developer.companieshouse.gov.uk/api/docs/index.html).
|
82
|
+
The endpoints currently implemented by the gem are:
|
83
|
+
|
84
|
+
| Client Method | Endpoint | Description |
|
85
|
+
| --------------------------------------------------------------- | --------------------------------------- | ----------- |
|
86
|
+
| `.company(company_number)` | `GET /company/:company_number` | Retrieves a company profile. |
|
87
|
+
| `.officers(company_number)` | `GET /company/:company_number/officers` | Retrieves a list of company officers. |
|
88
|
+
| `.company_search(query, items_per_page: nil, start_index: nil)` | `GET /search/companies` | Retrieves a list of companies that match the given query. |
|
89
|
+
|
90
|
+
### .company
|
91
|
+
This method implements the [readCompanyProfile](https://developer.companieshouse.gov.uk/api/docs/company/company_number/readCompanyProfile.html)
|
92
|
+
API and returns the full [companyProfile](https://developer.companieshouse.gov.uk/api/docs/company/company_number/companyProfile-resource.html)
|
93
|
+
resource.
|
94
|
+
|
95
|
+
### .officers
|
96
|
+
This method implements the [officersList](https://developer.companieshouse.gov.uk/api/docs/company/company_number/officers/officerList.html)
|
97
|
+
API. It will make one or more requests against this API, as necessary, to obtain
|
98
|
+
the full list of company officers. It returns only the values under the `items`
|
99
|
+
key from the
|
100
|
+
[officerList](https://developer.companieshouse.gov.uk/api/docs/company/company_number/officers/officerList-resource.html)
|
101
|
+
resource(s) which it reads.
|
102
|
+
|
103
|
+
### .company_search
|
104
|
+
This method implements the [searchCompanies](https://developer.companieshouse.gov.uk/api/docs/search/companies/companysearch.html)
|
105
|
+
API and returns the list of [companySearch](https://developer.companieshouse.gov.uk/api/docs/search-overview/CompanySearch-resource.html)
|
106
|
+
resources that match the given query. The `items_per_page` and `start_index` parameters are optional.
|
107
|
+
|
108
|
+
### Other API Methods
|
109
|
+
While there are other resources exposed by the
|
110
|
+
[Companies House API](https://developer.companieshouse.gov.uk/api/docs/index.html),
|
111
|
+
this gem does not implement access to these resources at this time.
|
112
|
+
|
113
|
+
## Error Handling
|
114
|
+
If a request to the Companies House API encounters an HTTP status other than
|
115
|
+
`200 OK`, it will raise an instance of `CompaniesHouse::APIError` instead of
|
116
|
+
returning response data. The error will have the following fields:
|
117
|
+
|
118
|
+
| Field | Description |
|
119
|
+
| ---------- | ----------- |
|
120
|
+
| `response` | The Net::HTTP response object from the failed API call. |
|
121
|
+
| `status` | A string containing the response status code. |
|
122
|
+
|
123
|
+
|
124
|
+
Certain API responses will raise an instance of a more specific subclass of
|
125
|
+
`CompaniesHouse::APIError`:
|
126
|
+
|
127
|
+
| Status | Error | Description |
|
128
|
+
| ------ | ------------------------------------- | ----------- |
|
129
|
+
| 401 | `CompaniesHouse::AuthenticationError` | Authentication error (invalid API key) |
|
130
|
+
| 404 | `CompaniesHouse::NotFoundError` | Not Found. (No record of the company is available.) |
|
131
|
+
| 429 | `CompaniesHouse::RateLimitError` | Application is being [rate limited](https://developer.companieshouse.gov.uk/api/docs/index/gettingStarted/rateLimiting.html) |
|
132
|
+
|
133
|
+
The client will not catch any other errors which may occur, such as
|
134
|
+
errors involving network connections (e.g. `Errno::ECONNRESET`).
|
135
|
+
|
136
|
+
## Development
|
137
|
+
|
138
|
+
This gem is configured for development using a `bundler` workflow.
|
139
|
+
Tests are written using RSpec, and Rubocop is used to provide linting.
|
140
|
+
Bug reports and pull requests are welcome on this project's
|
141
|
+
[GitHub repository](https://github.com/gocardless/companies-house-rest).
|
142
|
+
|
143
|
+
To get started:
|
144
|
+
|
145
|
+
``` shell
|
146
|
+
bundle install --path vendor
|
147
|
+
```
|
148
|
+
|
149
|
+
|
150
|
+
To run all tests and Rubocop:
|
151
|
+
|
152
|
+
```shell
|
153
|
+
bundle exec rake
|
154
|
+
```
|
@@ -1,34 +1,34 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
lib = File.expand_path("lib", __dir__)
|
4
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
-
require "companies_house/version"
|
6
|
-
|
7
|
-
Gem::Specification.new do |spec|
|
8
|
-
spec.name = "companies-house-rest"
|
9
|
-
spec.version = CompaniesHouse::VERSION
|
10
|
-
spec.authors = ["GoCardless Engineering"]
|
11
|
-
spec.email = ["developers@gocardless.com"]
|
12
|
-
spec.license = "MIT"
|
13
|
-
|
14
|
-
spec.summary = "Look up UK company registration information"
|
15
|
-
spec.description = "Client for the Companies House REST API. Provides company " \
|
16
|
-
"profiles and officer lists."
|
17
|
-
spec.homepage = "https://github.com/gocardless/companies-house-rest"
|
18
|
-
|
19
|
-
spec.files = `git ls-files -z lib/ *.gemspec LICENSE README.md`.split("\x0")
|
20
|
-
spec.bindir = "exe"
|
21
|
-
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
-
spec.require_paths = ["lib"]
|
23
|
-
spec.required_ruby_version = ">= 2.3"
|
24
|
-
|
25
|
-
spec.add_runtime_dependency "activesupport", "
|
26
|
-
spec.add_runtime_dependency "virtus", "~> 1.0", ">= 1.0.5"
|
27
|
-
|
28
|
-
spec.add_development_dependency "bundler", "~> 1.10"
|
29
|
-
spec.add_development_dependency "gc_ruboconfig", "~> 2.3"
|
30
|
-
spec.add_development_dependency "rake", "~> 12.0"
|
31
|
-
spec.add_development_dependency "rspec", "~> 3.5"
|
32
|
-
spec.add_development_dependency "timecop", "~> 0.8"
|
33
|
-
spec.add_development_dependency "webmock", "~> 3.0"
|
34
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path("lib", __dir__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require "companies_house/version"
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = "companies-house-rest"
|
9
|
+
spec.version = CompaniesHouse::VERSION
|
10
|
+
spec.authors = ["GoCardless Engineering"]
|
11
|
+
spec.email = ["developers@gocardless.com"]
|
12
|
+
spec.license = "MIT"
|
13
|
+
|
14
|
+
spec.summary = "Look up UK company registration information"
|
15
|
+
spec.description = "Client for the Companies House REST API. Provides company " \
|
16
|
+
"profiles and officer lists."
|
17
|
+
spec.homepage = "https://github.com/gocardless/companies-house-rest"
|
18
|
+
|
19
|
+
spec.files = `git ls-files -z lib/ *.gemspec LICENSE README.md`.split("\x0")
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
spec.required_ruby_version = ">= 2.3"
|
24
|
+
|
25
|
+
spec.add_runtime_dependency "activesupport", ">= 4.2", "< 6"
|
26
|
+
spec.add_runtime_dependency "virtus", "~> 1.0", ">= 1.0.5"
|
27
|
+
|
28
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
29
|
+
spec.add_development_dependency "gc_ruboconfig", "~> 2.3"
|
30
|
+
spec.add_development_dependency "rake", "~> 12.0"
|
31
|
+
spec.add_development_dependency "rspec", "~> 3.5"
|
32
|
+
spec.add_development_dependency "timecop", "~> 0.8"
|
33
|
+
spec.add_development_dependency "webmock", "~> 3.0"
|
34
|
+
end
|
data/lib/companies_house.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "companies_house/client"
|
4
|
-
require "companies_house/api_error"
|
5
|
-
require "companies_house/not_found_error"
|
6
|
-
require "companies_house/authentication_error"
|
7
|
-
require "companies_house/rate_limit_error"
|
8
|
-
|
9
|
-
module CompaniesHouse
|
10
|
-
# The module that contains all the classes implementing the API client
|
11
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "companies_house/client"
|
4
|
+
require "companies_house/api_error"
|
5
|
+
require "companies_house/not_found_error"
|
6
|
+
require "companies_house/authentication_error"
|
7
|
+
require "companies_house/rate_limit_error"
|
8
|
+
|
9
|
+
module CompaniesHouse
|
10
|
+
# The module that contains all the classes implementing the API client
|
11
|
+
end
|
@@ -1,18 +1,18 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module CompaniesHouse
|
4
|
-
# Represents any response from the API which is not a 200 OK
|
5
|
-
class APIError < StandardError
|
6
|
-
attr_reader :status, :response
|
7
|
-
|
8
|
-
def initialize(msg, response = nil)
|
9
|
-
if response
|
10
|
-
msg = "#{msg} - HTTP #{response.code}"
|
11
|
-
@status = response.code
|
12
|
-
end
|
13
|
-
|
14
|
-
super(msg)
|
15
|
-
@response = response
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CompaniesHouse
|
4
|
+
# Represents any response from the API which is not a 200 OK
|
5
|
+
class APIError < StandardError
|
6
|
+
attr_reader :status, :response
|
7
|
+
|
8
|
+
def initialize(msg, response = nil)
|
9
|
+
if response
|
10
|
+
msg = "#{msg} - HTTP #{response.code}"
|
11
|
+
@status = response.code
|
12
|
+
end
|
13
|
+
|
14
|
+
super(msg)
|
15
|
+
@response = response
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module CompaniesHouse
|
4
|
-
# Specific error class for when an invalid API key is used to access the service
|
5
|
-
class AuthenticationError < APIError
|
6
|
-
def initialize(response = nil)
|
7
|
-
super("Invalid API key", response)
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CompaniesHouse
|
4
|
+
# Specific error class for when an invalid API key is used to access the service
|
5
|
+
class AuthenticationError < APIError
|
6
|
+
def initialize(response = nil)
|
7
|
+
super("Invalid API key", response)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -1,104 +1,104 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "companies_house/request"
|
4
|
-
require "net/http"
|
5
|
-
|
6
|
-
module CompaniesHouse
|
7
|
-
# This class provides an interface to the Companies House API
|
8
|
-
# at https://api.companieshouse.gov.uk.
|
9
|
-
# Specifically, it manages the connections and arranges requests.
|
10
|
-
class Client
|
11
|
-
ENDPOINT = "https://api.companieshouse.gov.uk"
|
12
|
-
|
13
|
-
attr_reader :api_key, :endpoint
|
14
|
-
|
15
|
-
def initialize(config)
|
16
|
-
raise ArgumentError, "Missing API key" unless config[:api_key]
|
17
|
-
@api_key = config[:api_key]
|
18
|
-
@endpoint = URI(config[:endpoint] || ENDPOINT)
|
19
|
-
@open_timeout = config[:open_timeout] || 60
|
20
|
-
@read_timeout = config[:read_timeout] || 60
|
21
|
-
raise ArgumentError, "HTTP is not supported" if @endpoint.scheme != "https"
|
22
|
-
end
|
23
|
-
|
24
|
-
def end_connection
|
25
|
-
@connection.finish if @connection&.started?
|
26
|
-
end
|
27
|
-
|
28
|
-
def company(id)
|
29
|
-
request(:company, "company/#{id}", {}, make_transaction_id, id)
|
30
|
-
end
|
31
|
-
|
32
|
-
def officers(id)
|
33
|
-
get_all_pages(:officers, "company/#{id}/officers", id)
|
34
|
-
end
|
35
|
-
|
36
|
-
def persons_with_significant_control(id, register_view: false)
|
37
|
-
get_all_pages(
|
38
|
-
:persons_with_significant_control,
|
39
|
-
"company/#{id}/persons-with-significant-control",
|
40
|
-
id,
|
41
|
-
register_view: register_view,
|
42
|
-
)
|
43
|
-
end
|
44
|
-
|
45
|
-
def company_search(query, items_per_page: nil, start_index: nil)
|
46
|
-
request(
|
47
|
-
:company_search,
|
48
|
-
"search/companies",
|
49
|
-
{ q: query, items_per_page: items_per_page, start_index: start_index }.compact,
|
50
|
-
)
|
51
|
-
end
|
52
|
-
|
53
|
-
def connection
|
54
|
-
@connection ||= Net::HTTP.new(endpoint.host, endpoint.port).tap do |conn|
|
55
|
-
conn.use_ssl = true
|
56
|
-
conn.open_timeout = @open_timeout
|
57
|
-
conn.read_timeout = @read_timeout
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
private
|
62
|
-
|
63
|
-
# Fetch and combine all pages of a paginated API call
|
64
|
-
def get_all_pages(resource, path, id, query = {})
|
65
|
-
items = []
|
66
|
-
offset = 0
|
67
|
-
xid = make_transaction_id
|
68
|
-
|
69
|
-
loop do
|
70
|
-
page = request(resource, path, query.merge(start_index: offset), xid, id)
|
71
|
-
new_items = page["items"]
|
72
|
-
total = page["total_results"] || new_items.count
|
73
|
-
|
74
|
-
items += new_items
|
75
|
-
offset += new_items.count
|
76
|
-
|
77
|
-
break if items.count >= total
|
78
|
-
end
|
79
|
-
|
80
|
-
items
|
81
|
-
end
|
82
|
-
|
83
|
-
def make_transaction_id
|
84
|
-
SecureRandom.hex(10)
|
85
|
-
end
|
86
|
-
|
87
|
-
def request(resource,
|
88
|
-
path,
|
89
|
-
params = {},
|
90
|
-
transaction_id = make_transaction_id,
|
91
|
-
resource_id = nil)
|
92
|
-
Request.new(
|
93
|
-
connection: connection,
|
94
|
-
api_key: @api_key,
|
95
|
-
endpoint: @endpoint,
|
96
|
-
path: path,
|
97
|
-
query: params,
|
98
|
-
resource_type: resource,
|
99
|
-
resource_id: resource_id,
|
100
|
-
transaction_id: transaction_id,
|
101
|
-
).execute
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "companies_house/request"
|
4
|
+
require "net/http"
|
5
|
+
|
6
|
+
module CompaniesHouse
|
7
|
+
# This class provides an interface to the Companies House API
|
8
|
+
# at https://api.companieshouse.gov.uk.
|
9
|
+
# Specifically, it manages the connections and arranges requests.
|
10
|
+
class Client
|
11
|
+
ENDPOINT = "https://api.companieshouse.gov.uk"
|
12
|
+
|
13
|
+
attr_reader :api_key, :endpoint
|
14
|
+
|
15
|
+
def initialize(config)
|
16
|
+
raise ArgumentError, "Missing API key" unless config[:api_key]
|
17
|
+
@api_key = config[:api_key]
|
18
|
+
@endpoint = URI(config[:endpoint] || ENDPOINT)
|
19
|
+
@open_timeout = config[:open_timeout] || 60
|
20
|
+
@read_timeout = config[:read_timeout] || 60
|
21
|
+
raise ArgumentError, "HTTP is not supported" if @endpoint.scheme != "https"
|
22
|
+
end
|
23
|
+
|
24
|
+
def end_connection
|
25
|
+
@connection.finish if @connection&.started?
|
26
|
+
end
|
27
|
+
|
28
|
+
def company(id)
|
29
|
+
request(:company, "company/#{id}", {}, make_transaction_id, id)
|
30
|
+
end
|
31
|
+
|
32
|
+
def officers(id)
|
33
|
+
get_all_pages(:officers, "company/#{id}/officers", id)
|
34
|
+
end
|
35
|
+
|
36
|
+
def persons_with_significant_control(id, register_view: false)
|
37
|
+
get_all_pages(
|
38
|
+
:persons_with_significant_control,
|
39
|
+
"company/#{id}/persons-with-significant-control",
|
40
|
+
id,
|
41
|
+
register_view: register_view,
|
42
|
+
)
|
43
|
+
end
|
44
|
+
|
45
|
+
def company_search(query, items_per_page: nil, start_index: nil)
|
46
|
+
request(
|
47
|
+
:company_search,
|
48
|
+
"search/companies",
|
49
|
+
{ q: query, items_per_page: items_per_page, start_index: start_index }.compact,
|
50
|
+
)
|
51
|
+
end
|
52
|
+
|
53
|
+
def connection
|
54
|
+
@connection ||= Net::HTTP.new(endpoint.host, endpoint.port).tap do |conn|
|
55
|
+
conn.use_ssl = true
|
56
|
+
conn.open_timeout = @open_timeout
|
57
|
+
conn.read_timeout = @read_timeout
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
|
63
|
+
# Fetch and combine all pages of a paginated API call
|
64
|
+
def get_all_pages(resource, path, id, query = {})
|
65
|
+
items = []
|
66
|
+
offset = 0
|
67
|
+
xid = make_transaction_id
|
68
|
+
|
69
|
+
loop do
|
70
|
+
page = request(resource, path, query.merge(start_index: offset), xid, id)
|
71
|
+
new_items = page["items"]
|
72
|
+
total = page["total_results"] || new_items.count
|
73
|
+
|
74
|
+
items += new_items
|
75
|
+
offset += new_items.count
|
76
|
+
|
77
|
+
break if items.count >= total
|
78
|
+
end
|
79
|
+
|
80
|
+
items
|
81
|
+
end
|
82
|
+
|
83
|
+
def make_transaction_id
|
84
|
+
SecureRandom.hex(10)
|
85
|
+
end
|
86
|
+
|
87
|
+
def request(resource,
|
88
|
+
path,
|
89
|
+
params = {},
|
90
|
+
transaction_id = make_transaction_id,
|
91
|
+
resource_id = nil)
|
92
|
+
Request.new(
|
93
|
+
connection: connection,
|
94
|
+
api_key: @api_key,
|
95
|
+
endpoint: @endpoint,
|
96
|
+
path: path,
|
97
|
+
query: params,
|
98
|
+
resource_type: resource,
|
99
|
+
resource_id: resource_id,
|
100
|
+
transaction_id: transaction_id,
|
101
|
+
).execute
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -1,14 +1,14 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module CompaniesHouse
|
4
|
-
# Specific error class for when a company cannot be found (for example, if the company
|
5
|
-
# number given is invaid)
|
6
|
-
class NotFoundError < APIError
|
7
|
-
def initialize(resource_type, resource_id = nil, response = nil)
|
8
|
-
super(
|
9
|
-
"Resource not found - type `#{resource_type}`, id `#{resource_id || 'nil'}`",
|
10
|
-
response,
|
11
|
-
)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CompaniesHouse
|
4
|
+
# Specific error class for when a company cannot be found (for example, if the company
|
5
|
+
# number given is invaid)
|
6
|
+
class NotFoundError < APIError
|
7
|
+
def initialize(resource_type, resource_id = nil, response = nil)
|
8
|
+
super(
|
9
|
+
"Resource not found - type `#{resource_type}`, id `#{resource_id || 'nil'}`",
|
10
|
+
response,
|
11
|
+
)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module CompaniesHouse
|
4
|
-
# Specific error class for when an invalid API key is used to access the service
|
5
|
-
class RateLimitError < APIError
|
6
|
-
def initialize(response = nil)
|
7
|
-
super("Rate limit exceeded", response)
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CompaniesHouse
|
4
|
+
# Specific error class for when an invalid API key is used to access the service
|
5
|
+
class RateLimitError < APIError
|
6
|
+
def initialize(response = nil)
|
7
|
+
super("Rate limit exceeded", response)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -1,96 +1,96 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "companies_house/api_error"
|
4
|
-
require "companies_house/not_found_error"
|
5
|
-
require "companies_house/authentication_error"
|
6
|
-
require "companies_house/rate_limit_error"
|
7
|
-
require "companies_house/timeout_error"
|
8
|
-
|
9
|
-
require "virtus"
|
10
|
-
require "uri"
|
11
|
-
require "json"
|
12
|
-
|
13
|
-
require "active_support/notifications"
|
14
|
-
|
15
|
-
module CompaniesHouse
|
16
|
-
# This class manages individual requests.
|
17
|
-
# Users of the CompaniesHouse gem should not instantiate this class
|
18
|
-
# and should instead use CompaniesHouse::Client.
|
19
|
-
class Request
|
20
|
-
include Virtus.model
|
21
|
-
# API-level attributes
|
22
|
-
attribute :connection, Net::HTTP, required: true
|
23
|
-
attribute :api_key, String, required: true
|
24
|
-
attribute :endpoint, URI, required: true
|
25
|
-
|
26
|
-
# Physical request attributes
|
27
|
-
attribute :path, String, required: true
|
28
|
-
attribute :query, Hash, required: true
|
29
|
-
|
30
|
-
# Logical request attributes
|
31
|
-
attribute :resource_type, Symbol, required: true
|
32
|
-
attribute :resource_id, String
|
33
|
-
|
34
|
-
attribute :transaction_id, String, required: true
|
35
|
-
|
36
|
-
def initialize(args)
|
37
|
-
super(args)
|
38
|
-
|
39
|
-
@uri = URI.join(endpoint, path)
|
40
|
-
@uri.query = URI.encode_www_form(query)
|
41
|
-
|
42
|
-
@notification_payload = {
|
43
|
-
method: :get,
|
44
|
-
path: path,
|
45
|
-
query: query,
|
46
|
-
}
|
47
|
-
end
|
48
|
-
|
49
|
-
def execute
|
50
|
-
@started = Time.now.utc
|
51
|
-
|
52
|
-
req = Net::HTTP::Get.new(@uri)
|
53
|
-
req.basic_auth @api_key, ""
|
54
|
-
|
55
|
-
response = connection.request req
|
56
|
-
@notification_payload[:status] = response.code
|
57
|
-
|
58
|
-
begin
|
59
|
-
@notification_payload[:response] = parse(response, resource_type, resource_id)
|
60
|
-
rescue StandardError => e
|
61
|
-
@notification_payload[:error] = e
|
62
|
-
raise e
|
63
|
-
ensure
|
64
|
-
publish_notification
|
65
|
-
end
|
66
|
-
rescue Net::OpenTimeout, Net::ReadTimeout
|
67
|
-
raise TimeoutError
|
68
|
-
end
|
69
|
-
|
70
|
-
private
|
71
|
-
|
72
|
-
def publish_notification
|
73
|
-
ActiveSupport::Notifications.publish(
|
74
|
-
"companies_house.#{resource_type}",
|
75
|
-
@started, Time.now.utc,
|
76
|
-
transaction_id,
|
77
|
-
@notification_payload
|
78
|
-
)
|
79
|
-
end
|
80
|
-
|
81
|
-
def parse(response, resource_type, resource_id)
|
82
|
-
case response.code
|
83
|
-
when "200"
|
84
|
-
JSON[response.body]
|
85
|
-
when "401"
|
86
|
-
raise CompaniesHouse::AuthenticationError, response
|
87
|
-
when "404"
|
88
|
-
raise CompaniesHouse::NotFoundError.new(resource_type, resource_id, response)
|
89
|
-
when "429"
|
90
|
-
raise CompaniesHouse::RateLimitError, response
|
91
|
-
else
|
92
|
-
raise CompaniesHouse::APIError.new("Unknown API response", response)
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
96
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "companies_house/api_error"
|
4
|
+
require "companies_house/not_found_error"
|
5
|
+
require "companies_house/authentication_error"
|
6
|
+
require "companies_house/rate_limit_error"
|
7
|
+
require "companies_house/timeout_error"
|
8
|
+
|
9
|
+
require "virtus"
|
10
|
+
require "uri"
|
11
|
+
require "json"
|
12
|
+
|
13
|
+
require "active_support/notifications"
|
14
|
+
|
15
|
+
module CompaniesHouse
|
16
|
+
# This class manages individual requests.
|
17
|
+
# Users of the CompaniesHouse gem should not instantiate this class
|
18
|
+
# and should instead use CompaniesHouse::Client.
|
19
|
+
class Request
|
20
|
+
include Virtus.model
|
21
|
+
# API-level attributes
|
22
|
+
attribute :connection, Net::HTTP, required: true
|
23
|
+
attribute :api_key, String, required: true
|
24
|
+
attribute :endpoint, URI, required: true
|
25
|
+
|
26
|
+
# Physical request attributes
|
27
|
+
attribute :path, String, required: true
|
28
|
+
attribute :query, Hash, required: true
|
29
|
+
|
30
|
+
# Logical request attributes
|
31
|
+
attribute :resource_type, Symbol, required: true
|
32
|
+
attribute :resource_id, String
|
33
|
+
|
34
|
+
attribute :transaction_id, String, required: true
|
35
|
+
|
36
|
+
def initialize(args)
|
37
|
+
super(args)
|
38
|
+
|
39
|
+
@uri = URI.join(endpoint, path)
|
40
|
+
@uri.query = URI.encode_www_form(query)
|
41
|
+
|
42
|
+
@notification_payload = {
|
43
|
+
method: :get,
|
44
|
+
path: path,
|
45
|
+
query: query,
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
def execute
|
50
|
+
@started = Time.now.utc
|
51
|
+
|
52
|
+
req = Net::HTTP::Get.new(@uri)
|
53
|
+
req.basic_auth @api_key, ""
|
54
|
+
|
55
|
+
response = connection.request req
|
56
|
+
@notification_payload[:status] = response.code
|
57
|
+
|
58
|
+
begin
|
59
|
+
@notification_payload[:response] = parse(response, resource_type, resource_id)
|
60
|
+
rescue StandardError => e
|
61
|
+
@notification_payload[:error] = e
|
62
|
+
raise e
|
63
|
+
ensure
|
64
|
+
publish_notification
|
65
|
+
end
|
66
|
+
rescue Net::OpenTimeout, Net::ReadTimeout
|
67
|
+
raise TimeoutError
|
68
|
+
end
|
69
|
+
|
70
|
+
private
|
71
|
+
|
72
|
+
def publish_notification
|
73
|
+
ActiveSupport::Notifications.publish(
|
74
|
+
"companies_house.#{resource_type}",
|
75
|
+
@started, Time.now.utc,
|
76
|
+
transaction_id,
|
77
|
+
@notification_payload
|
78
|
+
)
|
79
|
+
end
|
80
|
+
|
81
|
+
def parse(response, resource_type, resource_id)
|
82
|
+
case response.code
|
83
|
+
when "200"
|
84
|
+
JSON[response.body]
|
85
|
+
when "401"
|
86
|
+
raise CompaniesHouse::AuthenticationError, response
|
87
|
+
when "404"
|
88
|
+
raise CompaniesHouse::NotFoundError.new(resource_type, resource_id, response)
|
89
|
+
when "429"
|
90
|
+
raise CompaniesHouse::RateLimitError, response
|
91
|
+
else
|
92
|
+
raise CompaniesHouse::APIError.new("Unknown API response", response)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module CompaniesHouse
|
4
|
-
# Raised when a request has timed out
|
5
|
-
class TimeoutError < APIError
|
6
|
-
def initialize(response = nil)
|
7
|
-
super("Request timed out", response)
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CompaniesHouse
|
4
|
+
# Raised when a request has timed out
|
5
|
+
class TimeoutError < APIError
|
6
|
+
def initialize(response = nil)
|
7
|
+
super("Request timed out", response)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module CompaniesHouse
|
4
|
-
VERSION = "0.4.
|
5
|
-
end
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CompaniesHouse
|
4
|
+
VERSION = "0.4.3"
|
5
|
+
end
|
metadata
CHANGED
@@ -1,29 +1,35 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: companies-house-rest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- GoCardless Engineering
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '4.2'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '6'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '4.2'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '6'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: virtus
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|