@go-mailer/jarvis 6.0.0 → 7.0.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/lib/clients/users.js +13 -2
- package/package.json +1 -1
package/lib/clients/users.js
CHANGED
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
const axios = require("axios").default;
|
|
2
2
|
const Env = require("../env");
|
|
3
|
+
const { fetchTenants } = require("./iam");
|
|
3
4
|
const USERS_URI = Env.fetch("USERS_SERVICE_URI", true);
|
|
4
5
|
const GM_API_KEY = Env.fetch("GM_API_KEY", true);
|
|
5
6
|
|
|
6
|
-
const updateContact = async (
|
|
7
|
+
const updateContact = async (tenant_id, data = {}) => {
|
|
8
|
+
const {
|
|
9
|
+
tenants: [tenant]
|
|
10
|
+
} = await fetchTenants(`id=${tenant_id}`)
|
|
11
|
+
|
|
12
|
+
if (!tenant) throw new Error('Cannot trigger event for tenant')
|
|
13
|
+
const {
|
|
14
|
+
emails: [email],
|
|
15
|
+
name
|
|
16
|
+
} = tenant
|
|
17
|
+
|
|
7
18
|
await axios.post(
|
|
8
19
|
`${USERS_URI}/api/contacts`,
|
|
9
|
-
{ email, ...data },
|
|
20
|
+
{ email, name, ...data },
|
|
10
21
|
{ headers: { Authorization: `Bearer ${GM_API_KEY}` } }
|
|
11
22
|
);
|
|
12
23
|
};
|