@companieshouse/api-sdk-node 1.0.95 → 1.0.96
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.
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { IHttpClient } from "../../../http";
|
|
2
2
|
import { CertificateItem, CertificateItemInitialRequest, CertificateItemPatchRequest, CertificateItemPostRequest } from "./types";
|
|
3
|
-
import
|
|
3
|
+
import { ApiResponse, ApiResult } from "../../resource";
|
|
4
4
|
export default class {
|
|
5
5
|
private readonly client;
|
|
6
6
|
constructor(client: IHttpClient);
|
|
7
|
-
getCertificate(certificateId: string): Promise<
|
|
7
|
+
getCertificate(certificateId: string): Promise<ApiResult<ApiResponse<CertificateItem>>>;
|
|
8
8
|
postCertificate(certificateItemRequest: CertificateItemPostRequest): Promise<ApiResult<ApiResponse<CertificateItem>>>;
|
|
9
9
|
postInitialCertificate(certificateItemRequest: CertificateItemInitialRequest): Promise<ApiResult<ApiResponse<CertificateItem>>>;
|
|
10
|
-
patchCertificate(certificateItemRequest: CertificateItemPatchRequest, certificateId: string): Promise<
|
|
11
|
-
private
|
|
10
|
+
patchCertificate(certificateItemRequest: CertificateItemPatchRequest, certificateId: string): Promise<ApiResult<ApiResponse<CertificateItem>>>;
|
|
11
|
+
private handleResponse;
|
|
12
12
|
}
|
|
@@ -20,20 +20,15 @@ class default_1 {
|
|
|
20
20
|
}
|
|
21
21
|
getCertificate(certificateId) {
|
|
22
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
httpStatusCode: resp.status
|
|
26
|
-
};
|
|
27
|
-
if (!resp.error) {
|
|
28
|
-
resource.resource = mapping_1.default.camelCaseKeys(resp.body);
|
|
29
|
-
}
|
|
30
|
-
return resource;
|
|
23
|
+
const response = yield this.client.httpGet(`/orderable/certificates/${certificateId}`);
|
|
24
|
+
return this.handleResponse(response);
|
|
31
25
|
});
|
|
32
26
|
}
|
|
33
27
|
// Create a whole certificate item in one invocation
|
|
34
28
|
postCertificate(certificateItemRequest) {
|
|
35
29
|
return __awaiter(this, void 0, void 0, function* () {
|
|
36
|
-
|
|
30
|
+
const response = yield this.client.httpPost("/orderable/certificates", mapping_1.default.snakeCaseKeys(certificateItemRequest));
|
|
31
|
+
return this.handleResponse(response);
|
|
37
32
|
});
|
|
38
33
|
}
|
|
39
34
|
/*
|
|
@@ -43,7 +38,8 @@ class default_1 {
|
|
|
43
38
|
*/
|
|
44
39
|
postInitialCertificate(certificateItemRequest) {
|
|
45
40
|
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
-
|
|
41
|
+
const response = yield this.client.httpPost("/orderable/certificates/initial", mapping_1.default.snakeCaseKeys(certificateItemRequest));
|
|
42
|
+
return this.handleResponse(response);
|
|
47
43
|
});
|
|
48
44
|
}
|
|
49
45
|
/*
|
|
@@ -53,38 +49,27 @@ class default_1 {
|
|
|
53
49
|
*/
|
|
54
50
|
patchCertificate(certificateItemRequest, certificateId) {
|
|
55
51
|
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
-
const patchRequest = mapping_1.default.snakeCaseKeys(certificateItemRequest);
|
|
57
52
|
const additionalHeaders = {
|
|
58
53
|
"Content-Type": "application/merge-patch+json"
|
|
59
54
|
};
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
httpStatusCode: resp.status
|
|
63
|
-
};
|
|
64
|
-
if (!resp.error) {
|
|
65
|
-
resource.resource = mapping_1.default.camelCaseKeys(resp.body);
|
|
66
|
-
}
|
|
67
|
-
return resource;
|
|
55
|
+
const response = yield this.client.httpPatch(`/orderable/certificates/${certificateId}`, mapping_1.default.snakeCaseKeys(certificateItemRequest), additionalHeaders);
|
|
56
|
+
return this.handleResponse(response);
|
|
68
57
|
});
|
|
69
58
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
response.resource = mapping_1.default.camelCaseKeys(serverResponse.body);
|
|
85
|
-
return result_1.success(response);
|
|
86
|
-
}
|
|
87
|
-
});
|
|
59
|
+
handleResponse(serverResponse) {
|
|
60
|
+
const response = {
|
|
61
|
+
httpStatusCode: serverResponse.status
|
|
62
|
+
};
|
|
63
|
+
if (serverResponse.error) {
|
|
64
|
+
return result_1.failure({
|
|
65
|
+
httpStatusCode: serverResponse.status,
|
|
66
|
+
errors: serverResponse.error.errors
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
response.resource = mapping_1.default.camelCaseKeys(serverResponse.body);
|
|
71
|
+
return result_1.success(response);
|
|
72
|
+
}
|
|
88
73
|
}
|
|
89
74
|
}
|
|
90
75
|
exports.default = default_1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../../../src/services/order/certificates/service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAQA,uEAA+C;AAC/C,yCAAgD;AAEhD;IACI,YAA8B,MAAmB;QAAnB,WAAM,GAAN,MAAM,CAAa;IACjD,CAAC;IAEY,cAAc,CAAE,aAAqB;;YAC9C,MAAM,
|
|
1
|
+
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../../../src/services/order/certificates/service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAQA,uEAA+C;AAC/C,yCAAgD;AAEhD;IACI,YAA8B,MAAmB;QAAnB,WAAM,GAAN,MAAM,CAAa;IACjD,CAAC;IAEY,cAAc,CAAE,aAAqB;;YAC9C,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,2BAA2B,aAAa,EAAE,CAAC,CAAC;YACvF,OAAO,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;QACzC,CAAC;KAAA;IAED,oDAAoD;IACvC,eAAe,CAAE,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