Skip to content

Commit 8bfc93d

Browse files
authored
Merge pull request #762 from companieshouse/lp550-create-usual-residential-address-for-general=partner-choice-page
lp550-create general partner usual residential choice page
2 parents 907ab5f + 83ba0a7 commit 8bfc93d

File tree

3 files changed

+111
-6
lines changed

3 files changed

+111
-6
lines changed

src/services/limited-partnerships/service.ts

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import { HttpResponse, IHttpClient } from "../../http";
2-
import { LimitedPartnership, LimitedPartnershipResourceCreated, LimitedPartnershipIncorporation, GeneralPartner } from "./types";
2+
import {
3+
LimitedPartnership,
4+
LimitedPartnershipResourceCreated,
5+
LimitedPartnershipIncorporation,
6+
GeneralPartner
7+
} from "./types";
38
import Resource, { ApiErrorResponse } from "../resource";
49

510
export default class LimitedPartnershipsService {
@@ -50,7 +55,8 @@ export default class LimitedPartnershipsService {
5055
*/
5156

5257
public async postLimitedPartnershipIncorporation (
53-
transactionId: string): Promise<Resource<LimitedPartnershipResourceCreated> | ApiErrorResponse> {
58+
transactionId: string
59+
): Promise<Resource<LimitedPartnershipResourceCreated> | ApiErrorResponse> {
5460
const URL = `/transactions/${transactionId}/incorporation/limited-partnership`;
5561
const response: HttpResponse = await this.client.httpPost(URL);
5662

@@ -63,8 +69,11 @@ export default class LimitedPartnershipsService {
6369
public async getLimitedPartnershipIncorporation (
6470
transactionId: string,
6571
filingResourceId: string,
66-
includeSubResources?: boolean): Promise<Resource<LimitedPartnershipIncorporation> | ApiErrorResponse> {
67-
const subResourcesQuery: string = (includeSubResources ? ("?include_sub_resources=" + includeSubResources) : "");
72+
includeSubResources?: boolean
73+
): Promise<Resource<LimitedPartnershipIncorporation> | ApiErrorResponse> {
74+
const subResourcesQuery: string = includeSubResources
75+
? "?include_sub_resources=" + includeSubResources
76+
: "";
6877
const URL = `/transactions/${transactionId}/incorporation/limited-partnership/${filingResourceId}${subResourcesQuery}`;
6978

7079
const response: HttpResponse = await this.client.httpGet(URL);
@@ -81,7 +90,8 @@ export default class LimitedPartnershipsService {
8190

8291
public async postGeneralPartner (
8392
transactionId: string,
84-
body: GeneralPartner): Promise<Resource<LimitedPartnershipResourceCreated> | ApiErrorResponse> {
93+
body: GeneralPartner
94+
): Promise<Resource<LimitedPartnershipResourceCreated> | ApiErrorResponse> {
8595
const URL = `/transactions/${transactionId}/limited-partnership/general-partner`;
8696
const response: HttpResponse = await this.client.httpPost(URL, body);
8797

@@ -90,4 +100,17 @@ export default class LimitedPartnershipsService {
90100
resource: { ...response.body }
91101
};
92102
}
103+
104+
public async getGeneralPartner (
105+
transactionId: string,
106+
generalPartnerId: string
107+
): Promise<Resource<GeneralPartner> | ApiErrorResponse> {
108+
const URL = `/transactions/${transactionId}/limited-partnership/general-partner/${generalPartnerId}`;
109+
const response: HttpResponse = await this.client.httpGet(URL);
110+
111+
return {
112+
httpStatusCode: response.status,
113+
resource: { ...response.body }
114+
};
115+
}
93116
}

test/services/limited-partnerships/limited.partnerships.mock.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,3 +156,9 @@ export const mockPostGeneralPartnerResponse = {
156156
400: { status: 400, body: { error: BAD_REQUEST } },
157157
401: { status: 401, body: { error: UNAUTHORISED } }
158158
};
159+
160+
export const mockGetGeneralPartnerResponse = {
161+
200: { status: 200, body: GENERAL_PARTNER_OBJECT_MOCK },
162+
404: { status: 404, body: { error: NOT_FOUND } },
163+
401: { status: 401, body: { error: UNAUTHORISED } }
164+
};

test/services/limited-partnerships/limited.partnerships.spec.ts

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ import {
88
LimitedPartnershipResourceCreated,
99
LimitedPartnershipsService,
1010
LimitedPartnershipIncorporation,
11-
NameEndingType
11+
NameEndingType,
12+
GeneralPartner
1213
} from "../../../src/services/limited-partnerships";
1314
import Resource from "../../../src/services/resource";
1415

@@ -194,6 +195,7 @@ describe("LimitedPartnershipsService", () => {
194195
"/transactions/12345/limited-partnership/partnership/09876"
195196
)
196197
).to.be.true;
198+
197199
expect(response.httpStatusCode).to.equal(200);
198200
expect(response?.resource).to.eql(mockValues.LIMITED_PARTNERSHIP_OBJECT_MOCK);
199201
});
@@ -498,4 +500,78 @@ describe("LimitedPartnershipsService", () => {
498500
});
499501
})
500502
});
503+
504+
describe("getGeneralPartner", () => {
505+
it("should return a status 200 and the generalPartner object", async () => {
506+
const mockRequest = sinon
507+
.stub(mockValues.requestClient, "httpGet")
508+
.resolves(mockValues.mockGetGeneralPartnerResponse[200]);
509+
510+
const service = new LimitedPartnershipsService(
511+
mockValues.requestClient
512+
);
513+
514+
const response = await service.getGeneralPartner(
515+
mockValues.TRANSACTION_ID,
516+
mockValues.SUBMISSION_ID
517+
) as Resource<GeneralPartner>;
518+
519+
expect(mockRequest).to.have.been.calledOnce;
520+
expect(
521+
mockRequest.calledWith(
522+
"/transactions/12345/limited-partnership/general-partner/09876"
523+
)
524+
).to.be.true;
525+
expect(response.httpStatusCode).to.equal(200);
526+
expect(response?.resource).to.eql(mockValues.GENERAL_PARTNER_OBJECT_MOCK);
527+
});
528+
529+
it("should return error 401 (Unauthorised)", async () => {
530+
const mockRequest = sinon
531+
.stub(mockValues.requestClient, "httpGet")
532+
.resolves(mockValues.mockGetGeneralPartnerResponse[401]);
533+
534+
const service = new LimitedPartnershipsService(
535+
mockValues.requestClient
536+
);
537+
const response = (await service.getGeneralPartner(
538+
mockValues.TRANSACTION_ID,
539+
mockValues.SUBMISSION_ID
540+
)) as Resource<any>;
541+
542+
expect(mockRequest).to.have.been.calledOnce;
543+
expect(
544+
mockRequest.calledWith(
545+
"/transactions/12345/limited-partnership/general-partner/09876"
546+
)
547+
).to.be.true;
548+
549+
expect(response.httpStatusCode).to.equal(401);
550+
expect(response.resource.error).to.equal(mockValues.UNAUTHORISED);
551+
});
552+
553+
it("should return error 404 (Not Found)", async () => {
554+
const mockRequest = sinon
555+
.stub(mockValues.requestClient, "httpGet")
556+
.resolves(mockValues.mockGetGeneralPartnerResponse[404]);
557+
558+
const service = new LimitedPartnershipsService(
559+
mockValues.requestClient
560+
);
561+
const response = (await service.getGeneralPartner(
562+
mockValues.TRANSACTION_ID,
563+
"wrong-id"
564+
)) as Resource<any>;
565+
566+
expect(mockRequest).to.have.been.calledOnce;
567+
expect(
568+
mockRequest.calledWith(
569+
"/transactions/12345/limited-partnership/general-partner/wrong-id"
570+
)
571+
).to.be.true;
572+
573+
expect(response.httpStatusCode).to.equal(404);
574+
expect(response.resource.error).to.equal(mockValues.NOT_FOUND);
575+
});
576+
})
501577
});

0 commit comments

Comments
 (0)