@companieshouse/api-sdk-node 2.0.152 → 2.0.154

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.
Files changed (34) hide show
  1. package/dist/client.d.ts +4 -0
  2. package/dist/client.js +4 -0
  3. package/dist/client.js.map +1 -1
  4. package/dist/config.d.ts +1 -0
  5. package/dist/config.js +4 -1
  6. package/dist/config.js.map +1 -1
  7. package/dist/services/account-validator/types.d.ts +29 -0
  8. package/dist/services/account-validator/types.js +41 -0
  9. package/dist/services/account-validator/types.js.map +1 -0
  10. package/dist/services/accounts-filing/index.d.ts +1 -0
  11. package/dist/services/accounts-filing/index.js +6 -0
  12. package/dist/services/accounts-filing/index.js.map +1 -0
  13. package/dist/services/accounts-filing/service.d.ts +117 -0
  14. package/dist/services/accounts-filing/service.js +291 -0
  15. package/dist/services/accounts-filing/service.js.map +1 -0
  16. package/dist/services/accounts-filing/types.d.ts +21 -0
  17. package/dist/services/accounts-filing/types.js +19 -0
  18. package/dist/services/accounts-filing/types.js.map +1 -0
  19. package/dist/services/psc-verification-link/index.d.ts +2 -0
  20. package/dist/services/psc-verification-link/index.js +20 -0
  21. package/dist/services/psc-verification-link/index.js.map +1 -0
  22. package/dist/services/psc-verification-link/service.d.ts +9 -0
  23. package/dist/services/psc-verification-link/service.js +39 -0
  24. package/dist/services/psc-verification-link/service.js.map +1 -0
  25. package/dist/services/psc-verification-link/types.d.ts +43 -0
  26. package/dist/services/psc-verification-link/types.js +16 -0
  27. package/dist/services/psc-verification-link/types.js.map +1 -0
  28. package/dist/services/transaction/service.d.ts +14 -5
  29. package/dist/services/transaction/service.js +38 -7
  30. package/dist/services/transaction/service.js.map +1 -1
  31. package/dist/util.d.ts +14 -0
  32. package/dist/util.js +25 -0
  33. package/dist/util.js.map +1 -0
  34. package/package.json +1 -1
package/dist/client.d.ts CHANGED
@@ -24,6 +24,8 @@ import OfficerFilingService from "./services/officer-filing/service";
24
24
  import RegisteredEmailAddressService from "./services/registered-email-address/service";
25
25
  import { ClientType } from "./enums";
26
26
  import { PostcodeLookupService } from "./services/postcode-lookup";
27
+ import PscVerificationService from "./services/psc-verification-link/service";
28
+ import { AccountsFilingService } from "./services/accounts-filing";
27
29
  /**
28
30
  * ApiClient is the class that all service objects hang off.
29
31
  */
@@ -60,5 +62,7 @@ export default class ApiClient {
60
62
  readonly overseasEntity: OverseasEntityService;
61
63
  readonly officerFiling: OfficerFilingService;
62
64
  readonly postCodeLookup: PostcodeLookupService;
65
+ readonly pscVerificationService: PscVerificationService;
66
+ readonly accountsFilingService: AccountsFilingService;
63
67
  constructor(apiClient: IHttpClient, accountClient: IHttpClient);
64
68
  }
