npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

exaconnect-node-sdk

v2.1.2

Published

Exaconnect node.js SDK

Downloads

101

Readme

exaconnect-node-sdk

actions codecov npm npm

Node.js SDK for exaconnect webservice (https://www.exaprint.fr/).

Installation

npm i exaconnect-node-sdk

Usage

By default, a production configuration is setup and and exempts you to use the configure method, but if you feel the need to use a custom configuration, you can still use the method as the example below.

const exaconnect = require('exaconnect-node-sdk');

exaconnect.configure({
  schema: 'http',
  hostname: 'stg-connect.exaprint.fr'
});

exaconnect
  .createClient()
  .then(console.log)
  .catch(console.error);

Methods

getToken

Promise example :

const exaconnect = require('exaconnect-node-sdk');

exaconnect
  .createClient()
  .then(client =>
    client.getToken({
      username: '[email protected]',
      password: 'secret'
    })
  )
  .then(console.log)
  .catch(console.error);

async/await example :

const exaconnect = require('exaconnect-node-sdk');

(async () => {
  const client = await exaconnect.createClient();

  const token = await client.getToken({
    username: '[email protected]',
    password: 'secret'
  });

  console.log(token);
})().catch(console.error);

createOrder

Promise example :

const exaconnect = require('exaconnect-node-sdk');

exaconnect
  .createClient()
  .then(client =>
    Promise.all([
      client,
      client.getToken({
        username: '[email protected]',
        password: 'secret'
      })
    ])
  )
  .then(([client, token]) =>
    client.createOrder({
      token: token,
      order: {
        reference: 'My first automated order',
        product: '25086',
        quantity: 100,
        openedFormatLength: '8.6',
        openedFormatWidth: '5.4',
        closedFormatLength: '0',
        closedFormatWidth: '0',
        comment: '',
        address: {
          contactName: 'M. Dupond',
          line1: '1 Place Georges Frêche',
          line2: '',
          line3: '',
          doorCode: '#3412',
          mail: '[email protected]',
          phone: '0432000000',
          mobile: '0660000000',
          city: 'Montpellier',
          zipCode: '34000',
          country: 'FR',
          comment: ''
        }
      }
    })
  )
  .then(console.log)
  .catch(console.error);

async/await example :

const exaconnect = require('exaconnect-node-sdk');

(async () => {
  const client = await exaconnect.createClient();

  const token = await client.getToken({
    username: '[email protected]',
    password: 'secret'
  });

  const order = await client.createOrder({
    token: token,
    order: {
      reference: 'My first automated order',
      product: '25086',
      quantity: 100,
      openedFormatLength: '8.6',
      openedFormatWidth: '5.4',
      closedFormatLength: '0',
      closedFormatWidth: '0',
      comment: '',
      address: {
        contactName: 'M. Dupond',
        line1: '1 Place Georges Frêche',
        line2: '',
        line3: '',
        doorCode: '#3412',
        mail: '[email protected]',
        phone: '0432000000',
        mobile: '0660000000',
        city: 'Montpellier',
        zipCode: '34000',
        country: 'FR',
        comment: ''
      }
    }
  });

  console.log(order);
})().catch(console.error);

createOrderFromPartnerOrder

Promise example :

const exaconnect = require('exaconnect-node-sdk');

exaconnect
  .createClient()
  .then(client =>
    Promise.all([
      client,
      client.getToken({
        username: '[email protected]',
        password: 'secret'
      })
    ])
  )
  .then(([client, token]) =>
    client.createOrderFromPartnerOrder({
      token: token,
      order: {
        reference: 'My first automated order from partner order',
        partnerOrderId: 327999,
        comment: '',
        address: {
          contactName: 'M. Dupond',
          line1: '1 Place Georges Frêche',
          line2: '',
          line3: '',
          doorCode: '#3412',
          mail: '[email protected]',
          phone: '0432000000',
          mobile: '0660000000',
          city: 'Montpellier',
          zipCode: '34000',
          country: 'FR',
          comment: ''
        }
      }
    })
  )
  .then(console.log)
  .catch(console.error);

async/await exemple :

const exaconnect = require('exaconnect-node-sdk');

(async () => {
  const client = await exaconnect.createClient();

  const token = await client.getToken({
    username: '[email protected]',
    password: 'secret'
  });

  const orderFromPartnerOrder = await client.createOrderFromPartnerOrder({
    token: token,
    order: {
      reference: 'My first automated order from partner order',
      partnerOrderId: 327999,
      comment: '',
      address: {
        contactName: 'M. Dupond',
        line1: '1 Place Georges Frêche',
        line2: '',
        line3: '',
        doorCode: '#3412',
        mail: '[email protected]',
        phone: '0432000000',
        mobile: '0660000000',
        city: 'Montpellier',
        zipCode: '34000',
        country: 'FR',
        comment: ''
      }
    }
  });

  console.log(orderFromPartnerOrder);
})().catch(console.error);

setOrderStateAsFileTransferred

Promise example :

const exaconnect = require('exaconnect-node-sdk');

exaconnect
  .createClient()
  .then(client =>
    Promise.all([
      client,
      client.getToken({
        username: '[email protected]',
        password: 'secret'
      })
    ])
  )
  .then(([client, token]) =>
    client.setOrderStateAsFileTransferred({
      token: token,
      orders: [5591277, 5591389]
    })
  )
  .then(console.log)
  .catch(console.error);

async/await example :

const exaconnect = require('exaconnect-node-sdk');

(async () => {
  const client = await exaconnect.createClient();

  const token = await client.getToken({
    username: '[email protected]',
    password: 'secret'
  });

  const updatedOrders = await client.setOrderStateAsFileTransferred({
    token: token,
    orders: [5591277, 5591389]
  });

  console.log(updatedOrders);
})().catch(console.error);

getOrders

Promise example :

const exaconnect = require('exaconnect-node-sdk');

exaconnect
  .createClient()
  .then(client =>
    Promise.all([
      client,
      client.getToken({
        username: '[email protected]',
        password: 'secret'
      })
    ])
  )
  .then(([client, token]) =>
    client.getOrders({
      token: token,
      dateFilterMin: '20200101',
      dateFilterMax: '20200701',
      statusFilter: 24,
      page: 1
    })
  )
  .then(console.log)
  .catch(console.error);

async/await example :

const exaconnect = require('exaconnect-node-sdk');

(async () => {
  const client = await exaconnect.createClient();

  const token = await client.getToken({
    username: '[email protected]',
    password: 'secret'
  });

  const orders = await client.getOrders({
    token: token,
    dateFilterMin: '20200101',
    dateFilterMax: '20200701',
    statusFilter: 24,
    page: 1
  });

  console.log(orders);
})().catch(console.error);

getOrderStatus

Promise example :

const exaconnect = require('exaconnect-node-sdk');

exaconnect
  .createClient()
  .then(client =>
    Promise.all([
      client,
      client.getToken({
        username: '[email protected]',
        password: 'secret'
      })
    ])
  )
  .then(([client, token]) =>
    client.getOrderStatus({
      token: token,
      orders: [5591277, 5591389]
    })
  )
  .then(console.log)
  .catch(console.error);

async/await example :

const exaconnect = require('exaconnect-node-sdk');

(async () => {
  const client = await exaconnect.createClient();

  const token = await client.getToken({
    username: '[email protected]',
    password: 'secret'
  });

  const ordersStatus = await client.getOrderStatus({
    token: token,
    orders: [5591277, 5591389]
  });

  console.log(ordersStatus);
})().catch(console.error);

cancelOrder

Promise example :

const exaconnect = require('exaconnect-node-sdk');

exaconnect
  .createClient()
  .then(client =>
    Promise.all([
      client,
      client.getToken({
        username: '[email protected]',
        password: 'secret'
      })
    ])
  )
  .then(([client, token]) =>
    client.cancelOrder({
      token,
      order: { orderId: 5591277, reason: 'File error' }
    })
  )
  .then(console.log)
  .catch(console.error);

async/await example :

const exaconnect = require('exaconnect-node-sdk');

(async () => {
  const client = await exaconnect.createClient();

  const token = await client.getToken({
    username: '[email protected]',
    password: 'secret'
  });

  const cancelledOrder = await client.cancelOrder({
    token,
    order: { orderId: 5591277, reason: 'File error' }
  });

  console.log(cancelledOrder);
})().catch(console.error);

More examples

You can find more examples in the example directory of this repository.

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request

License

MIT