Skip to content

Zonos/zonos_deno_module

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Zonos API

zonos api integration for deno




Configuration

Initialize

import { Zonos } from "https://deno.land/x/zonos_api/mod.ts";

const zonos = new Zonos({
  account_number: "",
  api_key: ""
});

Note: register for an account_number and api_key at Zonos



Change API version

/* 
    Version: string | number 
*/
zonos.setVersion(1);

This can also be set directly on the Zonos class initialization with: apiVersion: '1'.



Set Cors Proxy

some endpoints do not support cross origin if called from the client side. In that case you can set a cors proxy, either your own or https://cors.zonos.com, to pass the request through.

zonos.setCorsProxy("https://cors.zonos.com");

This can also be set directly on the Zonos class initialization with: corsProxy: 'https://cors.zonos.com'.



Direct API Call

/* 
    path: string
    body: JSON
    method: string
*/
zonos.directApiCall(
    "orderDetail",
    { 
        "key": "value"
    },
    "POST|GET|PUT|DELETE"
);

Note: see Zonos Docs for more information on our supported REST endpoints.




Orders


Get Order

Returns a single orders details

By zonos order id:

/* 
    id: string | number
    isReferenceId?: boolean
*/
zonos.getOrder("12312312");

By refrerence id:

/* 
    id: string | number
    isReferenceId?: boolean
*/
zonos.getOrder("order_bt23", true);

Additonal Docs: Order Details


Get Orders

Returns a list of orders that have been created from your checkouts. (requires api version 1)

/* 
    sinceDate?: string - yyyyMMdd
    throughDate?: string - yyyyMMdd,
    sinceOrderId?: string,
    statuses?: boolean
    missingMerchantOrderId?: boolean
*/

zonos.getOrders({sinceDate: "20230920", throughDate: "20230923", statuses: true});

Update Order Status

Updates an orders status in Zonos Dashboard

/* 
    orderId: string | number
    status: string 
*/
zonos.updateOrderStatus("152352", "ready");

Allowed statuses: preparing - ready - printed - cancelled - completed


Update Order Number

Adds a merchant order id to the order.

    /*
        orderId: string | number 
        merchantOrderId: string | number
    */
    zonos.updateOrderNumber("152352", "bc_123");

merchantOrderId should match the order id used in your ecomm platform


Add/Update Order Tracking Numbers

Add or update a tracking number to the order.

/*
    orderId: string | number
    trackingNumber: string
*/
zonos.updateOrderTracking("152352", "fedex_tracking_number");

this will automatically mark the order as completed in Zonos Dashboard


Checkout


Create a Checkout

creates a checkout and returns a url for the customer to access the checkout

/*
    cart: ZonosCart
    countryCode?: string
*/
zonos.createCheckout(cart, "CA");

cart must be json format with at least the rquired fields shown on the ZonosCart type