package/dist/client.js CHANGED
@@ -27,6 +27,8 @@ const service_15 = __importDefault(require("./services/order/checkout-item/servi
27
27
  const service_16 = __importDefault(require("./services/officer-filing/service"));
28
28
  const service_17 = __importDefault(require("./services/registered-email-address/service"));
29
29
  const postcode_lookup_1 = require("./services/postcode-lookup");
30
+ const service_18 = __importDefault(require("./services/psc-verification-link/service"));
31
+ const accounts_filing_1 = require("./services/accounts-filing");
30
32
  /**
31
33
  * ApiClient is the class that all service objects hang off.
32
34
  */
@@ -66,6 +68,8 @@ class ApiClient {
66
68
  this.transaction = new service_11.default(apiClient);
67
69
  this.registeredEmailAddressService = new service_17.default(apiClient);
68
70
  this.postCodeLookup = new postcode_lookup_1.PostcodeLookupService(apiClient);
71
+ this.pscVerificationService = new service_18.default(apiClient);
72
+ this.accountsFilingService = new accounts_filing_1.AccountsFilingService(apiClient);
69
73
  }
70
74
  }
71
75
  exports.default = ApiClient;
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;;;AACA,kFAAyE;AACzE,iFAAuE;AACvE,iFAAuE;AACvE,6EAA+D;AAC/D,wCAA0D;AAC1D,6CAO2B;AAC3B,iDAAqD;AACrD,wFAAoF;AACpF,4DAA+D;AAC/D,wFAA8E;AAC9E,4FAAsF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B,CAAC,SAAS,CAAC,CAAC;QACrD,IAAI,CAAC,6BAA6B,GAAG,IAAI,kBAA6B,CAAC,SAAS,CAAC,CAAC;QAClF,IAAI,CAAC,cAAc,GAAG,IAAI,uCAAqB,CAAC,SAAS,CAAC,CAAC;QAC3D,IAAI,CAAC,sBAAsB,GAAG,IAAI,kBAAsB,CAAC,SAAS,CAAC,CAAC;QACpE,IAAI,CAAC,qBAAqB,GAAG,IAAI,uCAAqB,CAAC,SAAS,CAAC,CAAC;IACtE,CAAC;CACF;AAtED,4BAsEC"}
package/dist/config.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export declare const API_URL: string;
2
2
  export declare const ACCOUNT_URL: string;
3
+ export declare const REQUEST_ID_HEADER = "X-Request-Id";
package/dist/config.js CHANGED
@@ -1,6 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ACCOUNT_URL = exports.API_URL = void 0;
3
+ exports.REQUEST_ID_HEADER = exports.ACCOUNT_URL = exports.API_URL = void 0;
4
4
  exports.API_URL = process.env.API_URL || "https://api.companieshouse.gov.uk";
5
5
  exports.ACCOUNT_URL = process.env.ACCOUNT_URL || "https://account.companieshouse.gov.uk";
6
+ // Header used to correlate logs between services.
7
+ // This will be used as the context key for logging.
8
+ exports.REQUEST_ID_HEADER = "X-Request-Id";
6
9
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,mCAAmC,CAAC;AACrE,QAAA,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,uCAAuC,CAAC"}
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,OAAO,IAAI,mCAAmC,CAAC;AACrE,QAAA,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,WAAW,IAAI,uCAAuC,CAAC;AAE9F,kDAAkD;AAClD,oDAAoD;AACvC,QAAA,iBAAiB,GAAG,cAAc,CAAC"}
@@ -0,0 +1,29 @@
1
+ import { PackageType } from "../accounts-filing/types";
2
+ export interface AccountValidatorRequest {
3
+ fileName: string;
4
+ id: string;
5
+ packageType?: PackageType;
6
+ }
7
+ export interface Data {
8
+ balanceSheetDate: string;
9
+ accountsType: string;
10
+ companieshouseRegisteredNumber: string;
11
+ }
12
+ export interface ErrorMessage {
13
+ errorMessage: string;
14
+ }
15
+ export interface Result {
16
+ errorMessages: ErrorMessage[];
17
+ data: Data;
18
+ validationStatus: ValidationStatus;
19
+ }
20
+ export interface AccountValidatorResponse {
21
+ status: RequestStatus;
22
+ result: Result;
23
+ fileId: string;
24
+ fileName: string;
25
+ }
26
+ declare type RequestStatus = "complete" | "pending" | "error";
27
+ declare type ValidationStatus = "OK" | "FAILED";
28
+ export declare function isAccountValidatorResponse(object: any): object is AccountValidatorResponse;
29
+ export {};
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isAccountValidatorResponse = void 0;
4
+ function isAccountValidatorResponse(object) {
5
+ if (typeof object.status !== "string" ||
6
+ typeof object.fileId !== "string" ||
7
+ typeof object.fileName !== "string") {
8
+ return false;
9
+ }
10
+ if (!["complete", "pending", "error"].includes(object.status)) {
11
+ return false;
12
+ }
13
+ if (typeof object.result !== "object" || object.result === null) {
14
+ return false;
15
+ }
16
+ const { errorMessages, data, validationStatus } = object.result;
17
+ if ((errorMessages !== undefined && !Array.isArray(errorMessages)) ||
18
+ typeof data !== "object" ||
19
+ typeof validationStatus !== "string") {
20
+ return false;
21
+ }
22
+ if (!["OK", "FAILED"].includes(validationStatus)) {
23
+ return false;
24
+ }
25
+ if (typeof data.balance_sheet_date !== "string" ||
26
+ typeof data.accounts_type !== "string" ||
27
+ typeof data.companieshouse_registered_number !== "string") {
28
+ return false;
29
+ }
30
+ for (const errorMessage of errorMessages !== null && errorMessages !== void 0 ? errorMessages : []) {
31
+ if (typeof errorMessage !== "object" || errorMessage === null) {
32
+ return false;
33
+ }
34
+ if (typeof errorMessage.errorMessage !== "string") {
35
+ return false;
36
+ }
37
+ }
38
+ return true;
39
+ }
40
+ exports.isAccountValidatorResponse = isAccountValidatorResponse;
41
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/services/account-validator/types.ts"],"names":[],"mappings":";;;AAkCA,SAAgB,0BAA0B,CAAE,MAAW;IACnD,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ;QACjC,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ;QACjC,OAAO,MAAM,CAAC,QAAQ,KAAK,QAAQ,EAAE;QACrC,OAAO,KAAK,CAAC;KAChB;IAED,IAAI,CAAC,CAAC,UAAU,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE;QAC3D,OAAO,KAAK,CAAC;KAChB;IAED,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,MAAM,KAAK,IAAI,EAAE;QAC7D,OAAO,KAAK,CAAC;KAChB;IAED,MAAM,EAAE,aAAa,EAAE,IAAI,EAAE,gBAAgB,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC;IAChE,IAAI,CAAC,aAAa,KAAK,SAAS,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;QAC9D,OAAO,IAAI,KAAK,QAAQ;QACxB,OAAO,gBAAgB,KAAK,QAAQ,EAAE;QACtC,OAAO,KAAK,CAAC;KAChB;IAED,IAAI,CAAC,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE;QAC9C,OAAO,KAAK,CAAC;KAChB;IAED,IAAI,OAAO,IAAI,CAAC,kBAAkB,KAAK,QAAQ;QAC5C,OAAO,IAAI,CAAC,aAAa,KAAK,QAAQ;QACtC,OAAO,IAAI,CAAC,gCAAgC,KAAK,QAAQ,EAAE;QAC1D,OAAO,KAAK,CAAC;KAChB;IAED,KAAK,MAAM,YAAY,IAAI,aAAa,aAAb,aAAa,cAAb,aAAa,GAAI,EAAE,EAAE;QAC5C,IAAI,OAAO,YAAY,KAAK,QAAQ,IAAI,YAAY,KAAK,IAAI,EAAE;YAC3D,OAAO,KAAK,CAAC;SAChB;QACD,IAAI,OAAO,YAAY,CAAC,YAAY,KAAK,QAAQ,EAAE;YAC/C,OAAO,KAAK,CAAC;SAChB;KACJ;IAED,OAAO,IAAI,CAAC;AAChB,CAAC;AA1CD,gEA0CC"}
@@ -0,0 +1 @@
1
+ export { AccountsFilingService } from "./service";
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AccountsFilingService = void 0;
4
+ var service_1 = require("./service");
5
+ Object.defineProperty(exports, "AccountsFilingService", { enumerable: true, get: function () { return service_1.AccountsFilingService; } });
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/accounts-filing/index.ts"],"names":[],"mappings":";;;AAAA,qCAAkD;AAAzC,gHAAA,qBAAqB,OAAA"}
@@ -0,0 +1,117 @@
1
+ import { IHttpClient } from "../../http";
2
+ import Resource, { ApiErrorResponse } from "../resource";
3
+ import { AccountsFilingValidationRequest, AccountsFileValidationResponse, AccountsFilingCompanyResponse, PackageType, ConfirmCompanyRequest } from "./types";
4
+ import { Result } from "../result";
5
+ /**
6
+ * A service class for managing communications with the accounts filing API.
7
+ * This class serves as the interface for various interactions with the accounts filing system.
8
+ * Currently, it includes functionality to check the validation status of an accounts file,
9
+ * but it is designed to accommodate additional features and communications with the accounts filing API
10
+ * as they are implemented.
11
+ *
12
+ * The service handles various HTTP response scenarios, providing appropriate
13
+ * responses based on the different statuses encountered during the file validation process
14
+ * or other interactions with the accounts filing API.
15
+ */
16
+ export declare class AccountsFilingService {
17
+ private readonly client;
18
+ /**
19
+ * Constructs an AccountsFilingService instance.
20
+ * @param client - The HTTP client for making requests.
21
+ */
22
+ constructor(client: IHttpClient);
23
+ /**
24
+ * This service will submit the required input from the web to confirm the company.
25
+ * @param companyNumber The company number
26
+ * @param transactionId The transaction Id
27
+ * @returns the company response.
28
+ */
29
+ confirmCompany(companyNumber: string, transactionId: string, confirmCompanyRequest: ConfirmCompanyRequest, requestId?: string): Promise<Resource<AccountsFilingCompanyResponse>>;
30
+ /**
31
+ * Checks the validation status of an accounts file.
32
+ * Calls the accounts filing api, which in turn calls the accounts validation service.
33
+ * @param fileValidationRequest - The request details for file validation.
34
+ * @returns A promise that resolves to the validation response or an error.
35
+ */
36
+ checkAccountsFileValidationStatus(fileValidationRequest: AccountsFilingValidationRequest): Promise<Resource<AccountsFileValidationResponse> | ApiErrorResponse>;
37
+ /**
38
+ * Initiates an HTTP GET request to retrieve the status of a file validation process.
39
+ * This method queries the server for the current validation status of a specific file
40
+ * associated with an accounts filing and transaction ID.
41
+ *
42
+ * @param fileValidationRequest - An object containing the identifiers needed to locate the file.
43
+ * This includes the file ID, accounts filing ID, and transaction ID.
44
+ * @returns A promise that resolves to the HTTP response from the server. The response includes
45
+ * the current status of the file validation process.
46
+ * @throws Will throw an error if the HTTP request fails.
47
+ */
48
+ private getFileValidationRequest;
49
+ /**
50
+ * Processes the HTTP response from the file validation request.
51
+ * This method examines the HTTP status code of the response and delegates
52
+ * to the appropriate handler based on the status code.
53
+ *
54
+ * @param response - The HttpResponse object received from the file validation request.
55
+ * It includes the status code and the response data from the server.
56
+ * @param fileId - The unique identifier of the file whose validation status is being checked.
57
+ * @returns Depending on the response status, this method can return:
58
+ * - The result of the handleOkResponse method if the status is HTTP_STATUS_OK (200),
59
+ * indicating a successful response from the server.
60
+ * - The result of the fileNotFoundResponse method if the status is HTTP_STATUS_NOT_FOUND (404),
61
+ * indicating that the file was not found on the server.
62
+ * - The result of the handleUnexpectedStatus method for any other unexpected status codes,
63
+ * handling any unforeseen responses.
64
+ */
65
+ private processResponse;
66
+ /**
67
+ * Handles unexpected HTTP response statuses received from the file validation request.
68
+ * This method is used as a catch-all for any HTTP status codes that are not specifically
69
+ * handled in the processResponse method. It constructs a standardized error response
70
+ * which can be used to notify the caller of an unexpected condition.
71
+ *
72
+ * @param response - The HttpResponse object received from the file validation request.
73
+ * This includes the status code and any associated response data.
74
+ * @returns An ApiErrorResponse object that encapsulates the unexpected status code and
75
+ * a descriptive error message. This response can be used to inform the user
76
+ * or calling function about the unexpected server behavior.
77
+ */
78
+ private handleUnexpectedStatus;
79
+ /**
80
+ * Handles the OK response received from the file validation request.
81
+ * This method checks if the response body conforms to the AccountValidatorResponse structure.
82
+ * If it does, the method returns a successful response, otherwise, it delegates to
83
+ * the invalidResponseType method for further handling.
84
+ *
85
+ * @param response - The HttpResponse object received, expected with a status of HTTP_STATUS_OK.
86
+ * @param fileId - The unique identifier of the file whose validation status is being checked.
87
+ * @returns An object with the HTTP status code and the validated response body,
88
+ * or the result of the invalidResponseType method in case of an incorrect response type.
89
+ */
90
+ private handleOkResponse;
91
+ /**
92
+ * Generates a standardized error response for the scenario where the requested file is not found.
93
+ *
94
+ * @param fileId - The unique identifier of the file that was not found.
95
+ * @returns An ApiErrorResponse object with the HTTP status of NOT FOUND and an error message.
96
+ */
97
+ private fileNotFoundResponse;
98
+ /**
99
+ * Constructs an error response for situations where the file validation response is not of the expected type.
100
+ *
101
+ * @param fileId - The unique identifier of the file for which the validation response is incorrect.
102
+ * @param response - The original HttpResponse object received from the file validation request.
103
+ * @returns An ApiErrorResponse object encapsulating the actual HTTP status and a descriptive error message,
104
+ * including the response received for debugging purposes.
105
+ */
106
+ private invalidResponseType;
107
+ /**
108
+ * Generic error handling method to capture and process exceptions or errors encountered during
109
+ * the file validation request process. Converts unhandled errors into a standardized API error response.
110
+ *
111
+ * @param error - The error or exception caught during the execution of the file validation request.
112
+ * @returns An ApiErrorResponse object with the status of INTERNAL_SERVER_ERROR for unhandled errors,
113
+ * or the original ApiErrorResponse if the error is already in this format.
114
+ */
115
+ private handleError;
116
+ setPackageType(transactionId: string, accountsFilingId: string, packageType: PackageType, requestId?: string): Promise<Result<void, Error>>;
117
+ }
@@ -0,0 +1,291 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.AccountsFilingService = void 0;
16
+ const types_1 = require("../../services/account-validator/types");
17
+ const mapping_1 = __importDefault(require("../../mapping/mapping"));
18
+ const result_1 = require("../result");
19
+ const util_1 = require("../../util");
20
+ const HTTP_STATUS_OK = 200;
21
+ const HTTP_STATUS_NOT_FOUND = 404;
22
+ const HTTP_STATUS_INTERNAL_SERVER_ERROR = 500;
23
+ /**
24
+ * A service class for managing communications with the accounts filing API.
25
+ * This class serves as the interface for various interactions with the accounts filing system.
26
+ * Currently, it includes functionality to check the validation status of an accounts file,
27
+ * but it is designed to accommodate additional features and communications with the accounts filing API
28
+ * as they are implemented.
29
+ *
30
+ * The service handles various HTTP response scenarios, providing appropriate
31
+ * responses based on the different statuses encountered during the file validation process
32
+ * or other interactions with the accounts filing API.
33
+ */
34
+ class AccountsFilingService {
35
+ /**
36
+ * Constructs an AccountsFilingService instance.
37
+ * @param client - The HTTP client for making requests.
38
+ */
39
+ constructor(client) {
40
+ this.client = client;
41
+ }
42
+ /**
43
+ * This service will submit the required input from the web to confirm the company.
44
+ * @param companyNumber The company number
45
+ * @param transactionId The transaction Id
46
+ * @returns the company response.
47
+ */
48
+ confirmCompany(companyNumber, transactionId, confirmCompanyRequest, requestId) {
49
+ return __awaiter(this, void 0, void 0, function* () {
50
+ const url = `/transactions/${transactionId}/accounts-filing/company/${companyNumber}/confirm`;
51
+ const headers = util_1.addRequestIdHeader(requestId);
52
+ const resp = yield this.client.httpPut(url, confirmCompanyRequest, headers);
53
+ const resource = {
54
+ httpStatusCode: resp.status
55
+ };
56
+ if (resp.error) {
57
+ return resource;
58
+ }
59
+ const body = resp.body;
60
+ resource.resource = mapping_1.default.camelCaseKeys(body);
61
+ return resource;
62
+ });
63
+ }
64
+ /**
65
+ * Checks the validation status of an accounts file.
66
+ * Calls the accounts filing api, which in turn calls the accounts validation service.
67
+ * @param fileValidationRequest - The request details for file validation.
68
+ * @returns A promise that resolves to the validation response or an error.
69
+ */
70
+ checkAccountsFileValidationStatus(fileValidationRequest) {
71
+ return __awaiter(this, void 0, void 0, function* () {
72
+ try {
73
+ const response = yield this.getFileValidationRequest(fileValidationRequest);
74
+ return this.processResponse(response, fileValidationRequest.fileId);
75
+ }
76
+ catch (error) {
77
+ return this.handleError(error);
78
+ }
79
+ });
80
+ }
81
+ /**
82
+ * Initiates an HTTP GET request to retrieve the status of a file validation process.
83
+ * This method queries the server for the current validation status of a specific file
84
+ * associated with an accounts filing and transaction ID.
85
+ *
86
+ * @param fileValidationRequest - An object containing the identifiers needed to locate the file.
87
+ * This includes the file ID, accounts filing ID, and transaction ID.
88
+ * @returns A promise that resolves to the HTTP response from the server. The response includes
89
+ * the current status of the file validation process.
90
+ * @throws Will throw an error if the HTTP request fails.
91
+ */
92
+ getFileValidationRequest(fileValidationRequest) {
93
+ return __awaiter(this, void 0, void 0, function* () {
94
+ const { fileId, accountsFilingId, transactionId } = fileValidationRequest;
95
+ return yield this.client.httpGet(`/transactions/${transactionId}/accounts-filing/${accountsFilingId}/file/${fileId}/status`);
96
+ });
97
+ }
98
+ /**
99
+ * Processes the HTTP response from the file validation request.
100
+ * This method examines the HTTP status code of the response and delegates
101
+ * to the appropriate handler based on the status code.
102
+ *
103
+ * @param response - The HttpResponse object received from the file validation request.
104
+ * It includes the status code and the response data from the server.
105
+ * @param fileId - The unique identifier of the file whose validation status is being checked.
106
+ * @returns Depending on the response status, this method can return:
107
+ * - The result of the handleOkResponse method if the status is HTTP_STATUS_OK (200),
108
+ * indicating a successful response from the server.
109
+ * - The result of the fileNotFoundResponse method if the status is HTTP_STATUS_NOT_FOUND (404),
110
+ * indicating that the file was not found on the server.
111
+ * - The result of the handleUnexpectedStatus method for any other unexpected status codes,
112
+ * handling any unforeseen responses.
113
+ */
114
+ processResponse(response, fileId) {
115
+ switch (response.status) {
116
+ case HTTP_STATUS_OK:
117
+ return this.handleOkResponse(response, fileId);
118
+ case HTTP_STATUS_NOT_FOUND:
119
+ return this.fileNotFoundResponse(fileId);
120
+ default:
121
+ return this.handleUnexpectedStatus(response);
122
+ }
123
+ }
124
+ /**
125
+ * Handles unexpected HTTP response statuses received from the file validation request.
126
+ * This method is used as a catch-all for any HTTP status codes that are not specifically
127
+ * handled in the processResponse method. It constructs a standardized error response
128
+ * which can be used to notify the caller of an unexpected condition.
129
+ *
130
+ * @param response - The HttpResponse object received from the file validation request.
131
+ * This includes the status code and any associated response data.
132
+ * @returns An ApiErrorResponse object that encapsulates the unexpected status code and
133
+ * a descriptive error message. This response can be used to inform the user
134
+ * or calling function about the unexpected server behavior.
135
+ */
136
+ handleUnexpectedStatus(response) {
137
+ return {
138
+ httpStatusCode: response.status,
139
+ errors: [{
140
+ error: `Unexpected server response: Status Code ${response.status}`
141
+ }]
142
+ };
143
+ }
144
+ /**
145
+ * Handles the OK response received from the file validation request.
146
+ * This method checks if the response body conforms to the AccountValidatorResponse structure.
147
+ * If it does, the method returns a successful response, otherwise, it delegates to
148
+ * the invalidResponseType method for further handling.
149
+ *
150
+ * @param response - The HttpResponse object received, expected with a status of HTTP_STATUS_OK.
151
+ * @param fileId - The unique identifier of the file whose validation status is being checked.
152
+ * @returns An object with the HTTP status code and the validated response body,
153
+ * or the result of the invalidResponseType method in case of an incorrect response type.
154
+ */
155
+ handleOkResponse(response, fileId) {
156
+ if (types_1.isAccountValidatorResponse(response.body)) {
157
+ return {
158
+ httpStatusCode: response.status,
159
+ resource: response.body
160
+ };
161
+ }
162
+ return this.invalidResponseType(fileId, response);
163
+ }
164
+ /**
165
+ * Generates a standardized error response for the scenario where the requested file is not found.
166
+ *
167
+ * @param fileId - The unique identifier of the file that was not found.
168
+ * @returns An ApiErrorResponse object with the HTTP status of NOT FOUND and an error message.
169
+ */
170
+ fileNotFoundResponse(fileId) {
171
+ return {
172
+ httpStatusCode: HTTP_STATUS_NOT_FOUND,
173
+ errors: [{ error: `File with ID [${fileId}] not found.` }]
174
+ };
175
+ }
176
+ /**
177
+ * Constructs an error response for situations where the file validation response is not of the expected type.
178
+ *
179
+ * @param fileId - The unique identifier of the file for which the validation response is incorrect.
180
+ * @param response - The original HttpResponse object received from the file validation request.
181
+ * @returns An ApiErrorResponse object encapsulating the actual HTTP status and a descriptive error message,
182
+ * including the response received for debugging purposes.
183
+ */
184
+ invalidResponseType(fileId, response) {
185
+ return {
186
+ httpStatusCode: response.status,
187
+ errors: [{
188
+ error: `File validation response for file [${fileId}] is not the correct type. Response: ${JSON.stringify(response.body, null, 2)}`
189
+ }]
190
+ };
191
+ }
192
+ /**
193
+ * Generic error handling method to capture and process exceptions or errors encountered during
194
+ * the file validation request process. Converts unhandled errors into a standardized API error response.
195
+ *
196
+ * @param error - The error or exception caught during the execution of the file validation request.
197
+ * @returns An ApiErrorResponse object with the status of INTERNAL_SERVER_ERROR for unhandled errors,
198
+ * or the original ApiErrorResponse if the error is already in this format.
199
+ */
200
+ handleError(error) {
201
+ if (isApiErrorResponse(error)) {
202
+ return error;
203
+ }
204
+ return {
205
+ httpStatusCode: HTTP_STATUS_INTERNAL_SERVER_ERROR,
206
+ errors: [{ error: "Internal Server Error" }]
207
+ };
208
+ }
209
+ setPackageType(transactionId, accountsFilingId, packageType, requestId) {
210
+ return __awaiter(this, void 0, void 0, function* () {
211
+ const url = `/transactions/${transactionId}/accounts-filing/${accountsFilingId}`;
212
+ const packageTypeRequest = {
213
+ packageType: packageType
214
+ };
215
+ const requestBody = mapping_1.default.snakeCaseKeys(packageTypeRequest);
216
+ const headers = util_1.addRequestIdHeader(requestId);
217
+ const resp = yield this.client.httpPut(url, requestBody, headers);
218
+ // Needed due to javascripts switch block scoping rules
219
+ let errorMessage = "";
220
+ switch (resp.status) {
221
+ case 204:
222
+ return new result_1.Success(undefined);
223
+ case 404:
224
+ // The api only checks to see if a transaction with the given id exists. No such test is performed for the accountsFilingId.
225
+ errorMessage = `No transaction with id [${transactionId}] found`;
226
+ return new result_1.Failure(new Error(errorMessage));
227
+ default:
228
+ var errorMessageData = {
229
+ httpStatusCode: resp.status,
230
+ transactionId,
231
+ accountsFilingId,
232
+ responseBody: resp.body
233
+ };
234
+ errorMessage = `An unknown error occured when setting accounts filing package type. ${JSON.stringify(errorMessageData, null, 2)}`;
235
+ return new result_1.Failure(new Error(errorMessage));
236
+ }
237
+ });
238
+ }
239
+ }
240
+ exports.AccountsFilingService = AccountsFilingService;
241
+ /**
242
+ * Type guard function to check if a given object conforms to the ApiErrorResponse interface.
243
+ * This function performs structural validation by checking the existence and types of certain properties
244
+ * expected in a standard ApiErrorResponse. It is used to determine if an arbitrary object can be treated
245
+ * as an ApiErrorResponse, typically in error handling scenarios.
246
+ *
247
+ * @param object - The object to be checked. It can be any type, as the function will verify its structure.
248
+ * @returns A boolean value indicating whether the object is an ApiErrorResponse. Returns true if the object
249
+ * has the expected structure of an ApiErrorResponse, false otherwise.
250
+ *
251
+ * The function checks for the following properties:
252
+ * - httpStatusCode: Must exist and be of type number.
253
+ * - errors: Must exist and be an array. Each item in the array must be an object with specific properties
254
+ * like 'error', 'errorValues', 'location', 'locationType', and 'type', each with appropriate types.
255
+ */
256
+ function isApiErrorResponse(object) {
257
+ if (object.hasOwnProperty("httpStatusCode") &&
258
+ typeof object.httpStatusCode !== "number") {
259
+ return false;
260
+ }
261
+ if (object.hasOwnProperty("errors")) {
262
+ if (!Array.isArray(object.errors)) {
263
+ return false;
264
+ }
265
+ for (const error of object.errors) {
266
+ if (typeof error !== "object" || error === null) {
267
+ return false;
268
+ }
269
+ if (error.hasOwnProperty("error") && typeof error.error !== "string") {
270
+ return false;
271
+ }
272
+ if (error.hasOwnProperty("errorValues") &&
273
+ typeof error.errorValues !== "object") {
274
+ return false;
275
+ }
276
+ if (error.hasOwnProperty("location") &&
277
+ typeof error.location !== "string") {
278
+ return false;
279
+ }
280
+ if (error.hasOwnProperty("locationType") &&
281
+ typeof error.locationType !== "string") {
282
+ return false;
283
+ }
284
+ if (error.hasOwnProperty("type") && typeof error.type !== "string") {
285
+ return false;
286
+ }
287
+ }
288
+ }
289
+ return true;
290
+ }
291
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/services/accounts-filing/service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,kEAAoF;AAEpF,oEAA4C;AAC5C,sCAAqD;AACrD,qCAAgD;AAEhD,MAAM,cAAc,GAAG,GAAG,CAAC;AAC3B,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAClC,MAAM,iCAAiC,GAAG,GAAG,CAAC;AAE9C;;;;;;;;;;GAUG;AACH,MAAa,qBAAqB;IAC9B;;;OAGG;IACH,YAA8B,MAAmB;QAAnB,WAAM,GAAN,MAAM,CAAa;IAAG,CAAC;IAErD;;;;;OAKG;IACU,cAAc,CAAE,aAAqB,EAAE,aAAqB,EAAE,qBAA4C,EAAE,SAAkB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I,KAAK,QAAQ,EAAE;gBAChE,OAAO,KAAK,CAAC;aAChB;SACJ;KACJ;IAED,OAAO,IAAI,CAAC;AAChB,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { AccountValidatorResponse } from "../account-validator/types";
2
+ export declare type AccountsFileValidationResponse = AccountValidatorResponse;
3
+ declare const packageTypes: readonly ["uksef", "cic", "welsh", "limited-partnership", "group-package-400", "group-package-401", "overseas", "audit-exempt-subsidiary", "filing-exempt-subsidiary"];
4
+ declare type ElementType<T extends ReadonlyArray<unknown>> = T extends ReadonlyArray<infer ElementType> ? ElementType : never;
5
+ export declare type PackageType = ElementType<typeof packageTypes>;
6
+ export declare function isPackageType(o: any): o is PackageType;
7
+ export interface AccountsFilingValidationRequest {
8
+ fileId: string;
9
+ accountsFilingId: string;
10
+ transactionId: string;
11
+ }
12
+ export interface AccountsFilingCompanyResponse {
13
+ accountsFilingId: string;
14
+ }
15
+ export interface PackageTypeRequest {
16
+ packageType: PackageType;
17
+ }
18
+ export interface ConfirmCompanyRequest {
19
+ companyName: String;
20
+ }
21
+ export {};
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isPackageType = void 0;
4
+ const packageTypes = [
5
+ "uksef",
6
+ "cic",
7
+ "welsh",
8
+ "limited-partnership",
9
+ "group-package-400",
10
+ "group-package-401",
11
+ "overseas",
12
+ "audit-exempt-subsidiary",
13
+ "filing-exempt-subsidiary"
14
+ ];
15
+ function isPackageType(o) {
16
+ return packageTypes.includes(o);
17
+ }
18
+ exports.isPackageType = isPackageType;
19
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/services/accounts-filing/types.ts"],"names":[],"mappings":";;;AAIA,MAAM,YAAY,GAAG;IACjB,OAAO;IACP,KAAK;IACL,OAAO;IACP,qBAAqB;IACrB,mBAAmB;IACnB,mBAAmB;IACnB,UAAU;IACV,yBAAyB;IACzB,0BAA0B;CACpB,CAAC;AAUX,SAAgB,aAAa,CAAE,CAAM;IACjC,OAAO,YAAY,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;AACpC,CAAC;AAFD,sCAEC"}
@@ -0,0 +1,2 @@
1
+ export * from "./types";
2
+ export { default as PscVerificationService } from "./service";
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ var __importDefault = (this && this.__importDefault) || function (mod) {
13
+ return (mod && mod.__esModule) ? mod : { "default": mod };
14
+ };
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ exports.PscVerificationService = void 0;
17
+ __exportStar(require("./types"), exports);
18
+ var service_1 = require("./service");
19
+ Object.defineProperty(exports, "PscVerificationService", { enumerable: true, get: function () { return __importDefault(service_1).default; } });
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/services/psc-verification-link/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAEA,0CAAwB;AACxB,qCAA8D;AAArD,kIAAA,OAAO,OAA0B"}
@@ -0,0 +1,9 @@
1
+ import { PscVerification, PscVerificationResource } from "./types";
2
+ import { IHttpClient } from "../../http";
3
+ import Resource, { ApiErrorResponse } from "../resource";
4
+ export default class {
5
+ private readonly client;
6
+ constructor(client: IHttpClient);
7
+ postPscVerification(transactionId: string, pscVerification: PscVerification): Promise<Resource<PscVerificationResource> | ApiErrorResponse>;
8
+ private populateResource;
9
+ }
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ class default_1 {
13
+ constructor(client) {
14
+ this.client = client;
15
+ }
16
+ postPscVerification(transactionId, pscVerification) {
17
+ return __awaiter(this, void 0, void 0, function* () {
18
+ const url = `/transactions/${transactionId}/persons-with-significant-control-verification`;
19
+ const response = yield this.client.httpPost(url, pscVerification);
20
+ if (response.error) {
21
+ return {
22
+ httpStatusCode: response.status,
23
+ errors: [response.error]
24
+ };
25
+ }
26
+ const resource = {
27
+ httpStatusCode: response.status
28
+ };
29
+ const body = response.body;
30
+ this.populateResource(resource, body);
31
+ return resource;
32
+ });
33
+ }
34
+ populateResource(resource, body) {
35
+ resource.resource = body;
36
+ }
37
+ }
38
+ exports.default = default_1;
39
+ //# sourceMappingURL=service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/services/psc-verification-link/service.ts"],"names":[],"mappings":";;;;;;;;;;;AAOA;IACI,YAA8B,MAAmB;QAAnB,WAAM,GAAN,MAAM,CAAa;IAAG,CAAC;IAExC,mBAAmB,CAAE,aAAqB,EAAE,eAAgC;;YACrF,MAAM,GAAG,GAAG,iBAAiB,aAAa,gDAAgD,CAAC;YAC3F,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;YAElE,IAAI,QAAQ,CAAC,KAAK,EAAE;gBAChB,OAAO;oBACH,cAAc,EAAE,QAAQ,CAAC,MAAM;oBAC/B,MAAM,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC;iBAC3B,CAAA;aACJ;YAED,MAAM,QAAQ,GAAsC;gBAChD,cAAc,EAAE,QAAQ,CAAC,MAAM;aAClC,CAAC;YACF,MAAM,IAAI,GAAG,QAAQ,CAAC,IAA+B,CAAA;YACrD,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;YACtC,OAAO,QAAQ,CAAC;QACpB,CAAC;KAAA;IAEO,gBAAgB,CAAE,QAA2C,EAAE,IAA6B;QAChG,QAAQ,CAAC,QAAQ,GAAG,IAAI,CAAC;IAC7B,CAAC;CACJ;AAzBD,4BAyBC"}
@@ -0,0 +1,43 @@
1
+ export interface NameElements {
2
+ forename?: string;
3
+ other_forenames?: string;
4
+ middlename?: string;
5
+ surname?: string;
6
+ title?: string;
7
+ }
8
+ export interface RelevantOfficer {
9
+ name_elements: NameElements;
10
+ date_of_birth: Date;
11
+ is_employee: boolean;
12
+ is_director: boolean;
13
+ }
14
+ export declare enum NameMismatchReason {
15
+ PREFERRED_NAME = "PREFERRED_NAME",
16
+ MAIDEN_NAME = "MAIDEN_NAME"
17
+ }
18
+ export declare enum VerificationStatement {
19
+ INDIVIDUAL_VERIFIED = "INDIVIDUAL_VERIFIED",
20
+ RO_IDENTIFIED = "RO_IDENTIFIED",
21
+ RO_VERIFIED = "RO_VERIFIED",
22
+ RO_DECLARATION = "RO_DECLARATION"
23
+ }
24
+ export interface VerificationDetails {
25
+ name_mismatch_reason?: NameMismatchReason;
26
+ verification_statements: VerificationStatement[];
27
+ }
28
+ export interface PscVerification {
29
+ company_number: string;
30
+ psc_appointment_id: string;
31
+ relevant_officer?: RelevantOfficer;
32
+ verification_details: VerificationDetails;
33
+ }
34
+ export interface Links {
35
+ self: string;
36
+ validation_status: string;
37
+ }
38
+ export interface PscVerificationResource {
39
+ created_at: Date;
40
+ updated_at: Date;
41
+ links: Links;
42
+ data: PscVerification;
43
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VerificationStatement = exports.NameMismatchReason = void 0;
4
+ var NameMismatchReason;
5
+ (function (NameMismatchReason) {
6
+ NameMismatchReason["PREFERRED_NAME"] = "PREFERRED_NAME";
7
+ NameMismatchReason["MAIDEN_NAME"] = "MAIDEN_NAME";
8
+ })(NameMismatchReason = exports.NameMismatchReason || (exports.NameMismatchReason = {}));
9
+ var VerificationStatement;
10
+ (function (VerificationStatement) {
11
+ VerificationStatement["INDIVIDUAL_VERIFIED"] = "INDIVIDUAL_VERIFIED";
12
+ VerificationStatement["RO_IDENTIFIED"] = "RO_IDENTIFIED";
13
+ VerificationStatement["RO_VERIFIED"] = "RO_VERIFIED";
14
+ VerificationStatement["RO_DECLARATION"] = "RO_DECLARATION";
15
+ })(VerificationStatement = exports.VerificationStatement || (exports.VerificationStatement = {}));
16
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/services/psc-verification-link/types.ts"],"names":[],"mappings":";;;AAeA,IAAY,kBAGX;AAHD,WAAY,kBAAkB;IAC1B,uDAAiC,CAAA;IACjC,iDAA2B,CAAA;AAC/B,CAAC,EAHW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAG7B;AAED,IAAY,qBAKX;AALD,WAAY,qBAAqB;IAC7B,oEAA2C,CAAA;IAC3C,wDAA8B,CAAA;IAC9B,oDAA2B,CAAA;IAC3B,0DAAiC,CAAA;AACrC,CAAC,EALW,qBAAqB,GAArB,6BAAqB,KAArB,6BAAqB,QAKhC"}
@@ -1,5 +1,5 @@
1
1
  import { IHttpClient } from "../../http";
2
- import { Transaction } from "./types";
2
+ import { Transaction, TransactionResource } from "./types";
3
3
  import Resource, { ApiErrorResponse, ApiResponse } from "../resource";
4
4
  export default class TransactionService {
5
5
  private readonly client;
@@ -9,19 +9,28 @@ export default class TransactionService {
9
9
  *
10
10
  * @param transaction the transaction to create
11
11
  */
12
- postTransaction(transaction: Transaction): Promise<Resource<Transaction> | ApiErrorResponse>;
12
+ postTransaction(transaction: Transaction, requestId?: string): Promise<Resource<Transaction> | ApiErrorResponse>;
13
13
  /**
14
14
  * Put a transaction
15
15
  *
16
- * @param replacment transaction
16
+ * @param {Transaction} transaction The transaction object to be updated
17
+ * @param {string} [requestId] Optional unique identifier for the request used for correlating logs between services
18
+ * @returns {Promise<ApiResponse<Transaction> | ApiErrorResponse>} A promise resolving to the transaction update response
17
19
  */
18
- putTransaction(transaction: Transaction): Promise<ApiResponse<Transaction> | ApiErrorResponse>;
20
+ putTransaction(transaction: Transaction, requestId?: string): Promise<ApiResponse<Transaction> | ApiErrorResponse>;
19
21
  private populateResource;
20
22
  /**
21
23
  * Get a transaction.
22
24
  *
23
25
  * @param transactionId the id of the transaction to retrieve
24
26
  */
25
- getTransaction(transactionId: string): Promise<Resource<Transaction> | ApiErrorResponse>;
27
+ getTransaction(transactionId: string, requestId?: string): Promise<Resource<Transaction> | ApiErrorResponse>;
28
+ /**
29
+ * Patch a transaction.
30
+ *
31
+ * @param transactionId the ID of the transaction to update
32
+ * @param transactionResource the partial transaction resource with updates
33
+ */
34
+ patchTransaction(transactionId: string, transactionResource: Partial<TransactionResource>, requestId?: string): Promise<Resource<Transaction> | ApiErrorResponse>;
26
35
  private mapToResource;
27
36
  }
@@ -9,6 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
+ const util_1 = require("../../util");
12
13
  class TransactionService {
13
14
  constructor(client) {
14
15
  this.client = client;
@@ -18,14 +19,15 @@ class TransactionService {
18
19
  *
19
20
  * @param transaction the transaction to create
20
21
  */
21
- postTransaction(transaction) {
22
+ postTransaction(transaction, requestId) {
22
23
  return __awaiter(this, void 0, void 0, function* () {
23
24
  let url = "/transactions";
24
25
  if (transaction.id) {
25
26
  url += "/" + transaction.id;
26
27
  }
27
28
  const transactionResource = this.mapToResource(transaction);
28
- const resp = yield this.client.httpPost(url, transactionResource);
29
+ const headers = util_1.addRequestIdHeader(requestId);
30
+ const resp = yield this.client.httpPost(url, transactionResource, headers);
29
31
  if (resp.error) {
30
32
  return {
31
33
  httpStatusCode: resp.status,
@@ -44,13 +46,16 @@ class TransactionService {
44
46
  /**
45
47
  * Put a transaction
46
48
  *
47
- * @param replacment transaction
49
+ * @param {Transaction} transaction The transaction object to be updated
50
+ * @param {string} [requestId] Optional unique identifier for the request used for correlating logs between services
51
+ * @returns {Promise<ApiResponse<Transaction> | ApiErrorResponse>} A promise resolving to the transaction update response
48
52
  */
49
- putTransaction(transaction) {
53
+ putTransaction(transaction, requestId) {
50
54
  return __awaiter(this, void 0, void 0, function* () {
51
55
  const url = "/transactions/" + transaction.id;
56
+ const headers = util_1.addRequestIdHeader(requestId);
52
57
  const transactionResource = this.mapToResource(transaction);
53
- const resp = yield this.client.httpPut(url, transactionResource);
58
+ const resp = yield this.client.httpPut(url, transactionResource, headers);
54
59
  if (resp.error) {
55
60
  return {
56
61
  httpStatusCode: resp.status,
@@ -86,10 +91,11 @@ class TransactionService {
86
91
  *
87
92
  * @param transactionId the id of the transaction to retrieve
88
93
  */
89
- getTransaction(transactionId) {
94
+ getTransaction(transactionId, requestId) {
90
95
  return __awaiter(this, void 0, void 0, function* () {
91
96
  const url = "/transactions/" + transactionId;
92
- const resp = yield this.client.httpGet(url);
97
+ const headers = util_1.addRequestIdHeader(requestId);
98
+ const resp = yield this.client.httpGet(url, headers);
93
99
  if (resp.error) {
94
100
  return {
95
101
  httpStatusCode: resp.status,
@@ -119,6 +125,31 @@ class TransactionService {
119
125
  return resource;
120
126
  });
121
127
  }
128
+ /**
129
+ * Patch a transaction.
130
+ *
131
+ * @param transactionId the ID of the transaction to update
132
+ * @param transactionResource the partial transaction resource with updates
133
+ */
134
+ patchTransaction(transactionId, transactionResource, requestId) {
135
+ return __awaiter(this, void 0, void 0, function* () {
136
+ const url = `/transactions/${transactionId}`;
137
+ const headers = util_1.addRequestIdHeader(requestId);
138
+ const resp = yield this.client.httpPatch(url, transactionResource, headers);
139
+ if (resp.error) {
140
+ return {
141
+ httpStatusCode: resp.status,
142
+ errors: [resp.error]
143
+ };
144
+ }
145
+ const resource = {
146
+ httpStatusCode: resp.status
147
+ };
148
+ const body = resp.body;
149
+ this.populateResource(resource, body);
150
+ return resource;
151
+ });
152
+ }
122
153
  mapToResource(transaction) {
123
154
  return {
124
155
  company_name: transaction.companyName,
@@ -1 +1 @@
1
- {"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/services/transaction/service.ts"],"names":[],"mappings":";;;;;;;;;;;AAIA,MAAqB,kBAAkB;IACnC,YAA8B,MAAmB;QAAnB,WAAM,GAAN,MAAM,CAAa;IAAI,CAAC;IAEtD;;;;KAIC;IACY,eAAe,CAAE,WAAwB;;YAClD,IAAI,GAAG,GAAG,eAAe,CAAA;YACzB,IAAI,WAAW,CAAC,EAAE,EAAE;gBAChB,GAAG,IAAI,GAAG,GAAG,WAAW,CAAC,EAAE,CAAA;aAC9B;YAED,MAAM,mBAAmB,GAAwB,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;YAEjF,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,mBAAmB,CAAC,CAAC;YAElE,IAAI,IAAI,CAAC,KAAK,EAAE;gBACZ,OAAO;oBACH,cAAc,EAAE,IAAI,CAAC,MAAM;oBAC3B,MAAM,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC;iBACvB,CAAC;aACL;YAED,MAAM,QAAQ,GAA0B;gBACpC,cAAc,EAAE,IAAI,CAAC,MAAM;aAC9B,CAAC;YAEF,8CAA8C;YAC9C,MAAM,IAAI,GAAG,IAAI,CAAC,IAA2B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AE,WAAW,CAAC,MAAM;YAC1B,UAAU,EAAE,WAAW,CAAC,SAAS;SACpC,CAAA;IACL,CAAC;CACJ;AA9KD,qCA8KC"}
package/dist/util.d.ts ADDED
@@ -0,0 +1,14 @@
1
+ import { Headers } from "./http";
2
+ /**
3
+ * Adds a Request ID header to the existing headers, if the Request ID is provided.
4
+ *
5
+ * The Request ID header is utilised to correlate requests between services, allowing
6
+ * for easier tracking of how requests propagate through a system of microservices.
7
+ * It is also used as a context key for logger systems to maintain tracing information
8
+ * across service calls.
9
+ *
10
+ * @param {string | undefined} requestId The unique identifier for the request, used for tracing.
11
+ * @param {Headers} otherHeaders Existing set of headers to which the Request ID header will be added.
12
+ * @returns {Headers | undefined} A new headers object with the Request ID added, or undefined if no Request ID was provided.
13
+ */
14
+ export declare function addRequestIdHeader(requestId?: string, otherHeaders?: Headers): Headers | undefined;
package/dist/util.js ADDED
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.addRequestIdHeader = void 0;
4
+ const config_1 = require("./config");
5
+ /**
6
+ * Adds a Request ID header to the existing headers, if the Request ID is provided.
7
+ *
8
+ * The Request ID header is utilised to correlate requests between services, allowing
9
+ * for easier tracking of how requests propagate through a system of microservices.
10
+ * It is also used as a context key for logger systems to maintain tracing information
11
+ * across service calls.
12
+ *
13
+ * @param {string | undefined} requestId The unique identifier for the request, used for tracing.
14
+ * @param {Headers} otherHeaders Existing set of headers to which the Request ID header will be added.
15
+ * @returns {Headers | undefined} A new headers object with the Request ID added, or undefined if no Request ID was provided.
16
+ */
17
+ function addRequestIdHeader(requestId, otherHeaders = {}) {
18
+ if (requestId === undefined) {
19
+ return undefined;
20
+ }
21
+ otherHeaders = otherHeaders !== undefined ? otherHeaders : {};
22
+ return Object.assign(Object.assign({}, otherHeaders), { [config_1.REQUEST_ID_HEADER]: requestId });
23
+ }
24
+ exports.addRequestIdHeader = addRequestIdHeader;
25
+ //# sourceMappingURL=util.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":";;;AAAA,qCAA6C;AAG7C;;;;;;;;;;;GAWG;AACH,SAAgB,kBAAkB,CAAE,SAAkB,EAAE,eAAwB,EAAE;IAC9E,IAAI,SAAS,KAAK,SAAS,EAAE;QACzB,OAAO,SAAS,CAAA;KACnB;IAED,YAAY,GAAG,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,CAAA;IAE7D,uCAAY,YAAY,KAAE,CAAC,0BAAiB,CAAC,EAAE,SAAS,IAAG;AAC/D,CAAC;AARD,gDAQC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@companieshouse/api-sdk-node",
3
- "version": "2.0.152",
3
+ "version": "2.0.154",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "files": [