@line/bot-sdk
Version:
Node.js SDK for LINE Messaging API
111 lines (99 loc) • 3.72 kB
text/typescript
/**
* Mission Stickers API
* This document describes LINE Mission Stickers API.
*
* The version of the OpenAPI document: 0.0.1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/* tslint:disable:no-unused-locals */
import { MissionStickerRequest } from "../model/missionStickerRequest.js";
import * as Types from "../../types.js";
import { ensureJSON, buildPath } from "../../utils.js";
import { Readable } from "node:stream";
import HTTPFetchClient, {
convertResponseToReadable,
mergeHeaders,
} from "../../http-fetch.js";
// ===============================================
// This file is autogenerated - Please do not edit
// ===============================================
interface httpClientConfig {
/**
* Base URL for requests.
* Defaults to 'https://api.line.me'.
* You can override this for testing or to use a mock server.
*/
baseURL?: string;
/**
* Channel access token used for authorization.
*/
channelAccessToken: string;
/**
* Extra headers merged into every request.
*/
defaultHeaders?: Record<string, string>;
}
/**
* @see {@link LineBotClient} for a unified interface that wraps this client.
*/
export class ShopClient {
private httpClient: HTTPFetchClient;
/**
* Initializes a new `ShopClient`.
*
* @param config Configuration for this API client.
* @param config.baseURL The base URL for requests. Defaults to `https://api.line.me`.
* @param config.channelAccessToken The channel access token used for authorization.
* @param config.defaultHeaders Extra headers merged into every request.
*
* @example
* const client = new ShopClient({
* channelAccessToken: process.env.LINE_CHANNEL_ACCESS_TOKEN!,
* });
*/
constructor(config: httpClientConfig) {
const baseURL = config.baseURL || "https://api.line.me";
const defaultHeaders = mergeHeaders(config.defaultHeaders, {
Authorization: "Bearer " + config.channelAccessToken,
});
this.httpClient = new HTTPFetchClient({
defaultHeaders: defaultHeaders,
baseURL: baseURL,
});
}
/**
* Sends a mission sticker.
* Calls `POST https://api.line.me/shop/v3/mission`.
* To inspect the HTTP status code or response headers, use {@link missionStickerV3WithHttpInfo}.
* @param missionStickerRequest
* @returns A promise resolving to the response body.
* @see <a href="https://developers.line.biz/en/reference/partner-docs/#send-mission-stickers-v3">LINE Developers documentation</a>
*/
public async missionStickerV3(
missionStickerRequest: MissionStickerRequest,
): Promise<Types.MessageAPIResponseBase> {
return (await this.missionStickerV3WithHttpInfo(missionStickerRequest))
.body;
}
/**
* Sends a mission sticker.
* Calls `POST https://api.line.me/shop/v3/mission`.
* This method returns the response body together with the underlying `httpResponse`.
* @param missionStickerRequest
* @returns A promise resolving to the response body together with the underlying `httpResponse`.
* @see <a href="https://developers.line.biz/en/reference/partner-docs/#send-mission-stickers-v3">LINE Developers documentation</a>
*/
public async missionStickerV3WithHttpInfo(
missionStickerRequest: MissionStickerRequest,
): Promise<Types.ApiResponseType<Types.MessageAPIResponseBase>> {
const params = missionStickerRequest;
const res = await this.httpClient.post("/shop/v3/mission", params);
const text = await res.text();
const parsedBody = text ? JSON.parse(text) : null;
return { httpResponse: res, body: parsedBody };
}
}