41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import {
|
|
DeliveryAction,
|
|
RespondToOfferResponse,
|
|
PendingOfferResponse,
|
|
ActiveOrdersResponse,
|
|
} from '@interfaces';
|
|
import { apiClient } from '@services';
|
|
|
|
/**
|
|
* POST /delivery-partners/deliveries/{id}/respond
|
|
* Accept or reject a delivery offer.
|
|
*/
|
|
export const respondToOffer = async (
|
|
deliveryId: string,
|
|
action: DeliveryAction,
|
|
): Promise<RespondToOfferResponse> => {
|
|
const response = await apiClient.post<RespondToOfferResponse>(
|
|
`/delivery-partners/deliveries/${deliveryId}/respond`,
|
|
{ action },
|
|
);
|
|
return response;
|
|
};
|
|
|
|
/**
|
|
* GET /delivery-partners/deliveries/pending-offer
|
|
* Check if there is a pending offer for the current partner (e.g. after app restart).
|
|
*/
|
|
export const getPendingOffer = async (): Promise<PendingOfferResponse> => {
|
|
const response = await apiClient.get<PendingOfferResponse>(
|
|
'/delivery-partners/deliveries/pending-offer',
|
|
);
|
|
return response;
|
|
};
|
|
|
|
export const getActiveDeliveries = async (): Promise<ActiveOrdersResponse> => {
|
|
const response = await apiClient.get<ActiveOrdersResponse>(
|
|
'/delivery-partners/deliveries/active',
|
|
);
|
|
return response;
|
|
};
|