UNPKG

@portone/server-sdk

Version:

PortOne JavaScript SDK for server-side usage

46 lines (45 loc) 1.53 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BulkPayoutClient = BulkPayoutClient; exports.GetPlatformBulkPayoutsError = void 0; var _BulkPayoutError = require("./BulkPayoutError.cjs"); var _client = require("../../../client.cjs"); function BulkPayoutClient(init) { const baseUrl = init.baseUrl ?? "https://api.portone.io"; const secret = init.secret; return { getPlatformBulkPayouts: 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/bulk-payouts?${query}`, baseUrl), { method: "GET", headers: { Authorization: `PortOne ${secret}`, "User-Agent": _client.USER_AGENT } }); if (!response.ok) { throw new GetPlatformBulkPayoutsError(await response.json()); } return response.json(); } }; } class GetPlatformBulkPayoutsError extends _BulkPayoutError.BulkPayoutError { /** @ignore */ constructor(data) { super(data); Object.setPrototypeOf(this, GetPlatformBulkPayoutsError.prototype); this.name = "GetPlatformBulkPayoutsError"; } } exports.GetPlatformBulkPayoutsError = GetPlatformBulkPayoutsError;