companies-house-gateway 0.2.0 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/README.md +32 -3
- data/lib/companies_house_gateway/checks/check.rb +8 -3
- data/lib/companies_house_gateway/checks/company_appointments.rb +3 -3
- data/lib/companies_house_gateway/checks/document.rb +14 -2
- data/lib/companies_house_gateway/checks/mortgages.rb +3 -3
- data/lib/companies_house_gateway/checks/name_search.rb +1 -2
- data/lib/companies_house_gateway/checks/number_search.rb +1 -2
- data/lib/companies_house_gateway/checks/officer_details.rb +4 -3
- data/lib/companies_house_gateway/checks/officer_search.rb +2 -2
- data/lib/companies_house_gateway/client.rb +6 -5
- data/lib/companies_house_gateway/constants.rb +14 -0
- data/lib/companies_house_gateway/errors/api_error.rb +4 -0
- data/lib/companies_house_gateway/errors/invalid_request_error.rb +10 -0
- data/lib/companies_house_gateway/errors/invalid_response_error.rb +4 -0
- data/lib/companies_house_gateway/middleware/check_response.rb +29 -0
- data/lib/companies_house_gateway/request.rb +2 -1
- data/lib/companies_house_gateway/validations.rb +78 -0
- data/lib/companies_house_gateway/version.rb +1 -1
- data/lib/companies_house_gateway.rb +5 -0
- data/spec/checks/company_appointments_spec.rb +3 -3
- data/spec/checks/company_details_spec.rb +2 -1
- data/spec/checks/document_info_spec.rb +2 -1
- data/spec/checks/document_spec.rb +6 -3
- data/spec/checks/filing_history_spec.rb +2 -1
- data/spec/checks/mortgages_spec.rb +3 -3
- data/spec/checks/name_search_spec.rb +2 -1
- data/spec/checks/number_search_spec.rb +2 -1
- data/spec/checks/officer_details_spec.rb +2 -2
- data/spec/checks/officer_search_spec.rb +2 -2
- data/spec/fixtures/bad_response.xml +35 -0
- data/spec/fixtures/check_responses/company_appointments.xml +319 -0
- data/spec/fixtures/check_responses/company_details.xml +62 -0
- data/spec/fixtures/check_responses/document.xml +32 -0
- data/spec/fixtures/check_responses/document_info.xml +34 -0
- data/spec/fixtures/check_responses/filing_history.xml +57 -0
- data/spec/fixtures/check_responses/mortgages.xml +107 -0
- data/spec/fixtures/check_responses/name_search.xml +101 -0
- data/spec/fixtures/check_responses/number_search.xml +36 -0
- data/spec/fixtures/check_responses/officer_details.xml +65 -0
- data/spec/fixtures/check_responses/officer_search.xml +90 -0
- data/spec/fixtures/{checks → check_schemas}/chbase.xsd +0 -0
- data/spec/fixtures/{checks → check_schemas}/company_appointments.xsd +0 -0
- data/spec/fixtures/{checks → check_schemas}/company_details.xsd +0 -0
- data/spec/fixtures/{checks → check_schemas}/document.xsd +0 -0
- data/spec/fixtures/{checks → check_schemas}/document_info.xsd +0 -0
- data/spec/fixtures/{checks → check_schemas}/filing_history.xsd +0 -0
- data/spec/fixtures/{checks → check_schemas}/mortgages.xsd +0 -0
- data/spec/fixtures/{checks → check_schemas}/name_search.xsd +0 -0
- data/spec/fixtures/{checks → check_schemas}/number_search.xsd +0 -0
- data/spec/fixtures/{checks → check_schemas}/officer_details.xsd +0 -0
- data/spec/fixtures/{checks → check_schemas}/officer_search.xsd +0 -0
- data/spec/fixtures/response.xml +56 -0
- data/spec/request_spec.rb +24 -3
- data/spec/shared_examples.rb +20 -3
- data/spec/validations_spec.rb +157 -0
- metadata +55 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3a8d19739e0b13770a8238d162130526eeb8a399
|
4
|
+
data.tar.gz: d20152355242794ee5286ab6910b9fb83f6fd5a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d8df95b6d5fc31e4cbe356ef9135a8e75cb6ccc2f94bab3c2ef38d688ddb3ab6aa2025526a5422b9eb29e871e07629be6414ed2361fc7555cc9cf72c7e72c80
|
7
|
+
data.tar.gz: 4922e54e1e34f4ce490b77b52ff11c9304f84c9a61c9794e4ff33eb25225671635420ffb0cd9cef8841d84d2b0f4b9a1318b7d22a64ae099d8c5084aa88d2491
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
## 0.3.3 - February 25, 2014
|
2
|
+
|
3
|
+
- Only return the body of the response if raw mode is false
|
4
|
+
|
5
|
+
## 0.3.2 - February 25, 2014
|
6
|
+
|
7
|
+
- Check Companies House response for errors or unexpected XML
|
8
|
+
|
9
|
+
## 0.3.1 - February 25, 2014
|
10
|
+
|
11
|
+
- Make UserReference optional on all checks (pre-populate if not provided)
|
12
|
+
|
13
|
+
## 0.3.0 - February 25, 2014
|
14
|
+
|
15
|
+
- Validate inputs to all checks. Add InvalidRequestError
|
16
|
+
|
1
17
|
## 0.2.0 - February 23, 2014
|
2
18
|
|
3
19
|
- Add filing_history and document_info and document classes. Gem now covers
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Companies House
|
1
|
+
# Companies House Gateway
|
2
2
|
|
3
3
|
Simple Ruby Gem for interacting with the Companies House XML Gateway API. Wraps
|
4
4
|
the XML submissions and responses required so you can deal with Ruby hashes
|
@@ -22,7 +22,36 @@ you'll need to get in touch with
|
|
22
22
|
|
23
23
|
```ruby
|
24
24
|
CompaniesHouseGateway.configure do |config|
|
25
|
-
config[:sender_id]
|
26
|
-
config[:password]
|
25
|
+
config[:sender_id] = YOUR_SENDER_ID
|
26
|
+
config[:password] = YOUR_PASSWORD
|
27
|
+
config[:email] = YOUR_EMAIL # Optional
|
27
28
|
end
|
29
|
+
```
|
30
|
+
|
31
|
+
### Performing checks
|
32
|
+
Each check type has a convenience method on the top-level module:
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
CompaniesHouseGateway.name_search(company_name: "GoCardless")
|
36
|
+
CompaniesHouseGateway.company_details(company_number: "07495895")
|
37
|
+
```
|
38
|
+
|
39
|
+
The library will raise an error if you're missing any of the required
|
40
|
+
parameters, or including any which can't be used.
|
41
|
+
|
42
|
+
### Parsing responses
|
43
|
+
|
44
|
+
Unless you've set the "raw" argument to true in your config, checks return a
|
45
|
+
hash.
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
CompaniesHouseGateway.name_search(...) # => Hash of results
|
49
|
+
```
|
50
|
+
|
51
|
+
Set the "raw" argument to true if you need the full, unprocessed response
|
52
|
+
(including headers, etc.).
|
53
|
+
|
54
|
+
```ruby
|
55
|
+
CompaniesHouseGateway.config[:raw] = true
|
56
|
+
CompaniesHouseGateway.name_search(...) # => Faraday::Response object
|
28
57
|
```
|
@@ -13,7 +13,8 @@ module CompaniesHouseGateway
|
|
13
13
|
data = self.class.default_inputs.merge(data)
|
14
14
|
check_params(data)
|
15
15
|
check_type = Util.underscore(Util.demodulize(self.class))
|
16
|
-
@client.perform_check(check_type, data)
|
16
|
+
response = @client.perform_check(check_type, data)
|
17
|
+
@client.config[:raw] ? response : response_body(response)
|
17
18
|
end
|
18
19
|
|
19
20
|
private
|
@@ -22,7 +23,7 @@ module CompaniesHouseGateway
|
|
22
23
|
self.class.required_inputs.each do |param|
|
23
24
|
if data[param].nil?
|
24
25
|
msg = "#{Util.demodulize(self.class)} requires a #{param}"
|
25
|
-
raise
|
26
|
+
raise InvalidRequestError.new(msg, param)
|
26
27
|
end
|
27
28
|
end
|
28
29
|
|
@@ -31,11 +32,15 @@ module CompaniesHouseGateway
|
|
31
32
|
msg = "#{Util.demodulize(self.class)} does not accept " +
|
32
33
|
"#{param}. Only the following inputs are permitted: " +
|
33
34
|
"#{self.class.allowed_inputs.to_a}"
|
34
|
-
raise
|
35
|
+
raise InvalidRequestError.new(msg, param)
|
35
36
|
end
|
36
37
|
end
|
37
38
|
end
|
38
39
|
|
40
|
+
def response_body(response)
|
41
|
+
response["GovTalkMessage"]["Body"][Util.demodulize(self.class)]
|
42
|
+
end
|
43
|
+
|
39
44
|
module ClassMethods
|
40
45
|
# Add one or more required arguments
|
41
46
|
def required_input(*inputs)
|
@@ -4,11 +4,11 @@ module CompaniesHouseGateway
|
|
4
4
|
include Check
|
5
5
|
|
6
6
|
required_input :company_name,
|
7
|
-
:company_number
|
8
|
-
:user_reference
|
7
|
+
:company_number
|
9
8
|
|
10
9
|
default_input continuation_key: nil,
|
11
|
-
include_resigned_ind: false
|
10
|
+
include_resigned_ind: false,
|
11
|
+
user_reference: "REFERENCE"
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
@@ -3,8 +3,20 @@ module CompaniesHouseGateway
|
|
3
3
|
class Document
|
4
4
|
include Check
|
5
5
|
|
6
|
-
required_input :doc_request_key
|
7
|
-
|
6
|
+
required_input :doc_request_key
|
7
|
+
|
8
|
+
default_input user_reference: "REFERENCE"
|
9
|
+
|
10
|
+
# Override response_body to include file URL details
|
11
|
+
def response_body(response)
|
12
|
+
body = response["GovTalkMessage"]["Body"]["Document"]
|
13
|
+
body["URL"] = response.fetch("GovTalkMessage").
|
14
|
+
fetch("Header").
|
15
|
+
fetch("MessageDetails").
|
16
|
+
fetch("ResponseEndPoint").
|
17
|
+
fetch("__content__")
|
18
|
+
body
|
19
|
+
end
|
8
20
|
end
|
9
21
|
end
|
10
22
|
end
|
@@ -4,13 +4,13 @@ module CompaniesHouseGateway
|
|
4
4
|
include Check
|
5
5
|
|
6
6
|
required_input :company_name,
|
7
|
-
:company_number
|
8
|
-
:user_reference
|
7
|
+
:company_number
|
9
8
|
|
10
9
|
default_input satisfied_charges_ind: false,
|
11
10
|
start_date: nil,
|
12
11
|
end_date: nil,
|
13
|
-
continuation_key: nil
|
12
|
+
continuation_key: nil,
|
13
|
+
user_reference: "REFERENCE"
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -3,10 +3,11 @@ module CompaniesHouseGateway
|
|
3
3
|
class OfficerDetails
|
4
4
|
include Check
|
5
5
|
|
6
|
-
required_input :person_id
|
7
|
-
|
6
|
+
required_input :person_id
|
7
|
+
|
8
|
+
default_input user_reference: "REFERENCE",
|
9
|
+
continuation_key: nil
|
8
10
|
|
9
|
-
default_input continuation_key: nil
|
10
11
|
end
|
11
12
|
end
|
12
13
|
end
|
@@ -3,11 +3,11 @@ module CompaniesHouseGateway
|
|
3
3
|
class OfficerSearch
|
4
4
|
include Check
|
5
5
|
|
6
|
-
required_input :surname
|
7
|
-
:officer_type
|
6
|
+
required_input :surname
|
8
7
|
|
9
8
|
default_input forename: nil,
|
10
9
|
post_town: nil,
|
10
|
+
officer_type: "CUR",
|
11
11
|
country_of_residence: nil,
|
12
12
|
continuation_key: nil,
|
13
13
|
include_resigned_ind: false
|
@@ -34,11 +34,12 @@ module CompaniesHouseGateway
|
|
34
34
|
}
|
35
35
|
}
|
36
36
|
|
37
|
-
Faraday.new(options) do |
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
37
|
+
Faraday.new(options) do |c|
|
38
|
+
c.response :check_ch_response unless @config[:raw] # Check XML
|
39
|
+
c.response :xml unless @config[:raw] # Parse response
|
40
|
+
c.response :follow_redirects, limit: 3 # Follow redirect
|
41
|
+
c.response :raise_error # Raise errors
|
42
|
+
c.adapter @config[:adapter]
|
42
43
|
end
|
43
44
|
end
|
44
45
|
end
|
@@ -4,5 +4,19 @@ module CompaniesHouseGateway
|
|
4
4
|
SUPPORTED_REQUESTS = %w(NameSearch NumberSearch CompanyAppointments
|
5
5
|
CompanyDetails OfficerSearch OfficerDetails
|
6
6
|
Mortgages FilingHistory DocumentInfo Document)
|
7
|
+
|
8
|
+
DATA_SETS = [
|
9
|
+
"LIVE", # Live companies and those dissolved in the last 12 months
|
10
|
+
"DISSOLVED", # Companies that have been dissolved in the last 20 years
|
11
|
+
"FORMER", # All previous company names from the last 20 years
|
12
|
+
"PROPOSED", # Proposed changes to the names of existing companies
|
13
|
+
].freeze
|
14
|
+
|
15
|
+
OFFICER_TYPES = [
|
16
|
+
"DIS", # Disqualified Directors only
|
17
|
+
"LLP", # Limited Liability Partnerships
|
18
|
+
"CUR", # Current (i.e., not above)
|
19
|
+
"EUR", # SE and ES appointments only
|
20
|
+
].freeze
|
7
21
|
end
|
8
22
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module CompaniesHouseGateway
|
2
|
+
module Middleware
|
3
|
+
class CheckResponse < Faraday::Middleware
|
4
|
+
def call(env)
|
5
|
+
@app.call(env).on_complete do |env|
|
6
|
+
response_body = env[:body]["GovTalkMessage"]
|
7
|
+
|
8
|
+
unless response_body && response_body["GovTalkDetails"]
|
9
|
+
raise InvalidResponseError.new(nil, env[:status], env)
|
10
|
+
end
|
11
|
+
|
12
|
+
if errors = response_body["GovTalkDetails"]["GovTalkErrors"]
|
13
|
+
errors = errors.values.flatten
|
14
|
+
messages = errors.map { |e| "(#{e['Number']}) #{e['Text']}" }
|
15
|
+
raise APIError.new(messages.join(" | "), env[:status], env)
|
16
|
+
end
|
17
|
+
|
18
|
+
response_values(env)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def response_values(env)
|
23
|
+
{ status: env[:status], headers: env[:headers], body: env[:body] }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
Faraday.register_middleware :response, check_ch_response: CheckResponse
|
28
|
+
end
|
29
|
+
end
|
@@ -83,7 +83,8 @@ module CompaniesHouseGateway
|
|
83
83
|
search_data.each do |key, value|
|
84
84
|
if value
|
85
85
|
element_name = Util.camelize(key).sub(/Id\z/, "ID")
|
86
|
-
|
86
|
+
cleaned_value = Validations.clean_param(key, value)
|
87
|
+
xml.send(element_name, cleaned_value)
|
87
88
|
end
|
88
89
|
end
|
89
90
|
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
module CompaniesHouseGateway
|
2
|
+
module Validations
|
3
|
+
|
4
|
+
VALIDATIONS = {
|
5
|
+
company_name: ->(value) { clean_string(value, :company_name) },
|
6
|
+
company_number: ->(value) { value }, # TODO!
|
7
|
+
partial_company_number: ->(value) { value }, # TODO!
|
8
|
+
give_mort_totals: ->(value) { clean_boolean(value, :give_mort_totals) },
|
9
|
+
search_rows: ->(value) { clean_number(value, :search_rows) },
|
10
|
+
data_set: ->(value) { clean_data_set(value) },
|
11
|
+
capital_doc_ind: ->(value) { clean_boolean(value, :capital_doc_ind) },
|
12
|
+
include_resigned_ind: ->(value) { clean_boolean(value, :include_resigned_ind) },
|
13
|
+
satisfied_charges_ind: ->(value) { clean_boolean(value, :satisfied_charges_ind) },
|
14
|
+
start_date: ->(value) { clean_date(value, :start_date) },
|
15
|
+
end_date: ->(value) { clean_date(value, :end_date) },
|
16
|
+
surname: ->(value) { clean_string(value, :surname) },
|
17
|
+
forename: ->(value) { clean_string(value, :forename) },
|
18
|
+
post_town: ->(value) { clean_string(value, :post_town) },
|
19
|
+
officer_type: ->(value) { clean_officer_type(value) },
|
20
|
+
}
|
21
|
+
|
22
|
+
def self.clean_param(key, value)
|
23
|
+
validator = VALIDATIONS.fetch(key, ->(value){ value })
|
24
|
+
validator.call(value)
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.clean_string(string, param)
|
28
|
+
return unless string
|
29
|
+
input_error(param, string) unless string =~ /\A.{0,160}\z/
|
30
|
+
string
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.clean_date(date, param)
|
34
|
+
return unless date
|
35
|
+
date = Date.parse(date) if date.is_a? String
|
36
|
+
date.strftime("%d/%m/%Y")
|
37
|
+
rescue
|
38
|
+
input_error(param, date)
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.clean_boolean(bool, param)
|
42
|
+
return unless bool
|
43
|
+
input_error(param, bool) unless [true, false].include?(bool)
|
44
|
+
bool
|
45
|
+
end
|
46
|
+
|
47
|
+
def self.clean_number(value, param)
|
48
|
+
return unless value
|
49
|
+
input_error(param, value) unless value.to_s =~ /\A\d+\z/
|
50
|
+
value.to_s
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.clean_data_set(value)
|
54
|
+
return unless value
|
55
|
+
value = value.to_s.upcase
|
56
|
+
input_error(:data_set, value) unless Constants::DATA_SETS.include?(value)
|
57
|
+
value
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.clean_officer_type(type)
|
61
|
+
return unless type
|
62
|
+
type = type.to_s.upcase
|
63
|
+
unless Constants::OFFICER_TYPES.include?(type)
|
64
|
+
input_error(:officer_type, type)
|
65
|
+
end
|
66
|
+
type
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.input_error(param, value=nil)
|
70
|
+
msg = if value.nil?
|
71
|
+
"#{param} is a required param"
|
72
|
+
else
|
73
|
+
%{Invalid value "#{value}" for #{param}}
|
74
|
+
end
|
75
|
+
raise InvalidRequestError.new(msg, param)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
@@ -4,11 +4,16 @@ require 'nokogiri'
|
|
4
4
|
require 'companies_house_gateway/version'
|
5
5
|
require 'companies_house_gateway/constants'
|
6
6
|
require 'companies_house_gateway/util'
|
7
|
+
require 'companies_house_gateway/validations'
|
7
8
|
require 'companies_house_gateway/config'
|
8
9
|
require 'companies_house_gateway/request'
|
9
10
|
require 'companies_house_gateway/client'
|
11
|
+
require 'companies_house_gateway/middleware/check_response'
|
10
12
|
|
11
13
|
require 'companies_house_gateway/errors/companies_house_gateway_error'
|
14
|
+
require 'companies_house_gateway/errors/invalid_request_error'
|
15
|
+
require 'companies_house_gateway/errors/invalid_response_error'
|
16
|
+
require 'companies_house_gateway/errors/api_error'
|
12
17
|
|
13
18
|
require 'companies_house_gateway/checks/check'
|
14
19
|
require 'companies_house_gateway/checks/name_search'
|
@@ -5,12 +5,12 @@ describe CompaniesHouseGateway::Checks::CompanyAppointments do
|
|
5
5
|
let(:check_data) do
|
6
6
|
{ company_name: "GoCardless",
|
7
7
|
company_number: "07495895",
|
8
|
-
user_reference:
|
8
|
+
user_reference: "REFERECE" }
|
9
9
|
end
|
10
10
|
|
11
|
-
it_behaves_like "it
|
11
|
+
it_behaves_like "it generates valid xml"
|
12
|
+
it_behaves_like "it returns only the body of the response"
|
12
13
|
it_behaves_like "it validates presence", :company_number
|
13
14
|
it_behaves_like "it validates presence", :company_name
|
14
|
-
it_behaves_like "it validates presence", :user_reference
|
15
15
|
end
|
16
16
|
end
|
@@ -4,7 +4,8 @@ describe CompaniesHouseGateway::Checks::CompanyDetails do
|
|
4
4
|
describe "#perform" do
|
5
5
|
let(:check_data) { { company_number: "07495895" } }
|
6
6
|
|
7
|
-
it_behaves_like "it
|
7
|
+
it_behaves_like "it generates valid xml"
|
8
|
+
it_behaves_like "it returns only the body of the response"
|
8
9
|
it_behaves_like "it validates presence", :company_number
|
9
10
|
end
|
10
11
|
end
|
@@ -8,7 +8,8 @@ describe CompaniesHouseGateway::Checks::DocumentInfo do
|
|
8
8
|
image_key: "asd121a" }
|
9
9
|
end
|
10
10
|
|
11
|
-
it_behaves_like "it
|
11
|
+
it_behaves_like "it generates valid xml"
|
12
|
+
it_behaves_like "it returns only the body of the response"
|
12
13
|
it_behaves_like "it validates presence", :company_name
|
13
14
|
it_behaves_like "it validates presence", :company_number
|
14
15
|
it_behaves_like "it validates presence", :image_key
|
@@ -2,10 +2,13 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe CompaniesHouseGateway::Checks::Document do
|
4
4
|
describe "#perform" do
|
5
|
-
let(:check_data)
|
5
|
+
let(:check_data) do
|
6
|
+
{ doc_request_key: "als123lkj123",
|
7
|
+
user_reference: "REFERECE" }
|
8
|
+
end
|
6
9
|
|
7
|
-
it_behaves_like "it
|
10
|
+
it_behaves_like "it generates valid xml"
|
11
|
+
it_behaves_like "it returns only the body of the response"
|
8
12
|
it_behaves_like "it validates presence", :doc_request_key
|
9
|
-
it_behaves_like "it validates presence", :user_reference
|
10
13
|
end
|
11
14
|
end
|
@@ -4,7 +4,8 @@ describe CompaniesHouseGateway::Checks::FilingHistory do
|
|
4
4
|
describe "#perform" do
|
5
5
|
let(:check_data) { { company_number: "07495895" } }
|
6
6
|
|
7
|
-
it_behaves_like "it
|
7
|
+
it_behaves_like "it generates valid xml"
|
8
|
+
it_behaves_like "it returns only the body of the response"
|
8
9
|
it_behaves_like "it validates presence", :company_number
|
9
10
|
end
|
10
11
|
end
|
@@ -5,12 +5,12 @@ describe CompaniesHouseGateway::Checks::Mortgages do
|
|
5
5
|
let(:check_data) do
|
6
6
|
{ company_name: "GoCardless",
|
7
7
|
company_number: "07495895",
|
8
|
-
user_reference: "
|
8
|
+
user_reference: "REFERECE" }
|
9
9
|
end
|
10
10
|
|
11
|
-
it_behaves_like "it
|
11
|
+
it_behaves_like "it generates valid xml"
|
12
|
+
it_behaves_like "it returns only the body of the response"
|
12
13
|
it_behaves_like "it validates presence", :company_name
|
13
14
|
it_behaves_like "it validates presence", :company_number
|
14
|
-
it_behaves_like "it validates presence", :user_reference
|
15
15
|
end
|
16
16
|
end
|
@@ -4,7 +4,8 @@ describe CompaniesHouseGateway::Checks::NameSearch do
|
|
4
4
|
describe "#perform" do
|
5
5
|
let(:check_data) { { company_name: "GoCardless", data_set: "LIVE" } }
|
6
6
|
|
7
|
-
it_behaves_like "it
|
7
|
+
it_behaves_like "it generates valid xml"
|
8
|
+
it_behaves_like "it returns only the body of the response"
|
8
9
|
it_behaves_like "it validates presence", :company_name
|
9
10
|
end
|
10
11
|
end
|
@@ -4,7 +4,8 @@ describe CompaniesHouseGateway::Checks::NumberSearch do
|
|
4
4
|
describe "#perform" do
|
5
5
|
let(:check_data) { { partial_company_number: "123", data_set: "LIVE" } }
|
6
6
|
|
7
|
-
it_behaves_like "it
|
7
|
+
it_behaves_like "it generates valid xml"
|
8
|
+
it_behaves_like "it returns only the body of the response"
|
8
9
|
it_behaves_like "it validates presence", :partial_company_number
|
9
10
|
end
|
10
11
|
end
|
@@ -4,8 +4,8 @@ describe CompaniesHouseGateway::Checks::OfficerDetails do
|
|
4
4
|
describe "#perform" do
|
5
5
|
let(:check_data) { { person_id: "alsdkj123", user_reference: 1 } }
|
6
6
|
|
7
|
-
it_behaves_like "it
|
7
|
+
it_behaves_like "it generates valid xml"
|
8
|
+
it_behaves_like "it returns only the body of the response"
|
8
9
|
it_behaves_like "it validates presence", :person_id
|
9
|
-
it_behaves_like "it validates presence", :user_reference
|
10
10
|
end
|
11
11
|
end
|
@@ -4,8 +4,8 @@ describe CompaniesHouseGateway::Checks::OfficerSearch do
|
|
4
4
|
describe "#perform" do
|
5
5
|
let(:check_data) { { surname: "Baker", officer_type: "DIS" } }
|
6
6
|
|
7
|
-
it_behaves_like "it
|
7
|
+
it_behaves_like "it generates valid xml"
|
8
|
+
it_behaves_like "it returns only the body of the response"
|
8
9
|
it_behaves_like "it validates presence", :surname
|
9
|
-
it_behaves_like "it validates presence", :officer_type
|
10
10
|
end
|
11
11
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
2
|
+
<GovTalkMessage xsi:schemaLocation="http://www.govtalk.gov.uk/CM/envelope http://xmlgw.companieshouse.gov.uk/v1-1/schema/Egov_ch-v2-0.xsd" xmlns="http://www.govtalk.gov.uk/CM/envelope" xmlns:dsig="http://www.w3.org/2000/09/xmldsig#" xmlns:gt="http://www.govtalk.gov.uk/schemas/govtalk/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
|
3
|
+
<EnvelopeVersion>1.0</EnvelopeVersion>
|
4
|
+
<Header>
|
5
|
+
<MessageDetails>
|
6
|
+
<Class>Document</Class>
|
7
|
+
<Qualifier>error</Qualifier>
|
8
|
+
<TransactionID>139335771961</TransactionID>
|
9
|
+
<GatewayTimestamp>2014-02-25T19:48:40-00:00</GatewayTimestamp>
|
10
|
+
</MessageDetails>
|
11
|
+
<SenderDetails>
|
12
|
+
<IDAuthentication>
|
13
|
+
<SenderID>XMLGatewayTestUserID</SenderID>
|
14
|
+
<Authentication>
|
15
|
+
<Method>CHMD5</Method>
|
16
|
+
<Value>760b2d181e070027c70761eaf1e93f05</Value>
|
17
|
+
</Authentication>
|
18
|
+
</IDAuthentication>
|
19
|
+
</SenderDetails>
|
20
|
+
</Header>
|
21
|
+
<GovTalkDetails>
|
22
|
+
<Keys/>
|
23
|
+
<GovTalkErrors>
|
24
|
+
<Error>
|
25
|
+
<RaisedBy>Document</RaisedBy>
|
26
|
+
<Number>604</Number>
|
27
|
+
<Type>fatal</Type>
|
28
|
+
<Text>Error text</Text>
|
29
|
+
<Location></Location>
|
30
|
+
</Error>
|
31
|
+
</GovTalkErrors>
|
32
|
+
</GovTalkDetails>
|
33
|
+
<Body>
|
34
|
+
</Body>
|
35
|
+
</GovTalkMessage>
|