🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

@liongard/connectwise-rest

Package Overview
Dependencies
Maintainers
3
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

@liongard/connectwise-rest

A nodejs module for interacting with the ConnectWise REST API.

unpublished
latest
Source
npmnpm
Version
0.1.5
Version published
Maintainers
3
Created
Source

connectwise-rest

npm version npm downloads

A nodejs module for interacting with the ConnectWise REST API. This module is currently under construction. This module provides bindings for ease of development against the ConnectWise REST API.

Requirements

  • ConnectWise 2015.3+, though these functions are written for ConnectWise 2016.1 APIs (API3.0 v1.0.0).
  • ConnectWise API keys (available on ConnectWise 2015.3+), or API Only Member keys (only available on ConnectWise 2015.6+). See the documentation for more details.

Documentation

See the documentation here

Usage

Create a new API key, or API Only Member, then instantiate the module.

    
    var ConnectWiseRest = require('connectwise-rest');
    
    var cw = new ConnectWiseRest({
        companyId: 'company',
        companyUrl: 'your.connectwise.com',
        publicKey: '<public key>',
        privateKey: '<private key>',
        entryPoint: 'v4_6_release', // optional, defaults to 'v4_6_release'
        timeout: 20000,             // optional, request connection timeout in ms, defaults to 20000
        retry: false,               // optional, defaults to false
        retryOptions: {             // optional, override retry behavior, defaults as shown
          retries: 4,               // maximum number of retries
          minTimeout: 50,           // number of ms to wait between retries
          maxTimeout: 20000,        // maximum number of ms between retries
          randomize: true,          // randomize timeouts
        },
        debug: false,               // optional, enable debug logging
        logger: (level, text, meta) => { } // optional, pass in logging function
    });
    
    cw.ServiceDeskAPI.Tickets.getTicketById(1234)
        .then(function (result){
            //do something with results
        })
        .catch(function (error){
            //handle errors
        });

Or if you only require access to one API component:


    var ConnectWiseRest = require('connectwise-rest');
    
    var tickets = new ConnectWiseRest(options).ServiceDeskAPI.Tickets;
    
    tickets.getTicketById(1234)
        .then(function (result){
            //do something with results
        })
        .catch(function (error){
            //handle errors
        });

You can also manually access the API:


    var ConnectWiseRest = require('connectwise-rest');

    var api = new ConnectWiseRest(options).API.api;

    api('/path/to/api', 'POST', {
        'param1': 'val1',
        'param2': 'val2'
    })
    .then(function (result){
        //do something with results
    })
    .catch(function (error){
        //handle errors
    });

Cloud-Hosted ConnectWise

To access cloud-hosted ConnectWise, use the companyUrl of api-na.myconnectwise.net and override the default entryPoint.

    options = {
        companyId: 'company',
        companyUrl: 'api-na.myconnectwise.net',
        entryPoint: 'v2016_2',
        publicKey: '<public key>',
        privateKey: '<private key>'
    }

Implemented APIs

ModuleAPIStatus
Company APICompaniesComplete
Company APICompanyTeamsComplete
Company APIConfigurationsComplete
Company APIContactsComplete
Finance APIAdditionsComplete
Finance APIAdjustmentsComplete
Finance APIAgreementsComplete
Finance APIAgreementSitesComplete
Finance APIBoardDefaultsComplete
Finance APIWorkRolesComplete
Finance APIWorkTypeExclusionsComplete
Finance APIWorkTypesComplete
Project APIProjectsComplete
ScheduleAPIScheduleEntriesComplete
ScheduleAPIScheduleTypesComplete
Service Desk APIBoardsComplete
Service Desk APIBoardTeamsComplete
Service Desk APIPrioritiesComplete
Service Desk APIServiceNotesComplete
Service Desk APIStatusesComplete
Service Desk APITicketsComplete
System APIMembersComplete
System APIReportsComplete
Time APITimeEntriesComplete

Examples

Code Examples

Get ticket 1234 and print ticket number, summary and status.


    tickets.getTicketById(1234)
        .then(function (res) { console.log(res.id, res.summary, res.status.name); })
        .catch(function (err) { console.log(err); });

Create new ticket on service board, then print the returned ticket number, or any errors


    tickets.createTicket({
        summary: "This is the summary",
        board: {
            name: "Service Board"
        },
        company: {
            identifier: "ABC" //company ID
        },
        initialDescription: "ticket description",
        recordType: "ServiceTicket"
        //can also pass in any other Ticket object settings as needed
    })
    .then(function (res) { console.log(res.id); });
    .catch(function (err) { console.log(err); });    
    

Change the status of a ticket


    updateTicket(1234, [{
        op: 'replace',
        path: 'status',
        value: {id: 123} //id of the status to change to, find with boards.getBoards and status.getStatuses
    }, {
        //second or more operations
    }])
    .then(function(res) { //do something with returned ticket });
    .catch(function(err) { //do something with errors });    

Conditions

Valid example conditions string:


    var conditions = '(contact/name like "Fred%" and closedFlag = false) and dateEntered > [2015-12-23T05:53:27Z] or summary contains "test" AND  summary != "Some Summary"'

Error message returned from server when invalid conditions are passed in:

Expected a boolean value, not a numeric. String values should be enclosed with double or single quotes; DateTime values should be enclosed in square brackets; numbers should consist of only digits, and optionally a decimal point and a negation sign; boolean values should be indicated with the keywords true or false; null values should be indicated by the keyword null.

Keywords

connectwise

FAQs

Package last updated on 12 Mar 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts