2021-09-20 12:26:19 +02:00
|
|
|
const API = require("./api")
|
|
|
|
const env = require("../environment")
|
2021-10-04 14:40:50 +02:00
|
|
|
const { Headers } = require("../constants")
|
2021-09-20 12:26:19 +02:00
|
|
|
|
|
|
|
const api = new API(env.ACCOUNT_PORTAL_URL)
|
|
|
|
|
|
|
|
exports.getAccount = async email => {
|
|
|
|
const payload = {
|
|
|
|
email,
|
|
|
|
}
|
|
|
|
const response = await api.post(`/api/accounts/search`, {
|
|
|
|
body: payload,
|
2021-10-04 14:40:50 +02:00
|
|
|
headers: {
|
|
|
|
[Headers.API_KEY]: env.ACCOUNT_PORTAL_API_KEY,
|
|
|
|
},
|
2021-09-20 12:26:19 +02:00
|
|
|
})
|
|
|
|
const json = await response.json()
|
|
|
|
|
|
|
|
if (response.status !== 200) {
|
|
|
|
throw Error(`Error getting account by email ${email}`, json)
|
|
|
|
}
|
|
|
|
|
|
|
|
return json[0]
|
|
|
|
}
|