@getpaidhq/sdk
Version:
TypeScript SDK for GetPaidHQ API - Comprehensive subscription billing platform
2 lines • 16.5 kB
JavaScript
'use strict';var a=class{constructor(t){this.httpClient=t;}resourcePath="/api/customers";buildQueryString(t){if(!t)return "";let e=Object.entries(t).filter(([n,i])=>i!=null).map(([n,i])=>Array.isArray(i)?i.map(s=>`${n}[]=${encodeURIComponent(s)}`).join("&"):`${n}=${encodeURIComponent(i)}`).join("&");return e?`?${e}`:""}async list(t){return this.httpClient.get(`${this.resourcePath}${this.buildQueryString(t)}`)}async create(t){return this.httpClient.post(this.resourcePath,t)}async get(t){return this.httpClient.get(`${this.resourcePath}/${t}`)}async update(t,e){return this.httpClient.patch(`${this.resourcePath}/${t}`,e)}async delete(t){return this.httpClient.delete(`${this.resourcePath}/${t}`)}async suspend(t){return this.update(t,{status:"inactive"})}async activate(t){return this.update(t,{status:"active"})}async getOrders(t){return console.warn("getOrders endpoint not implemented in API"),[]}async listInvoices(t,e){let n=this.buildQueryString(e);return this.httpClient.get(`${this.resourcePath}/${t}/invoices${n}`)}async createPaymentMethod(t,e){return this.httpClient.post(`${this.resourcePath}/${t}/payment-methods`,e)}async listPaymentMethods(t){return this.httpClient.get(`${this.resourcePath}/${t}/payment-methods`)}async getPaymentMethod(t,e){return this.httpClient.get(`${this.resourcePath}/${t}/payment-methods/${e}`)}async updatePaymentMethod(t,e,n){return this.httpClient.put(`${this.resourcePath}/${t}/payment-methods/${e}`,n)}async deletePaymentMethod(t,e){return this.httpClient.delete(`${this.resourcePath}/${t}/payment-methods/${e}`)}async getDunningHistory(t){return this.httpClient.get(`${this.resourcePath}/${t}/dunning-history`)}async listDiscountRedemptions(t,e){let n=this.buildQueryString(e);return this.httpClient.get(`${this.resourcePath}/${t}/discount-redemptions${n}`)}async getMrr(t){return this.httpClient.get(`${this.resourcePath}/${t}/mrr`)}};var p=class{constructor(t){this.httpClient=t;}resourcePath="/api/products";buildQueryString(t){if(!t)return "";let e=Object.entries(t).filter(([n,i])=>i!=null).map(([n,i])=>Array.isArray(i)?i.map(s=>`${n}[]=${encodeURIComponent(s)}`).join("&"):`${n}=${encodeURIComponent(i)}`).join("&");return e?`?${e}`:""}async list(t){return this.httpClient.get(`${this.resourcePath}${this.buildQueryString(t)}`)}async create(t){return this.httpClient.post(this.resourcePath,t)}async get(t){return this.httpClient.get(`${this.resourcePath}/${t}`)}async update(t,e){return this.httpClient.patch(`${this.resourcePath}/${t}`,e)}async delete(t){return this.httpClient.delete(`${this.resourcePath}/${t}`)}async listVariants(t){return this.httpClient.get(`${this.resourcePath}/${t}/variants`)}async createVariant(t,e){return this.httpClient.post(`${this.resourcePath}/${t}/variants`,e)}},u=class{constructor(t){this.httpClient=t;}resourcePath="/api/variants";async get(t){return this.httpClient.get(`${this.resourcePath}/${t}`)}async update(t,e){return this.httpClient.put(`${this.resourcePath}/${t}`,e)}async delete(t){return this.httpClient.delete(`${this.resourcePath}/${t}`)}async listPrices(t){return this.httpClient.get(`${this.resourcePath}/${t}/prices`)}},c=class{constructor(t){this.httpClient=t;}resourcePath="/api/prices";async create(t){return this.httpClient.post(this.resourcePath,t)}async get(t){return this.httpClient.get(`${this.resourcePath}/${t}`)}async update(t,e){return this.httpClient.patch(`${this.resourcePath}/${t}`,e)}async delete(t){return this.httpClient.delete(`${this.resourcePath}/${t}`)}};var m=class{constructor(t){this.httpClient=t;}resourcePath="/api/subscriptions";buildQueryString(t){if(!t)return "";let e=Object.entries(t).filter(([n,i])=>i!=null).map(([n,i])=>Array.isArray(i)?i.map(s=>`${n}[]=${encodeURIComponent(s)}`).join("&"):`${n}=${encodeURIComponent(i)}`).join("&");return e?`?${e}`:""}async list(t){return this.httpClient.get(`${this.resourcePath}${this.buildQueryString(t)}`)}async create(t){return this.httpClient.post(this.resourcePath,t)}async get(t){return this.httpClient.get(`${this.resourcePath}/${t}`)}async update(t,e){return this.httpClient.patch(`${this.resourcePath}/${t}`,e)}async pause(t,e){return this.httpClient.put(`${this.resourcePath}/${t}/pause`,e)}async resume(t,e){return this.httpClient.put(`${this.resourcePath}/${t}/resume`,e)}async activate(t,e){return this.httpClient.put(`${this.resourcePath}/${t}/activate`,e||{})}async cancel(t,e){return this.httpClient.put(`${this.resourcePath}/${t}/cancel`,e)}async changePlan(t,e){return this.httpClient.put(`${this.resourcePath}/${t}/change-plan`,e)}async updateBillingAnchor(t,e){return this.httpClient.put(`${this.resourcePath}/${t}/billing-anchor`,e)}async listPayments(t,e){let n=this.buildQueryString(e);return this.httpClient.get(`${this.resourcePath}/${t}/payments${n}`)}async getUsage(t,e){let n=this.buildQueryString(e);return this.httpClient.get(`${this.resourcePath}/${t}/usage${n}`)}async getUsageEstimate(t){return this.httpClient.get(`${this.resourcePath}/${t}/estimate`)}};var h=class{constructor(t){this.httpClient=t;}buildQueryString(t){if(!t)return "";let e=Object.entries(t).filter(([n,i])=>i!=null).map(([n,i])=>Array.isArray(i)?i.map(s=>`${n}[]=${encodeURIComponent(s)}`).join("&"):`${n}=${encodeURIComponent(i)}`).join("&");return e?`?${e}`:""}async recordCloudEvent(t){return this.httpClient.post("/api/usage-events",t)}async record(t){return this.httpClient.post("/api/usage-records",t)}async batchRecord(t){return this.httpClient.post("/api/usage-records/batch",t)}async list(t){let e=this.buildQueryString(t);return this.httpClient.get(`/api/usage-records${e}`)}async getUsageRecord(t){return this.httpClient.get(`/api/usage-records/${t}`)}async deleteUsageRecord(t){return this.httpClient.delete(`/api/usage-records/${t}`)}async getSummary(t,e){let n=this.buildQueryString(e);return this.httpClient.get(`/api/subscription-items/${t}/usage-summary${n}`)}};var g=class{constructor(t){this.httpClient=t;}async create(t){return this.httpClient.post("/api/organizations",t)}async getApiKeys(){return this.httpClient.get("/api/organizations/api-keys")}};var P=class{constructor(t){this.httpClient=t;}resourcePath="/api/meters";buildQueryString(t){if(!t)return "";let e=Object.entries(t).filter(([n,i])=>i!=null).map(([n,i])=>Array.isArray(i)?i.map(s=>`${n}[]=${encodeURIComponent(s)}`).join("&"):`${n}=${encodeURIComponent(i)}`).join("&");return e?`?${e}`:""}async list(t){return this.httpClient.get(`${this.resourcePath}${this.buildQueryString(t)}`)}async create(t){return this.httpClient.post(this.resourcePath,t)}async get(t){return this.httpClient.get(`${this.resourcePath}/${t}`)}async getBySlug(t){return this.httpClient.get(`${this.resourcePath}/slug/${t}`)}async update(t,e){return this.httpClient.put(`${this.resourcePath}/${t}`,e)}async delete(t){return this.httpClient.delete(`${this.resourcePath}/${t}`)}};var l=class{constructor(t){this.httpClient=t;}resourcePath="/api/orders";buildQueryString(t){if(!t)return "";let e=Object.entries(t).filter(([n,i])=>i!=null).map(([n,i])=>Array.isArray(i)?i.map(s=>`${n}[]=${encodeURIComponent(s)}`).join("&"):`${n}=${encodeURIComponent(i)}`).join("&");return e?`?${e}`:""}async list(t){return this.httpClient.get(`${this.resourcePath}${this.buildQueryString(t)}`)}async create(t){return this.httpClient.post(this.resourcePath,t)}async get(t){return this.httpClient.get(`${this.resourcePath}/${t}`)}async complete(t,e){return this.httpClient.post(`${this.resourcePath}/${t}/complete`,e)}async addCartItem(t,e){return this.httpClient.post(`/api/carts/${t}/add`,e)}async removeCartItem(t,e){return this.httpClient.post(`/api/carts/${t}/remove`,e)}async listSubscriptions(t){return this.httpClient.get(`${this.resourcePath}/${t}/subscriptions`)}};var d=class{constructor(t){this.httpClient=t;}resourcePath="/api/payments";buildQueryString(t){if(!t)return "";let e=Object.entries(t).filter(([n,i])=>i!=null).map(([n,i])=>Array.isArray(i)?i.map(s=>`${n}[]=${encodeURIComponent(s)}`).join("&"):`${n}=${encodeURIComponent(i)}`).join("&");return e?`?${e}`:""}async list(t){return this.httpClient.get(`${this.resourcePath}${this.buildQueryString(t)}`)}async get(t){return this.httpClient.get(`${this.resourcePath}/${t}`)}async refund(t,e){return this.httpClient.post(`${this.resourcePath}/${t}/refund`,e)}async getPaymentMethod(t){return this.httpClient.get(`/api/payment-methods/${t}`)}};var y=class{constructor(t){this.httpClient=t;}resourcePath="/api/invoices";buildQueryString(t){if(!t)return "";let e=Object.entries(t).filter(([n,i])=>i!=null).map(([n,i])=>Array.isArray(i)?i.map(s=>`${n}[]=${encodeURIComponent(s)}`).join("&"):`${n}=${encodeURIComponent(i)}`).join("&");return e?`?${e}`:""}async list(t){return this.httpClient.get(`${this.resourcePath}${this.buildQueryString(t)}`)}async create(t){return this.httpClient.post(this.resourcePath,t)}async get(t){return this.httpClient.get(`${this.resourcePath}/${t}`)}async update(t,e){return this.httpClient.put(`${this.resourcePath}/${t}`,e)}async performAction(t,e){return this.httpClient.post(`${this.resourcePath}/${t}/actions`,{action:e})}async send(t){return this.performAction(t,"send")}async finalize(t){return this.performAction(t,"finalize")}async void(t){return this.performAction(t,"void")}async markPaid(t){return this.performAction(t,"mark_paid")}async listLineItems(t){return this.httpClient.get(`${this.resourcePath}/${t}/line-items`)}async addLineItem(t,e){return this.httpClient.post(`${this.resourcePath}/${t}/line-items`,e)}async updateLineItem(t,e,n){return this.httpClient.put(`${this.resourcePath}/${t}/line-items/${e}`,n)}async deleteLineItem(t,e){return this.httpClient.delete(`${this.resourcePath}/${t}/line-items/${e}`)}async listHistory(t){return this.httpClient.get(`${this.resourcePath}/${t}/history`)}async generatePdf(t){return (await this.httpClient.getAxiosInstance().post(`${this.resourcePath}/${t}/pdf`,{},{responseType:"blob"})).data}async createPaymentLink(t,e){return this.httpClient.post(`${this.resourcePath}/${t}/payment-link`,e||{})}async initiatePayment(t,e){return this.httpClient.post(`${this.resourcePath}/${t}/initiate-payment`,e)}};var C=class{constructor(t){this.httpClient=t;}buildQueryString(t){if(!t)return "";let e=Object.entries(t).filter(([n,i])=>i!=null).map(([n,i])=>Array.isArray(i)?i.map(s=>`${n}[]=${encodeURIComponent(s)}`).join("&"):`${n}=${encodeURIComponent(i)}`).join("&");return e?`?${e}`:""}async listCampaigns(t){return this.httpClient.get(`/api/dunning/campaigns${this.buildQueryString(t)}`)}async getCampaign(t){return this.httpClient.get(`/api/dunning/campaigns/${t}`)}async updateCampaign(t,e){return this.httpClient.patch(`/api/dunning/campaigns/${t}`,e)}async listCampaignAttempts(t){return this.httpClient.get(`/api/dunning/campaigns/${t}/attempts`)}async triggerManualAttempt(t){return this.httpClient.post(`/api/dunning/campaigns/${t}/attempts`,{})}async listCampaignCommunications(t){return this.httpClient.get(`/api/dunning/campaigns/${t}/communications`)}async listConfigurations(){return this.httpClient.get("/api/dunning/configurations")}async createConfiguration(t){return this.httpClient.post("/api/dunning/configurations",t)}async getConfiguration(t){return this.httpClient.get(`/api/dunning/configurations/${t}`)}async updateConfiguration(t,e){return this.httpClient.patch(`/api/dunning/configurations/${t}`,e)}async verifyPaymentToken(t){return this.httpClient.post("/api/payment-tokens/verify",t)}async activatePaymentToken(t){return this.httpClient.post("/api/payment-tokens/activate",t)}async createSubscriptionPaymentToken(t){return this.httpClient.post(`/api/admin/subscriptions/${t}/payment-tokens`,{})}};var R=class{constructor(t){this.httpClient=t;}resourcePath="/api/webhooks";async list(){return this.httpClient.get(this.resourcePath)}async create(t){return this.httpClient.post(this.resourcePath,t)}async processWebhook(t){return this.httpClient.post("/api/notify",t)}async processCdcWebhook(t){return this.httpClient.post("/api/notify/cdc",t)}};var $=class{constructor(t){this.httpClient=t;}buildQueryString(t){if(!t)return "";let e=Object.entries(t).filter(([n,i])=>i!=null).map(([n,i])=>Array.isArray(i)?i.map(s=>`${n}[]=${encodeURIComponent(s)}`).join("&"):`${n}=${encodeURIComponent(i)}`).join("&");return e?`?${e}`:""}async getMrr(t){return this.httpClient.get(`/api/reports/revenue/mrr${this.buildQueryString(t)}`)}async getArr(t){return this.httpClient.get(`/api/reports/revenue/arr${this.buildQueryString(t)}`)}async getActiveSubscribers(t){return this.httpClient.get(`/api/reports/active-subscribers${this.buildQueryString(t)}`)}async getRefundTotals(t){return this.httpClient.get(`/api/reports/refunds${this.buildQueryString(t)}`)}async getChurnTotals(t){return this.httpClient.get(`/api/reports/churn/totals${this.buildQueryString(t)}`)}async getChurnRates(t){return this.httpClient.get(`/api/reports/churn/rates${this.buildQueryString(t)}`)}};var f=class{constructor(t){this.httpClient=t;}async list(t){return this.httpClient.get(`/api/settings/${t}`)}async create(t,e){return this.httpClient.post(`/api/settings/${t}`,e)}async get(t,e){return this.httpClient.get(`/api/settings/${t}/${e}`)}async update(t,e,n){return this.httpClient.put(`/api/settings/${t}/${e}`,n)}async delete(t,e){return this.httpClient.delete(`/api/settings/${t}/${e}`)}};var b=class{constructor(t){this.httpClient=t;}resourcePath="/api/gateways";buildQueryString(t){if(!t)return "";let e=Object.entries(t).filter(([n,i])=>i!=null).map(([n,i])=>Array.isArray(i)?i.map(s=>`${n}[]=${encodeURIComponent(s)}`).join("&"):`${n}=${encodeURIComponent(i)}`).join("&");return e?`?${e}`:""}async list(t){return this.httpClient.get(`${this.resourcePath}${this.buildQueryString(t)}`)}async create(t){return this.httpClient.post(this.resourcePath,t)}async get(t){return this.httpClient.get(`${this.resourcePath}/${t}`)}async update(t,e){return this.httpClient.put(`${this.resourcePath}/${t}`,e)}async delete(t){return this.httpClient.delete(`${this.resourcePath}/${t}`)}};var q=class{constructor(t){this.httpClient=t;}async create(t){return this.httpClient.post("/api/sessions",t)}};var v=class{constructor(t){this.httpClient=t;}async list(t){return this.httpClient.get("/api/discounts",{params:t})}async create(t){return this.httpClient.post("/api/discounts",t)}async get(t){return this.httpClient.get(`/api/discounts/${t}`)}async update(t,e){return this.httpClient.put(`/api/discounts/${t}`,e)}async delete(t){return this.httpClient.delete(`/api/discounts/${t}`)}async validate(t){return this.httpClient.post("/api/discounts/validate",t)}async apply(t){return this.httpClient.post("/api/discounts/apply",t)}async listRedemptions(t,e){return this.httpClient.get(`/api/discounts/${t}/redemptions`,{params:e})}};var L=class{constructor(t){this.httpClient=t;}async list(t){return this.httpClient.get("/api/payment-links",{params:t})}async create(t){return this.httpClient.post("/api/payment-links",t)}async get(t){return this.httpClient.get(`/api/payment-links/${t}`)}async update(t,e){return this.httpClient.put(`/api/payment-links/${t}`,e)}async delete(t){return this.httpClient.delete(`/api/payment-links/${t}`)}async getBySlug(t){return this.httpClient.get(`/api/payment-links/slug/${t}`)}async listUsages(t,e){return this.httpClient.get(`/api/payment-links/${t}/usage`,{params:e})}async recordUsage(t){return this.httpClient.post("/api/payment-links/usage",t)}async getUsage(t){return this.httpClient.get(`/api/payment-links/usage/${t}`)}};var S=class{constructor(t){this.httpClient=t;}resourcePath="/api/carts";async addItem(t,e){return this.httpClient.post(`${this.resourcePath}/${t}/add`,e)}async removeItem(t,e){return this.httpClient.post(`${this.resourcePath}/${t}/remove`,e)}async validateCoupon(t,e){return this.httpClient.post(`${this.resourcePath}/${t}/validate-coupon`,e)}};var I=class{constructor(t){this.httpClient=t;}resourcePath="/api/pay";async getPublicPaymentDetails(t){return this.httpClient.get(`${this.resourcePath}/${t}`)}async createPublicPaymentOrder(t,e){return this.httpClient.post(`${this.resourcePath}/${t}/create-order`,e)}async getPublicOrderStatus(t,e){return this.httpClient.get(`${this.resourcePath}/${t}/order/${e}/status`)}};exports.a=a;exports.b=p;exports.c=u;exports.d=c;exports.e=m;exports.f=h;exports.g=g;exports.h=P;exports.i=l;exports.j=d;exports.k=y;exports.l=C;exports.m=R;exports.n=$;exports.o=f;exports.p=b;exports.q=q;exports.r=v;exports.s=L;exports.t=S;exports.u=I;//# sourceMappingURL=chunk-M7FS46VT.cjs.map
//# sourceMappingURL=chunk-M7FS46VT.cjs.map