import { api, publicApi } from "./client"; import type { AdventureOffering, AdventureOfferingDetail, AdventureStorefrontResponse, AvailabilityResponse, Booking, CreateVendorAdventureRequest, CreateVendorEquipmentRequest, CustomerRegisterRequest, EquipmentCategory, EquipmentItem, EquipmentItemDetail, EquipmentStorefrontResponse, ListingClick, LoginRequest, MarketingSummary, TokenPair, User, VendorProfile, VendorRegisterRequest, } from "./types"; export async function login(body: LoginRequest): Promise { const { data } = await api.post("/accounts/token/", body); return data; } export async function fetchMe(): Promise { const { data } = await api.get("/accounts/me/"); return data; } export async function registerVendor(body: VendorRegisterRequest): Promise { const { data } = await api.post("/accounts/register/vendor/", body); return data; } export async function registerCustomer(body: CustomerRegisterRequest): Promise { const { data } = await api.post("/accounts/register/customer/", body); return data; } export async function requestPasswordReset(email?: string): Promise<{ detail: string }> { const { data } = await api.post<{ detail: string }>("/accounts/password/reset/request/", { email: email ?? "" }); return data; } export async function fetchVendorProfile(): Promise { const { data } = await api.get("/accounts/vendor-profile/me/"); return data; } export async function patchVendorProfile(body: Partial): Promise { const { data } = await api.patch("/accounts/vendor-profile/me/", body); return data; } export type EquipmentListParams = { category?: string; location?: string; vendor_slug?: string; min_price?: string; max_price?: string; available_from?: string; available_to?: string; }; export async function listEquipmentItems(params?: EquipmentListParams): Promise { const { data } = await publicApi.get("/equipment/items/", { params }); return data; } export async function getEquipmentItem( publicId: string, params?: Record, ): Promise { const { data } = await publicApi.get(`/equipment/items/${publicId}/`, { params }); return data; } export async function listVendorEquipment(): Promise { const { data } = await api.get("/equipment/vendor/items/"); return data; } export async function listEquipmentCategories(): Promise { const { data } = await publicApi.get("/equipment/categories/"); return data; } export async function createVendorEquipment(body: CreateVendorEquipmentRequest): Promise { const { data } = await api.post("/equipment/vendor/items/", body); return data; } export type AdventureListParams = EquipmentListParams; export async function listAdventureOfferings(params?: AdventureListParams): Promise { const { data } = await publicApi.get("/adventrues/offerings/", { params }); return data; } export async function getAdventureOffering( publicId: string, params?: Record, ): Promise { const { data } = await publicApi.get(`/adventrues/offerings/${publicId}/`, { params, }); return data; } export async function listVendorAdventures(): Promise { const { data } = await api.get("/adventrues/vendor/offerings/"); return data; } export async function createVendorAdventure(body: CreateVendorAdventureRequest): Promise { const { data } = await api.post("/adventrues/vendor/offerings/", body); return data; } export async function getEquipmentStorefront(slug: string): Promise { const { data } = await publicApi.get(`/equipment/storefront/${slug}/`); return data; } export async function getAdventureStorefront(slug: string): Promise { const { data } = await publicApi.get(`/adventrues/storefront/${slug}/`); return data; } export async function checkAvailability(params: { equipment_item_id?: number; adventure_offering_id?: number; starts_at: string; ends_at: string; }): Promise { const { data } = await api.get("/booking/availability/", { params }); return data; } export async function listBookings(): Promise { const { data } = await api.get("/booking/bookings/"); return data; } export async function getBooking(id: number): Promise { const { data } = await api.get(`/booking/bookings/${id}/`); return data; } export async function fetchVendorMarketingSummary(from: string, to: string): Promise { const { data } = await api.get("/marketing/vendor/summary/", { params: { from, to }, }); return data; } export async function fetchVendorListingClicks( from: string, to: string, extra?: { traffic_type?: "organic" | "marketing"; listing_type?: "equipment" | "adventure"; utm_campaign?: string; }, ): Promise { const { data } = await api.get("/marketing/vendor/clicks/", { params: { from, to, ...extra }, }); return data; }