How to use the messaging-api-common.createRequestInterceptor 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-messenger / src / MessengerClient.ts View on Github external
const appSecretProof = crypto
          .createHmac('sha256', appSecret)
          .update(accessToken, 'utf8')
          .digest('hex');

        // eslint-disable-next-line no-param-reassign
        config.url = appendQuery(config.url || '', {
          appsecret_proof: appSecretProof,
        });

        return config;
      });
    }

    this._axios.interceptors.request.use(
      createRequestInterceptor({ onRequest: this._onRequest })
    );
  }
github Yoctol / messaging-apis / packages / messaging-api-slack / src / SlackOAuthClient.ts View on Github external
this._token = config.accessToken;
      this._onRequest = config.onRequest;
      origin = config.origin;
    }

    // Web API
    // https://api.slack.com/web
    this._axios = axios.create({
      baseURL: `${origin || 'https://slack.com'}/api/`,
      headers: {
        'Content-Type': 'application/x-www-form-urlencoded',
      },
    });

    this._axios.interceptors.request.use(
      createRequestInterceptor({ onRequest: this._onRequest })
    );

    this.chat = {
      postMessage: this._postMessage.bind(this),
      postEphemeral: this._postEphemeral.bind(this),
      update: this._updateMessage.bind(this),
      delete: this._deleteMessage.bind(this),
      meMessage: this._meMessage.bind(this),
      getPermalink: this._getPermalink.bind(this),
      scheduleMessage: this._scheduleMessage.bind(this),
      deleteScheduledMessage: this._deleteScheduledMessage.bind(this),
      unfurl: this._unfurl.bind(this),
      scheduledMessages: {
        list: this._getScheduledMessages.bind(this),
      },
    };
github Yoctol / messaging-apis / packages / messaging-api-slack / src / SlackWebhookClient.ts View on Github external
url = config.url;
      this._onRequest = config.onRequest;
    } else {
      url = urlOrConfig;
    }

    // incoming webhooks
    // https://api.slack.com/incoming-webhooks
    this._axios = axios.create({
      baseURL: url,
      headers: { 'Content-Type': 'application/json' },
    });

    this._axios.interceptors.request.use(
      createRequestInterceptor({ onRequest: this._onRequest })
    );
  }
github Yoctol / messaging-apis / packages / messaging-api-telegram / src / TelegramClient.ts View on Github external
this._token = config.accessToken;
      this._onRequest = config.onRequest;
      origin = config.origin;
    } else {
      this._token = accessTokenOrConfig;
    }

    this._axios = axios.create({
      baseURL: `${origin || 'https://api.telegram.org'}/bot${this._token}/`,
      headers: {
        'Content-Type': 'application/json',
      },
    });

    this._axios.interceptors.request.use(
      createRequestInterceptor({
        onRequest: this._onRequest,
      })
    );
  }
github Yoctol / messaging-apis / packages / messaging-api-wechat / src / WechatClient.ts View on Github external
origin = config.origin;
    } else {
      this._appId = appIdOrClientConfig;
      this._appSecret = appSecret;
      this._onRequest = onRequest;
    }

    this._axios = axios.create({
      baseURL: `${origin || 'https://api.weixin.qq.com'}/cgi-bin/`,
      headers: {
        'Content-Type': 'application/json',
      },
    });

    this._axios.interceptors.request.use(
      createRequestInterceptor({
        onRequest: this._onRequest,
      })
    );
  }
github Yoctol / messaging-apis / packages / messaging-api-line / src / LineClient.ts View on Github external
origin = config.origin;
    } else {
      this._accessToken = accessTokenOrConfig;
      this._channelSecret = channelSecret as string;
    }

    this._axios = axios.create({
      baseURL: `${origin || 'https://api.line.me'}/`,
      headers: {
        Authorization: `Bearer ${this._accessToken}`,
        'Content-Type': 'application/json',
      },
    });

    this._axios.interceptors.request.use(
      createRequestInterceptor({ onRequest: this._onRequest })
    );
  }
github Yoctol / messaging-apis / packages / messaging-api-viber / src / ViberClient.ts View on Github external
} else {
      this._token = accessTokenOrConfig;
      this._sender = sender as Types.Sender;
      this._onRequest = onRequest;
    }

    this._axios = axios.create({
      baseURL: `${origin || 'https://chatapi.viber.com'}/pa/`,
      headers: {
        'Content-Type': 'application/json',
        'X-Viber-Auth-Token': this._token,
      },
    });

    this._axios.interceptors.request.use(
      createRequestInterceptor({ onRequest: this._onRequest })
    );
  }