@bisondesk/core-sdk 1.0.439 → 1.0.441

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/src/apis/crm.ts CHANGED
@@ -155,6 +155,30 @@ export const searchCrmOrganizations = async (
155
155
  throw new XError(response.statusText, { method, url, body, tenantId, req, opts });
156
156
  };
157
157
 
158
+ export const listUsedBranchIdsForOrganization = async (
159
+ tenantId: string,
160
+ organizationId: string
161
+ ): Promise<string[]> => {
162
+ const auth = await getAdminAuth();
163
+ const url = `${process.env.CORE_API_ORIGIN}/api/crm/organizations/${organizationId}/branches`;
164
+ const method = 'GET';
165
+ const response: Response = await fetch(url, {
166
+ method,
167
+ headers: cleanHeaders({
168
+ Authorization: auth,
169
+ [TENANT_ID_ADMIN_HEADER]: tenantId,
170
+ 'Content-Type': 'application/json',
171
+ }),
172
+ });
173
+
174
+ if (response.ok) {
175
+ return response.json() as any;
176
+ }
177
+
178
+ const body = await response.text();
179
+ throw new XError(response.statusText, { method, url, body, tenantId });
180
+ };
181
+
158
182
  export const searchCrmContacts = async (
159
183
  tenantId: string,
160
184
  req: SearchRequest,
@@ -21,6 +21,43 @@ export const listTenants = async (): Promise<Tenant[]> => {
21
21
  throw new XError(response.statusText, { url, body });
22
22
  };
23
23
 
24
+ export const listTenantsByConglomerate = async (conglomerate: string): Promise<Tenant[]> => {
25
+ const auth = await getAdminAuth();
26
+ const url = `${process.env.CORE_API_ORIGIN}/admin/tenants/conglomerate/${conglomerate}`;
27
+ const response: Response = await fetch(url, {
28
+ headers: {
29
+ Authorization: auth,
30
+ },
31
+ });
32
+
33
+ if (response.ok) {
34
+ return response.json() as any;
35
+ }
36
+
37
+ const body = await response.text();
38
+ throw new XError(response.statusText, { url, body });
39
+ };
40
+
41
+ export const listTenantsByBranches = async (branches: string[]): Promise<Tenant[]> => {
42
+ const auth = await getAdminAuth();
43
+ const url = `${process.env.CORE_API_ORIGIN}/admin/tenants/by-tenants`;
44
+ const response: Response = await fetch(url, {
45
+ method: 'POST',
46
+ headers: {
47
+ Authorization: auth,
48
+ 'Content-Type': 'application/json',
49
+ },
50
+ body: JSON.stringify(branches),
51
+ });
52
+
53
+ if (response.ok) {
54
+ return response.json() as any;
55
+ }
56
+
57
+ const body = await response.text();
58
+ throw new XError(response.statusText, { url, body });
59
+ };
60
+
24
61
  export const listTenantsSyncSettings = async (): Promise<TenantSyncSettings[]> => {
25
62
  const auth = await getAdminAuth();
26
63
  const url = `${process.env.CORE_API_ORIGIN}/admin/tenants/settings/sync`;
package/src/types/crm.ts CHANGED
@@ -48,7 +48,9 @@ export type CrmOrganizationEvent = BaseEvent & {
48
48
  };
49
49
 
50
50
  type BaseOrganization = {
51
- inUse: boolean;
51
+ usages: {
52
+ [tenantId: string]: string[]; // branchIds that are using this organization
53
+ };
52
54
  countryCode: string;
53
55
  syncedAt: string;
54
56
  name: string;
@@ -119,6 +121,9 @@ export type OrgLeasingContract = {
119
121
  export type SearchOrganization = {
120
122
  org: Organization;
121
123
  contract: OrgLeasingContract[]; // important for the logic regarding leasing overdue reminders
124
+ custom: {
125
+ inUse: boolean; // is this organization in use by any of the branches of this tenant, or is it an organization from another tenant.
126
+ };
122
127
  };
123
128
 
124
129
  export type PotentialDuplicatesReferenceData = ReferenceData & { blockIgnore?: boolean };
@@ -11,6 +11,7 @@ export enum InternalEventTypes {
11
11
  VEHICLE_PURCHASE = 'vehicle-purchases',
12
12
  ORGANIZATION = 'organizations',
13
13
  CONTACT = 'contacts',
14
+ FINANCE_DOCUMENT = 'finance-documents',
14
15
  OPPORTUNITY = 'opportunities',
15
16
  VEHICLE = 'vehicles',
16
17
  PAYMENT = 'payments',
@@ -251,6 +251,8 @@ export type SearchVehicle = {
251
251
  logisticsStatus?: VehiclePurchaseLogisticsStatus;
252
252
  purchasedBy?: string;
253
253
  parkingName?: string;
254
+ organizationId: string;
255
+ organizationExternalId?: number;
254
256
  };
255
257
  reservation?: Pick<OpportunityReservation, 'expiresAt' | 'opportunityId' | 'createdBy'>;
256
258
  vehicle: Vehicle;