@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.
Files changed (225) hide show
  1. package/lib/constants.d.ts +0 -77
  2. package/lib/constants.d.ts.map +1 -1
  3. package/lib/constants.js +1 -924
  4. package/lib/constants.js.map +1 -1
  5. package/lib/types/crm.d.ts +30 -102
  6. package/lib/types/crm.d.ts.map +1 -1
  7. package/lib/types/crm.js +0 -16
  8. package/lib/types/crm.js.map +1 -1
  9. package/lib/types/definitions.d.ts +13 -15
  10. package/lib/types/definitions.d.ts.map +1 -1
  11. package/lib/types/fields.d.ts +25 -26
  12. package/lib/types/fields.d.ts.map +1 -1
  13. package/lib/types/fields.js +0 -4
  14. package/lib/types/fields.js.map +1 -1
  15. package/lib/types/interests.d.ts +31 -0
  16. package/lib/types/interests.d.ts.map +1 -0
  17. package/lib/types/{settings.js → interests.js} +1 -1
  18. package/lib/types/interests.js.map +1 -0
  19. package/lib/types/picklists.d.ts +4 -15
  20. package/lib/types/picklists.d.ts.map +1 -1
  21. package/lib/types/search.d.ts +4 -26
  22. package/lib/types/search.d.ts.map +1 -1
  23. package/lib/types/search.js.map +1 -1
  24. package/lib/types/storage.d.ts +11 -1
  25. package/lib/types/storage.d.ts.map +1 -1
  26. package/lib/types/storage.js +0 -15
  27. package/lib/types/storage.js.map +1 -1
  28. package/lib/types/tenants.d.ts +9 -32
  29. package/lib/types/tenants.d.ts.map +1 -1
  30. package/lib/types/tenants.js +0 -11
  31. package/lib/types/tenants.js.map +1 -1
  32. package/lib/types/users.d.ts +3 -11
  33. package/lib/types/users.d.ts.map +1 -1
  34. package/lib/types/utils.d.ts +0 -20
  35. package/lib/types/utils.d.ts.map +1 -1
  36. package/lib/types/utils.js +0 -6
  37. package/lib/types/utils.js.map +1 -1
  38. package/lib/types/vehicles.d.ts +92 -406
  39. package/lib/types/vehicles.d.ts.map +1 -1
  40. package/lib/types/vehicles.js +1 -54
  41. package/lib/types/vehicles.js.map +1 -1
  42. package/package.json +6 -8
  43. package/src/constants.ts +1 -930
  44. package/src/types/crm.ts +30 -117
  45. package/src/types/definitions.ts +12 -19
  46. package/src/types/fields.ts +31 -72
  47. package/src/types/interests.ts +28 -0
  48. package/src/types/picklists.ts +7 -26
  49. package/src/types/search.ts +4 -34
  50. package/src/types/storage.ts +12 -1
  51. package/src/types/tenants.ts +11 -37
  52. package/src/types/users.ts +3 -17
  53. package/src/types/utils.ts +0 -25
  54. package/src/types/vehicles.ts +93 -461
  55. package/tsconfig.tsbuildinfo +2995 -1
  56. package/lib/apis/crm.d.ts +0 -39
  57. package/lib/apis/crm.d.ts.map +0 -1
  58. package/lib/apis/crm.js +0 -201
  59. package/lib/apis/crm.js.map +0 -1
  60. package/lib/apis/documents.d.ts +0 -4
  61. package/lib/apis/documents.d.ts.map +0 -1
  62. package/lib/apis/documents.js +0 -47
  63. package/lib/apis/documents.js.map +0 -1
  64. package/lib/apis/internet-vehicles.d.ts +0 -3
  65. package/lib/apis/internet-vehicles.d.ts.map +0 -1
  66. package/lib/apis/internet-vehicles.js +0 -27
  67. package/lib/apis/internet-vehicles.js.map +0 -1
  68. package/lib/apis/leasing-administration.d.ts +0 -8
  69. package/lib/apis/leasing-administration.d.ts.map +0 -1
  70. package/lib/apis/leasing-administration.js +0 -49
  71. package/lib/apis/leasing-administration.js.map +0 -1
  72. package/lib/apis/leasing.d.ts +0 -19
  73. package/lib/apis/leasing.d.ts.map +0 -1
  74. package/lib/apis/leasing.js +0 -168
  75. package/lib/apis/leasing.js.map +0 -1
  76. package/lib/apis/opportunities.d.ts +0 -9
  77. package/lib/apis/opportunities.d.ts.map +0 -1
  78. package/lib/apis/opportunities.js +0 -94
  79. package/lib/apis/opportunities.js.map +0 -1
  80. package/lib/apis/picklists.d.ts +0 -5
  81. package/lib/apis/picklists.d.ts.map +0 -1
  82. package/lib/apis/picklists.js +0 -44
  83. package/lib/apis/picklists.js.map +0 -1
  84. package/lib/apis/tenants.d.ts +0 -7
  85. package/lib/apis/tenants.d.ts.map +0 -1
  86. package/lib/apis/tenants.js +0 -80
  87. package/lib/apis/tenants.js.map +0 -1
  88. package/lib/apis/users.d.ts +0 -3
  89. package/lib/apis/users.d.ts.map +0 -1
  90. package/lib/apis/users.js +0 -26
  91. package/lib/apis/users.js.map +0 -1
  92. package/lib/apis/utils.d.ts +0 -9
  93. package/lib/apis/utils.d.ts.map +0 -1
  94. package/lib/apis/utils.js +0 -23
  95. package/lib/apis/utils.js.map +0 -1
  96. package/lib/apis/vehicles.d.ts +0 -18
  97. package/lib/apis/vehicles.d.ts.map +0 -1
  98. package/lib/apis/vehicles.js +0 -159
  99. package/lib/apis/vehicles.js.map +0 -1
  100. package/lib/ddb-entities.d.ts +0 -2
  101. package/lib/ddb-entities.d.ts.map +0 -1
  102. package/lib/ddb-entities.js +0 -5
  103. package/lib/ddb-entities.js.map +0 -1
  104. package/lib/types/activities.d.ts +0 -38
  105. package/lib/types/activities.d.ts.map +0 -1
  106. package/lib/types/activities.js +0 -16
  107. package/lib/types/activities.js.map +0 -1
  108. package/lib/types/documents.d.ts +0 -105
  109. package/lib/types/documents.d.ts.map +0 -1
  110. package/lib/types/documents.js +0 -3
  111. package/lib/types/documents.js.map +0 -1
  112. package/lib/types/internet-vehicles.d.ts +0 -64
  113. package/lib/types/internet-vehicles.d.ts.map +0 -1
  114. package/lib/types/internet-vehicles.js +0 -3
  115. package/lib/types/internet-vehicles.js.map +0 -1
  116. package/lib/types/leads.d.ts +0 -134
  117. package/lib/types/leads.d.ts.map +0 -1
  118. package/lib/types/leads.js +0 -3
  119. package/lib/types/leads.js.map +0 -1
  120. package/lib/types/leasing-administration.d.ts +0 -107
  121. package/lib/types/leasing-administration.d.ts.map +0 -1
  122. package/lib/types/leasing-administration.js +0 -3
  123. package/lib/types/leasing-administration.js.map +0 -1
  124. package/lib/types/leasing-search.d.ts +0 -22
  125. package/lib/types/leasing-search.d.ts.map +0 -1
  126. package/lib/types/leasing-search.js +0 -3
  127. package/lib/types/leasing-search.js.map +0 -1
  128. package/lib/types/leasing-settings.d.ts +0 -113
  129. package/lib/types/leasing-settings.d.ts.map +0 -1
  130. package/lib/types/leasing-settings.js +0 -10
  131. package/lib/types/leasing-settings.js.map +0 -1
  132. package/lib/types/leasing.d.ts +0 -322
  133. package/lib/types/leasing.d.ts.map +0 -1
  134. package/lib/types/leasing.js +0 -24
  135. package/lib/types/leasing.js.map +0 -1
  136. package/lib/types/machines.d.ts +0 -38
  137. package/lib/types/machines.d.ts.map +0 -1
  138. package/lib/types/machines.js +0 -3
  139. package/lib/types/machines.js.map +0 -1
  140. package/lib/types/opportunities.d.ts +0 -448
  141. package/lib/types/opportunities.d.ts.map +0 -1
  142. package/lib/types/opportunities.js +0 -68
  143. package/lib/types/opportunities.js.map +0 -1
  144. package/lib/types/payments.d.ts +0 -38
  145. package/lib/types/payments.d.ts.map +0 -1
  146. package/lib/types/payments.js +0 -9
  147. package/lib/types/payments.js.map +0 -1
  148. package/lib/types/quotes.d.ts +0 -173
  149. package/lib/types/quotes.d.ts.map +0 -1
  150. package/lib/types/quotes.js +0 -26
  151. package/lib/types/quotes.js.map +0 -1
  152. package/lib/types/recently-viewed.d.ts +0 -33
  153. package/lib/types/recently-viewed.d.ts.map +0 -1
  154. package/lib/types/recently-viewed.js +0 -3
  155. package/lib/types/recently-viewed.js.map +0 -1
  156. package/lib/types/saved-filters.d.ts +0 -20
  157. package/lib/types/saved-filters.d.ts.map +0 -1
  158. package/lib/types/saved-filters.js +0 -3
  159. package/lib/types/saved-filters.js.map +0 -1
  160. package/lib/types/settings.d.ts +0 -50
  161. package/lib/types/settings.d.ts.map +0 -1
  162. package/lib/types/settings.js.map +0 -1
  163. package/lib/types/templates.d.ts +0 -35
  164. package/lib/types/templates.d.ts.map +0 -1
  165. package/lib/types/templates.js +0 -9
  166. package/lib/types/templates.js.map +0 -1
  167. package/lib/types/website.d.ts +0 -24
  168. package/lib/types/website.d.ts.map +0 -1
  169. package/lib/types/website.js +0 -3
  170. package/lib/types/website.js.map +0 -1
  171. package/lib/utils/forms.d.ts +0 -6
  172. package/lib/utils/forms.d.ts.map +0 -1
  173. package/lib/utils/forms.js +0 -33
  174. package/lib/utils/forms.js.map +0 -1
  175. package/lib/utils/leasing.d.ts +0 -3
  176. package/lib/utils/leasing.d.ts.map +0 -1
  177. package/lib/utils/leasing.js +0 -10
  178. package/lib/utils/leasing.js.map +0 -1
  179. package/lib/utils/slug.d.ts +0 -3
  180. package/lib/utils/slug.d.ts.map +0 -1
  181. package/lib/utils/slug.js +0 -23
  182. package/lib/utils/slug.js.map +0 -1
  183. package/lib/utils/tenants.d.ts +0 -4
  184. package/lib/utils/tenants.d.ts.map +0 -1
  185. package/lib/utils/tenants.js +0 -16
  186. package/lib/utils/tenants.js.map +0 -1
  187. package/lib/utils/vehicles.d.ts +0 -12
  188. package/lib/utils/vehicles.d.ts.map +0 -1
  189. package/lib/utils/vehicles.js +0 -73
  190. package/lib/utils/vehicles.js.map +0 -1
  191. package/src/apis/crm.ts +0 -302
  192. package/src/apis/documents.ts +0 -54
  193. package/src/apis/internet-vehicles.ts +0 -23
  194. package/src/apis/leasing-administration.ts +0 -70
  195. package/src/apis/leasing.ts +0 -257
  196. package/src/apis/opportunities.ts +0 -133
  197. package/src/apis/picklists.ts +0 -50
  198. package/src/apis/tenants.ts +0 -100
  199. package/src/apis/users.ts +0 -22
  200. package/src/apis/utils.ts +0 -23
  201. package/src/apis/vehicles.ts +0 -229
  202. package/src/ddb-entities.ts +0 -1
  203. package/src/environment.d.ts +0 -6
  204. package/src/types/activities.ts +0 -41
  205. package/src/types/documents.ts +0 -110
  206. package/src/types/internet-vehicles.ts +0 -67
  207. package/src/types/leads.ts +0 -144
  208. package/src/types/leasing-administration.ts +0 -131
  209. package/src/types/leasing-search.ts +0 -24
  210. package/src/types/leasing-settings.ts +0 -111
  211. package/src/types/leasing.ts +0 -360
  212. package/src/types/machines.ts +0 -40
  213. package/src/types/opportunities.ts +0 -496
  214. package/src/types/payments.ts +0 -40
  215. package/src/types/quotes.ts +0 -186
  216. package/src/types/recently-viewed.ts +0 -45
  217. package/src/types/saved-filters.ts +0 -21
  218. package/src/types/settings.ts +0 -51
  219. package/src/types/templates.ts +0 -40
  220. package/src/types/website.ts +0 -28
  221. package/src/utils/forms.ts +0 -32
  222. package/src/utils/leasing.ts +0 -14
  223. package/src/utils/slug.ts +0 -19
  224. package/src/utils/tenants.ts +0 -14
  225. package/src/utils/vehicles.ts +0 -92
@@ -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,IAAI,OAAO,CAAC,QAAQ,CAAC,IAAI,KAAK,MAAM,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC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,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
- };
@@ -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
- };