@companieshouse/api-sdk-node 2.0.76 → 2.0.78

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,4 +1,4 @@
1
- import { CompanyOfficer } from "./types";
1
+ import { CompanyOfficer, FilingResponse, OfficerFiling } from "./types";
2
2
  import { IHttpClient } from "../../http";
3
3
  import Resource, { ApiErrorResponse } from "../resource";
4
4
  export default class {
@@ -15,5 +15,23 @@ export default class {
15
15
  */
16
16
  getDirectorAndTerminationDate(transactionId: string, submissionId: string): Promise<Resource<CompanyOfficer> | ApiErrorResponse>;
17
17
  getCurrentOrFutureDissolved(companyNumber: String): Promise<Resource<Boolean> | ApiErrorResponse>;
18
+ /**
19
+ * Post an officer filing object to update on the API.
20
+ */
21
+ postOfficerFiling(transactionId: string, officerFiling: OfficerFiling): Promise<Resource<FilingResponse> | ApiErrorResponse>;
22
+ /**
23
+ * Patch an officer filing object to update on the API.
24
+ */
25
+ patchOfficerFiling(transactionId: string, filingId: string, officerFiling: OfficerFiling): Promise<Resource<FilingResponse> | ApiErrorResponse>;
26
+ /**
27
+ * Map an OfficerFiling object to an OfficerFilingDto which represents the expected json data model
28
+ */
29
+ private mapToDto;
30
+ /**
31
+ * Map a FilingResponseDto in its json data model to a regular FilingResponse object
32
+ * @param resource Where the FilingResponse fields will be set
33
+ * @param body The FilingResponseDto json data model that will be mapped
34
+ */
35
+ private populateResource;
18
36
  private getCompanyOfficerDetails;
19
37
  }
@@ -51,6 +51,71 @@ class default_1 {
51
51
  return { httpStatusCode: resp.status, resource: resp.body };
52
52
  });
53
53
  }
