Skip to content
This repository has been archived by the owner on Feb 16, 2019. It is now read-only.

Latest commit

 

History

History
125 lines (101 loc) · 2.33 KB

README.md

File metadata and controls

125 lines (101 loc) · 2.33 KB

unbill-node

A node.js client library for the Unbill API.

Table of Contents

Getting started

$ npm install unbill
var Unbill = require('unbill')(unbillKey)

Examples

Authenticate a user's bill credentials

var Unbill = require('unbill')(unbillKey)

Unbill.auth({
  userId: userId,
  companyId: companyId,
  form: {
    username: 'username',
    password: 'password'
  }
})
.then(function (response) {

  if (response.status === 200) {
    var billData = response.data
    return billData
  }
  else if (response.status === 201) {
    return Unbill.authStep({
      token: response.data.token,
      mfa: ['Secret Answer']
    })
    .then(function (response) {
      // Repeat until 200 status is returned
    })
  }

})
.catch(function (e) {
  var errMessage = e.response.data.message
))

API

The module supports all Unbill API endpoints. For complete information about the API, head over to the docs.

Every function requires a payload as specified by the docs and returns a promise that can be used to access the response of the call.

Auth

// Auth
Unbill.auth(payload)
// Auth step
Unbill.authStep(payload)

Bill

// Bill details
Unbill.getBillDetails(payload)
// Bill list
Unbill.getBills(payload)
// Fix bill hold
Unbill.fixBillHold(payload)
// Remove bill
Unbill.removeBill(payload)

Company

// Get company
Unbill.getCompany(payload)
// Search companies
Unbill.searchCompanies(payload)
// Get company categories
Unbill.getCompanyCategories(payload)

Payment

// Add payment method
Unbill.addPaymentMethod(payload)
// Get payment method
Unbill.getPaymentMethod(payload)
// Retry payment method
Unbill.retryPaymentMethod(payload)
// Update autopay
Unbill.updateAutopay(payload)
// Make payment
Unbill.makePayment(payload)

User

// Create user
Unbill.createUser

Support

We’ve tried to make this documentation user-friendly and example-filled, but please drop us a line with any questions.