Skip to content

Commit 032499a

Browse files
authored
Merge pull request #829 from companieshouse/lp-1316-allow-appointment-id-for-lp-partners
LP-1316 Introduce get appointments function, add a field to lp partners
2 parents 910387a + f630bf2 commit 032499a

File tree

3 files changed

+132
-2
lines changed

3 files changed

+132
-2
lines changed

src/services/company-officers/service.ts

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { IHttpClient } from "../../http";
2-
import { CompanyOfficersResource, CompanyOfficers } from "./types";
2+
import { CompanyOfficersResource, CompanyOfficers, CompanyOfficer } from "./types";
33
import Resource from "../resource";
44
import Mapping from "../../mapping/mapping";
55

@@ -48,4 +48,30 @@ export default class CompanyOfficersService {
4848

4949
return resource;
5050
}
51+
52+
/**
53+
* Get a specific company appointment.
54+
* @param number the company number to look up
55+
* @param appointmentId the appointment ID to look up
56+
* @returns the company appointment
57+
*/
58+
public async getCompanyAppointment (number: string, appointmentId: string): Promise<Resource<CompanyOfficer>> {
59+
const url = `/company/${number}/appointments/${appointmentId}`;
60+
61+
const resp = await this.client.httpGet(url);
62+
63+
const resource: Resource<CompanyOfficer> = {
64+
httpStatusCode: resp.status
65+
};
66+
67+
if (resp.error) {
68+
return resource;
69+
}
70+
71+
const body = resp.body as CompanyOfficersResource;
72+
73+
resource.resource = Mapping.camelCaseKeys<CompanyOfficer>(body);
74+
75+
return resource;
76+
}
5177
}

src/services/limited-partnerships/types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export interface LimitedPartnership {
3333
}
3434

