0.1.0 • Published 5 years ago

@mathieudutour/pwinty v0.1.0

Weekly downloads
1
License
MIT
Repository
-
Last release
5 years ago

pwinty

A modern Node.js wrapper for the Pwinty API. Typescript definitions included.

Installation

npm install @mathieudutour/pwinty

Usage

Sign up to Pwinty and note the MerchantID and API key you received when signing up.

import Pwinty, { ShippingMethod } from '@mathieudutour/pwinty'

const pwinty = new Pwinty({
  merchantId: String, // defaults to process.env.PWINTY_MERCHANT_ID
  apiKey: String, // defaults to process.env.PWINTY_API_KEY
  baseApiEndpoint: String, // defaults to `https://api.pwinty.com/v3.0` if process.env.NODE_ENV === 'production', `https://sandbox.pwinty.com/v3.0` otherwise
})

Then access the Pwinty endpoints:

pwinty.orders
  .create({
    recipientName: '',
    addressTownOrCity: 'Lyon',
    countryCode: 'FR',
    preferredShippingMethod: ShippingMethod.Standard,
  })
  .then(order => {
    // todo
  })
  .catch(err => {
    // todo
  })

See the typescript definitions for an overview of the methods available.

License

MIT