UNPKG

@paybyrd/ai-agent-toolkit

Version:

Toolkit for building AI agents with various models

30 lines (29 loc) 1.09 kB
import { createPaymentLink, createRefund, retrieveOrder } from './functions.js'; class PaybyrdAPI { constructor(apiKey, context) { this.apiKey = apiKey; this.baseUrl = (context === null || context === void 0 ? void 0 : context.baseUrl) || 'https://gateway.paybyrd.com/api/v2'; this.context = context || {}; } async run(method, arg) { const authInfo = { apiKey: this.apiKey }; if (method === 'create_payment_link') { const output = JSON.stringify(await createPaymentLink(authInfo, this.baseUrl, arg)); return output; } else if (method === 'create_refund') { const output = JSON.stringify(await createRefund(authInfo, this.baseUrl, arg)); return output; } else if (method === 'retrieve_order') { const output = JSON.stringify(await retrieveOrder(authInfo, this.baseUrl, arg)); return output; } else { throw new Error('Invalid method ' + method); } } } export default PaybyrdAPI;