3535
type Partner = {
36+
appointment_id?: string;
3637
completed?: boolean;
3738
date_effective_from?: string;
3839
date_of_birth?: string;
@@ -52,6 +53,8 @@ type Partner = {
5253
resignation_date?: string;
5354
surname?: string;
5455
usual_residential_address?: Address;
56+
cease_date?: string;
57+
remove_confirmation_checked?: boolean;
5558
};
5659

5760
export interface LimitedPartner {

test/services/company-officers/service.spec.ts

Lines changed: 102 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import chaiHttp from "chai-http";
55

66
import CompanyOfficersService from "../../../src/services/company-officers/service";
77
import { RequestClient, HttpResponse } from "../../../src/http";
8-
import { CompanyOfficersResource } from "../../../src/services/company-officers/types";
8+
import { CompanyOfficerResource, CompanyOfficersResource } from "../../../src/services/company-officers/types";
99
const expect = chai.expect;
1010

1111
const requestClient = new RequestClient({ baseUrl: "URL-NOT-USED", oauthToken: "TOKEN-NOT-USED" });
@@ -183,4 +183,105 @@ describe("company-officers", () => {
183183
await companyOfficers.getCompanyOfficers("123", 10, 2, true, "resigned_on");
184184
expect(spy.calledWith("/company/123/officers?page_size=10&page_index=2&register_view=true&order_by=resigned_on")).to.equal(true);
185185
});
186+
187+
it("maps the company field data correctly for specific appointment", async () => {
188+
const mockResponseBody : CompanyOfficerResource = ({
189+
appointed_on: (new Date()).toISOString(),
190+
occupation: "director",
191+
country_of_residence: "United Kingdom",
192+
nationality: "British",
193+
resigned_on: (new Date()).toISOString(),
194+
name: "Some Director",
195+
officer_role: "director",
196+
responsibilities: "Determining the company’s strategic objectives and policies",
197+
address: {
198+
address_line_1: "123 Street",
199+
address_line_2: "Some area",
200+
care_of: "Some council",
201+
country: "United Kingdom",
202+
locality: "Wales",
203+
po_box: "123",
204+
postal_code: "SW1",
205+
premises: "some premises",
206+
region: "South"
207+
},
208+
date_of_birth: {
209+
day: "15",
210+
month: "4",
211+
year: "1996"
212+
},
213+
former_names: [
214+
{
215+
forenames: "Fore",
216+
surname: "Sur"
217+
}
218+
],
219+
identification: {
220+
identification_type: "some identification type",
221+
legal_authority: "some legal auth",
222+
legal_form: "some legal form",
223+
place_registered: "some place",
224+
registration_number: "some reg"
225+
},
226+
contact_details: {
227+
contact_name: "Firstname Surname"
228+
},
229+
links: {
230+
self: "appointmentIdabc",
231+
officer: {
232+
appointments: "company/123/appointments/abc"
233+
}
234+
}
235+
236+
});
237+
238+
const mockGetResponse = {
239+
status: 200,
240+
body: mockResponseBody
241+
};
242+
243+
const mockRequest = sinon.stub(requestClient, "httpGet").resolves(mockGetResponse);
244+
const companyOfficers : CompanyOfficersService = new CompanyOfficersService(requestClient);
245+
const data = await companyOfficers.getCompanyAppointment("123", "abc");
246+
247+
expect(data.httpStatusCode).to.equal(200);
248+
249+
expect(data.resource.appointedOn).to.equal(mockResponseBody.appointed_on);
250+
expect(data.resource.countryOfResidence).to.equal(mockResponseBody.country_of_residence);
251+
expect(data.resource.nationality).to.equal(mockResponseBody.nationality);
252+
expect(data.resource.occupation).to.equal(mockResponseBody.occupation);
253+
expect(data.resource.resignedOn).to.equal(mockResponseBody.resigned_on);
254+
expect(data.resource.name).to.equal(mockResponseBody.name);
255+
expect(data.resource.officerRole).to.equal(mockResponseBody.officer_role);
256+
expect(data.resource.responsibilities).to.equal(mockResponseBody.responsibilities);
257+
258+
expect(data.resource.address.addressLine1).to.equal(mockResponseBody.address.address_line_1);
259+
expect(data.resource.address.addressLine2).to.equal(mockResponseBody.address.address_line_2);
260+
expect(data.resource.address.careOf).to.equal(mockResponseBody.address.care_of);
261+
expect(data.resource.address.country).to.equal(mockResponseBody.address.country);
262+
expect(data.resource.address.locality).to.equal(mockResponseBody.address.locality);
263+
expect(data.resource.address.poBox).to.equal(mockResponseBody.address.po_box);
264+
expect(data.resource.address.postalCode).to.equal(mockResponseBody.address.postal_code);
265+
expect(data.resource.address.premises).to.equal(mockResponseBody.address.premises);
266+
expect(data.resource.address.region).to.equal(mockResponseBody.address.region);
267+
268+
expect(data.resource.dateOfBirth.day).to.equal(mockResponseBody.date_of_birth.day);
269+
expect(data.resource.dateOfBirth.month).to.equal(mockResponseBody.date_of_birth.month);
270+
expect(data.resource.dateOfBirth.year).to.equal(mockResponseBody.date_of_birth.year);
271+
272+
expect(data.resource.formerNames.length).to.equal(mockResponseBody.former_names.length);
273+
expect(data.resource.formerNames[0].forenames).to.equal(mockResponseBody.former_names[0].forenames);
274+
expect(data.resource.formerNames[0].surname).to.equal(mockResponseBody.former_names[0].surname);
275+
276+
expect(data.resource.identification.identificationType).to.equal(mockResponseBody.identification.identification_type);
277+
expect(data.resource.identification.legalAuthority).to.equal(mockResponseBody.identification.legal_authority);
278+
expect(data.resource.identification.legalForm).to.equal(mockResponseBody.identification.legal_form);
279+
expect(data.resource.identification.placeRegistered).to.equal(mockResponseBody.identification.place_registered);
280+
expect(data.resource.identification.registrationNumber).to.equal(mockResponseBody.identification.registration_number);
281+
282+
expect(data.resource.contactDetails.contactName).to.equal(mockResponseBody.contact_details.contact_name);
283+
284+
expect(data.resource.links.officer.appointments).to.equal(mockResponseBody.links.officer.appointments);
285+
expect(data.resource.links.self).to.equal(mockResponseBody.links.self);
286+
});
186287
});

0 commit comments

Comments
 (0)