Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async _callAPI(
path: string,
body: Record = {}
): Promise | never> {
try {
const response = await this._axios.post(
path,
// we can't apply a deep snake_case transform here
// because it accept only PascalCase for keyboard and rich media
snakecaseKeys(body, { deep: false })
);
const { config, request } = response;
const data = (camelcaseKeysDeep(
response.data
) as any) as Types.ResponseData;
if (data.status !== 0) {
throw new AxiosError(`Viber API - ${data.statusMessage}`, {
config,
request,
response,
});
}
wxcard: {
cardId: string;
};
}
| {
msgtype: 'miniprogrampage';
miniprogrampage: Types.MiniProgramPage;
}
)
): Promise {
await this._refreshTokenWhenExpired();
return this._axios
.post(
`/message/custom/send?access_token=${this._accessToken}`,
snakecaseKeys(body, { deep: true })
)
.then(throwErrorIfAny)
.then(
res =>
camelcaseKeys(res.data, {
deep: true,
}) as any
);
}