@companieshouse/api-sdk-node 2.0.63 → 2.0.65
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.
- package/dist/http/request-client.js +12 -14
- package/dist/http/request-client.js.map +1 -1
- package/dist/services/officer-filing/service.d.ts +2 -4
- package/dist/services/officer-filing/service.js +6 -22
- package/dist/services/officer-filing/service.js.map +1 -1
- package/dist/services/officer-filing/types.d.ts +87 -52
- package/dist/services/officer-filing/types.js +3 -0
- package/dist/services/officer-filing/types.js.map +1 -1
- package/package.json +3 -3
|
@@ -13,7 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const http_client_1 = require("./http-client");
|
|
16
|
-
const
|
|
16
|
+
const axios_1 = __importDefault(require("axios"));
|
|
17
17
|
/**
|
|
18
18
|
* RequestClient is an implementation of our http client using the request
|
|
19
19
|
* library.
|
|
@@ -49,30 +49,28 @@ class RequestClient extends http_client_1.AbstractClient {
|
|
|
49
49
|
return __awaiter(this, void 0, void 0, function* () {
|
|
50
50
|
try {
|
|
51
51
|
const options = {
|
|
52
|
-
baseUrl: this.options.baseUrl,
|
|
53
|
-
uri: additionalOptions.url,
|
|
54
52
|
method: additionalOptions.method,
|
|
55
53
|
headers: Object.assign(Object.assign({}, this.headers), additionalOptions.headers),
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
url: `${this.options.baseUrl}{additionalOptions.url}`,
|
|
55
|
+
data: additionalOptions.body,
|
|
56
|
+
responseType: "json",
|
|
57
|
+
validateStatus: () => true
|
|
59
58
|
};
|
|
60
59
|
// any errors (including status code errors) are thrown as exceptions and
|
|
61
60
|
// will be caught in the catch block.
|
|
62
|
-
const resp = yield
|
|
61
|
+
const resp = yield axios_1.default(options);
|
|
63
62
|
return {
|
|
64
|
-
status: resp.
|
|
65
|
-
body: resp.
|
|
63
|
+
status: resp.status,
|
|
64
|
+
body: resp.data,
|
|
66
65
|
headers: resp.headers
|
|
67
66
|
};
|
|
68
67
|
}
|
|
69
68
|
catch (e) {
|
|
70
|
-
// e
|
|
71
|
-
//
|
|
72
|
-
|
|
73
|
-
const error = ((_a = e === null || e === void 0 ? void 0 : e.response) === null || _a === void 0 ? void 0 : _a.body) || { message: "failed to execute http request" };
|
|
69
|
+
// e can be an instance of AxiosError or a generic error
|
|
70
|
+
// however, we cannot specify a type for e coz type annotations for catch block errors must be 'any' or 'unknown' if specified
|
|
71
|
+
const error = ((_a = e === null || e === void 0 ? void 0 : e.response) === null || _a === void 0 ? void 0 : _a.data) || { message: "failed to execute http request" };
|
|
74
72
|
return {
|
|
75
|
-
status: (e === null || e === void 0 ? void 0 : e.
|
|
73
|
+
status: (e === null || e === void 0 ? void 0 : e.status) || 500,
|
|
76
74
|
error
|
|
77
75
|
};
|
|
78
76
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request-client.js","sourceRoot":"","sources":["../../src/http/request-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+CAAyF;AACzF,
|
|
1
|
+
{"version":3,"file":"request-client.js","sourceRoot":"","sources":["../../src/http/request-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+CAAyF;AACzF,kDAA6E;AAE7E;;;GAGG;AACH,MAAqB,aAAc,SAAQ,4BAAc;IACxC,OAAO,CAAE,GAAW,EAAE,OAAiB;;YAChD,OAAO,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,CAAC;QACzD,CAAC;KAAA;IAEY,QAAQ,CAAE,GAAW,EAAE,IAAU,EAAE,OAAiB;;YAC7D,OAAO,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;QAChE,CAAC;KAAA;IAEY,SAAS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AI,KAAI,EAAE,OAAO,EAAE,gCAAgC,EAAE,CAAC;gBACjF,OAAO;oBACH,MAAM,EAAE,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,MAAM,KAAI,GAAG;oBACxB,KAAK;iBACR,CAAC;aACL;;KACJ;CACJ;AArDD,gCAqDC"}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CompanyOfficer } from "./types";
|
|
2
2
|
import { IHttpClient } from "../../http";
|
|
3
3
|
import Resource, { ApiErrorResponse } from "../resource";
|
|
4
4
|
export default class {
|
|
5
5
|
private readonly client;
|
|
6
6
|
constructor(client: IHttpClient);
|
|
7
|
-
getListActiveDirectorDetails(transactionId: string): Promise<Resource<
|
|
8
|
-
private mapToListActiveOfficerDetails;
|
|
9
|
-
private mapToAddress;
|
|
7
|
+
getListActiveDirectorDetails(transactionId: string): Promise<Resource<CompanyOfficer[]> | ApiErrorResponse>;
|
|
10
8
|
private getOfficerFilingUrlIncTransactionId;
|
|
11
9
|
}
|
|
@@ -8,7 +8,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const mapping_1 = __importDefault(require("../../mapping/mapping"));
|
|
12
16
|
class default_1 {
|
|
13
17
|
constructor(client) {
|
|
14
18
|
this.client = client;
|
|
@@ -21,31 +25,11 @@ class default_1 {
|
|
|
21
25
|
return { httpStatusCode: resp.status, errors: [resp.error] };
|
|
22
26
|
}
|
|
23
27
|
const resource = { httpStatusCode: resp.status };
|
|
24
|
-
|
|
28
|
+
const body = resp.body;
|
|
29
|
+
resource.resource = mapping_1.default.camelCaseKeys(body);
|
|
25
30
|
return resource;
|
|
26
31
|
});
|
|
27
32
|
}
|
|
28
|
-
mapToListActiveOfficerDetails(officerResourceList) {
|
|
29
|
-
const officerList = [];
|
|
30
|
-
for (let index = 0; index < officerResourceList.length; index++) {
|
|
31
|
-
const officerResource = officerResourceList[index];
|
|
32
|
-
officerList[index] = Object.assign(Object.assign(Object.assign({ foreName1: officerResource.fore_name_1, foreName2: officerResource.fore_name_2, surname: officerResource.surname, occupation: officerResource.occupation, nationality: officerResource.nationality, dateOfBirth: officerResource.date_of_birth, dateOfAppointment: officerResource.date_of_appointment, countryOfResidence: officerResource.country_of_residence }, (officerResource.service_address && { serviceAddress: this.mapToAddress(officerResource.service_address) })), (officerResource.residential_address && { residentialAddress: this.mapToAddress(officerResource.residential_address) })), { isCorporate: officerResource.is_corporate, role: officerResource.role, placeRegistered: officerResource.place_registered, registrationNumber: officerResource.registration_number, lawGoverned: officerResource.law_governed, legalForm: officerResource.legal_form, identificationType: officerResource.identification_type });
|
|
33
|
-
}
|
|
34
|
-
return officerList;
|
|
35
|
-
}
|
|
36
|
-
mapToAddress(addressResource) {
|
|
37
|
-
return {
|
|
38
|
-
addressLine1: addressResource.address_line_1,
|
|
39
|
-
addressLine2: addressResource.address_line_2,
|
|
40
|
-
careOf: addressResource.care_of,
|
|
41
|
-
country: addressResource.country,
|
|
42
|
-
locality: addressResource.locality,
|
|
43
|
-
poBox: addressResource.po_box,
|
|
44
|
-
postalCode: addressResource.postal_code,
|
|
45
|
-
premises: addressResource.premises,
|
|
46
|
-
region: addressResource.region
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
33
|
getOfficerFilingUrlIncTransactionId(transactionId) {
|
|
50
34
|
return `/transactions/${transactionId}/officers`;
|
|
51
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.js","sourceRoot":"","sources":["../../../src/services/officer-filing/service.ts"],"names":[],"mappings":"
|
|
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,CAAE,aAAqB;;YAC5D,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,mCAAmC,CAAC,aAAa,CAAC,2BAA2B,CAAC;YAClG,MAAM,IAAI,GAAiB,MAAM,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YAE1D,IAAI,IAAI,CAAC,MAAM,IAAI,GAAG,EAAE;gBACpB,OAAO,EAAE,cAAc,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;aAChE;YAED,MAAM,QAAQ,GAA+B,EAAE,cAAc,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC;YAE7E,MAAM,IAAI,GAAG,IAAI,CAAC,IAAgC,CAAC;YAEnD,QAAQ,CAAC,QAAQ,GAAG,iBAAO,CAAC,aAAa,CAAmB,IAAI,CAAC,CAAC;YAElE,OAAO,QAAQ,CAAC;QACpB,CAAC;KAAA;IAEO,mCAAmC,CAAE,aAAqB;QAC9D,OAAO,iBAAiB,aAAa,WAAW,CAAC;IACrD,CAAC;CACJ;AAvBD,4BAuBC"}
|
|
@@ -1,65 +1,100 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/**
|
|
2
|
+
* CompanyOfficerResource is what is returned from the api.
|
|
3
|
+
*/
|
|
4
|
+
export interface CompanyOfficerResource {
|
|
5
|
+
address: AddressResource;
|
|
6
|
+
appointed_on: string;
|
|
7
|
+
country_of_residence?: string;
|
|
8
|
+
date_of_birth?: DateOfBirthResource;
|
|
9
|
+
former_names?: FormerNameResource[];
|
|
10
|
+
identification?: IdentificationResource;
|
|
11
|
+
links: CompanyOfficerResourceLinks;
|
|
12
|
+
name: string;
|
|
13
|
+
nationality?: string;
|
|
14
|
+
occupation?: string;
|
|
15
|
+
officer_role: string;
|
|
16
|
+
resigned_on?: string;
|
|
5
17
|
}
|
|
6
|
-
export interface
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
lawGoverned?: string;
|
|
22
|
-
legalForm?: string;
|
|
23
|
-
identificationType?: string;
|
|
18
|
+
export interface AddressResource {
|
|
19
|
+
address_line_1: string;
|
|
20
|
+
address_line_2?: string;
|
|
21
|
+
care_of?: string;
|
|
22
|
+
country: string;
|
|
23
|
+
locality: string;
|
|
24
|
+
po_box?: string;
|
|
25
|
+
postal_code?: string;
|
|
26
|
+
premises?: string;
|
|
27
|
+
region?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface DateOfBirthResource {
|
|
30
|
+
day?: string;
|
|
31
|
+
month: string;
|
|
32
|
+
year: string;
|
|
24
33
|
}
|
|
25
|
-
export interface
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
country_of_residence: string;
|
|
34
|
-
service_address: AddressResource;
|
|
35
|
-
residential_address: AddressResource;
|
|
36
|
-
is_corporate: boolean;
|
|
37
|
-
role: string;
|
|
34
|
+
export interface FormerNameResource {
|
|
35
|
+
forenames?: string;
|
|
36
|
+
surname?: string;
|
|
37
|
+
}
|
|
38
|
+
export interface IdentificationResource {
|
|
39
|
+
identification_type?: string;
|
|
40
|
+
legal_authority?: string;
|
|
41
|
+
legal_form?: string;
|
|
38
42
|
place_registered?: string;
|
|
39
43
|
registration_number?: string;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
44
|
+
}
|
|
45
|
+
export interface CompanyOfficerResourceLinks {
|
|
46
|
+
officer: OfficerResourceLinks;
|
|
47
|
+
}
|
|
48
|
+
export interface OfficerResourceLinks {
|
|
49
|
+
appointments: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* CompanyOfficers is the interface used within this SDK.
|
|
53
|
+
*/
|
|
54
|
+
export interface CompanyOfficer {
|
|
55
|
+
address: Address;
|
|
56
|
+
appointedOn: string;
|
|
57
|
+
countryOfResidence?: string;
|
|
58
|
+
dateOfBirth?: DateOfBirth;
|
|
59
|
+
formerNames?: FormerName[];
|
|
60
|
+
identification?: Identification;
|
|
61
|
+
links: CompanyOfficerLinks;
|
|
62
|
+
name: string;
|
|
63
|
+
nationality?: string;
|
|
64
|
+
occupation?: string;
|
|
65
|
+
officerRole: string;
|
|
66
|
+
resignedOn?: string;
|
|
43
67
|
}
|
|
44
68
|
export interface Address {
|
|
45
|
-
addressLine1
|
|
46
|
-
addressLine2
|
|
69
|
+
addressLine1: string;
|
|
70
|
+
addressLine2: string;
|
|
47
71
|
careOf?: string;
|
|
48
|
-
country
|
|
49
|
-
locality
|
|
72
|
+
country: string;
|
|
73
|
+
locality: string;
|
|
50
74
|
poBox?: string;
|
|
51
75
|
postalCode?: string;
|
|
52
76
|
premises?: string;
|
|
53
77
|
region?: string;
|
|
54
78
|
}
|
|
55
|
-
export interface
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
79
|
+
export interface DateOfBirth {
|
|
80
|
+
day?: string;
|
|
81
|
+
month: string;
|
|
82
|
+
year: string;
|
|
83
|
+
}
|
|
84
|
+
export interface FormerName {
|
|
85
|
+
forenames?: string;
|
|
86
|
+
surname?: string;
|
|
87
|
+
}
|
|
88
|
+
export interface Identification {
|
|
89
|
+
identificationType?: string;
|
|
90
|
+
legalAuthority?: string;
|
|
91
|
+
legalForm?: string;
|
|
92
|
+
placeRegistered?: string;
|
|
93
|
+
registrationNumber?: string;
|
|
94
|
+
}
|
|
95
|
+
export interface CompanyOfficerLinks {
|
|
96
|
+
officer: OfficerLinks;
|
|
97
|
+
}
|
|
98
|
+
export interface OfficerLinks {
|
|
99
|
+
appointments: string;
|
|
65
100
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/services/officer-filing/types.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/services/officer-filing/types.ts"],"names":[],"mappings":";AAAA;;GAEG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@companieshouse/api-sdk-node",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.65",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -17,13 +17,13 @@
|
|
|
17
17
|
"analyse-code": "sonar-scanner"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
+
"axios": "^0.21.4",
|
|
20
21
|
"camelcase-keys": "~6.2.2",
|
|
21
|
-
"request": "~2.88.2",
|
|
22
|
-
"request-promise-native": "~1.0.9",
|
|
23
22
|
"snakecase-keys": "~3.2.0",
|
|
24
23
|
"url-search-params-polyfill": "~8.1.1"
|
|
25
24
|
},
|
|
26
25
|
"devDependencies": {
|
|
26
|
+
"@types/axios": "^0.14.0",
|
|
27
27
|
"@types/chai": "^4.2.22",
|
|
28
28
|
"@types/chai-as-promised": "^7.1.4",
|
|
29
29
|
"@types/chai-http": "~4.2.0",
|