54
+ /**
55
+ * Post an officer filing object to update on the API.
56
+ */
57
+ postOfficerFiling(transactionId, officerFiling) {
58
+ return __awaiter(this, void 0, void 0, function* () {
59
+ const url = `/transactions/${transactionId}/officers`;
60
+ const officerFilingResource = this.mapToDto(officerFiling);
61
+ const resp = yield this.client.httpPost(url, officerFilingResource);
62
+ if (resp.error) {
63
+ return {
64
+ httpStatusCode: resp.status,
65
+ errors: [resp.error]
66
+ };
67
+ }
68
+ const resource = {
69
+ httpStatusCode: resp.status
70
+ };
71
+ const body = resp.body;
72
+ this.populateResource(resource, body);
73
+ return resource;
74
+ });
75
+ }
76
+ /**
77
+ * Patch an officer filing object to update on the API.
78
+ */
79
+ patchOfficerFiling(transactionId, filingId, officerFiling) {
80
+ return __awaiter(this, void 0, void 0, function* () {
81
+ const url = `/transactions/${transactionId}/officers/${filingId}`;
82
+ const officerFilingResource = this.mapToDto(officerFiling);
83
+ const resp = yield this.client.httpPatch(url, officerFilingResource);
84
+ if (resp.error) {
85
+ return {
86
+ httpStatusCode: resp.status,
87
+ errors: [resp.error]
88
+ };
89
+ }
90
+ const resource = {
91
+ httpStatusCode: resp.status
92
+ };
93
+ const body = resp.body;
94
+ this.populateResource(resource, body);
95
+ return resource;
96
+ });
97
+ }
98
+ /**
99
+ * Map an OfficerFiling object to an OfficerFilingDto which represents the expected json data model
100
+ */
101
+ mapToDto(officerFiling) {
102
+ return {
103
+ reference_appointment_id: officerFiling.referenceAppointmentId,
104
+ reference_etag: officerFiling.referenceEtag,
105
+ resigned_on: officerFiling.resignedOn
106
+ };
107
+ }
108
+ /**
109
+ * Map a FilingResponseDto in its json data model to a regular FilingResponse object
110
+ * @param resource Where the FilingResponse fields will be set
111
+ * @param body The FilingResponseDto json data model that will be mapped
112
+ */
113
+ populateResource(resource, body) {
114
+ resource.resource = {
115
+ submissionId: body.submission_id,
116
+ name: body.name
117
+ };
118
+ }
54
119
  getCompanyOfficerDetails(url) {
55
120
  return __awaiter(this, void 0, void 0, function* () {
56
121
  const resp = yield this.client.httpGet(url);
@@ -1 +1 @@
1
- {"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/services/officer-filing/service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAMA,oEAA4C;AAE5C;IACI,YAA8B,MAAmB;QAAnB,WAAM,GAAN,MAAM,CAAa;IAAI,CAAC;IAEzC,4BAA4B,C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;YAEnD,QAAQ,CAAC,QAAQ,GAAG,iBAAO,CAAC,aAAa,CAAmB,IAAI,CAAC,CAAC;YAElE,OAAO,QAAQ,CAAC;QACpB,CAAC;KAAA;CACJ;AA1HD,4BA0HC"}
@@ -1,6 +1,6 @@
1
1
  /**
2
- * CompanyOfficerResource is what is returned from the api.
3
- */
2
+ * CompanyOfficerResource is what is returned from the api.
3
+ */
4
4
  export interface CompanyOfficerResource {
5
5
  address: AddressResource;
6
6
  appointed_on: string;
@@ -43,6 +43,7 @@ export interface IdentificationResource {
43
43
  registration_number?: string;
44
44
  }
45
45
  export interface CompanyOfficerResourceLinks {
46
+ self: string;
46
47
  officer: OfficerResourceLinks;
47
48
  }
48
49
  export interface OfficerResourceLinks {
@@ -51,6 +52,10 @@ export interface OfficerResourceLinks {
51
52
  /**
52
53
  * CompanyOfficers is the interface used within this SDK.
53
54
  */
55
+ export interface OfficerCard {
56
+ removeUrl: string;
57
+ officer: CompanyOfficer;
58
+ }
54
59
  export interface CompanyOfficer {
55
60
  address: Address;
56
61
  appointedOn: string;
@@ -93,8 +98,34 @@ export interface Identification {
93
98
  registrationNumber?: string;
94
99
  }
95
100
  export interface CompanyOfficerLinks {
101
+ self: string;
96
102
  officer: OfficerLinks;
97
103
  }
98
104
  export interface OfficerLinks {
99
105
  appointments: string;
100
106
  }
107
+ /**
108
+ * The response returned when a filing has been sent to the api. The submission ID can be used to refer back to the saved filing.
109
+ */
110
+ export interface FilingResponse {
111
+ submissionId: string;
112
+ name: string;
113
+ }
114
+ export interface FilingResponseDto {
115
+ submission_id: string;
116
+ name: string;
117
+ }
118
+ /**
119
+ * OfficerFiling represents the filing of an officer. It is populated with the necessary information for a filing to be processed.
120
+ * This is used for both post and patch requests.
121
+ */
122
+ export interface OfficerFiling {
123
+ referenceAppointmentId?: string;
124
+ referenceEtag?: string;
125
+ resignedOn?: string;
126
+ }
127
+ export interface OfficerFilingDto {
128
+ reference_appointment_id?: string;
129
+ reference_etag?: string;
130
+ resigned_on?: string;
131
+ }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /**
3
- * CompanyOfficerResource is what is returned from the api.
4
- */
3
+ * CompanyOfficerResource is what is returned from the api.
4
+ */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/services/officer-filing/types.ts"],"names":[],"mappings":";AAAA;;GAEG"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/services/officer-filing/types.ts"],"names":[],"mappings":";AAAA;;EAEE"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@companieshouse/api-sdk-node",
3
- "version": "2.0.76",
3
+ "version": "2.0.78",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "files": [