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

node-moco

v4.2.0

Published

A microservice api-client to access Mocoapp.com API

Downloads

13

Readme

node-moco

GitHub license Build Status npm version

A microservice api-client to access Mocoapp.com API.

This module is based on my Extended-Request package, in fact it's using that package in order to perform the api requests.

Features:

  • ES8 (Async/Await)
  • ES6 (Promises)
  • ES5 (Callback)
  • Debug Mode

Table of contents


API Reference

Moco(
    [Object {
      domain: String='mycompany'
      debug: Boolean=false
      token: String=''
    } details]
) -> Object {
    /* Constants */
    this: Object=this

    /* Methods */
    getActivities: [Object=options, function(class ErrorClass err, any results) cb] | Promise
    getActivity: [String|Number=id, function(class ErrorClass err, any results) cb] | Promise

    getCompanies: [Object=options, function(class ErrorClass err, any results) cb] | Promise
    getCompany: [String|Number=id, function(class ErrorClass err, any results) cb] | Promise

    getComments: [Object=options, function(class ErrorClass err, any results) cb] | Promise
    getComment: [String|Number=id, function(class ErrorClass err, any results) cb] | Promise

    getContactsPeople: [Object=options, function(class ErrorClass err, any results) cb] | Promise
    getContactsPerson: [String|Number=id, function(class ErrorClass err, any results) cb] | Promise

    getDeals: [Object=options, function(class ErrorClass err, any results) cb] | Promise
    getDeal: [String|Number=id, function(class ErrorClass err, any results) cb] | Promise

    getDealCategories: [Object=options, function(class ErrorClass err, any results) cb] | Promise
    getDealCategory: [String|Number=id, function(class ErrorClass err, any results) cb] | Promise

    getInvoices: [Object=options, function(class ErrorClass err, any results) cb] | Promise
    getInvoice: [String|Number=id, function(class ErrorClass err, any results) cb] | Promise

    getInvoicePayments: [Object=options, function(class ErrorClass err, any results) cb] | Promise
    getInvoicePayment: [String|Number=id, function(class ErrorClass err, any results) cb] | Promise

    getOffers: [Object=options, function(class ErrorClass err, any results) cb] | Promise
    getOffer: [String|Number=id, function(class ErrorClass err, any results) cb] | Promise

    getProjects: [Object=options, function(class ErrorClass err, any results) cb] | Promise
    getProject: [String|Number=id, function(class ErrorClass err, any results) cb] | Promise

    getProjectsAssigned: [Object=options, function(class ErrorClass err, any results) cb] | Promise
    getProjectsExpenses: [Object=options, function(class ErrorClass err, any results) cb] | Promise

    getPurchases: [Object=options, function(class ErrorClass err, any results) cb] | Promise
    getPurchase: [String|Number=id, function(class ErrorClass err, any results) cb] | Promise

    getPurchaseCategories: [Object=options, function(class ErrorClass err, any results) cb] | Promise
    getPurchaseCategory: [String|Number=id, function(class ErrorClass err, any results) cb] | Promise

    getSchedules: [Object=options, function(class ErrorClass err, any results) cb] | Promise
    getSchedule: [String|Number=id, function(class ErrorClass err, any results) cb] | Promise

    getUnits: [Object=options, function(class ErrorClass err, any results) cb] | Promise
    getUnit: [String|Number=id, function(class ErrorClass err, any results) cb] | Promise

    getUsers: [Object=options, function(class ErrorClass err, any results) cb] | Promise
    getUser: [String|Number=id, function(class ErrorClass err, any results) cb] | Promise

    getUserEmployments: [Object=options, function(class ErrorClass err, any results) cb] | Promise
    getUserEmployment: [String|Number=id, function(class ErrorClass err, any results) cb] | Promise

    getUserHolidays: [Object=options, function(class ErrorClass err, any results) cb] | Promise
    getUserHoliday: [String|Number=id, function(class ErrorClass err, any results) cb] | Promise    
}

Property reference:

| Property | Description | | ------ | ----------- | | details | An object containing configuration details | | domain | The first part of your MOCO domain (eg. mycompany) | | apikey | Your MOCO integration API Key | | debug | Whether to debug requests |

Method reference:

Create a Moco instance

Available options:

| | | Required | Default | | ------ | ----------- | ------ | ----- | | domain | mycompany | Yes | | | apikey | your key | Yes | | | debug | enable debugging | No | false |

const company = new Moco({
  domain: 'mycompany',
  apikey: '<key here>'
})

Get Activities

Available options:

