Javascript SDK for Space Invoices API
Switch branches/tags
Nothing to show
Clone or download

README.md

spaceinvoices-js-sdk

Build Status codecov dependencies Status devDependencies Status JavaScript Style Guide Commitizen friendly

Instalation

yarn

Usage

import dotenv from 'dotenv'
import { SpaceInvoices, siFilter } from './src/spaceInvoices'

dotenv.config()

let spaceInvoices = new SpaceInvoices(process.env.API_TOKEN)

spaceInvoices.account.authenticate(process.env.TEST_EMAIL, process.env.TEST_PASSWORD).then(account => {
  console.log('account', account)

  // Example 1: List All Organizations
  account.listOrganizations().then(organizations => {
    console.log('allOrganizations', organizations.length)
    let organization = organizations.pop()

    if (organization) {
      organization.listDocuments().then((documents) => {
        console.log('documents from organization', documents)
      })
    }
  })

  // Example 2: List Filtered Organizations

  let filter = siFilter()
    .where('locale').eq('en')
    .and('supportPin').gte(10000)

  account.listOrganizations(filter).then(organizations => {
    console.log('filteredOrganizations', organizations.length)
  })
}).catch((error) => {
  console.error('Error', error)
})

Compile

yarn compile

Test

yarn test

Contribution guide

Developing spaceinvoices-js-sdk

You consider contributing changes to spaceinvoices-js-sdk – thank you! Please consider these guidelines when filing a pull request:

  • Project uses standard JavaScript style guide, linter, and formatter. Use it and save yourselve some time
  • Commits follow the Angular commit convention. The project uses commitizen library
  • JavaScript is written using ES6 features
  • Features and bug fixes should be covered by test cases

License

MIT © Robert Tajnšek