How to use the messaging-api-common.snakecaseKeys function in messaging-api-common

To help you get started, we’ve selected a few messaging-api-common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Yoctol / messaging-apis / packages / messaging-api-viber / src / ViberClient.ts View on Github external
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,
        });
      }
github Yoctol / messaging-apis / packages / messaging-api-wechat / src / WechatClient.ts View on Github external
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
      );
  }