The CurriClientService
class enables interaction with the Curri API, facilitating operations such as fetching delivery quotes, booking deliveries, managing deliveries with multiple stops, retrieving delivery information, estimating delivery times, and canceling deliveries. This README details how to install, configure, and utilize this service in your projects.
Ensure Node.js is installed on your system. Include this library in your project using npm or yarn if lib on public registry:
npm install @christopher.kendrick/curri --save
yarn add @christopher.kendrick/curri
Obtain your user ID and API key from your Curri API account. Initialize the CurriClientService
with these credentials:
const { CurriClientService } = require('@christopher.kendrick/curri');
const curri = new CurriClientService({ userID: "********", apiKey: "********" });
CurriClientService
provides methods for:
- Booking deliveries
- Booking deliveries with multiple stops
- Fetching delivery quotes
- Fetching quotes for deliveries with multiple stops
- Retrieving delivery information
- Estimating delivery times
- Canceling deliveries
- Updating a delivery
- Listing deliveries
- Get current API User
async function bookDelivery() {
const booking = await curri.book(req.body);
console.log(booking);
}
async function bookMultiDelivery() {
const bookingMulti = await curri.bookMulti(req.body);
console.log(bookingMulti);
}
async function fetchMultistopQuote() {
const quoteMulti = await curri.quoteMultistop(req.query);
console.log(quoteMulti);
}
async function retrieveDelivery() {
const delivery = await curri.getDelivery(req.query.delivery_id);
console.log(delivery);
}
async function estimateDelivery() {
const originLocation = {/* Define origin location */};
const selectedDeliveryMethod = "MethodHere"; // Define delivery method
const derivedDeliveryEstimate = await curri.deliveryDerivedEstimate(originLocation, selectedDeliveryMethod);
console.log(derivedDeliveryEstimate);
}
async function cancelDeliveryAction() {
const delivery_id = "YourDeliveryIDHere"; // Define delivery ID
const reason = "YourReasonHere"; // Define cancellation reason
const cancelDelivery = await curri.cancelDelivery(delivery_id, `Cancel Delivery Reason: ${reason}`);
console.log(cancelDelivery);
}
async function fetchQuote() {
const quote = await curri.quote(req.query);
console.log(quote);
}
async function updateDelivery() {
const updatedDelivery = await curri.updateDelivery(req.body);
console.log(updatedDelivery);
}
async function listDeliveries() {
const deliveries = await curri.listDeliveries();
console.log(deliveries);
}
async function deliveryEstimates() {
const deliveryEstimates = await curri.deliveryEstimates(delivery_id);
console.log(deliveryEstimates);
}
async function currentUser() {
const currentUser = await curri.getCurrentUser();
console.log(currentUser);
}
For any issues, questions, or contributions, refer to the project's GitHub repository or directly contact the project maintainers.