Update: nueva version Horux Despachos
This commit is contained in:
37
apps/web/lib/api/addons.ts
Normal file
37
apps/web/lib/api/addons.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { apiClient } from './client';
|
||||
|
||||
export interface SubscriptionAddon {
|
||||
id: string;
|
||||
codename: string;
|
||||
nombre: string;
|
||||
precio: number;
|
||||
quantity: number;
|
||||
contribuyenteId: string | null;
|
||||
status: string;
|
||||
currentPeriodStart: string | null;
|
||||
currentPeriodEnd: string | null;
|
||||
}
|
||||
|
||||
export interface AddonsResponse {
|
||||
subscription: { id: string; plan: string; status: string } | null;
|
||||
addons: SubscriptionAddon[];
|
||||
}
|
||||
|
||||
export async function listMyAddons(contribuyenteId?: string): Promise<AddonsResponse> {
|
||||
const params = contribuyenteId ? { contribuyenteId } : undefined;
|
||||
const { data } = await apiClient.get<AddonsResponse>('/subscriptions/me/addons', { params });
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function subscribeAddon(params: {
|
||||
addonCodename: string;
|
||||
quantity?: number;
|
||||
contribuyenteId?: string | null;
|
||||
}): Promise<{ addon: SubscriptionAddon; paymentUrl: string }> {
|
||||
const { data } = await apiClient.post('/subscriptions/me/addons', params);
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function cancelAddon(addonId: string): Promise<void> {
|
||||
await apiClient.delete(`/subscriptions/me/addons/${addonId}`);
|
||||
}
|
||||
Reference in New Issue
Block a user