UNPKG

@salla.sa/twilight-components

Version:
53 lines (52 loc) 2.14 kB
/** * API Service for salla-bullet-delivery component * Uses Salla's shipping API and scope API for delivery location management */ import type { Branch, City, Country, District, Region, SavedAddress, ScopeAllocationPayload, ScopeAllocationResponse } from './interfaces'; /** Uses country code from API (e.g. 'SA'). */ export declare const isSaudiArabia: (countryCode: string) => boolean; /** * Fast Delivery API Service * Uses Salla's shipping API and scopes API. Branch and address data are used as returned by the API (no mapping). */ export declare const bulletDeliveryAPI: { /** * Get available countries from Salla shipping API * @param forBranch - when true, use for_branch=1 (e.g. for pickup/branches tab) */ getCountries(forBranch?: boolean, query?: string): Promise<Country[]>; /** * Get regions for a country from Salla shipping API * Endpoint: GET /shipping/countries/<COUNTRY_ID>/region */ getRegions(countryId: number | string, query?: string): Promise<Region[]>; /** * Get cities from Salla shipping API * @param regionId - Optional; when provided (e.g. for SA), cities are filtered by region */ getCities(countryId: number | string, regionId?: number | string, query?: string): Promise<City[]>; /** * Get districts from Salla shipping API */ getDistricts(cityId: number, query?: string): Promise<District[]>; getSavedAddresses(): Promise<SavedAddress[]>; getBranches({ query, lat, lng, country_id, per_page }?: { query?: string; lat?: number | string; lng?: number | string; country_id?: number | string; per_page?: number; }): Promise<Branch[]>; saveAddressLocation(payload: Record<string, unknown>): Promise<{ success: boolean; address?: SavedAddress; }>; setDeliveryScope(scopeId: number): Promise<boolean>; allocateScope(payload: ScopeAllocationPayload): Promise<{ success: boolean; error?: string; data?: ScopeAllocationResponse; }>; }; export declare function clearApiCache(): void; export default bulletDeliveryAPI;