companies-house-rest 0.5.0 → 0.6.0

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: acbe329349686658408d7b6d6cc2ba267b6a685f01238a56d00a465853f2862b
4
- data.tar.gz: 55ad4bcb56c3895963785a1bb173c7095ad5443b9819bb562280d2df67bcb68d
3
+ metadata.gz: 52bdd785678f5c27983569bd6392900dc4f26f939e1f228ed6c955b1146d32ff
4
+ data.tar.gz: ad9d77152c5c44548c2c43f5f398be1aa3fd85d3eef8947917667fd16164fc72
5
5
  SHA512:
6
- metadata.gz: a5df96312aae7d77a847b33ad67b916fcfc3ef2ea67c8c333523322389adb79baed76033847c64a4aff29ab30c5b0bc1896ea8b40b6f72365c06fade8ff3ff57
7
- data.tar.gz: 05ab11572766fdc6d61fa9d32ed9088297fc3dd399853343a9ad1767ede56ad94ef04f024a92269bbd3fa0641193de24bc05c5b712c02cb11ea2ad85ee292475
6
+ metadata.gz: b38b76b8e985cbd5dd9e2e0da8812a504d88bcb0c26a84276a923778fda5fb3cce6b2401afd49b0cfa58ab1e15d17aa82d5636362fd6e5b6ff1d1bd5fa4524b9
7
+ data.tar.gz: c1cf8db5f63af5ced3d1bf9809730d7a833b3453bb7f7bf7231654c00d71efda8bf1cacd1333def031b1239047eca14bbf5d553c8e35167688aedbb9f0cf9f19
data/README.md CHANGED
@@ -110,6 +110,13 @@ This method implements the [searchCompanies](https://developer.companieshouse.go
110
110
  API and returns the list of [companySearch](https://developer.companieshouse.gov.uk/api/docs/search-overview/CompanySearch-resource.html)
111
111
  resources that match the given query. The `items_per_page` and `start_index` parameters are optional.
112
112
 
113
+ ### .filing_history_list
114
+ This method implements the [filingHistoryList](https://developer.companieshouse.gov.uk/api/docs/company/company_number/filing-history/getFilingHistoryList.html) API and returns the full [filingHistoryList](https://developer.companieshouse.gov.uk/api/docs/company/company_number/filing-history/filingHistoryList-resource.html) resource.
115
+
116
+ ### .filing_history_item
117
+ This method implements the [filingHistoryItem](https://developer.companieshouse.gov.uk/api/docs/company/company_number/filing-history/transaction_id/getFilingHistoryItem.html) API and returns the full
118
+ [filingHistoryItem](https://developer.companieshouse.gov.uk/api/docs/company/company_number/filing-history/filingHistoryItem-resource.html) resource.
119
+
113
120
  ### Other API Methods
114
121
  While there are other resources exposed by the
115
122
  [Companies House API](https://developer.companieshouse.gov.uk/api/docs/index.html),
@@ -47,6 +47,17 @@ module CompaniesHouse
47
47
  )
48
48
  end
49
49
 
50
+ def filing_history_list(id)
51
+ get_all_pages(:filing_history_list, "company/#{id}/filing-history", id)
52
+ end
53
+
54
+ def filing_history_item(id, transaction_id)
55
+ request(
56
+ :filing_history_item,
57
+ "company/#{id}/filing-history/#{transaction_id}",
58
+ )
59
+ end
60
+
50
61
  def company_search(query, items_per_page: nil, start_index: nil)
51
62
  request(
52
63
  :company_search,
@@ -63,6 +74,26 @@ module CompaniesHouse
63
74
  end
64
75
  end
65
76
 
77
+ def request(resource,
78
+ path,
79
+ params = {},
80
+ transaction_id = make_transaction_id,
81
+ resource_id = nil,
82
+ headers = {})
83
+ Request.new(
84
+ connection: connection,
85
+ api_key: @api_key,
86
+ endpoint: @endpoint,
87
+ path: path,
88
+ query: params,
89
+ resource_type: resource,
90
+ resource_id: resource_id,
91
+ transaction_id: transaction_id,
92
+ instrumentation: instrumentation,
93
+ headers: headers,
94
+ ).execute
95
+ end
96
+
66
97
  private
67
98
 
68
99
  # Fetch and combine all pages of a paginated API call
@@ -89,24 +120,6 @@ module CompaniesHouse
89
120
  SecureRandom.hex(10)
90
121
  end
91
122
 
92
- def request(resource,
93
- path,
94
- params = {},
95
- transaction_id = make_transaction_id,
96
- resource_id = nil)
97
- Request.new(
98
- connection: connection,
99
- api_key: @api_key,
100
- endpoint: @endpoint,
101
- path: path,
102
- query: params,
103
- resource_type: resource,
104
- resource_id: resource_id,
105
- transaction_id: transaction_id,
106
- instrumentation: instrumentation,
107
- ).execute
108
- end
109
-
110
123
  def configure_instrumentation(instrumentation)
111
124
  return instrumentation unless instrumentation.nil?
112
125
 
@@ -25,6 +25,7 @@ module CompaniesHouse
25
25
  # Physical request attributes
26
26
  attribute :path, Dry.Types::String
27
27
  attribute :query, Dry.Types::Hash
28
+ attribute :headers, Dry.Types::Hash
28
29
 
29
30
  # Logical request attributes
30
31
  attribute :resource_type, Dry.Types::Symbol
@@ -82,10 +83,12 @@ module CompaniesHouse
82
83
  )
83
84
  end
84
85
 
86
+ # rubocop:disable Metrics/CyclomaticComplexity
85
87
  def parse(response, resource_type, resource_id)
86
88
  case response.code
87
89
  when "200"
88
90
  JSON[response.body]
91
+ when "302" then { 'location': response["location"] }
89
92
  when "401"
90
93
  raise CompaniesHouse::AuthenticationError, response
91
94
  when "404"
@@ -98,5 +101,6 @@ module CompaniesHouse
98
101
  raise CompaniesHouse::APIError.new("Unknown API response", response)
99
102
  end
100
103
  end
104
+ # rubocop:enable Metrics/CyclomaticComplexity
101
105
  end
102
106
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CompaniesHouse
4
- VERSION = "0.5.0"
4
+ VERSION = "0.6.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: companies-house-rest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GoCardless Engineering
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-10-04 00:00:00.000000000 Z
11
+ date: 2020-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-struct
@@ -155,7 +155,7 @@ homepage: https://github.com/gocardless/companies-house-rest
155
155
  licenses:
156
156
  - MIT
157
157
  metadata: {}
158
- post_install_message:
158
+ post_install_message:
159
159
  rdoc_options: []
160
160
  require_paths:
161
161
  - lib
@@ -170,8 +170,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
170
170
  - !ruby/object:Gem::Version
171
171
  version: '0'
172
172
  requirements: []
173
- rubygems_version: 3.0.6
174
- signing_key:
173
+ rubygems_version: 3.1.3
174
+ signing_key:
175
175
  specification_version: 4
176
176
  summary: Look up UK company registration information
177
177
  test_files: []