@salla.sa/twilight-components
Version:
Salla Web Component
62 lines (61 loc) • 2.24 kB
TypeScript
/**
* API Service for salla-bullet-delivery component
* Uses Salla's shipping API and scope API for delivery location management
*/
import type { Country, City, District, Region, Branch, SavedAddress, 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): Promise<Country[]>;
/**
* Get regions for a country from Salla shipping API
* Endpoint: GET /shipping/countries/<COUNTRY_ID>/region
*/
getRegions(countryId: number | 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): Promise<City[]>;
/**
* Get districts from Salla shipping API
*/
getDistricts(cityId: number): 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: {
type: "address" | "branch";
country_id?: string;
region_id?: string;
city_id?: string;
district_id?: string;
lat?: string;
lng?: string;
address_id?: string;
branch_id?: string;
}): Promise<{
success: boolean;
error?: string;
data?: ScopeAllocationResponse;
}>;
};
export default bulletDeliveryAPI;