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.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +16 -0
  3. data/README.md +32 -3
  4. data/lib/companies_house_gateway/checks/check.rb +8 -3
  5. data/lib/companies_house_gateway/checks/company_appointments.rb +3 -3
  6. data/lib/companies_house_gateway/checks/document.rb +14 -2
  7. data/lib/companies_house_gateway/checks/mortgages.rb +3 -3
  8. data/lib/companies_house_gateway/checks/name_search.rb +1 -2
  9. data/lib/companies_house_gateway/checks/number_search.rb +1 -2
  10. data/lib/companies_house_gateway/checks/officer_details.rb +4 -3
  11. data/lib/companies_house_gateway/checks/officer_search.rb +2 -2
  12. data/lib/companies_house_gateway/client.rb +6 -5
  13. data/lib/companies_house_gateway/constants.rb +14 -0
  14. data/lib/companies_house_gateway/errors/api_error.rb +4 -0
  15. data/lib/companies_house_gateway/errors/invalid_request_error.rb +10 -0
  16. data/lib/companies_house_gateway/errors/invalid_response_error.rb +4 -0
  17. data/lib/companies_house_gateway/middleware/check_response.rb +29 -0
  18. data/lib/companies_house_gateway/request.rb +2 -1
  19. data/lib/companies_house_gateway/validations.rb +78 -0
  20. data/lib/companies_house_gateway/version.rb +1 -1
  21. data/lib/companies_house_gateway.rb +5 -0
  22. data/spec/checks/company_appointments_spec.rb +3 -3
  23. data/spec/checks/company_details_spec.rb +2 -1
  24. data/spec/checks/document_info_spec.rb +2 -1
  25. data/spec/checks/document_spec.rb +6 -3
  26. data/spec/checks/filing_history_spec.rb +2 -1
  27. data/spec/checks/mortgages_spec.rb +3 -3
  28. data/spec/checks/name_search_spec.rb +2 -1
  29. data/spec/checks/number_search_spec.rb +2 -1
  30. data/spec/checks/officer_details_spec.rb +2 -2
  31. data/spec/checks/officer_search_spec.rb +2 -2
  32. data/spec/fixtures/bad_response.xml +35 -0
  33. data/spec/fixtures/check_responses/company_appointments.xml +319 -0
  34. data/spec/fixtures/check_responses/company_details.xml +62 -0
  35. data/spec/fixtures/check_responses/document.xml +32 -0
  36. data/spec/fixtures/check_responses/document_info.xml +34 -0
  37. data/spec/fixtures/check_responses/filing_history.xml +57 -0
  38. data/spec/fixtures/check_responses/mortgages.xml +107 -0
  39. data/spec/fixtures/check_responses/name_search.xml +101 -0
  40. data/spec/fixtures/check_responses/number_search.xml +36 -0
  41. data/spec/fixtures/check_responses/officer_details.xml +65 -0
  42. data/spec/fixtures/check_responses/officer_search.xml +90 -0
  43. data/spec/fixtures/{checks → check_schemas}/chbase.xsd +0 -0
  44. data/spec/fixtures/{checks → check_schemas}/company_appointments.xsd +0 -0
  45. data/spec/fixtures/{checks → check_schemas}/company_details.xsd +0 -0
  46. data/spec/fixtures/{checks → check_schemas}/document.xsd +0 -0
  47. data/spec/fixtures/{checks → check_schemas}/document_info.xsd +0 -0
  48. data/spec/fixtures/{checks → check_schemas}/filing_history.xsd +0 -0
  49. data/spec/fixtures/{checks → check_schemas}/mortgages.xsd +0 -0
  50. data/spec/fixtures/{checks → check_schemas}/name_search.xsd +0 -0
  51. data/spec/fixtures/{checks → check_schemas}/number_search.xsd +0 -0
  52. data/spec/fixtures/{checks → check_schemas}/officer_details.xsd +0 -0
  53. data/spec/fixtures/{checks → check_schemas}/officer_search.xsd +0 -0
  54. data/spec/fixtures/response.xml +56 -0
  55. data/spec/request_spec.rb +24 -3
  56. data/spec/shared_examples.rb +20 -3
  57. data/spec/validations_spec.rb +157 -0
  58. metadata +55 -24
@@ -0,0 +1,101 @@
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>NameSearch</Class>
7
+ <Qualifier>response</Qualifier>
8
+ <TransactionID>139337237538</TransactionID>
9
+ <GatewayTimestamp>2014-02-25T23:52:55-00:00</GatewayTimestamp>
10
+ </MessageDetails>
11
+ <SenderDetails>
12
+ <IDAuthentication>
13
+ <SenderID>XMLGatewayTestUserID</SenderID>
14
+ <Authentication>
15
+ <Method>CHMD5</Method>
16
+ <Value></Value>
17
+ </Authentication>
18
+ </IDAuthentication>
19
+ </SenderDetails>
20
+ </Header>
21
+ <GovTalkDetails>
22
+ <Keys/>
23
+ </GovTalkDetails>
24
+ <Body>
25
+ <NameSearch xmlns="http://xmlgw.companieshouse.gov.uk/v1-0/schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlgw.companieshouse.gov.uk/v1-0/schema http://xmlgw.companieshouse.gov.uk/v1-0/schema/NameSearch.xsd">
26
+ <ContinuationKey>deeab6eJyt0WtP2zAUBuByCQ2GwbiWMTZg4yYGUkFUjGqaNKOMIqCtCuv2zTKJRaK1SRSn0H7b+K38EN7jtYixj6PSU8UnOsdvbCs7xS3ORoUrXV95VXmlNLd/U8UPrnylUyqZyoiI8VhuNS9VYgpMyDjWqUxbmmYMeZc/VUfz/kwm08dG849+NC5UbTPrRHV4bqGcr5w7dadcKTvO8VHpwvx9Pa47KGCUcEPsw1kfWm2zr2n7fBg1YxkGSpeillbFIq3PlUxcv1h0H55LMvQaKtkVeZHf3zsofDwobDeCa9WLcRpJj+Y9DUnbyqbiObvXRl+tzcyLToxjuOXMEkl0o3luYIdaLOHJFC9+cZYV0k2DKOwuugdDi2HRlKnrP88ndIfVohvO+gs7dD5+kJp4zDKvqBSEnmqr3mUM/mm10dquUXr7js4iTtT1w5WMVelKanXH+VarVJ3bT0+D/jg7Pfr+b94vjdiXuPi/cv9X8wfKDJR9AAbBgiHIgg3DwGAEXsAYjMNLmIBJmIJpmIFZyMEcvIJ5eA0L8AbewiIswTK8g/ewAquwBuuwAZtAGbdg+x4YqdJr</ContinuationKey>
27
+ <RegressionKey>deeab6eJyt0WtP2zAUBuByCQ2GwbiWMTZg4yYGUkFUjGqaNKOMIqCtCuv2zTKJRaK1SRSn0H7b+K38EN7jtYixj6PSU8UnOsdvbCs7xS3ORoUrXV95VXmlNLd/U8UPrnylUyqZyoiI8VhuNS9VYgpMyDjWqUxbmmYMeZc/VUfz/kwm08dG849+NC5UbTPrRHV4bqGcr5w7dadcKTvO8VHpwvx9Pa47KGCUcEPsw1kfWm2zr2n7fBg1YxkGSpeillbFIq3PlUxcv1h0H55LMvQaKtkVeZHf3zsofDwobDeCa9WLcRpJj+Y9DUnbyqbiObvXRl+tzcyLToxjuOXMEkl0o3luYIdaLOHJFC9+cZYV0k2DKOwuugdDi2HRlKnrP88ndIfVohvO+gs7dD5+kJp4zDKvqBSEnmqr3mUM/mm10dquUXr7js4iTtT1w5WMVelKanXH+VarVJ3bT0+D/jg7Pfr+b94vjdiXuPi/cv9X8wfKDJR9AAbBgiHIgg3DwGAEXsAYjMNLmIBJmIJpmIFZyMEcvIJ5eA0L8AbewiIswTK8g/ewAquwBuuwAZtAGbdg+x4YqdJr</RegressionKey>
28
+ <SearchRows>10</SearchRows>
29
+ <CoSearchItem>
30
+ <CompanyName>OSERVE (EUROPE) LIMITED</CompanyName>
31
+ <CompanyNumber>05923212</CompanyNumber>
32
+ <DataSet>LIVE</DataSet>
33
+ <CompanyIndexStatus>DISSOLVED</CompanyIndexStatus>
34
+ <CompanyDate></CompanyDate>
35
+ </CoSearchItem>
36
+ <CoSearchItem>
37
+ <CompanyName>OSES LTD.</CompanyName>
38
+ <CompanyNumber>05517958</CompanyNumber>
39
+ <DataSet>LIVE</DataSet>
40
+ <CompanyIndexStatus>DISSOLVED</CompanyIndexStatus>
41
+ <CompanyDate></CompanyDate>
42
+ </CoSearchItem>
43
+ <CoSearchItem>
44
+ <CompanyName>OSE SECURITY SYSTEMS LTD</CompanyName>
45
+ <CompanyNumber>04405658</CompanyNumber>
46
+ <DataSet>LIVE</DataSet>
47
+ <CompanyIndexStatus></CompanyIndexStatus>
48
+ <CompanyDate></CompanyDate>
49
+ </CoSearchItem>
50
+ <CoSearchItem>
51
+ <CompanyName>OSE SOLUTIONS LTD</CompanyName>
52
+ <CompanyNumber>08032250</CompanyNumber>
53
+ <DataSet>LIVE</DataSet>
54
+ <CompanyIndexStatus></CompanyIndexStatus>
55
+ <CompanyDate></CompanyDate>
56
+ </CoSearchItem>
57
+ <CoSearchItem>
58
+ <CompanyName>OSE SOLUTIONS LTD</CompanyName>
59
+ <CompanyNumber>SC300065</CompanyNumber>
60
+ <DataSet>LIVE</DataSet>
61
+ <CompanyIndexStatus>DISSOLVED</CompanyIndexStatus>
62
+ <CompanyDate></CompanyDate>
63
+ </CoSearchItem>
64
+ <CoSearchItem>
65
+ <CompanyName>OSET LTD</CompanyName>
66
+ <CompanyNumber>06543966</CompanyNumber>
67
+ <DataSet>LIVE</DataSet>
68
+ <CompanyIndexStatus></CompanyIndexStatus>
69
+ <CompanyDate></CompanyDate>
70
+ </CoSearchItem>
71
+ <CoSearchItem>
72
+ <CompanyName>OSETALE LIMITED</CompanyName>
73
+ <CompanyNumber>06835401</CompanyNumber>
74
+ <DataSet>LIVE</DataSet>
75
+ <CompanyIndexStatus>DISSOLVED</CompanyIndexStatus>
76
+ <CompanyDate></CompanyDate>
77
+ </CoSearchItem>
78
+ <CoSearchItem>
79
+ <CompanyName>OSET BIKES LIMITED</CompanyName>
80
+ <CompanyNumber>06302289</CompanyNumber>
81
+ <DataSet>LIVE</DataSet>
82
+ <CompanyIndexStatus></CompanyIndexStatus>
83
+ <CompanyDate></CompanyDate>
84
+ </CoSearchItem>
85
+ <CoSearchItem>
86
+ <CompanyName>OSETEX LIMITED</CompanyName>
87
+ <CompanyNumber>06175964</CompanyNumber>
88
+ <DataSet>LIVE</DataSet>
89
+ <CompanyIndexStatus></CompanyIndexStatus>
90
+ <CompanyDate></CompanyDate>
91
+ </CoSearchItem>
92
+ <CoSearchItem>
93
+ <CompanyName>O SET (GB) LIMITED</CompanyName>
94
+ <CompanyNumber>07785966</CompanyNumber>
95
+ <DataSet>LIVE</DataSet>
96
+ <CompanyIndexStatus>DISSOLVED</CompanyIndexStatus>
97
+ <CompanyDate></CompanyDate>
98
+ </CoSearchItem>
99
+ </NameSearch>
100
+ </Body>
101
+ </GovTalkMessage>
@@ -0,0 +1,36 @@
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>NumberSearch</Class>
7
+ <Qualifier>response</Qualifier>
8
+ <TransactionID>139337250239</TransactionID>
9
+ <GatewayTimestamp>2014-02-25T23:55:02-00:00</GatewayTimestamp>
10
+ </MessageDetails>
11
+ <SenderDetails>
12
+ <IDAuthentication>
13
+ <SenderID>XMLGatewayTestUserID</SenderID>
14
+ <Authentication>
15
+ <Method>CHMD5</Method>
16
+ <Value></Value>
17
+ </Authentication>
18
+ </IDAuthentication>
19
+ </SenderDetails>
20
+ </Header>
21
+ <GovTalkDetails>
22
+ <Keys/>
23
+ </GovTalkDetails>
24
+ <Body>
25
+ <NumberSearch xmlns="http://xmlgw.companieshouse.gov.uk/v1-0/schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlgw.companieshouse.gov.uk/v1-0/schema http://xmlgw.companieshouse.gov.uk/v1-0/schema/NumberSearch.xsd">
26
+ <SearchRows>1</SearchRows>
27
+ <CoSearchItem>
28
+ <CompanyName>GOCARDLESS LTD</CompanyName>
29
+ <CompanyNumber>07495895</CompanyNumber>
30
+ <DataSet>LIVE</DataSet>
31
+ <CompanyIndexStatus></CompanyIndexStatus>
32
+ <CompanyDate></CompanyDate>
33
+ </CoSearchItem>
34
+ </NumberSearch>
35
+ </Body>
36
+ </GovTalkMessage>
@@ -0,0 +1,65 @@
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>OfficerDetails</Class>
7
+ <Qualifier>response</Qualifier>
8
+ <TransactionID>139337262380</TransactionID>
9
+ <GatewayTimestamp>2014-02-25T23:57:04-00:00</GatewayTimestamp>
10
+ </MessageDetails>
11
+ <SenderDetails>
12
+ <IDAuthentication>
13
+ <SenderID>XMLGatewayTestUserID</SenderID>
14
+ <Authentication>
15
+ <Method>CHMD5</Method>
16
+ <Value></Value>
17
+ </Authentication>
18
+ </IDAuthentication>
19
+ </SenderDetails>
20
+ </Header>
21
+ <GovTalkDetails>
22
+ <Keys/>
23
+ </GovTalkDetails>
24
+ <Body>
25
+ <OfficerDetails xmlns="http://xmlgw.companieshouse.gov.uk/v1-0/schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlgw.companieshouse.gov.uk/v1-0/schema http://xmlgw.companieshouse.gov.uk/v1-0/schema/OfficerDetails-v2-1.xsd">
26
+ <SearchRows>2</SearchRows>
27
+ <Person>
28
+ <Forename>DAVID</Forename>
29
+ <Surname>SMITH</Surname>
30
+ <Title></Title>
31
+ <DOB>1946-06-27</DOB>
32
+ <Nationality>BRITISH</Nationality>
33
+ <PersonAddress>
34
+ <AddressLine>FLAT 3 MILTON COURT ROAD</AddressLine>
35
+ <PostTown>LONDON</PostTown>
36
+ <Postcode>SE14 6JL</Postcode>
37
+ </PersonAddress>
38
+ <PersonID>CSeJxNkN1qg0AQhe/7FOJ9u2tT4hbGlZIfXJBUEnstVsd2SVzNrob49tUFG2+GM9+cwwwD4b2+ODfURjYqcL0X6jqoiqaU6idwv9L9M3OdkD/BGYex5m1rurzrDadAHs3Eu6FF7llqJZRSV41GldfIj2ITfRy3zindJdHuAGQ5nJym11YnkYhjkZysY4ajwVyFKqels4RzhtmQyazkn1UlC9RiC+QBoUWt+vqbU0rfV2/Me2VAZgYGc138pvZOsmzMIrZeecxn/mj4z5HpDX9njmly</PersonID>
39
+ </Person>
40
+ <ApptCount>
41
+ <NumCurrentAppt>0</NumCurrentAppt>
42
+ <NumDissolvedAppt>2</NumDissolvedAppt>
43
+ <NumResignedAppt>0</NumResignedAppt>
44
+ </ApptCount>
45
+ <OfficerAppt>
46
+ <CompanyName>FINEBO INTERNATIONAL LTD</CompanyName>
47
+ <CompanyNumber>03598690</CompanyNumber>
48
+ <CompanyStatus>Dissolved</CompanyStatus>
49
+ <AppointmentStatus>CURRENT</AppointmentStatus>
50
+ <AppointmentType>SEC</AppointmentType>
51
+ <AppointmentDate>1999-10-08</AppointmentDate>
52
+ <Occupation>SECRETARY</Occupation>
53
+ </OfficerAppt>
54
+ <OfficerAppt>
55
+ <CompanyName>FINEBO INTERNATIONAL LTD</CompanyName>
56
+ <CompanyNumber>03598690</CompanyNumber>
57
+ <CompanyStatus>Dissolved</CompanyStatus>
58
+ <AppointmentStatus>CURRENT</AppointmentStatus>
59
+ <AppointmentType>DIR</AppointmentType>
60
+ <AppointmentDate>1999-10-08</AppointmentDate>
61
+ <Occupation>SECRETARY</Occupation>
62
+ </OfficerAppt>
63
+ </OfficerDetails>
64
+ </Body>
65
+ </GovTalkMessage>
@@ -0,0 +1,90 @@
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>OfficerSearch</Class>
7
+ <Qualifier>response</Qualifier>
8
+ <TransactionID>139337270489</TransactionID>
9
+ <GatewayTimestamp>2014-02-25T23:58:26-00:00</GatewayTimestamp>
10
+ </MessageDetails>
11
+ <SenderDetails>
12
+ <IDAuthentication>
13
+ <SenderID>XMLGatewayTestUserID</SenderID>
14
+ <Authentication>
15
+ <Method>CHMD5</Method>
16
+ <Value></Value>
17
+ </Authentication>
18
+ </IDAuthentication>
19
+ </SenderDetails>
20
+ </Header>
21
+ <GovTalkDetails>
22
+ <Keys/>
23
+ </GovTalkDetails>
24
+ <Body>
25
+ <OfficerSearch xmlns="http://xmlgw.companieshouse.gov.uk/v1-0/schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlgw.companieshouse.gov.uk/v1-0/schema http://xmlgw.companieshouse.gov.uk/v1-0/schema/OfficerSearch-v2-3.xsd">
26
+ <ContinuationKey>8b04caeJyl0d9v0zAQB/DCSJt5RQwGlN8wGD+GFCm0WWF59B4oYmxoA8Gb5caXJdqahDgR9A34y/meh0Q18YBEpI8U++zz+ez11qQnRV8lOsnIvNdHZKX/Qwpf6apq5hVJ0eF4lh9lZBte4OIrqsLvXjubUu0mBG+wjW7a0wRdMz2muZXnO53OOdEPFz7OV9A3l+wtzeUA0VEYRltRtD1GtKuSAom5MN8d4xbt7ZSzShc52UnZWorj/TTNE6oPSddJFsfl4nCiC3OCwSxvMjXJ6/I4V2HwtyJ2S204/9kSuQg9Iy6ip1L+HbpWeKptcyPFxigKo/RVqgMKaRxsj4YmSIeUBBGZl1tTGk0pHEuxrKrSNk35tVjI9EIOuqdF8Q1tW7uThOfK5SmT2y9vCiP979xp6670gR/D44xpWZPb8SdLX/2+vls1WNr5ePAzPtuwz+92X3/6p779x9ZNfm/gd1+CC+BBF3rgwzIIWIE+XIRLsAqX4QqswVW4BtdhADfgJtyC23AH7sI9uA8PYB0ewiPYgMfwBJ7CM+D6nv8CZq68RQ==</ContinuationKey>
27
+ <SearchRows>28</SearchRows>
28
+ <OfficerSearchItem>
29
+ <Title>,MRS</Title>
30
+ <Surname>SMITH</Surname>
31
+ <Forename>HILARY SALLY LOUISE</Forename>
32
+ <DOB>1951-10-04</DOB>
33
+ <PostTown>MINEHEAD</PostTown>
34
+ <Postcode>TA24 </Postcode>
35
+ <CountryOfResidence>UNITED KINGDOM</CountryOfResidence>
36
+ <PersonID>CSeJxNkMtugzAQRff9CsS6FGNoAMlxFKmtQCKKFMgiK8RjSC3CozZU5e+LIYRsrLnn3PFiyO6vuim/wAVr6q1qvCFVgTprclZft+o5+tIcVdnRF1LCML5J24ou6XpBDaKvQfJuaIFOcJ5yxos6qcCgHuNNyYi+kofEdMV4xg0HmajnB/vTRQn3QXBRguPZDz/n7lKQbdHzaQ4PfuRNeiHSdqy7AX09nMJJzXEU4sevc4oknEdSxhAPMYtzeiwKlgH3P4i+QtImV5AXMC1kFU6RaIBgo7kmzrUCQ6ZZkNvvKZgpoA3RlzZpgdd9lVITIdNykWnYo7wzIiDh2Xc0n+05iKc1bLsOws5YeOzp8ut/KKOWCQ==</PersonID>
37
+ </OfficerSearchItem>
38
+ <OfficerSearchItem>
39
+ <Title></Title>
40
+ <Surname>SMITH</Surname>
41
+ <Forename>HILARY THERESE</Forename>
42
+ <DOB>1943-09-21</DOB>
43
+ <PostTown>CHELMSFORD</PostTown>
44
+ <Postcode>CM1 </Postcode>
45
+ <CountryOfResidence>UNITED KINGDOM</CountryOfResidence>
46
+ <PersonID>CSeJxNkEtvgzAQhO/9FYg7xTwCieQ4qlQqkFpVSuihJ2TwOrUIj9pQlX/fGIfQizXzzXilXXz4bS7WD0glunZve4/ItqCtOiba897+yF+crW0dyAOuYbq+tO/VQIdREQ+7q9F8mHogMzSKCclb2oBHUiG7WmB3JffQJyv2De4kaEfS7PXp+GnlaXJMTompLZkuqlHO+vSW5ekcL0SngxguYIbfJBPqO2sZQRoaiesCiqkQBSPvnIsKZPaM3RXinp5BLx6EKORbTh1AEDm7wGcO96FyQmDxpoSgBBRhd2njHmQ7NiXZRX7keddLLQAroLL6ys2p/hu1VDwUx0Ecba7x/Zerp/4BtBeSjg==</PersonID>
47
+ </OfficerSearchItem>
48
+ <OfficerSearchItem>
49
+ <Title>,MISS</Title>
50
+ <Surname>SMITH</Surname>
51
+ <Forename>HILARY ZOE</Forename>
52
+ <DOB>1965-07-31</DOB>
53
+ <PostTown>LONDON</PostTown>
54
+ <Postcode>N4 </Postcode>
55
+ <CountryOfResidence>ENGLAND</CountryOfResidence>
56
+ <PersonID>CSeJxNkF1PgzAYhe/9FYRrkfIxBknXxUQNJC5LZF7oDSn0ZTaMD1sw8u8tVMZumnOec943bfH+t74YPyAkb5ud6Twg04CmaBlvzjvz/fRihaaxJ3e4glGdtOtkT/tBEgfbq5l4P3ZAZqgV46JsaA0OibloK47tlVxDl6zY1bgVMDkSJ6+Pbx/G5/FZVxY+leQgZp0eklM8xwuZ0p73FyD3hyRN50x7lcjvpGEETVBLXGWQjRnPGDmWJS9AJE/YXiHu6Bmml3s+8suwpBYgCKzIc5lVulBYPrDtJgcvBxRge2njDkQz1DnxEPI3W+SjUIX/DEugovg66e+6NfJmzAuCKPLV2BWqe6nVfwhVk9U=</PersonID>
57
+ </OfficerSearchItem>
58
+ <OfficerSearchItem>
59
+ <Title>,MISS</Title>
60
+ <Surname>SMITH</Surname>
61
+ <Forename>HILARY ZOE</Forename>
62
+ <DOB></DOB>
63
+ <PostTown>LONDON</PostTown>
64
+ <Postcode>N4 </Postcode>
65
+ <PersonID>CSeJxNkF1rgzAUhu/3K8TrOeNnK6Qpg20orBRmd7HdSNSTLlijS3TMfz+js/YmnPd53hNI8P63vhg/IBVvxM50HpBpgCiakovzznw/vVhb09iTO1zBMJ60bVVHu14RB9tr0LwbWiATnKeSSyZoDQ6JuWwqju2VXKVLVuzOuJGgE4mT18e3D+Pz+DxXFq5LqpfTnB6SUzzphWjb8e4C5P6QpOnk5jwa9Z2IkiAN5xFXGWRDxrOSHBnjBcjkCdsrxC09g3655yOfbRm1AEFoRZ5bWsyFwvKh3AQ5eDmgENtLG7cgRV/nxEPIDzbId/xR/jOsgMri6zR/121QN2teGEZR4I2F656tr/4DBzSTzg==</PersonID>
66
+ </OfficerSearchItem>
67
+ <OfficerSearchItem>
68
+ <Title></Title>
69
+ <Surname>SMITH</Surname>
70
+ <Forename>HILDA</Forename>
71
+ <DOB>1954-05-29</DOB>
72
+ <PostTown>GLASGOW</PostTown>
73
+ <Postcode>G3 </Postcode>
74
+ <CountryOfResidence>SCOTLAND</CountryOfResidence>
75
+ <PersonID>CSeJxNkMFuhCAQhu99CuPdCmK3a8KyabJpNGnTQ+3ZoAxb4ooWtKlvX9F13Qv55/tgMgw9/jUX7xeMVa0++PgR+R7oqhVKnw/+V/4a7H3vyB5oDeN08q6zPe8HyzANt8LxfuyAzXBJQhmpeQOYpcq0taLhRm4yYhuOFtwacBVLs7fTy2JX5LwdzJw/37M8nfVKnO1Vf4Gl5zUKZX8yLRhycIm0LqAYC1UI9iGlqsBkJxpukHb8DO6/JEax3EseAIJdkJBIBDKCKohBPD+VQEpAOxqut2kHRg9NyQhCGO8Jwskkr4xa4Kb6zpcl3Rf27hlKooSQabU3OM01tf4Hxi+Q4Q==</PersonID>
76
+ <DuplicateOfficers>
77
+ <DuplicateOfficerSearchItem>
78
+ <Title></Title>
79
+ <Surname>SMITH</Surname>
80
+ <Forename>HILDA</Forename>
81
+ <DOB>1954-05-29</DOB>
82
+ <PostTown>PRESTWICK</PostTown>
83
+ <Postcode>KA9 </Postcode>
84
+ <CountryOfResidence>SCOTLAND</CountryOfResidence>
85
+ </DuplicateOfficerSearchItem>
86
+ </DuplicateOfficers>
87
+ </OfficerSearchItem>
88
+ </OfficerSearch>
89
+ </Body>
90
+ </GovTalkMessage>
File without changes
@@ -0,0 +1,56 @@
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>CompanyAppointments</Class>
7
+ <Qualifier>response</Qualifier>
8
+ <TransactionID>139335957980</TransactionID>
9
+ <GatewayTimestamp>2014-02-25T20:19:40-00:00</GatewayTimestamp>
10
+ </MessageDetails>
11
+ <SenderDetails>
12
+ <IDAuthentication>
13
+ <SenderID>XMLGatewayTestUserID</SenderID>
14
+ <Authentication>
15
+ <Method>CHMD5</Method>
16
+ <Value></Value>
17
+ </Authentication>
18
+ </IDAuthentication>
19
+ </SenderDetails>
20
+ </Header>
21
+ <GovTalkDetails>
22
+ <Keys/>
23
+ </GovTalkDetails>
24
+ <Body>
25
+ <CompanyAppointments xmlns="http://xmlgw.companieshouse.gov.uk/v1-0/schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlgw.companieshouse.gov.uk/v1-0/schema http://xmlgw.companieshouse.gov.uk/v1-0/schema/CompanyAppointments-v2-1.xsd">
26
+ <CompanyName>MILLENNIUM STADIUM PLC</CompanyName>
27
+ <CompanyNumber>03176906</CompanyNumber>
28
+ <NumCurrentAppt>12</NumCurrentAppt>
29
+ <NumResignedAppt>34</NumResignedAppt>
30
+ <SearchRows>12</SearchRows>
31
+ <CoAppt>
32
+ <Person>
33
+ <Forename>RICHARD STEPHEN</Forename>
34
+ <Surname>PHILLIPS</Surname>
35
+ <Title></Title>
36
+ <DOB>1964-04-01</DOB>
37
+ <Nationality>BRITISH</Nationality>
38
+ <CountryOfResidence>UK</CountryOfResidence>
39
+ <PersonAddress>
40
+ <AddressLine>BEDWEN NEWTOWN</AddressLine>
41
+ <PostTown>AMMANFORD</PostTown>
42
+ <County>CARMARTHENSHIRE</County>
43
+ <Country></Country>
44
+ <Postcode>SA18 3TE</Postcode>
45
+ </PersonAddress>
46
+ <PersonID>CSeJxNkN1qg0AQhe/7FOJ9u2tT4hbGlZIfXJBUEnstVsd2SVzNrob49tUFG2+GM9+cwwwD4b2+ODfURjYqcL0X6jqoiqaU6idwv9L9M3OdkD/BGYex5m1rurzrDadAHs3Eu6FF7llqJZRSV41GldfIj2ITfRy3zindJdHuAGQ5nJym11YnkYhjkZysY4ajwVyFKqels4RzhtmQyazkn1UlC9RiC+QBoUWt+vqbU0rfV2/Me2VAZgYGc138pvZOsmzMIrZeecxn/mj4z5HpDX9njmly</PersonID>
47
+ </Person>
48
+ <NumAppointments>16</NumAppointments>
49
+ <AppointmentType>SEC</AppointmentType>
50
+ <AppointmentStatus>CURRENT</AppointmentStatus>
51
+ <AppointmentDate>2009-08-27</AppointmentDate>
52
+ <Occupation>GROUP FINANCE DIRECTOR</Occupation>
53
+ </CoAppt>
54
+ </CompanyAppointments>
55
+ </Body>
56
+ </GovTalkMessage>
data/spec/request_spec.rb CHANGED
@@ -9,8 +9,10 @@ describe CompaniesHouseGateway::Request do
9
9
 
10
10
  let(:response_hash) { { status: status, body: body } }
11
11
  let(:status) { 200 }
12
- let(:body) { "<Results><Errors/></Results>" }
13
- before { stub_request(:post, config[:api_endpoint]).to_return(response_hash) }
12
+ let(:body) { load_fixture('response.xml') }
13
+ before do
14
+ stub_request(:post, config[:api_endpoint]).to_return(response_hash)
15
+ end
14
16
 
15
17
  let(:request_type) { :name_search }
16
18
  let(:request_data) { {} }
@@ -51,7 +53,7 @@ describe CompaniesHouseGateway::Request do
51
53
 
52
54
  context "when the config[:raw] is false" do
53
55
  it { should be_a Hash }
54
- it { should include "Results" }
56
+ it { should include "GovTalkMessage" }
55
57
 
56
58
  context "errors" do
57
59
  context "500" do
@@ -71,6 +73,25 @@ describe CompaniesHouseGateway::Request do
71
73
  to raise_error CompaniesHouseGateway::CompaniesHouseGatewayError
72
74
  end
73
75
  end
76
+
77
+ context "200 with an error from Companies House" do
78
+ let(:body) { load_fixture('bad_response.xml') }
79
+
80
+ it "wraps the error" do
81
+ expect { perform_check }.
82
+ to raise_error(
83
+ CompaniesHouseGateway::APIError, "(604) Error text")
84
+ end
85
+ end
86
+
87
+ context "200 with unexpected XML" do
88
+ let(:body) { "<TopLevel></TopLevel>" }
89
+
90
+ it "wraps the error" do
91
+ expect { perform_check }.
92
+ to raise_error CompaniesHouseGateway::InvalidResponseError
93
+ end
94
+ end
74
95
  end
75
96
  end
76
97
  end
@@ -8,12 +8,12 @@ shared_examples 'it validates presence' do |property|
8
8
 
9
9
  it "raises and error" do
10
10
  expect { perform_check }.
11
- to raise_error CompaniesHouseGateway::CompaniesHouseGatewayError
11
+ to raise_error CompaniesHouseGateway::InvalidRequestError
12
12
  end
13
13
  end
14
14
  end
15
15
 
16
- shared_examples 'it generates_valid_xml' do
16
+ shared_examples 'it generates valid xml' do
17
17
  let(:request) { CompaniesHouseGateway::Request.new(connection, config) }
18
18
  let(:client) { CompaniesHouseGateway::Client.new(config) }
19
19
  let(:config) { CompaniesHouseGateway::Config.new }
@@ -28,7 +28,7 @@ shared_examples 'it generates_valid_xml' do
28
28
  end
29
29
 
30
30
  let(:xsd_path) do
31
- fixture_path('checks',
31
+ fixture_path('check_schemas',
32
32
  "#{CompaniesHouseGateway::Util.underscore(klass)}.xsd")
33
33
  end
34
34
  let(:xsd_doc) { Nokogiri::XML(File.read(xsd_path), xsd_path) }
@@ -37,4 +37,21 @@ shared_examples 'it generates_valid_xml' do
37
37
  it "generates a valid XML request" do
38
38
  xsd.validate(request_xml).should == []
39
39
  end
40
+ end
41
+
42
+ shared_examples 'it returns only the body of the response' do
43
+ let(:client) { CompaniesHouseGateway::Client.new(config) }
44
+ let(:config) { CompaniesHouseGateway::Config.new }
45
+ let(:klass) { described_class.name.split("::").last }
46
+ let(:response) { { status: 200, body: body } }
47
+ let(:body) do
48
+ load_fixture('check_responses',
49
+ "#{CompaniesHouseGateway::Util.underscore(klass)}.xml")
50
+ end
51
+ before { stub_request(:post, config[:api_endpoint]).to_return(response) }
52
+ subject { described_class.new(client).perform(check_data) }
53
+
54
+ it { should be_a Hash }
55
+ it { should_not be_empty }
56
+ it { should_not include klass }
40
57
  end
@@ -0,0 +1,157 @@
1
+ require 'spec_helper'
2
+
3
+ describe CompaniesHouseGateway::Validations do
4
+ describe '#clean_string' do
5
+ subject { CompaniesHouseGateway::Validations.clean_string(string, :param) }
6
+
7
+ context "without a string" do
8
+ let(:string) { nil }
9
+ it { should == nil }
10
+ end
11
+
12
+ context "with a short string" do
13
+ let(:string) { "A" * 160 }
14
+ it { should == string }
15
+ end
16
+
17
+ context "with a long string" do
18
+ let(:string) { "A" * 161 }
19
+ it "raises an error" do
20
+ expect { subject }.
21
+ to raise_error CompaniesHouseGateway::InvalidRequestError
22
+ end
23
+ end
24
+ end
25
+
26
+ describe '#clean_date' do
27
+ subject { CompaniesHouseGateway::Validations.clean_date(date, :param) }
28
+
29
+ context "without a date" do
30
+ let(:date) { nil }
31
+ it { should == nil }
32
+ end
33
+
34
+ context "with a date object" do
35
+ let(:date) { Date.parse("01/01/2000") }
36
+ it { should == date.strftime("%d/%m/%Y") }
37
+ end
38
+
39
+ context "with a parseable string" do
40
+ let(:date) { "01-01-2000" }
41
+ it { should == "01/01/2000" }
42
+ end
43
+
44
+ context "with a load of rubbish" do
45
+ let(:date) { "A couple of weeks ago" }
46
+ it "raises an error" do
47
+ expect { subject }.
48
+ to raise_error CompaniesHouseGateway::InvalidRequestError
49
+ end
50
+ end
51
+ end
52
+
53
+ describe '#clean_boolean' do
54
+ subject { CompaniesHouseGateway::Validations.clean_boolean(bool, :param) }
55
+
56
+ context "without a boolean" do
57
+ let(:bool) { nil }
58
+ it { should == nil }
59
+ end
60
+
61
+ context "with a boolean" do
62
+ let(:bool) { true }
63
+ it { should == bool }
64
+ end
65
+
66
+ context "with a load of rubbish" do
67
+ let(:bool) { "Sometimes" }
68
+ it "raises an error" do
69
+ expect { subject }.
70
+ to raise_error CompaniesHouseGateway::InvalidRequestError
71
+ end
72
+ end
73
+ end
74
+
75
+ describe '#clean_number' do
76
+ subject { CompaniesHouseGateway::Validations.clean_number(number, :param) }
77
+
78
+ context "without a number" do
79
+ let(:number) { nil }
80
+ it { should == nil }
81
+ end
82
+
83
+ context "with a number" do
84
+ let(:number) { 9 }
85
+ it { should == number.to_s }
86
+ end
87
+
88
+ context "with a string that looks like a number" do
89
+ let(:number) { "91" }
90
+ it { should == number }
91
+ end
92
+
93
+ context "with a load of rubbish" do
94
+ let(:number) { "Ninety five" }
95
+ it "raises an error" do
96
+ expect { subject }.
97
+ to raise_error CompaniesHouseGateway::InvalidRequestError
98
+ end
99
+ end
100
+ end
101
+
102
+ describe '#clean_data_set' do
103
+ subject { CompaniesHouseGateway::Validations.clean_data_set(data_set) }
104
+
105
+ context "without a data_set" do
106
+ let(:data_set) { nil }
107
+ it { should == nil }
108
+ end
109
+
110
+ context "with a valid symbol" do
111
+ let(:data_set) { :live }
112
+ it { should == "LIVE" }
113
+ end
114
+
115
+ context "with a valid string" do
116
+ let(:data_set) { "LIVE" }
117
+ it { should == "LIVE" }
118
+ end
119
+
120
+ context "with a load of rubbish" do
121
+ let(:data_set) { "ALL THE DATAS!!" }
122
+ it "raises an error" do
123
+ expect { subject }.
124
+ to raise_error CompaniesHouseGateway::InvalidRequestError
125
+ end
126
+ end
127
+ end
128
+
129
+ describe '#clean_officer_type' do
130
+ subject do
131
+ CompaniesHouseGateway::Validations.clean_officer_type(officer_type)
132
+ end
133
+
134
+ context "without an officer_type" do
135
+ let(:officer_type) { nil }
136
+ it { should == nil }
137
+ end
138
+
139
+ context "with a valid symbol" do
140
+ let(:officer_type) { :dis }
141
+ it { should == "DIS" }
142
+ end
143
+
144
+ context "with a valid string" do
145
+ let(:officer_type) { "DIS" }
146
+ it { should == "DIS" }
147
+ end
148
+
149
+ context "with a load of rubbish" do
150
+ let(:officer_type) { "ALL THE DATAS!!" }
151
+ it "raises an error" do
152
+ expect { subject }.
153
+ to raise_error CompaniesHouseGateway::InvalidRequestError
154
+ end
155
+ end
156
+ end
157
+ end