UNPKG

typed-douyin-openapi

Version:
68 lines 2.92 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.OpenapiUrlLink = void 0; const openapi_base_1 = require("./openapi_base"); class OpenapiUrlLink extends openapi_base_1.OpenapiBase { /** * 成能够直接跳转到端内小程序的 url link。 */ generateUrlLink(data) { return __awaiter(this, void 0, void 0, function* () { const result = yield this.request({ url: 'https://developer.toutiao.com/api/apps/url_link/generate', method: 'post', data: { access_token: yield this.ensureAccessToken(), ma_app_id: this.appid, app_name: data.app_name || 'douyin', path: data.path, query: data.query || '{}', expire_time: data.expire_time || Math.floor(Date.now() / 1000 + 180 * 24 * 60 * 60) } }); return result.url_link; }); } /** * 查询已经生成的 link 的信息,过期的 url_link 返回"url_link 不存在"。 * @param url_link */ queryUrlLinkInfo(url_link) { return __awaiter(this, void 0, void 0, function* () { const result = yield this.request({ url: 'https://developer.toutiao.com/api/apps/url_link/query_info', method: 'post', data: { access_token: yield this.ensureAccessToken(), ma_app_id: this.appid, url_link: url_link } }); return result.url_link_info; }); } queryUrlLinkQuota() { return __awaiter(this, void 0, void 0, function* () { const result = yield this.request({ url: 'https://developer.toutiao.com/api/apps/url_link/query_quota', method: 'post', data: { access_token: yield this.ensureAccessToken(), ma_app_id: this.appid } }); return result.url_link_quota; }); } } exports.OpenapiUrlLink = OpenapiUrlLink; //# sourceMappingURL=openapi_url_link.js.map