Skip to content

austinkloske22/postmen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

postmen-ts

npm version install size npm downloads

Postmen types for third-party use

Installing

Using npm:

$ npm install postmen-ts

Example Usage

import { CalculateRatesRequest, CalculateRatesResponse, Common, ShipperAccount, Shipment } from "postmen-ts";
import axios, { AxiosError, AxiosInstance, AxiosResponse } from 'axios';

public Rate(shipment: any) {
    return new Promise<any> ((resolve, reject) => {
        const CalculateRatesRequest = {} as CalculateRatesRequest;
        CalculateRatesRequest.async = false;
        CalculateRatesRequest.is_document = false;
        CalculateRatesRequest.ship_date = new Date().toISOString().slice(0, 10);
        CalculateRatesRequest.shipment = this._mapShipment(shipment) as Shipment;
        CalculateRatesRequest.shipper_accounts = this._getShipperAccounts() as ShipperAccount[];

         this.axios.post(Common.Endpoint.Rates, CalculateRatesRequest)
        .then((response: AxiosResponse) => {
            const calculateRateResponse = response.data?.data as CalculateRatesResponse;
            resolve(calculateRateResponse);
        })
        .catch((error: any) => {
            reject(error);
        });
    });
}

About

Postmen Shipping Integration

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published