| | | Required | Default | | ------ | ----------- | ------ | ----- | | options | for example: { from: '2018-02-01' } | No | None | | cb | optional callback (in case you don't want to use promises) | No | |

Options reference: #get-activities Sorting

/* Async/Await */
const activities = await mycompany.getActivities()

const activities = await mycompany.getActivities({
  from: '2017-01-02'
  to: '2017-01-02'
})

/* Promise */
mycompany.getActivities()
.then((results) => {
  console.log(results)
})
.catch((err) => {
  console.log(err)
})

mycompany.getActivities({
  from: '2017-01-02'
  to: '2017-01-02'
})
.then((results) => {
  console.log(results)
})
.catch((err) => {
  console.log(err)
})

/* Callback */
mycompany.getActivities((err, response) => {
  console.log(err, response)
})

mycompany.getActivities({
  from: '2017-01-02'
  to: '2017-01-02'
},
(err, response) => {
  console.log(err, response)
})

Get Activity

Available options:

| | | Required | Default | | ------ | ----------- | ------ | ----- | | id | for example: 58844 | Yes | None | | cb | optional callback (in case you don't want to use promises) | No | |

/* Async/Await */
const activity = await mycompany.getActivity(58844)

/* Promise */
mycompany.getActivity(58844)
.then((results) => {
  console.log(results)
})
.catch((err) => {
  console.log(err)
})

/* Callback */
mycompany.getActivity(58844, (err, response) => {
  console.log(err, response)
})

Get Companies

Available options:

| | | Required | Default | | ------ | ----------- | ------ | ----- | | options | for example: { type: 'customer' } | No | None | | cb | optional callback (in case you don't want to use promises) | No | |

Options reference: #get-companies Sorting

/* Async/Await */
const companies = await mycompany.getCompanies()

const companies = await mycompany.getCompanies({
  type: 'customer'
})

/* Promise */
mycompany.getCompanies()
.then((results) => {
  console.log(results)
})
.catch((err) => {
  console.log(err)
})

mycompany.getCompanies({
  type: 'customer'
})
.then((results) => {
  console.log(results)
})
.catch((err) => {
  console.log(err)
})

/* Callback */
mycompany.getCompanies((err, response) => {
  console.log(err, response)
})

mycompany.getCompanies({
  type: 'customer'
},
(err, response) => {
  console.log(err, response)
})

Get Company

Available options:

| | | Required | Default | | ------ | ----------- | ------ | ----- | | id | for example: 58844 | Yes | None | | cb | optional callback (in case you don't want to use promises) | No | |

/* Async/Await */
const company = await mycompany.getCompany(58844)

/* Promise */
mycompany.getCompany(58844)
.then((results) => {
  console.log(results)
})
.catch((err) => {
  console.log(err)
})

/* Callback */
mycompany.getCompany(58844, (err, response) => {
  console.log(err, response)
})

Get Comments

Call as shown above in the API Reference.

Options reference: #get-comments Sorting

Get Comment

Call as shown above in the API Reference.


Get Contacts People

Call as shown above in the API Reference.

Available options: #get-contacts-people Sorting

Get Contacts Person

Call as shown above in the API Reference.


Get Deals

Call as shown above in the API Reference.

Options reference: #get-deals Sorting

Get Deal

Call as shown above in the API Reference.


Get Deal Categories

Call as shown above in the API Reference.

Options reference: #get-deal_categories Sorting

Get Deal Category

Call as shown above in the API Reference.


Get Invoices

Call as shown above in the API Reference.

Options reference: #get-invoices Sorting

Get Invoice

Call as shown above in the API Reference.


Get Invoice Payments

Call as shown above in the API Reference.

Options reference: #get-invoice-payments Sorting

Get Invoice Payment

Call as shown above in the API Reference.


Get Offers

Call as shown above in the API Reference.

Options reference: #get-offers Sorting

Get Offer

Call as shown above in the API Reference.


Get Projects

Available options:

| | | Required | Default | | ------ | ----------- | ------ | ----- | | options | for example: { include_archived: false } | No | None | | cb | optional callback (in case you don't want to use promises) | No | |

Options reference: #get-projects Sorting

/* Async/Await */
const projects = await mycompany.getProjects()

const projects = await mycompany.getProjects({
  include_archived: false
})

/* Promise */
mycompany.getProjects()
.then((results) => {
  console.log(results)
})
.catch((err) => {
  console.log(err)
})

mycompany.getProjects({
  include_archived: false
})
.then((results) => {
  console.log(results)
})
.catch((err) => {
  console.log(err)
})

/* Callback */
mycompany.getProjects((err, response) => {
  console.log(err, response)
})

mycompany.getProjects({
  include_archived: false
},
(err, response) => {
  console.log(err, response)
})

Get Project

Available options:

| | | Required | Default | | ------ | ----------- | ------ | ----- | | id | for example: 58844 | Yes | None | | cb | optional callback (in case you don't want to use promises) | No | |

/* Async/Await */
const project = await mycompany.getProject(58844)

/* Promise */
mycompany.getProject(58844)
.then((results) => {
  console.log(results)
})
.catch((err) => {
  console.log(err)
})

/* Callback */
mycompany.getProject(58844, (err, response) => {
  console.log(err, response)
})

Get Projects Assigned

Call as shown above in the API Reference.

Options reference: #get-projects-assigned

Get Projects Expenses

Call as shown above in the API Reference.

Options reference: #get-projects-expenses


Get Purchases

Call as shown above in the API Reference.

Options reference: #get-purchases Sorting

Get Purchase

Call as shown above in the API Reference.


Get Purchase Categories

Call as shown above in the API Reference.

Options reference: #get-purchases-categories Sorting

Get Purchase Category

Call as shown above in the API Reference.


Get Schedules

Available options:

| | | Required | Default | | ------ | ----------- | ------ | ----- | | options | for example: { from: '2018-02-01' } | No | None | | cb | optional callback (in case you don't want to use promises) | No | |

Options reference: #get-schedules Sorting

/* Async/Await */
const schedules = await mycompany.getSchedules()

const schedules = await mycompany.getSchedules({
  from: '2017-01-02'
  to: '2017-01-02'
})

/* Promise */
mycompany.getSchedules()
.then((results) => {
  console.log(results)
})
.catch((err) => {
  console.log(err)
})

mycompany.getSchedules({
  from: '2017-01-02'
  to: '2017-01-02'
})
.then((results) => {
  console.log(results)
})
.catch((err) => {
  console.log(err)
})

/* Callback */
mycompany.getSchedules((err, response) => {
  console.log(err, response)
})

mycompany.getSchedules({
  from: '2017-01-02'
  to: '2017-01-02'
}, 
(err, response) => {
  console.log(err, response)
})

Get Schedule

Available options:

| | | Required | Default | | ------ | ----------- | ------ | ----- | | id | for example: 58844 | Yes | None | | cb | optional callback (in case you don't want to use promises) | No | |

/* Async/Await */
const schedule = await mycompany.getSchedule(58844)

/* Promise */
mycompany.getSchedule(58844)
.then((results) => {
  console.log(results)
})
.catch((err) => {
  console.log(err)
})

/* Callback */
mycompany.getSchedule(58844, (err, response) => {
  console.log(err, response)
})

Get Units

Call as shown above in the API Reference.

Options reference: #get-units Sorting

Get Unit

Call as shown above in the API Reference.


Get Users

Available options:

| | | Required | Default | | ------ | ----------- | ------ | ----- | | options | | No | None | | cb | optional callback (in case you don't want to use promises) | No | |

Options reference: #get-users Sorting

/* Async/Await */
const users = await mycompany.getUsers()

/* Promise */
mycompany.getUsers()
.then((results) => {
  console.log(results)
})
.catch((err) => {
  console.log(err)
})

/* Callback */
mycompany.getUsers((err, response) => {
  console.log(err, response)
})

Get User

Available options:

| | | Required | Default | | ------ | ----------- | ------ | ----- | | id | for example: 58844 | Yes | None | | cb | optional callback (in case you don't want to use promises) | No | |

/* Async/Await */
const user = await mycompany.getUser(58844)

/* Promise */
mycompany.getUser(58844)
.then((results) => {
  console.log(results)
})
.catch((err) => {
  console.log(err)
})

/* Callback */
mycompany.getUser(58844, (err, response) => {
  console.log(err, response)
})

Get User Employments

Call as shown above in the API Reference.

Options reference: #get-user-employments Sorting

Get User Employment

Call as shown above in the API Reference.


Get User Holidays

Call as shown above in the API Reference.

Options reference: #get-user-holidays Sorting

Get User Holiday

Call as shown above in the API Reference.


Sorting

You can sort your results by adding sort_by to your options object.

sort_by: 'title'
sort_by: 'date desc'

Read more: #sorting


Setup / Install

Use npm install @burnett01/node-moco

const Moco = require('@burnett01/node-moco')

Unit-Tests

The testing-framework used in this module is Mocha with the BDD / TDD assertion library Chai.

Output using Mocha list reporter:

Default reporter: list

Make

make test

NPM

npm test


Contributing

You're very welcome and free to contribute. Thank you.


License

MIT