Git Product home page Git Product logo

sendle-node's Introduction

node-sendle

Build Status npm version Dependencies npm downloads code style: prettier License: MIT

Sendle Node.js library

In order to use this library, you need to have an account on https://www.sendle.com/. After registering, you will need the application credentials for your app.

Supported platforms

This SDK supports Node.js version 14+.

We test the library against a selection of Node.js versions which we update over time. Please refer to main.yml for the set of versions that are currently tested with CI.

If you find any compatibility issues, please raise an issue in the repository.

Installation

You need to be running at least Node.js 14 to use this library.

$ yarn add sendle-node

Create a client

import { SendleClient } from 'sendle-node';

const client = new SendleClient({
  sendleId: 'yourSendleId',
  apiKey: 'yourApiKey',
  sandbox: true, // default to false
  gotOptions: {}, // See https://github.com/sindresorhus/got#api
});

See the docs for usage reference.

Development

  1. Clone this repository
  2. Install dependencies using yarn install or npm install
  3. Build the module using yarn build or npm run build
  4. Start development server using yarn start or npm run start

๐Ÿ“‘ License

MIT License

sendle-node's People

Contributors

danieloaks avatar gomah avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

sendle-node's Issues

Prefer parcel_contents instead of contents

contents is an older, deprecated way to pass parcel contents to Sendle on international orders. These days we prefer that integrations send the parcel_contents list instead โ€“ as this list allows multiple items to be defined, the quantity of each, etc.

Preferably, if contents is passed it would be translated into parcel_contents instead, like this:

input:

  "contents": {
    "description": "T-shirt",
    "value": "20.00",
    "country_of_origin": "China",
    "currency": "AUD"
  },

sent to the api:

  "parcel_contents": [
    {
      "description": "T-shirt",
      "value": "20.00",
      "country_of_origin": "China",
      "currency": "AUD"
    }
  ],

How to update the HTTP User-Agent header?

Hi,

I'd like to update the HTTP User-Agent header with our app reference information (e.g. refAABB123) so that Sendle can recognise our app more easily. Can I update our reference number in the client below? Could you advise how to do so? An example would be extremely helpful. Thank you for your help!

const client = new SendleClient({
sendleId: 'yourSendleId',
apiKey: 'yourApiKey',
sandbox: true, // default to false
gotOptions: {},
});

Sarah

How to view a label

Hi,
Thanks for sharing codes in node js to create and cancel order. Could you please share code to view a Sendle label using node js? Thanks for your help.

Clean JSON body up a bit before sending it to the API

In the create order request, the parameters idempotencyKey, customerId, and orderId are recommended. These are passed as-is to the Sendle API as part of the JSON body, like this:

{
  ...
  "customerId": "#132",
  "orderId": "ABC-625",
  "idempotencyKey": "f5233746-71d4-4b05-bf63-56f4abaed5f6"
}

The orders get created successfully, but it'd be nice if they weren't included, both to make the requests cleaner and to prevent potential issues in future.

If possible, cleaning up the JSON before sending it would mean nicer calls. For example, removing idempotencyKey from the body, sending customerId as metadata.customerId instead (if it doesn't already exist) and doing the same for orderId, etc.

Update types for Canadian orders

Sendle's recently launched in Canada โ€“ and some types need to be updated for this:

  • Address.country refers to AU and US only.
  • currency is commonly defined as 'AUD' | 'USD', need to add CAD onto that list.
  • *_country params that are AU/US need to also include CA.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.