defra_ruby_mocks 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +32 -3
- data/app/controllers/defra_ruby_mocks/company_controller.rb +8 -1
- data/app/services/defra_ruby_mocks/companies_house_service.rb +12 -2
- data/app/views/defra_ruby_mocks/company/officers.json.erb +26 -0
- data/app/views/defra_ruby_mocks/company/show.json.erb +10 -1
- data/config/routes.rb +5 -0
- data/lib/defra_ruby_mocks/version.rb +1 -1
- data/spec/dummy/log/test.log +2095 -350
- data/spec/examples.txt +106 -91
- data/spec/requests/company_spec.rb +13 -2
- data/spec/requests/officers_spec.rb +37 -0
- data/spec/services/companies_house_service_spec.rb +28 -6
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc69209c2d4b90b3726d7486bb0f4f0f001d80aff649951f4e8eaa5e17e46cec
|
4
|
+
data.tar.gz: 2f8ca2c6731b2d0eae695e7aeae936c20288480bf758c4f16fcdcf3a27f70067
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed7a96c4eb66607adbe341b441181b339b60e28cf1d66e92e1eb6467606d82676110efc587d921a309fec419c472095a82c7b1b1bb8ebbff64740182c38723f4
|
7
|
+
data.tar.gz: f9b8847f14ac049e9b1cef302cfbe8893c6b56797e5f48e6b6548f939c16f923111c2f79be4023ab8c1c5a62aa91db10eebfc73b797de9feb7326798a65af215
|
data/README.md
CHANGED
@@ -71,14 +71,38 @@ The project currently mocks the following services.
|
|
71
71
|
|
72
72
|
When mounted into an app you can make requests to `/mocks/company/[company number]` to get a response that matches what our apps expect.
|
73
73
|
|
74
|
-
This is an important distinction to note. When our apps like the [Waste Exemptions front office](https://github.com/DEFRA/waste-exemptions-front-office) make a real request to Companies House, they get a lot more information back in the JSON reponse. However the only
|
74
|
+
This is an important distinction to note. When our apps like the [Waste Exemptions front office](https://github.com/DEFRA/waste-exemptions-front-office) make a real request to Companies House, they get a lot more information back in the JSON reponse. However the only things they are interested in are the value of `"company_name"`, `"company_status"`, `"company_type"` and `"registered_office"`, .
|
75
75
|
|
76
|
-
So rather than maintain a lot of unused JSON data, the mock just returns
|
76
|
+
So rather than maintain a lot of unused JSON data, the mock just returns those bits of the JSON.
|
77
77
|
|
78
78
|
```bash
|
79
79
|
curl http://localhost:3000/mocks/company/SC123456
|
80
80
|
{
|
81
|
-
"
|
81
|
+
"company_name": "Acme Industries",
|
82
|
+
"company_status": "active",
|
83
|
+
"company_type": "ltd",
|
84
|
+
"registered_office_address": {
|
85
|
+
"address_line_1": "10 Downing St",
|
86
|
+
"address_line_2": "Horizon House",
|
87
|
+
"locality": "Bristol",
|
88
|
+
"postal_code": "BS1 5AH"
|
89
|
+
}
|
90
|
+
}
|
91
|
+
```
|
92
|
+
|
93
|
+
Additionally, an Officers endpoint is available at `/mocks/company/[company number]/officers`. This returns a list of partial Officer data, eg:
|
94
|
+
```bash
|
95
|
+
curl http://localhost:3000/mocks/company/SC123456/officers
|
96
|
+
{
|
97
|
+
"items": [
|
98
|
+
{
|
99
|
+
"name": "APPLE, Alice",
|
100
|
+
"officer_role": "director"
|
101
|
+
},
|
102
|
+
{
|
103
|
+
"name": "BANANA, Bob",
|
104
|
+
"officer_role": "director"
|
105
|
+
},...
|
82
106
|
}
|
83
107
|
```
|
84
108
|
|
@@ -99,6 +123,11 @@ The exceptions to this are the 'special' numbers listed below. Use them if you a
|
|
99
123
|
- `33333333` will return `"open"`
|
100
124
|
- `22222222` will return `"closed"`
|
101
125
|
|
126
|
+
Additionally, an `"active"` LLP company can be retrieved by using the following registration numbers:
|
127
|
+
|
128
|
+
- `XX999999`
|
129
|
+
- `YY999999`
|
130
|
+
|
102
131
|
The list of possible statuses was taken from
|
103
132
|
|
104
133
|
- [Companies House API](https://developer.companieshouse.gov.uk/api/docs/company/company_number/companyProfile-resource.html)
|
@@ -6,13 +6,20 @@ module DefraRubyMocks
|
|
6
6
|
before_action :set_default_response_format
|
7
7
|
|
8
8
|
def show
|
9
|
-
|
9
|
+
service = CompaniesHouseService.run(params[:id])
|
10
|
+
|
11
|
+
@company_status = service.company_status
|
12
|
+
@company_type = service.company_type
|
10
13
|
|
11
14
|
respond_to :json
|
12
15
|
rescue NotFoundError
|
13
16
|
render "not_found", status: 404
|
14
17
|
end
|
15
18
|
|
19
|
+
def officers
|
20
|
+
respond_to :json
|
21
|
+
end
|
22
|
+
|
16
23
|
private
|
17
24
|
|
18
25
|
def set_default_response_format
|
@@ -31,15 +31,22 @@ module DefraRubyMocks
|
|
31
31
|
}
|
32
32
|
end
|
33
33
|
|
34
|
+
def self.llp_company_numbers
|
35
|
+
%w[XX999999 YY999999]
|
36
|
+
end
|
37
|
+
|
34
38
|
def run(company_number)
|
35
39
|
raise NotFoundError unless valid_company_number?(company_number)
|
36
40
|
raise NotFoundError if company_number == NOT_FOUND
|
37
41
|
|
38
|
-
|
42
|
+
@company_status = specials[company_number] || "active"
|
43
|
+
@company_type = llps.include?(company_number) ? "llp" : "ltd"
|
39
44
|
|
40
|
-
|
45
|
+
self
|
41
46
|
end
|
42
47
|
|
48
|
+
attr_reader :company_status, :company_type
|
49
|
+
|
43
50
|
private
|
44
51
|
|
45
52
|
def valid_company_number?(company_number)
|
@@ -50,5 +57,8 @@ module DefraRubyMocks
|
|
50
57
|
self.class.special_company_numbers
|
51
58
|
end
|
52
59
|
|
60
|
+
def llps
|
61
|
+
self.class.llp_company_numbers
|
62
|
+
end
|
53
63
|
end
|
54
64
|
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
// https://developer-specs.company-information.service.gov.uk/companies-house-public-data-api/resources/officerlist
|
2
|
+
{
|
3
|
+
"items": [
|
4
|
+
{
|
5
|
+
"name": "APPLE, Alice",
|
6
|
+
"officer_role": "director"
|
7
|
+
},
|
8
|
+
{
|
9
|
+
"name": "BANANA, Bob",
|
10
|
+
"officer_role": "director"
|
11
|
+
},
|
12
|
+
{
|
13
|
+
"name": "CARROT, Charlie",
|
14
|
+
"officer_role": "director",
|
15
|
+
"resigned_on": "2020-01-21"
|
16
|
+
},
|
17
|
+
{
|
18
|
+
"name": "DONUT, Dave Dickie",
|
19
|
+
"officer_role": "llp-member"
|
20
|
+
},
|
21
|
+
{
|
22
|
+
"name": "ENDIVE, Eve Marie",
|
23
|
+
"officer_role": "llp-designated-member"
|
24
|
+
}
|
25
|
+
]
|
26
|
+
}
|
@@ -1,3 +1,12 @@
|
|
1
|
+
// https://developer-specs.company-information.service.gov.uk/companies-house-public-data-api/resources/companyprofile
|
1
2
|
{
|
2
|
-
"
|
3
|
+
"company_name": "Acme Industries",
|
4
|
+
"company_status": "<%= @company_status %>",
|
5
|
+
"type": "<%= @company_type %>",
|
6
|
+
"registered_office_address": {
|
7
|
+
"address_line_1": "10 Downing St",
|
8
|
+
"address_line_2": "Horizon House",
|
9
|
+
"locality": "Bristol",
|
10
|
+
"postal_code": "BS1 5AH"
|
11
|
+
}
|
3
12
|
}
|
data/config/routes.rb
CHANGED
@@ -6,6 +6,11 @@ DefraRubyMocks::Engine.routes.draw do
|
|
6
6
|
as: "company",
|
7
7
|
constraints: ->(_request) { DefraRubyMocks.configuration.enabled? }
|
8
8
|
|
9
|
+
get "/company/:id/officers",
|
10
|
+
to: "company#officers",
|
11
|
+
as: "company_officers",
|
12
|
+
constraints: ->(_request) { DefraRubyMocks.configuration.enabled? }
|
13
|
+
|
9
14
|
get "/worldpay/payments-service",
|
10
15
|
to: "worldpay#payments_service",
|
11
16
|
as: "worldpay_payments_service",
|