UNPKG

@portone/server-sdk

Version:

PortOne JavaScript SDK for server-side usage

46 lines (45 loc) 1.47 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GetPlatformPayoutsError = void 0; exports.PayoutClient = PayoutClient; var _PayoutError = require("./PayoutError.cjs"); var _client = require("../../../client.cjs"); function PayoutClient(init) { const baseUrl = init.baseUrl ?? "https://api.portone.io"; const secret = init.secret; return { getPlatformPayouts: async options => { const isForTest = options?.isForTest; const page = options?.page; const filter = options?.filter; const requestBody = JSON.stringify({ isForTest, page, filter }); const query = [["requestBody", requestBody]].flatMap(([key, value]) => value == null ? [] : `${key}=${encodeURIComponent(value)}`).join("&"); const response = await fetch(new URL(`/platform/payouts?${query}`, baseUrl), { method: "GET", headers: { Authorization: `PortOne ${secret}`, "User-Agent": _client.USER_AGENT } }); if (!response.ok) { throw new GetPlatformPayoutsError(await response.json()); } return response.json(); } }; } class GetPlatformPayoutsError extends _PayoutError.PayoutError { /** @ignore */ constructor(data) { super(data); Object.setPrototypeOf(this, GetPlatformPayoutsError.prototype); this.name = "GetPlatformPayoutsError"; } } exports.GetPlatformPayoutsError = GetPlatformPayoutsError;