plane/web/services/license.service.ts
2023-10-25 21:01:23 +05:30

34 lines
995 B
TypeScript

// services
import { APIService } from "services/api.service";
import { IUser, IWorkspace } from "types";
export class LicenseService extends APIService {
constructor() {
super("http://localhost:8080");
}
async getProducts(): Promise<any[]> {
return this.get(`/api/products/`)
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
async createSubscription(user: IUser, priceId: string): Promise<any> {
return this.post(`/api/subscriptions/`, { user, priceId })
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
async createCheckoutSession(priceId: string, seats: number, workspace: IWorkspace, user: IUser): Promise<any> {
return this.post(`/api/checkout/create-session/`, { priceId, seats, workspace, user })
.then((response) => response?.data)
.catch((error) => {
throw error?.response?.data;
});
}
}