@flamescape/tnt
A library for using the TNT Express API
Last updated 14 days ago by flamescape .
ISC · Original npm · Tarball · package.json
$ cnpm install @flamescape/tnt 
SYNC missed versions from official npm registry.

TNT Lib

Install

npm i @flamescape/tnt

Example Usage

const TNT = require('@flamescape/tnt');

let tnt = new TNT({
    username: 'yourusername',
    password: 'yourpassword',
    accounts: {
        GB: {number:'0000000000', lineOfBusiness: 1},
        ROW: {number: '000000000', lineOfBusiness: 2}
    }
});

let consignment = tnt.newConsignment();

consignment.setSenderAddress({
    company_name: "Sender Company",
    address1: "Sender Address Line 1",
    address2: "Sender Address Line 2",
    address3: "Sender Address Line 3",
    city: "Sender City",
    county: "Sender County",
    postcode: "XX000XX",
    country: "GB",
    vat_no: "GB000000000",
    contact_name: "Sender Contact",
    contact_telephone: "00000000000",
    contact_email: "email@example.com"
});

consignment.setDeliveryAddress({
    company_name: "Company Name",
    address1: 'Address Line 1',
    city: 'City',
    postcode: 'XX000XX',
    country: 'GB',
    contact_name: "Contact Name",
    contact_telephone: "00000000000",
});

consignment.setBoxes([
    {
        id: 1,
        description: 'Item 1',
        depth_cm: 120,
        height_cm: 50,
        width_cm: 10,
        weight_kg: 3,
    },
    {
        id: 2,
        description: 'Item 2',
        depth_cm: 100,
        height_cm: 100,
        width_cm: 10,
        weight_kg: 3.2,
    }
])

consignment.setCollectionDate('2020-05-01 16:00');

const services = await cons.queryAvailableServices();

console.log('Available Services:', services);
cons.setService(services[0]);

const consignmentNum = await cons.createConsignment();
console.log('TNT Consignment Number:', consignmentNum);

const labelXml = await cons.fetchLabelXml();

const labelPdf = await tnt.renderLabel(labelXml, {
    width: "101mm",
    height: "152mm"
});

await fs.outputFile('./label.pdf', labelPdf);

Current Tags

  • 0.0.15                                ...           latest (14 days ago)

13 Versions

  • 0.0.15                                ...           14 days ago
  • 0.0.14                                ...           23 days ago
  • 0.0.13                                ...           a month ago
  • 0.0.11                                ...           a month ago
  • 0.0.10                                ...           a month ago
  • 0.0.9                                ...           a month ago
  • 0.0.8                                ...           a month ago
  • 0.0.7                                ...           a month ago
  • 0.0.5                                ...           a month ago
  • 0.0.4                                ...           a month ago
  • 0.0.3                                ...           a month ago
  • 0.0.2                                ...           a month ago
  • 0.0.1                                ...           a month ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 146
Dependencies (7)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |