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

ccrm

v1.1.1

Published

Node.js library for Continuity CRM API integration

Downloads

4

Readme

ccrm

Node.js library for interacting with Continuity CRM API

Use

Install from npm:

npm install --save ccrm

The export of this package is a function that takes a single argument of an object with a (usually) required config prop and an optional logger prop. The config is defined as: { url?: string, apiKey: string }. The url is optional in the sense that the default cloud hosted instance of CCRM does not require it. The API key must be provided, but for scenarios where it can't be passed in programatically, the CCRM_API_KEY env var can be used instead. Example:

const CCRM = require('ccrm');

const config = {
	apiKey: '11111-1111-1111-1111',
};

const ccrm = CCRM({ config });

ccrm is now a configured instance of the transport client.

Functions

newPartial(partialPayload: PartialData) => Promise<OrderResponse>

newPartial takes a single argument of type PartialData, defined as:

{
    productId: number
    firstName: string
    lastName: string
    address1: string
    address2?: string
    city: string
    country: string
    state: string
    postalCode: string
    phone: string
    email: string
    affid?: string
    sid?: string
    ip?: string
}

and returns a Promise that resolves to the CRM response data (but camel-cased, for your convenience). The important part of the response object is the partialId prop, which contains the id of the partial / prospect for you to save to your application for later use.

newOrder(customer: CustomerData, products: ProductData, payment: PaymentData) => Promise<OrderResponse>

newOrder takes three arguments in order of their types, defined as:

CustomerData {
    firstName: string
    lastName: string
    address1: string
    address2?: string
    city: string
    country: string
    state: string
    postalCode: string
    phone: string
    email: string
    affid?: string
    sid?: string
    ip?: string
}

ProductData Array<{
    quantity: number | string
    price: number | string
	productId: number | string
	promoPrice?: number | string
	rebillDiscount?: number | string
	discountCycleCount?: number | string
}>

PaymentData {
    firstName: string
    lastName: string
    address1: string
    address2?: string
    city: string
    country: string
    state: string
    postalCode: string
    cvv: string
    creditCardType: 'amex' | 'discover' | 'mastercard' | 'visa' | 'other'
    creditCardNumber: string
    expMonth: number
    expYear: number
    shippingMethodId: number
}

Note that if a product includes promoPrice without the rebillDiscount and/or discountCycleCount properties, they will be populated for you. This function returns a Promise that resolves to the CRM response data (but camel-cased, for your convenience). See example response data:

{
  "orderId": 1,
  "prepaid": true,
  "total": 5.00,
  "shippingPrice": 4.00,
  "descriptor": "acmecofoo8888888888",
  "customerServiceNumber": "8888888888",
  "ipAddress": "0.0.0.0",
  "subTotal": 8.00,
  "tax": 9.00,
  "transactionResponse": "sample string 10",
  "orderProducts": [
    {
      "productId": 1,
      "price": 2.0,
      "ProductName": "sample string 3"
    },
    {
      "productId": 1,
      "price": 2.0,
      "productName": "sample string 3"
    }
  ]
}

newOrderOnPartial(partialId: string | number, products: ProductData, payment: PaymentData) => Promise<OrderResponse>

newOrderOnPartial takes three arguments - the partialId on which to place the order, and then the ProductData and PaymentData, as previously defined above (see the newOrder function definition). The response is also nearly identical to the newOrder response as well. The main difference is you provide the partialId in lieu of the full set of customer data.

upsellOnOrder(orderId: string | number, products: ProductData) => Promise<OrderResponse>

upsellOnOrder is similar to the previous functions, but takes only an existing orderId plus a new ProductData array. No customer data or payment data is needed, as the data saved from the previous order is reused. The response data is also nearly identical to the newOrder response.

findOrder(options: FindOrderOptions) => Promise<OrderResponse[]>

findOrder takes a single options property defined as:

FindOrderOptions {
	fromDate: Date
	toDate: Date
	status?: number
	productId?: number
	orderId?: number
	affiliateId?: string
	customerId?: number
	shipped?: boolean
	address?: string
	address2?: string
	firstName?: string
	lastName?: string
	subId?: string
	email?: string
	city?: string
	zip?: string
	phone?: string
	state?: string
	country?: string
	transactionId?: string
	rma?: string
	ip?: string
	depth?: number
	bin?: number,
	lastFour: number,
	orderView?: boolean
}

and returns a promise resolving to an array of OrderResponse's similar to the example above.

getOrder(orderId: string | number) => Promise<OrderResponse[]>

getOrder simply takes an order id and returns the appropriate OrderResponse similar to the above examples.

getProvinces(country: string) => Promise<Subdivision[]>

getProvinces takes a string representing a country abbreviation and returns a promise resolving to an array of Subdivision, defined as:

Subdivision {
	id: number
	name: string
	provinceAbbreviation: string
	countryAbbreviation: string
}

getTaxForProduct(productId: number, country: string) => Promise<{ taxAmount: number }>

Logger

The exported function also takes an optional logger function. This is called throughout the req->res cycle and hands back various data points for you to log as you please. The shape of the object returned via this callback is:

{
	endpoint: string,
	requestBody: object,
	responseBody: object,
	latency: number,
	httpResponseCode: number,
	info?: string
}

Debugging

ccrm uses the debug library. Run your application with the env var DEBUG=ccrm to get debugging information related to transport and raw responses.