defra_ruby_mocks 2.1.0 → 2.2.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: 2400c544251ae5e153675efe7553c5fab5f1f7f85d22070dcc3ad638d57f37c4
4
- data.tar.gz: 0a0f9539751608fe818abb95441827cb870454221f6adf2560a3ea10a4bcad88
3
+ metadata.gz: bc69209c2d4b90b3726d7486bb0f4f0f001d80aff649951f4e8eaa5e17e46cec
4
+ data.tar.gz: 2f8ca2c6731b2d0eae695e7aeae936c20288480bf758c4f16fcdcf3a27f70067
5
5
  SHA512:
6
- metadata.gz: db8efa881a745c8b16c36b60d24ad7e2edc29a1ff237b060013289801be216e93e3af808b34f49aeddff80eb0855d9217b956c35080c72f83c84a243f98ccde3
7
- data.tar.gz: da2b9925edb39db3c89b8794a8bc184550cb5972affaf2978f8ea3c9302a6ab7d1d84dbf6c74bbebaa47f864cb17c369a1e4fa216ed6a15ec508b66ccc500d3e
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 thing they are interested in is the value of `"company_status"`.
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 that bit of the JSON.
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
- "company_status": "active"
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
- @status = CompaniesHouseService.run(params[:id])
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
- return specials[company_number] if specials.key?(company_number)
42
+ @company_status = specials[company_number] || "active"
43
+ @company_type = llps.include?(company_number) ? "llp" : "ltd"
39
44
 
40
- "active"
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
- "company_status": "<%= @status %>"
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",
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DefraRubyMocks
4
- VERSION = "2.1.0"
4
+ VERSION = "2.2.0"
5
5
  end