@bisondesk/core-sdk 1.0.23-B → 1.0.25
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/lib/constants.d.ts +0 -77
- package/lib/constants.d.ts.map +1 -1
- package/lib/constants.js +1 -924
- package/lib/constants.js.map +1 -1
- package/lib/types/crm.d.ts +30 -102
- package/lib/types/crm.d.ts.map +1 -1
- package/lib/types/crm.js +0 -16
- package/lib/types/crm.js.map +1 -1
- package/lib/types/definitions.d.ts +13 -15
- package/lib/types/definitions.d.ts.map +1 -1
- package/lib/types/fields.d.ts +25 -26
- package/lib/types/fields.d.ts.map +1 -1
- package/lib/types/fields.js +0 -4
- package/lib/types/fields.js.map +1 -1
- package/lib/types/interests.d.ts +31 -0
- package/lib/types/interests.d.ts.map +1 -0
- package/lib/types/{settings.js → interests.js} +1 -1
- package/lib/types/interests.js.map +1 -0
- package/lib/types/picklists.d.ts +4 -15
- package/lib/types/picklists.d.ts.map +1 -1
- package/lib/types/search.d.ts +4 -26
- package/lib/types/search.d.ts.map +1 -1
- package/lib/types/search.js.map +1 -1
- package/lib/types/storage.d.ts +11 -1
- package/lib/types/storage.d.ts.map +1 -1
- package/lib/types/storage.js +0 -15
- package/lib/types/storage.js.map +1 -1
- package/lib/types/tenants.d.ts +9 -32
- package/lib/types/tenants.d.ts.map +1 -1
- package/lib/types/tenants.js +0 -11
- package/lib/types/tenants.js.map +1 -1
- package/lib/types/users.d.ts +3 -11
- package/lib/types/users.d.ts.map +1 -1
- package/lib/types/utils.d.ts +0 -20
- package/lib/types/utils.d.ts.map +1 -1
- package/lib/types/utils.js +0 -6
- package/lib/types/utils.js.map +1 -1
- package/lib/types/vehicles.d.ts +92 -406
- package/lib/types/vehicles.d.ts.map +1 -1
- package/lib/types/vehicles.js +1 -54
- package/lib/types/vehicles.js.map +1 -1
- package/package.json +6 -8
- package/src/constants.ts +1 -930
- package/src/types/crm.ts +30 -117
- package/src/types/definitions.ts +12 -19
- package/src/types/fields.ts +31 -72
- package/src/types/interests.ts +28 -0
- package/src/types/picklists.ts +7 -26
- package/src/types/search.ts +4 -34
- package/src/types/storage.ts +12 -1
- package/src/types/tenants.ts +11 -37
- package/src/types/users.ts +3 -17
- package/src/types/utils.ts +0 -25
- package/src/types/vehicles.ts +93 -461
- package/tsconfig.tsbuildinfo +2995 -1
- package/lib/apis/crm.d.ts +0 -39
- package/lib/apis/crm.d.ts.map +0 -1
- package/lib/apis/crm.js +0 -201
- package/lib/apis/crm.js.map +0 -1
- package/lib/apis/documents.d.ts +0 -4
- package/lib/apis/documents.d.ts.map +0 -1
- package/lib/apis/documents.js +0 -47
- package/lib/apis/documents.js.map +0 -1
- package/lib/apis/internet-vehicles.d.ts +0 -3
- package/lib/apis/internet-vehicles.d.ts.map +0 -1
- package/lib/apis/internet-vehicles.js +0 -27
- package/lib/apis/internet-vehicles.js.map +0 -1
- package/lib/apis/leasing-administration.d.ts +0 -8
- package/lib/apis/leasing-administration.d.ts.map +0 -1
- package/lib/apis/leasing-administration.js +0 -49
- package/lib/apis/leasing-administration.js.map +0 -1
- package/lib/apis/leasing.d.ts +0 -19
- package/lib/apis/leasing.d.ts.map +0 -1
- package/lib/apis/leasing.js +0 -168
- package/lib/apis/leasing.js.map +0 -1
- package/lib/apis/opportunities.d.ts +0 -9
- package/lib/apis/opportunities.d.ts.map +0 -1
- package/lib/apis/opportunities.js +0 -94
- package/lib/apis/opportunities.js.map +0 -1
- package/lib/apis/picklists.d.ts +0 -5
- package/lib/apis/picklists.d.ts.map +0 -1
- package/lib/apis/picklists.js +0 -44
- package/lib/apis/picklists.js.map +0 -1
- package/lib/apis/tenants.d.ts +0 -7
- package/lib/apis/tenants.d.ts.map +0 -1
- package/lib/apis/tenants.js +0 -80
- package/lib/apis/tenants.js.map +0 -1
- package/lib/apis/users.d.ts +0 -3
- package/lib/apis/users.d.ts.map +0 -1
- package/lib/apis/users.js +0 -26
- package/lib/apis/users.js.map +0 -1
- package/lib/apis/utils.d.ts +0 -9
- package/lib/apis/utils.d.ts.map +0 -1
- package/lib/apis/utils.js +0 -23
- package/lib/apis/utils.js.map +0 -1
- package/lib/apis/vehicles.d.ts +0 -18
- package/lib/apis/vehicles.d.ts.map +0 -1
- package/lib/apis/vehicles.js +0 -159
- package/lib/apis/vehicles.js.map +0 -1
- package/lib/ddb-entities.d.ts +0 -2
- package/lib/ddb-entities.d.ts.map +0 -1
- package/lib/ddb-entities.js +0 -5
- package/lib/ddb-entities.js.map +0 -1
- package/lib/types/activities.d.ts +0 -38
- package/lib/types/activities.d.ts.map +0 -1
- package/lib/types/activities.js +0 -16
- package/lib/types/activities.js.map +0 -1
- package/lib/types/documents.d.ts +0 -105
- package/lib/types/documents.d.ts.map +0 -1
- package/lib/types/documents.js +0 -3
- package/lib/types/documents.js.map +0 -1
- package/lib/types/internet-vehicles.d.ts +0 -64
- package/lib/types/internet-vehicles.d.ts.map +0 -1
- package/lib/types/internet-vehicles.js +0 -3
- package/lib/types/internet-vehicles.js.map +0 -1
- package/lib/types/leads.d.ts +0 -134
- package/lib/types/leads.d.ts.map +0 -1
- package/lib/types/leads.js +0 -3
- package/lib/types/leads.js.map +0 -1
- package/lib/types/leasing-administration.d.ts +0 -107
- package/lib/types/leasing-administration.d.ts.map +0 -1
- package/lib/types/leasing-administration.js +0 -3
- package/lib/types/leasing-administration.js.map +0 -1
- package/lib/types/leasing-search.d.ts +0 -22
- package/lib/types/leasing-search.d.ts.map +0 -1
- package/lib/types/leasing-search.js +0 -3
- package/lib/types/leasing-search.js.map +0 -1
- package/lib/types/leasing-settings.d.ts +0 -113
- package/lib/types/leasing-settings.d.ts.map +0 -1
- package/lib/types/leasing-settings.js +0 -10
- package/lib/types/leasing-settings.js.map +0 -1
- package/lib/types/leasing.d.ts +0 -322
- package/lib/types/leasing.d.ts.map +0 -1
- package/lib/types/leasing.js +0 -24
- package/lib/types/leasing.js.map +0 -1
- package/lib/types/machines.d.ts +0 -38
- package/lib/types/machines.d.ts.map +0 -1
- package/lib/types/machines.js +0 -3
- package/lib/types/machines.js.map +0 -1
- package/lib/types/opportunities.d.ts +0 -448
- package/lib/types/opportunities.d.ts.map +0 -1
- package/lib/types/opportunities.js +0 -68
- package/lib/types/opportunities.js.map +0 -1
- package/lib/types/payments.d.ts +0 -38
- package/lib/types/payments.d.ts.map +0 -1
- package/lib/types/payments.js +0 -9
- package/lib/types/payments.js.map +0 -1
- package/lib/types/quotes.d.ts +0 -173
- package/lib/types/quotes.d.ts.map +0 -1
- package/lib/types/quotes.js +0 -26
- package/lib/types/quotes.js.map +0 -1
- package/lib/types/recently-viewed.d.ts +0 -33
- package/lib/types/recently-viewed.d.ts.map +0 -1
- package/lib/types/recently-viewed.js +0 -3
- package/lib/types/recently-viewed.js.map +0 -1
- package/lib/types/saved-filters.d.ts +0 -20
- package/lib/types/saved-filters.d.ts.map +0 -1
- package/lib/types/saved-filters.js +0 -3
- package/lib/types/saved-filters.js.map +0 -1
- package/lib/types/settings.d.ts +0 -50
- package/lib/types/settings.d.ts.map +0 -1
- package/lib/types/settings.js.map +0 -1
- package/lib/types/templates.d.ts +0 -35
- package/lib/types/templates.d.ts.map +0 -1
- package/lib/types/templates.js +0 -9
- package/lib/types/templates.js.map +0 -1
- package/lib/types/website.d.ts +0 -24
- package/lib/types/website.d.ts.map +0 -1
- package/lib/types/website.js +0 -3
- package/lib/types/website.js.map +0 -1
- package/lib/utils/forms.d.ts +0 -6
- package/lib/utils/forms.d.ts.map +0 -1
- package/lib/utils/forms.js +0 -33
- package/lib/utils/forms.js.map +0 -1
- package/lib/utils/leasing.d.ts +0 -3
- package/lib/utils/leasing.d.ts.map +0 -1
- package/lib/utils/leasing.js +0 -10
- package/lib/utils/leasing.js.map +0 -1
- package/lib/utils/slug.d.ts +0 -3
- package/lib/utils/slug.d.ts.map +0 -1
- package/lib/utils/slug.js +0 -23
- package/lib/utils/slug.js.map +0 -1
- package/lib/utils/tenants.d.ts +0 -4
- package/lib/utils/tenants.d.ts.map +0 -1
- package/lib/utils/tenants.js +0 -16
- package/lib/utils/tenants.js.map +0 -1
- package/lib/utils/vehicles.d.ts +0 -12
- package/lib/utils/vehicles.d.ts.map +0 -1
- package/lib/utils/vehicles.js +0 -73
- package/lib/utils/vehicles.js.map +0 -1
- package/src/apis/crm.ts +0 -302
- package/src/apis/documents.ts +0 -54
- package/src/apis/internet-vehicles.ts +0 -23
- package/src/apis/leasing-administration.ts +0 -70
- package/src/apis/leasing.ts +0 -257
- package/src/apis/opportunities.ts +0 -133
- package/src/apis/picklists.ts +0 -50
- package/src/apis/tenants.ts +0 -100
- package/src/apis/users.ts +0 -22
- package/src/apis/utils.ts +0 -23
- package/src/apis/vehicles.ts +0 -229
- package/src/ddb-entities.ts +0 -1
- package/src/environment.d.ts +0 -6
- package/src/types/activities.ts +0 -41
- package/src/types/documents.ts +0 -110
- package/src/types/internet-vehicles.ts +0 -67
- package/src/types/leads.ts +0 -144
- package/src/types/leasing-administration.ts +0 -131
- package/src/types/leasing-search.ts +0 -24
- package/src/types/leasing-settings.ts +0 -111
- package/src/types/leasing.ts +0 -360
- package/src/types/machines.ts +0 -40
- package/src/types/opportunities.ts +0 -496
- package/src/types/payments.ts +0 -40
- package/src/types/quotes.ts +0 -186
- package/src/types/recently-viewed.ts +0 -45
- package/src/types/saved-filters.ts +0 -21
- package/src/types/settings.ts +0 -51
- package/src/types/templates.ts +0 -40
- package/src/types/website.ts +0 -28
- package/src/utils/forms.ts +0 -32
- package/src/utils/leasing.ts +0 -14
- package/src/utils/slug.ts +0 -19
- package/src/utils/tenants.ts +0 -14
- package/src/utils/vehicles.ts +0 -92
package/lib/utils/vehicles.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.convertNumberToLetters = exports.getInternalTitle = exports.extractCustomFeatures = exports.extractCustomState = void 0;
|
|
4
|
-
const constants_1 = require("../constants");
|
|
5
|
-
const vehicles_1 = require("../types/vehicles");
|
|
6
|
-
const extractCustomState = (vehicle) => {
|
|
7
|
-
const state = [];
|
|
8
|
-
if (vehicle.internal.status.option != null) {
|
|
9
|
-
state.push(vehicles_1.CustomSearchState.Reserved);
|
|
10
|
-
}
|
|
11
|
-
if (vehicle.internal.role === 'SALE' && vehicle.internal.status.sale.dealStatus === 'NOT_SOLD') {
|
|
12
|
-
state.push(vehicles_1.CustomSearchState.Available);
|
|
13
|
-
}
|
|
14
|
-
return state;
|
|
15
|
-
};
|
|
16
|
-
exports.extractCustomState = extractCustomState;
|
|
17
|
-
const extractCustomFeatures = (vehicle) => {
|
|
18
|
-
const features = [
|
|
19
|
-
{
|
|
20
|
-
getValue: (vehicle) => vehicle.superstructure?.crane?.present,
|
|
21
|
-
picklistValueId: 'crane',
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
getValue: (vehicle) => vehicle.superstructure?.tailgate?.present,
|
|
25
|
-
picklistValueId: 'tailgate',
|
|
26
|
-
},
|
|
27
|
-
{ getValue: (vehicle) => vehicle.accessories.adr, picklistValueId: 'adr' },
|
|
28
|
-
{
|
|
29
|
-
getValue: (vehicle) => vehicle.accessories.retarderIntarder,
|
|
30
|
-
picklistValueId: 'retarderIntarder',
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
getValue: (vehicle) => vehicle.accessories.hydraulicTipperKit,
|
|
34
|
-
picklistValueId: 'hydraulicTipperKit',
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
getValue: (vehicle) => vehicle.accessories.lowDeck,
|
|
38
|
-
picklistValueId: 'lowDeck',
|
|
39
|
-
},
|
|
40
|
-
];
|
|
41
|
-
return features
|
|
42
|
-
.filter((feature) => !!feature.getValue(vehicle))
|
|
43
|
-
.map((feature) => feature.picklistValueId);
|
|
44
|
-
};
|
|
45
|
-
exports.extractCustomFeatures = extractCustomFeatures;
|
|
46
|
-
const getInternalTitle = ({ make, category, modelName, bodywork, modelTypeName, }) => {
|
|
47
|
-
if (category === constants_1.Categories.Trailer || category === constants_1.Categories.SemiTrailer) {
|
|
48
|
-
return [make, modelName, bodywork]
|
|
49
|
-
.filter((v) => !!v)
|
|
50
|
-
.map((v) => v.trim())
|
|
51
|
-
.join(' ')
|
|
52
|
-
.trim();
|
|
53
|
-
}
|
|
54
|
-
return [make, modelName, modelTypeName]
|
|
55
|
-
.filter((v) => !!v)
|
|
56
|
-
.map((v) => v.trim())
|
|
57
|
-
.join(' ')
|
|
58
|
-
.trim();
|
|
59
|
-
};
|
|
60
|
-
exports.getInternalTitle = getInternalTitle;
|
|
61
|
-
// example: 1 -> A, 2 -> B, 26 -> Z, 27 -> AA, 28 -> AB, 52 -> AZ, 53 -> BA, 54 -> BB, 702 -> ZZ, 703 -> AAA
|
|
62
|
-
const convertNumberToLetters = (num) => {
|
|
63
|
-
const letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
|
64
|
-
const lettersLength = letters.length;
|
|
65
|
-
if (num < 1) {
|
|
66
|
-
return '';
|
|
67
|
-
}
|
|
68
|
-
const remainder = num % lettersLength;
|
|
69
|
-
const quotient = Math.floor(num / lettersLength);
|
|
70
|
-
return (0, exports.convertNumberToLetters)(quotient) + letters.charAt(remainder - 1);
|
|
71
|
-
};
|
|
72
|
-
exports.convertNumberToLetters = convertNumberToLetters;
|
|
73
|
-
//# sourceMappingURL=vehicles.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"vehicles.js","sourceRoot":"","sources":["../../src/utils/vehicles.ts"],"names":[],"mappings":";;;AAAA,4CAA0C;AAC1C,gDAAoF;AAE7E,MAAM,kBAAkB,GAAG,CAAC,OAAgB,EAAuB,EAAE;IAC1E,MAAM,KAAK,GAAwB,EAAE,CAAC;IAEtC,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,IAAI,IAAI,EAAE;QAC1C,KAAK,CAAC,IAAI,CAAC,4BAAiB,CAAC,QAAQ,CAAC,CAAC;KACxC;IAED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AAA,8BAAsB,EAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC;AAC1E,CAAC,CAAC;AAZW,QAAA,sBAAsB,0BAYjC"}
|
package/src/apis/crm.ts
DELETED
|
@@ -1,302 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
SERVICE_ID_ADMIN_HEADER,
|
|
3
|
-
TENANT_ID_ADMIN_HEADER,
|
|
4
|
-
} from '@bisondesk/commons-sdk/lib/constants';
|
|
5
|
-
import { XError } from '@bisondesk/commons-sdk/lib/errors';
|
|
6
|
-
import { PaginatedList } from '@bisondesk/commons-sdk/lib/types';
|
|
7
|
-
import type { Patch } from 'immer';
|
|
8
|
-
import fetch, { Response } from 'node-fetch';
|
|
9
|
-
import {
|
|
10
|
-
Contact,
|
|
11
|
-
NewContact,
|
|
12
|
-
NewOrganization,
|
|
13
|
-
Organization,
|
|
14
|
-
SearchContact,
|
|
15
|
-
SearchOrganization,
|
|
16
|
-
} from '../types/crm';
|
|
17
|
-
import { SearchRequest } from '../types/search';
|
|
18
|
-
import { ReferenceData } from '../types/utils';
|
|
19
|
-
import { cleanHeaders, getAdminAuth } from './utils';
|
|
20
|
-
|
|
21
|
-
export const getCrmOrganization = async (
|
|
22
|
-
tenantId: string,
|
|
23
|
-
organizationId: string,
|
|
24
|
-
opts?: { serviceId: string }
|
|
25
|
-
): Promise<Organization | undefined> => {
|
|
26
|
-
const auth = await getAdminAuth();
|
|
27
|
-
const response: Response = await fetch(
|
|
28
|
-
`${process.env.CORE_API_ORIGIN}/api/crm/organizations/${organizationId}`,
|
|
29
|
-
{
|
|
30
|
-
headers: cleanHeaders({
|
|
31
|
-
Authorization: auth,
|
|
32
|
-
[TENANT_ID_ADMIN_HEADER]: tenantId,
|
|
33
|
-
[SERVICE_ID_ADMIN_HEADER]: opts?.serviceId,
|
|
34
|
-
}),
|
|
35
|
-
}
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
if (response.ok) {
|
|
39
|
-
return response.status === 200 ? (response.json() as any) : undefined;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const body = await response.text();
|
|
43
|
-
throw new XError(response.statusText, { body, tenantId, organizationId, opts });
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export const getCrmOrganizationByExternalId = async (
|
|
47
|
-
tenantId: string,
|
|
48
|
-
externalId: string,
|
|
49
|
-
opts?: { serviceId: string }
|
|
50
|
-
): Promise<Organization | undefined> => {
|
|
51
|
-
const auth = await getAdminAuth();
|
|
52
|
-
const response: Response = await fetch(
|
|
53
|
-
`${process.env.CORE_API_ORIGIN}/api/crm/organizations/external-id/${externalId}`,
|
|
54
|
-
{
|
|
55
|
-
headers: cleanHeaders({
|
|
56
|
-
Authorization: auth,
|
|
57
|
-
[TENANT_ID_ADMIN_HEADER]: tenantId,
|
|
58
|
-
[SERVICE_ID_ADMIN_HEADER]: opts?.serviceId,
|
|
59
|
-
}),
|
|
60
|
-
}
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
if (response.ok) {
|
|
64
|
-
return response.status === 200 ? (response.json() as any) : undefined;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const body = await response.text();
|
|
68
|
-
throw new XError(response.statusText, { body, tenantId, externalId, opts });
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
export const saveCrmOrganization = async (
|
|
72
|
-
tenantId: string,
|
|
73
|
-
org: Organization | NewOrganization,
|
|
74
|
-
opts?: { serviceId: string }
|
|
75
|
-
): Promise<Organization> => {
|
|
76
|
-
const auth = await getAdminAuth();
|
|
77
|
-
const response: Response = await fetch(`${process.env.CORE_API_ORIGIN}/api/crm/organizations`, {
|
|
78
|
-
method: 'POST',
|
|
79
|
-
headers: cleanHeaders({
|
|
80
|
-
Authorization: auth,
|
|
81
|
-
'Content-Type': 'application/json',
|
|
82
|
-
[TENANT_ID_ADMIN_HEADER]: tenantId,
|
|
83
|
-
[SERVICE_ID_ADMIN_HEADER]: opts?.serviceId,
|
|
84
|
-
}),
|
|
85
|
-
body: JSON.stringify(org),
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
if (response.ok) {
|
|
89
|
-
return response.json() as any;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
const body = await response.text();
|
|
93
|
-
throw new XError(response.statusText, { body, tenantId, org, opts });
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
export const patchCrmOrganization = async (
|
|
97
|
-
tenantId: string,
|
|
98
|
-
organizationId: string,
|
|
99
|
-
changes: Patch[],
|
|
100
|
-
opts?: { serviceId: string }
|
|
101
|
-
): Promise<Organization> => {
|
|
102
|
-
const auth = await getAdminAuth();
|
|
103
|
-
const response: Response = await fetch(
|
|
104
|
-
`${process.env.CORE_API_ORIGIN}/api/crm/organizations/${organizationId}`,
|
|
105
|
-
{
|
|
106
|
-
method: 'PATCH',
|
|
107
|
-
headers: cleanHeaders({
|
|
108
|
-
Authorization: auth,
|
|
109
|
-
'Content-Type': 'application/json',
|
|
110
|
-
[TENANT_ID_ADMIN_HEADER]: tenantId,
|
|
111
|
-
[SERVICE_ID_ADMIN_HEADER]: opts?.serviceId,
|
|
112
|
-
}),
|
|
113
|
-
body: JSON.stringify(changes),
|
|
114
|
-
}
|
|
115
|
-
);
|
|
116
|
-
|
|
117
|
-
if (response.ok) {
|
|
118
|
-
return response.json() as Promise<Organization>;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
const body = await response.text();
|
|
122
|
-
throw new XError(response.statusText, { tenantId, organizationId, changes, body, opts });
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
export const searchCrmOrganizations = async (
|
|
126
|
-
tenantId: string,
|
|
127
|
-
req: SearchRequest,
|
|
128
|
-
opts?: { serviceId: string }
|
|
129
|
-
): Promise<PaginatedList<SearchOrganization, ReferenceData>> => {
|
|
130
|
-
const auth = await getAdminAuth();
|
|
131
|
-
const response: Response = await fetch(
|
|
132
|
-
`${process.env.CORE_API_ORIGIN}/api/crm/organizations/search/results`,
|
|
133
|
-
{
|
|
134
|
-
method: 'POST',
|
|
135
|
-
headers: cleanHeaders({
|
|
136
|
-
Authorization: auth,
|
|
137
|
-
[TENANT_ID_ADMIN_HEADER]: tenantId,
|
|
138
|
-
[SERVICE_ID_ADMIN_HEADER]: opts?.serviceId,
|
|
139
|
-
}),
|
|
140
|
-
body: JSON.stringify(req),
|
|
141
|
-
}
|
|
142
|
-
);
|
|
143
|
-
|
|
144
|
-
if (response.ok) {
|
|
145
|
-
return response.status === 200 ? (response.json() as any) : undefined;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
const body = await response.text();
|
|
149
|
-
throw new XError(response.statusText, { body, tenantId, req, opts });
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
export const searchCrmContacts = async (
|
|
153
|
-
tenantId: string,
|
|
154
|
-
req: SearchRequest,
|
|
155
|
-
opts?: { serviceId: string }
|
|
156
|
-
): Promise<PaginatedList<SearchContact, ReferenceData>> => {
|
|
157
|
-
const auth = await getAdminAuth();
|
|
158
|
-
const response: Response = await fetch(
|
|
159
|
-
`${process.env.CORE_API_ORIGIN}/api/crm/contacts/search/results`,
|
|
160
|
-
{
|
|
161
|
-
method: 'POST',
|
|
162
|
-
headers: cleanHeaders({
|
|
163
|
-
Authorization: auth,
|
|
164
|
-
'Content-Type': 'application/json',
|
|
165
|
-
[TENANT_ID_ADMIN_HEADER]: tenantId,
|
|
166
|
-
[SERVICE_ID_ADMIN_HEADER]: opts?.serviceId,
|
|
167
|
-
}),
|
|
168
|
-
body: JSON.stringify(req),
|
|
169
|
-
}
|
|
170
|
-
);
|
|
171
|
-
|
|
172
|
-
if (response.ok) {
|
|
173
|
-
return response.status === 200 ? (response.json() as any) : undefined;
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
const body = await response.text();
|
|
177
|
-
throw new XError(response.statusText, { body, tenantId, req, opts });
|
|
178
|
-
};
|
|
179
|
-
|
|
180
|
-
export const deleteCrmOrganization = async (
|
|
181
|
-
tenantId: string,
|
|
182
|
-
orgId: string,
|
|
183
|
-
opts?: { serviceId: string }
|
|
184
|
-
): Promise<void> => {
|
|
185
|
-
const auth = await getAdminAuth();
|
|
186
|
-
const response: Response = await fetch(
|
|
187
|
-
`${process.env.CORE_API_ORIGIN}/api/crm/organizations/${orgId}`,
|
|
188
|
-
{
|
|
189
|
-
method: 'DELETE',
|
|
190
|
-
headers: cleanHeaders({
|
|
191
|
-
Authorization: auth,
|
|
192
|
-
[TENANT_ID_ADMIN_HEADER]: tenantId,
|
|
193
|
-
[SERVICE_ID_ADMIN_HEADER]: opts?.serviceId,
|
|
194
|
-
}),
|
|
195
|
-
}
|
|
196
|
-
);
|
|
197
|
-
|
|
198
|
-
if (!response.ok) {
|
|
199
|
-
const body = await response.text();
|
|
200
|
-
throw new XError(response.statusText, { body, tenantId, orgId, opts });
|
|
201
|
-
}
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
export const listCrmContacts = async (
|
|
205
|
-
tenantId: string,
|
|
206
|
-
organizationId: string,
|
|
207
|
-
opts?: { serviceId: string }
|
|
208
|
-
): Promise<Contact[]> => {
|
|
209
|
-
const auth = await getAdminAuth();
|
|
210
|
-
const response: Response = await fetch(
|
|
211
|
-
`${process.env.CORE_API_ORIGIN}/admin/crm/organizations/${organizationId}/contacts`,
|
|
212
|
-
{
|
|
213
|
-
headers: cleanHeaders({
|
|
214
|
-
Authorization: auth,
|
|
215
|
-
[TENANT_ID_ADMIN_HEADER]: tenantId,
|
|
216
|
-
[SERVICE_ID_ADMIN_HEADER]: opts?.serviceId,
|
|
217
|
-
}),
|
|
218
|
-
}
|
|
219
|
-
);
|
|
220
|
-
|
|
221
|
-
if (response.ok) {
|
|
222
|
-
return response.status === 200 ? (response.json() as any) : undefined;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
const body = await response.text();
|
|
226
|
-
throw new XError(response.statusText, { body, tenantId, organizationId, opts });
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
export const getCrmContact = async (
|
|
230
|
-
tenantId: string,
|
|
231
|
-
contactId: string,
|
|
232
|
-
opts?: { serviceId: string }
|
|
233
|
-
): Promise<Contact | undefined> => {
|
|
234
|
-
const auth = await getAdminAuth();
|
|
235
|
-
const response: Response = await fetch(
|
|
236
|
-
`${process.env.CORE_API_ORIGIN}/api/crm/contacts/${contactId}`,
|
|
237
|
-
{
|
|
238
|
-
headers: cleanHeaders({
|
|
239
|
-
Authorization: auth,
|
|
240
|
-
[TENANT_ID_ADMIN_HEADER]: tenantId,
|
|
241
|
-
[SERVICE_ID_ADMIN_HEADER]: opts?.serviceId,
|
|
242
|
-
}),
|
|
243
|
-
}
|
|
244
|
-
);
|
|
245
|
-
|
|
246
|
-
if (response.ok) {
|
|
247
|
-
return response.status === 200 ? (response.json() as any) : undefined;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
const body = await response.text();
|
|
251
|
-
throw new XError(response.statusText, { body, tenantId, contactId, opts });
|
|
252
|
-
};
|
|
253
|
-
|
|
254
|
-
export const saveCrmContact = async (
|
|
255
|
-
tenantId: string,
|
|
256
|
-
contact: Contact | NewContact,
|
|
257
|
-
opts?: { serviceId: string }
|
|
258
|
-
): Promise<Contact> => {
|
|
259
|
-
const auth = await getAdminAuth();
|
|
260
|
-
const response: Response = await fetch(`${process.env.CORE_API_ORIGIN}/api/crm/contacts`, {
|
|
261
|
-
method: 'POST',
|
|
262
|
-
headers: cleanHeaders({
|
|
263
|
-
Authorization: auth,
|
|
264
|
-
'Content-Type': 'application/json',
|
|
265
|
-
[TENANT_ID_ADMIN_HEADER]: tenantId,
|
|
266
|
-
[SERVICE_ID_ADMIN_HEADER]: opts?.serviceId,
|
|
267
|
-
}),
|
|
268
|
-
body: JSON.stringify(contact),
|
|
269
|
-
});
|
|
270
|
-
|
|
271
|
-
if (response.ok) {
|
|
272
|
-
return response.json() as any;
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
const body = await response.text();
|
|
276
|
-
throw new XError(response.statusText, { body, contact, tenantId, opts });
|
|
277
|
-
};
|
|
278
|
-
|
|
279
|
-
export const deleteCrmContact = async (
|
|
280
|
-
tenantId: string,
|
|
281
|
-
contactId: string,
|
|
282
|
-
orgId: string = '',
|
|
283
|
-
opts?: { serviceId: string }
|
|
284
|
-
): Promise<void> => {
|
|
285
|
-
const auth = await getAdminAuth();
|
|
286
|
-
const response: Response = await fetch(
|
|
287
|
-
`${process.env.CORE_API_ORIGIN}/api/crm/contacts/${contactId}?orgId=${orgId}`,
|
|
288
|
-
{
|
|
289
|
-
method: 'DELETE',
|
|
290
|
-
headers: cleanHeaders({
|
|
291
|
-
Authorization: auth,
|
|
292
|
-
[TENANT_ID_ADMIN_HEADER]: tenantId,
|
|
293
|
-
[SERVICE_ID_ADMIN_HEADER]: opts?.serviceId,
|
|
294
|
-
}),
|
|
295
|
-
}
|
|
296
|
-
);
|
|
297
|
-
|
|
298
|
-
if (!response.ok) {
|
|
299
|
-
const body = await response.text();
|
|
300
|
-
throw new XError(response.statusText, { body, tenantId, contactId, orgId, opts });
|
|
301
|
-
}
|
|
302
|
-
};
|
package/src/apis/documents.ts
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { TENANT_ID_ADMIN_HEADER } from '@bisondesk/commons-sdk/lib/constants';
|
|
2
|
-
import { XError } from '@bisondesk/commons-sdk/lib/errors';
|
|
3
|
-
import fetch, { Response } from 'node-fetch';
|
|
4
|
-
import { FinanceBooking, FinanceDocument } from '../types/documents';
|
|
5
|
-
import { getAdminAuth } from './utils';
|
|
6
|
-
|
|
7
|
-
export const upsertFinanceDoc = async (
|
|
8
|
-
tenantId: string,
|
|
9
|
-
doc: FinanceDocument
|
|
10
|
-
): Promise<FinanceDocument> => {
|
|
11
|
-
const auth = await getAdminAuth();
|
|
12
|
-
const response: Response = await fetch(`${process.env.CORE_API_ORIGIN}/api/documents/finance`, {
|
|
13
|
-
method: 'POST',
|
|
14
|
-
headers: {
|
|
15
|
-
'Content-Type': 'application/json',
|
|
16
|
-
Authorization: auth,
|
|
17
|
-
[TENANT_ID_ADMIN_HEADER]: tenantId,
|
|
18
|
-
},
|
|
19
|
-
body: JSON.stringify(doc),
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
if (response.status === 200) {
|
|
23
|
-
return response.json() as any;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const body = await response.text();
|
|
27
|
-
throw new XError(response.statusText, { tenantId, body });
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
export const upsertFinanceBooking = async (
|
|
31
|
-
tenantId: string,
|
|
32
|
-
booking: FinanceBooking
|
|
33
|
-
): Promise<FinanceBooking> => {
|
|
34
|
-
const auth = await getAdminAuth();
|
|
35
|
-
const response: Response = await fetch(
|
|
36
|
-
`${process.env.CORE_API_ORIGIN}/api/documents/finance/booking`,
|
|
37
|
-
{
|
|
38
|
-
method: 'POST',
|
|
39
|
-
headers: {
|
|
40
|
-
'Content-Type': 'application/json',
|
|
41
|
-
Authorization: auth,
|
|
42
|
-
[TENANT_ID_ADMIN_HEADER]: tenantId,
|
|
43
|
-
},
|
|
44
|
-
body: JSON.stringify(booking),
|
|
45
|
-
}
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
if (response.status === 200) {
|
|
49
|
-
return response.json() as any;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const body = await response.text();
|
|
53
|
-
throw new XError(response.statusText, { tenantId, body });
|
|
54
|
-
};
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { XError } from '@bisondesk/commons-sdk/lib/errors';
|
|
2
|
-
import fetch, { Response } from 'node-fetch';
|
|
3
|
-
import { SearchInternetVehicle } from '../types/internet-vehicles';
|
|
4
|
-
import { getAdminAuth } from './utils';
|
|
5
|
-
|
|
6
|
-
export const upsertInternetVehicles = async (vehicles: SearchInternetVehicle[]): Promise<void> => {
|
|
7
|
-
const auth = await getAdminAuth();
|
|
8
|
-
const response: Response = await fetch(`${process.env.CORE_API_ORIGIN}/api/internet-vehicles`, {
|
|
9
|
-
method: 'POST',
|
|
10
|
-
headers: {
|
|
11
|
-
'Content-Type': 'application/json',
|
|
12
|
-
Authorization: auth,
|
|
13
|
-
},
|
|
14
|
-
body: JSON.stringify(vehicles),
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
if (response.ok) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const body = await response.text();
|
|
22
|
-
throw new XError(response.statusText, { body });
|
|
23
|
-
};
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
SERVICE_ID_ADMIN_HEADER,
|
|
3
|
-
TENANT_ID_ADMIN_HEADER,
|
|
4
|
-
} from '@bisondesk/commons-sdk/lib/constants';
|
|
5
|
-
import { XError } from '@bisondesk/commons-sdk/lib/errors';
|
|
6
|
-
import fetch, { Response } from 'node-fetch';
|
|
7
|
-
import {
|
|
8
|
-
LeasingAdminUpload,
|
|
9
|
-
LeasingAdminUploadStatus,
|
|
10
|
-
NewLeasingAdminUploadRequest,
|
|
11
|
-
} from '../types/leasing-administration';
|
|
12
|
-
import { cleanHeaders, getAdminAuth } from './utils';
|
|
13
|
-
|
|
14
|
-
export const createLeasingAdminUpload = async (
|
|
15
|
-
tenantId: string,
|
|
16
|
-
data: NewLeasingAdminUploadRequest,
|
|
17
|
-
opts?: { serviceId: string }
|
|
18
|
-
): Promise<LeasingAdminUpload> => {
|
|
19
|
-
const auth = await getAdminAuth();
|
|
20
|
-
const response: Response = await fetch(
|
|
21
|
-
`${process.env.CORE_API_ORIGIN}/api/leasing/administration/uploads`,
|
|
22
|
-
{
|
|
23
|
-
method: 'POST',
|
|
24
|
-
headers: cleanHeaders({
|
|
25
|
-
Authorization: auth,
|
|
26
|
-
'Content-Type': 'application/json',
|
|
27
|
-
[TENANT_ID_ADMIN_HEADER]: tenantId,
|
|
28
|
-
[SERVICE_ID_ADMIN_HEADER]: opts?.serviceId,
|
|
29
|
-
}),
|
|
30
|
-
body: JSON.stringify(data),
|
|
31
|
-
}
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
if (response.ok) {
|
|
35
|
-
return response.json() as any;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const body = await response.text();
|
|
39
|
-
throw new XError(response.statusText, { body, data, opts });
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export const updateLeasingAdminUploadStatus = async (
|
|
43
|
-
tenantId: string,
|
|
44
|
-
handlerId: string,
|
|
45
|
-
uploadId: string,
|
|
46
|
-
newStatus: LeasingAdminUploadStatus,
|
|
47
|
-
opts?: { serviceId: string }
|
|
48
|
-
): Promise<LeasingAdminUpload> => {
|
|
49
|
-
const auth = await getAdminAuth();
|
|
50
|
-
const response: Response = await fetch(
|
|
51
|
-
`${process.env.CORE_API_ORIGIN}/api/leasing/administration/uploads/${handlerId}/${uploadId}/status`,
|
|
52
|
-
{
|
|
53
|
-
method: 'PUT',
|
|
54
|
-
headers: cleanHeaders({
|
|
55
|
-
Authorization: auth,
|
|
56
|
-
'Content-Type': 'application/json',
|
|
57
|
-
[TENANT_ID_ADMIN_HEADER]: tenantId,
|
|
58
|
-
[SERVICE_ID_ADMIN_HEADER]: opts?.serviceId,
|
|
59
|
-
}),
|
|
60
|
-
body: JSON.stringify({ status: newStatus }),
|
|
61
|
-
}
|
|
62
|
-
);
|
|
63
|
-
|
|
64
|
-
if (response.ok) {
|
|
65
|
-
return response.json() as any;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const body = await response.text();
|
|
69
|
-
throw new XError(response.statusText, { body, tenantId, handlerId, uploadId, opts });
|
|
70
|
-
};
|