Have ideas to improve npm?Join in the discussion! »

trailpack-lob

1.0.0 • Public • Published

trailpack-lob

NPM version Build status Dependency Status Code Climate

Trailpack to send physical mail with Lob API

Install

With yo:

$ yo trails:trailpack trailpack-lob

With npm:

$ npm install --save trailpack-lob

Configure

// config/main.js
module.exports = {
  packs: [
    // ... other trailpacks
    require('trailpack-lob')
  ]
}
// config/lob.js
module.exports = {
  apiKey: 'Your API key',
  /**
   * Options to pass during lob initialisation
   * @see https://github.com/lob/lob-node#options
   */
  options: {},
 
  /**
   * From address used to send letters
   * Can be an object or an ID
   */
  from: {
    name: 'Person',
    address_line1: '123 Test',
    address_line2: 'Unit 200',
    address_city: 'Chicago',
    address_state: 'IL',
    address_zip: '60012',
    address_country: 'US'
  }
}

Usage

Native usage of lob API :

  this.app.packs.lob.api.letters.create({
     description: 'My First Letter',
     to: {
        name: 'Test Person',
        address_line1: '123 Test Street',
        address_line2: 'Unit 200',
        address_city: 'Chicago',
        address_state: 'IL',
        address_zip: '60012',
        address_country: 'US'
      },
     from: {
       name: 'Test Person',
       address_line1: '123 Test Street',
       address_line2: 'Unit 200',
       address_city: 'Chicago',
       address_state: 'IL',
       address_zip: '60012',
       address_country: 'US'
     },
     file: '<html>...</html>',
     data: {
       name: 'Robin'
     },
     color: false
   }).then(letter => {...})

Usage with the Trails service:

this.app.services.LobService.sendLetter(to, file, data, more).then(letter => {...}) 

this.app.services.LobService.sendPostcard(to, front, back, data, more).then(postcard => {...}) 

License

MIT

Install

npm i trailpack-lob

DownloadsWeekly Downloads

1

Version

1.0.0

License

MIT

Last publish

Collaborators

  • avatar