@companieshouse/api-sdk-node 2.0.250 → 2.0.251
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.
|
@@ -2,17 +2,79 @@ import { PlannedMaintenance, PscVerification, PscVerificationData } from "./type
|
|
|
2
2
|
import { IHttpClient } from "../../http";
|
|
3
3
|
import Resource, { ApiErrorResponse, ApiResponse } from "../resource";
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* Service class for handling PSC (Person with Significant Control) verification-related operations.
|
|
6
|
+
* This class provides methods to interact with the PSC verification API, including creating, retrieving,
|
|
7
|
+
* updating, and checking the validation status of PSC verifications, as well as checking planned maintenance.
|
|
8
8
|
*/
|
|
9
9
|
export default class PscVerificationService {
|
|
10
10
|
private readonly client;
|
|
11
11
|
constructor(client: IHttpClient);
|
|
12
|
+
/**
|
|
13
|
+
* Submits a new PSC verification for a given transaction.
|
|
14
|
+
*
|
|
15
|
+
* @param transactionId - The unique identifier of the transaction.
|
|
16
|
+
* @param pscVerification - The PSC verification data to be submitted.
|
|
17
|
+
* @returns A promise that resolves to either:
|
|
18
|
+
* - A `Resource<PscVerification>` object containing the created PSC verification details.
|
|
19
|
+
* - An `ApiErrorResponse` object if an error occurs during the request.
|
|
20
|
+
*/
|
|
12
21
|
postPscVerification(transactionId: string, pscVerification: PscVerificationData): Promise<Resource<PscVerification> | ApiErrorResponse>;
|
|
22
|
+
/**
|
|
23
|
+
* Retrieves a specific PSC verification by its ID for a given transaction.
|
|
24
|
+
*
|
|
25
|
+
* @param transactionId - The unique identifier of the transaction.
|
|
26
|
+
* @param pscVerificationId - The unique identifier of the PSC verification.
|
|
27
|
+
* @returns A promise that resolves to either:
|
|
28
|
+
* - A `Resource<PscVerification>` object containing the PSC verification details.
|
|
29
|
+
* - An `ApiErrorResponse` object if an error occurs during the request.
|
|
30
|
+
*/
|
|
13
31
|
getPscVerification(transactionId: string, pscVerificationId: string): Promise<Resource<PscVerification> | ApiErrorResponse>;
|
|
14
|
-
|
|
32
|
+
/**
|
|
33
|
+
* Updates a PSC verification using a PATCH request for a given transaction and filing ID.
|
|
34
|
+
*
|
|
35
|
+
* @param transactionId - The unique identifier of the transaction.
|
|
36
|
+
* @param pscVerificationId - The unique identifier of the filing.
|
|
37
|
+
* @param pscVerificationPatch - The PSC verification data to be updated.
|
|
38
|
+
* @returns A promise that resolves to either:
|
|
39
|
+
* - A `Resource<PscVerification>` object containing the updated PSC verification details.
|
|
40
|
+
* - An `ApiErrorResponse` object if an error occurs during the request.
|
|
41
|
+
*/
|
|
42
|
+
patchPscVerification(transactionId: string, pscVerificationId: string, pscVerificationPatch: PscVerificationData): Promise<Resource<PscVerification> | ApiErrorResponse>;
|
|
43
|
+
/**
|
|
44
|
+
* Retrieves the validation status of a Person with Significant Control (PSC) verification.
|
|
45
|
+
*
|
|
46
|
+
* @param transactionId - The unique identifier of the transaction.
|
|
47
|
+
* @param pscVerificationId - The unique identifier of the PSC verification.
|
|
48
|
+
* @returns A promise that resolves to either:
|
|
49
|
+
* - A `Resource<PscVerification>` object containing the validation status details.
|
|
50
|
+
* - An `ApiErrorResponse` object if an error occurs during the request.
|
|
51
|
+
*
|
|
52
|
+
* The method constructs the resource URI using the provided `transactionId` and `pscVerificationId`,
|
|
53
|
+
* performs an HTTP GET request, and processes the response. If an error is encountered, it is handled
|
|
54
|
+
* using the `handleErrorResponse` method. Otherwise, the response body is mapped to camelCase keys
|
|
55
|
+
* and returned as part of the resource.
|
|
56
|
+
*/
|
|
15
57
|
getValidationStatus(transactionId: string, pscVerificationId: string): Promise<Resource<PscVerification> | ApiErrorResponse>;
|
|
58
|
+
/**
|
|
59
|
+
* Checks if there is any planned maintenance for the PSC verification service.
|
|
60
|
+
*
|
|
61
|
+
* @returns A promise that resolves to either:
|
|
62
|
+
* - An `ApiResponse<PlannedMaintenance>` object containing maintenance details.
|
|
63
|
+
* - An `ApiErrorResponse` object if an error occurs during the request.
|
|
64
|
+
*/
|
|
16
65
|
checkPlannedMaintenance(): Promise<ApiResponse<PlannedMaintenance> | ApiErrorResponse>;
|
|
66
|
+
/**
|
|
67
|
+
* Maps the response body to a front-end resource format with camelCase keys.
|
|
68
|
+
*
|
|
69
|
+
* @param response - The HTTP response received from the API.
|
|
70
|
+
* @returns A `Resource<PscVerification>` object containing the mapped resource.
|
|
71
|
+
*/
|
|
17
72
|
private populateFrontEndResource;
|
|
73
|
+
/**
|
|
74
|
+
* Handles error responses from the API by mapping error details to camelCase keys.
|
|
75
|
+
*
|
|
76
|
+
* @param response - The HTTP response containing the error details.
|
|
77
|
+
* @returns An `ApiErrorResponse` object with the mapped error details.
|
|
78
|
+
*/
|
|
79
|
+
private handleErrorResponse;
|
|
18
80
|
}
|
|
@@ -14,62 +14,95 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const mapping_1 = __importDefault(require("../../mapping/mapping"));
|
|
16
16
|
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
17
|
+
* Service class for handling PSC (Person with Significant Control) verification-related operations.
|
|
18
|
+
* This class provides methods to interact with the PSC verification API, including creating, retrieving,
|
|
19
|
+
* updating, and checking the validation status of PSC verifications, as well as checking planned maintenance.
|
|
20
20
|
*/
|
|
21
21
|
class PscVerificationService {
|
|
22
22
|
constructor(client) {
|
|
23
23
|
this.client = client;
|
|
24
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Submits a new PSC verification for a given transaction.
|
|
27
|
+
*
|
|
28
|
+
* @param transactionId - The unique identifier of the transaction.
|
|
29
|
+
* @param pscVerification - The PSC verification data to be submitted.
|
|
30
|
+
* @returns A promise that resolves to either:
|
|
31
|
+
* - A `Resource<PscVerification>` object containing the created PSC verification details.
|
|
32
|
+
* - An `ApiErrorResponse` object if an error occurs during the request.
|
|
33
|
+
*/
|
|
25
34
|
postPscVerification(transactionId, pscVerification) {
|
|
26
35
|
return __awaiter(this, void 0, void 0, function* () {
|
|
27
36
|
const resourceUri = `/transactions/${transactionId}/persons-with-significant-control-verification`;
|
|
28
37
|
const pscVerificationResource = mapping_1.default.snakeCaseKeys(pscVerification);
|
|
29
38
|
const response = yield this.client.httpPost(resourceUri, pscVerificationResource);
|
|
30
39
|
if (response.error) {
|
|
31
|
-
return
|
|
32
|
-
httpStatusCode: response.status,
|
|
33
|
-
errors: [response.error]
|
|
34
|
-
};
|
|
40
|
+
return this.handleErrorResponse(response);
|
|
35
41
|
}
|
|
36
42
|
return this.populateFrontEndResource(response);
|
|
37
43
|
});
|
|
38
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Retrieves a specific PSC verification by its ID for a given transaction.
|
|
47
|
+
*
|
|
48
|
+
* @param transactionId - The unique identifier of the transaction.
|
|
49
|
+
* @param pscVerificationId - The unique identifier of the PSC verification.
|
|
50
|
+
* @returns A promise that resolves to either:
|
|
51
|
+
* - A `Resource<PscVerification>` object containing the PSC verification details.
|
|
52
|
+
* - An `ApiErrorResponse` object if an error occurs during the request.
|
|
53
|
+
*/
|
|
39
54
|
getPscVerification(transactionId, pscVerificationId) {
|
|
40
55
|
return __awaiter(this, void 0, void 0, function* () {
|
|
41
56
|
const resourceUri = `/transactions/${transactionId}/persons-with-significant-control-verification/${pscVerificationId}`;
|
|
42
57
|
const response = yield this.client.httpGet(resourceUri);
|
|
43
58
|
if (response.error) {
|
|
44
|
-
return
|
|
45
|
-
httpStatusCode: response.status,
|
|
46
|
-
errors: [response.error]
|
|
47
|
-
};
|
|
59
|
+
return this.handleErrorResponse(response);
|
|
48
60
|
}
|
|
49
61
|
return this.populateFrontEndResource(response);
|
|
50
62
|
});
|
|
51
63
|
}
|
|
52
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Updates a PSC verification using a PATCH request for a given transaction and filing ID.
|
|
66
|
+
*
|
|
67
|
+
* @param transactionId - The unique identifier of the transaction.
|
|
68
|
+
* @param pscVerificationId - The unique identifier of the filing.
|
|
69
|
+
* @param pscVerificationPatch - The PSC verification data to be updated.
|
|
70
|
+
* @returns A promise that resolves to either:
|
|
71
|
+
* - A `Resource<PscVerification>` object containing the updated PSC verification details.
|
|
72
|
+
* - An `ApiErrorResponse` object if an error occurs during the request.
|
|
73
|
+
*/
|
|
74
|
+
patchPscVerification(transactionId, pscVerificationId, pscVerificationPatch) {
|
|
53
75
|
return __awaiter(this, void 0, void 0, function* () {
|
|
54
76
|
const additionalHeaders = { "Content-Type": "application/merge-patch+json" };
|
|
55
|
-
const resourceUri = `/transactions/${transactionId}/persons-with-significant-control-verification/${
|
|
77
|
+
const resourceUri = `/transactions/${transactionId}/persons-with-significant-control-verification/${pscVerificationId}`;
|
|
56
78
|
const pscVerificationPatchResource = mapping_1.default.snakeCaseKeys(pscVerificationPatch);
|
|
57
79
|
const response = yield this.client.httpPatch(resourceUri, pscVerificationPatchResource, additionalHeaders);
|
|
58
80
|
if (response.error) {
|
|
59
|
-
return
|
|
60
|
-
httpStatusCode: response.status,
|
|
61
|
-
errors: [response.error]
|
|
62
|
-
};
|
|
81
|
+
return this.handleErrorResponse(response);
|
|
63
82
|
}
|
|
64
83
|
return this.populateFrontEndResource(response);
|
|
65
84
|
});
|
|
66
85
|
}
|
|
86
|
+
/**
|
|
87
|
+
* Retrieves the validation status of a Person with Significant Control (PSC) verification.
|
|
88
|
+
*
|
|
89
|
+
* @param transactionId - The unique identifier of the transaction.
|
|
90
|
+
* @param pscVerificationId - The unique identifier of the PSC verification.
|
|
91
|
+
* @returns A promise that resolves to either:
|
|
92
|
+
* - A `Resource<PscVerification>` object containing the validation status details.
|
|
93
|
+
* - An `ApiErrorResponse` object if an error occurs during the request.
|
|
94
|
+
*
|
|
95
|
+
* The method constructs the resource URI using the provided `transactionId` and `pscVerificationId`,
|
|
96
|
+
* performs an HTTP GET request, and processes the response. If an error is encountered, it is handled
|
|
97
|
+
* using the `handleErrorResponse` method. Otherwise, the response body is mapped to camelCase keys
|
|
98
|
+
* and returned as part of the resource.
|
|
99
|
+
*/
|
|
67
100
|
getValidationStatus(transactionId, pscVerificationId) {
|
|
68
101
|
return __awaiter(this, void 0, void 0, function* () {
|
|
69
102
|
const resourceUri = `/transactions/${transactionId}/persons-with-significant-control-verification/${pscVerificationId}/validation_status`;
|
|
70
103
|
const response = yield this.client.httpGet(resourceUri);
|
|
71
|
-
if (response.
|
|
72
|
-
return
|
|
104
|
+
if (response.error) {
|
|
105
|
+
return this.handleErrorResponse(response);
|
|
73
106
|
}
|
|
74
107
|
const resource = { httpStatusCode: response.status };
|
|
75
108
|
const body = response.body;
|
|
@@ -77,15 +110,19 @@ class PscVerificationService {
|
|
|
77
110
|
return resource;
|
|
78
111
|
});
|
|
79
112
|
}
|
|
113
|
+
/**
|
|
114
|
+
* Checks if there is any planned maintenance for the PSC verification service.
|
|
115
|
+
*
|
|
116
|
+
* @returns A promise that resolves to either:
|
|
117
|
+
* - An `ApiResponse<PlannedMaintenance>` object containing maintenance details.
|
|
118
|
+
* - An `ApiErrorResponse` object if an error occurs during the request.
|
|
119
|
+
*/
|
|
80
120
|
checkPlannedMaintenance() {
|
|
81
121
|
return __awaiter(this, void 0, void 0, function* () {
|
|
82
122
|
const maintenanceUri = `/persons-with-significant-control-verification/maintenance`;
|
|
83
123
|
const response = yield this.client.httpGet(maintenanceUri);
|
|
84
124
|
if (response.error) {
|
|
85
|
-
return
|
|
86
|
-
httpStatusCode: response.status,
|
|
87
|
-
errors: [response.error]
|
|
88
|
-
};
|
|
125
|
+
return this.handleErrorResponse(response);
|
|
89
126
|
}
|
|
90
127
|
return {
|
|
91
128
|
httpStatusCode: response.status,
|
|
@@ -93,6 +130,12 @@ class PscVerificationService {
|
|
|
93
130
|
};
|
|
94
131
|
});
|
|
95
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* Maps the response body to a front-end resource format with camelCase keys.
|
|
135
|
+
*
|
|
136
|
+
* @param response - The HTTP response received from the API.
|
|
137
|
+
* @returns A `Resource<PscVerification>` object containing the mapped resource.
|
|
138
|
+
*/
|
|
96
139
|
populateFrontEndResource(response) {
|
|
97
140
|
const frontEndResource = {
|
|
98
141
|
httpStatusCode: response.status,
|
|
@@ -102,6 +145,18 @@ class PscVerificationService {
|
|
|
102
145
|
frontEndResource.resource = mapping_1.default.camelCaseKeys(body);
|
|
103
146
|
return frontEndResource;
|
|
104
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* Handles error responses from the API by mapping error details to camelCase keys.
|
|
150
|
+
*
|
|
151
|
+
* @param response - The HTTP response containing the error details.
|
|
152
|
+
* @returns An `ApiErrorResponse` object with the mapped error details.
|
|
153
|
+
*/
|
|
154
|
+
handleErrorResponse(response) {
|
|
155
|
+
return {
|
|
156
|
+
httpStatusCode: response.status,
|
|
157
|
+
errors: [mapping_1.default.camelCaseKeys(response.error)]
|
|
158
|
+
};
|
|
159
|
+
}
|
|
105
160
|
}
|
|
106
161
|
exports.default = PscVerificationService;
|
|
107
162
|
//# sourceMappingURL=service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/services/psc-verification-link/service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAIA,oEAA4C;
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/services/psc-verification-link/service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAIA,oEAA4C;AAG5C;;;;GAIG;AACH,MAAqB,sBAAsB;IACvC,YAA8B,MAAmB;QAAnB,WAAM,GAAN,MAAM,CAAa;IAAG,CAAC;IAErD;;;;;;;;OAQG;IACU,mBAAmB,CAAE,aAAqB,EAAE,eAAoC;;YACzF,MAAM,WAAW,GAAG,iBAAiB,aAAa,gDAAgD,CAAC;YACnG,MAAM,uBAAuB,GAAG,iBAAO,CAAC,aAAa,CAAC,eAAe,CAAC,CAAC;YACvE,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,WAA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