pha-hermes 1.27.0 → 1.28.0
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/api/salesforce/accounts/accounts.d.ts +2 -1
- package/dist/pha-hermes.cjs.development.js +3 -2
- package/dist/pha-hermes.cjs.development.js.map +1 -1
- package/dist/pha-hermes.cjs.production.min.js +1 -1
- package/dist/pha-hermes.cjs.production.min.js.map +1 -1
- package/dist/pha-hermes.esm.js +3 -2
- package/dist/pha-hermes.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/api/salesforce/accounts/accounts.ts +20 -9
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AxiosInstance } from
|
|
1
|
+
import { AxiosInstance } from 'axios'
|
|
2
2
|
|
|
3
3
|
export interface Account {
|
|
4
4
|
id: string
|
|
@@ -16,6 +16,7 @@ export interface Account {
|
|
|
16
16
|
fax: string | null
|
|
17
17
|
email: string
|
|
18
18
|
lang: 'eng' | 'fra'
|
|
19
|
+
clientNumber: string
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
export interface HealthAuthority extends Account {
|
|
@@ -39,7 +40,8 @@ const ACCOUNT_FIELDS = [
|
|
|
39
40
|
'BillingAddress',
|
|
40
41
|
'Phone',
|
|
41
42
|
'Fax',
|
|
42
|
-
'Type'
|
|
43
|
+
'Type',
|
|
44
|
+
'Client_Number__c'
|
|
43
45
|
] as const
|
|
44
46
|
|
|
45
47
|
export class SFAccounts {
|
|
@@ -49,7 +51,10 @@ export class SFAccounts {
|
|
|
49
51
|
this.axiosInstance = axiosInstance
|
|
50
52
|
}
|
|
51
53
|
|
|
52
|
-
async fetchAccounts<T extends Account>(
|
|
54
|
+
async fetchAccounts<T extends Account>(
|
|
55
|
+
type: AccountType,
|
|
56
|
+
options?: { parentId?: string; active?: boolean; failfast?: boolean }
|
|
57
|
+
): Promise<T[]> {
|
|
53
58
|
try {
|
|
54
59
|
let accountType: 'Health Authority' | 'Hospital'
|
|
55
60
|
switch (type) {
|
|
@@ -68,7 +73,9 @@ export class SFAccounts {
|
|
|
68
73
|
let done = false
|
|
69
74
|
let url = `/services/data/v57.0/query`
|
|
70
75
|
do {
|
|
71
|
-
const {
|
|
76
|
+
const {
|
|
77
|
+
data: { records: pageRecords, nextRecordsUrl, done: isDone }
|
|
78
|
+
} = await this.axiosInstance.get(url, { params: { q: query } })
|
|
72
79
|
records.push(...pageRecords)
|
|
73
80
|
done = isDone
|
|
74
81
|
url = nextRecordsUrl
|
|
@@ -77,13 +84,16 @@ export class SFAccounts {
|
|
|
77
84
|
|
|
78
85
|
for (const i in accounts)
|
|
79
86
|
if (accounts[i].accountTypeName === 'healthAuthority')
|
|
80
|
-
(accounts[i] as HealthAuthority).children =
|
|
87
|
+
(accounts[i] as HealthAuthority).children =
|
|
88
|
+
await this.fetchAccounts<Establishment>('establishment', {
|
|
89
|
+
parentId: accounts[i].id,
|
|
90
|
+
active: options?.active
|
|
91
|
+
})
|
|
81
92
|
|
|
82
93
|
return accounts as T[]
|
|
83
94
|
} catch (error) {
|
|
84
95
|
console.error(`Error fetching ${type} accounts: `, error.message)
|
|
85
|
-
if (options?.failfast)
|
|
86
|
-
throw error
|
|
96
|
+
if (options?.failfast) throw error
|
|
87
97
|
return []
|
|
88
98
|
}
|
|
89
99
|
}
|
|
@@ -119,7 +129,8 @@ export class SFAccounts {
|
|
|
119
129
|
email: null,
|
|
120
130
|
phone2: null,
|
|
121
131
|
cellular: null,
|
|
122
|
-
lang: 'eng'
|
|
132
|
+
lang: 'eng',
|
|
133
|
+
clientNumber: record.Client_Number__c
|
|
123
134
|
}
|
|
124
135
|
}
|
|
125
|
-
}
|
|
136
|
+
}
|