mirror of
https://github.com/storytold/placeholder-artcraft.git
synced 2026-10-16 00:03:02 +00:00
0daf83dba9
Need to remove secrets before entire repo can be made public.
34 lines
1.0 KiB
TypeScript
34 lines
1.0 KiB
TypeScript
import { ApiManager, ApiResponse } from "./ApiManager.js";
|
|
import { Subscription } from "./models/Billing.js";
|
|
import { LoyaltyProgram } from "./enums/Billing.js";
|
|
|
|
export class BillingApi extends ApiManager {
|
|
public async ListActiveSubscriptions(): Promise<
|
|
ApiResponse<{
|
|
active_subscriptions: Subscription[];
|
|
maybe_loyalty_program?: LoyaltyProgram;
|
|
}>
|
|
> {
|
|
const endpoint = `${this.getApiSchemeAndHost()}/v1/billing/active_subscriptions`;
|
|
return await this.get<{
|
|
success: boolean;
|
|
active_subscriptions?: Subscription[];
|
|
maybe_loyalty_program?: LoyaltyProgram;
|
|
error_message?: string;
|
|
}>({ endpoint: endpoint })
|
|
.then((response) => ({
|
|
success: response.success,
|
|
data: {
|
|
active_subscriptions: response.active_subscriptions || [],
|
|
maybe_loyalty_program: response.maybe_loyalty_program,
|
|
},
|
|
}))
|
|
.catch((err) => {
|
|
return {
|
|
success: false,
|
|
errorMessage: err.message,
|
|
};
|
|
});
|
|
}
|
|
}
|