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 🙏

© 2025 – Pkg Stats / Ryan Hefner

ten99policy

v2.0.3

Published

1099Policy API wrapper

Readme

ten99policy Node.js Library

A Node.js library for interacting with the 1099Policy API.

Maintainability Test Coverage

Overview

The ten99policy library provides a simple and intuitive way to integrate 1099Policy's services into your Node.js applications. It allows you to manage entities, contractors, jobs, policies, quotes, assignments, invoices, and insurance application sessions through the 1099Policy API.

Table of Contents

Installation

Install the package using npm:

npm install ten99policy

Configuration

Before using the library, configure it with your API credentials and settings.

const Ten99Policy = require('ten99policy');

const ten99policy = new Ten99Policy({
  key: 'your_api_key_here',
  environment: 'production', // or 'sandbox' for testing
  logCurl: true, // Enable logging of CURL commands
});

Configuration Parameters:

  • key: Your API key for authentication.
  • environment: The API environment to use ('production' or 'sandbox').
  • logCurl: Whether to log CURL commands for debugging (true or false).

Usage

Entities

Creating an Entity

ten99policy.entities
  .create({
    name: 'Brooklyn Bowl',
    coverage_limit: {
      aggregate_limit: '200000000',
      occurrence_limit: '100000000',
    },
    address: {
      line1: '3639 18th St',
      locality: 'San Francisco',
      region: 'CA',
      postalcode: '94110',
    },
    required_coverage: ['general', 'workers-comp'],
  })
  .then((response) => console.log(response))
  .catch((error) => console.error(error));

Updating an Entity

ten99policy.entities
  .update('en_C9Z2DmfHSF', {
    name: 'California Roll',
  })
  .then((response) => console.log(response))
  .catch((error) => console.error(error));

Fetching the List of Entities

ten99policy.entities
  .list()
  .then((response) => console.log(response))
  .catch((error) => console.error(error));

Retrieving an Entity

ten99policy.entities
  .retrieve('en_BUcNa8jMrq') // Replace with an existing entity ID
  .then((response) => console.log(response))
  .catch((error) => console.error(error));

Deleting an Entity

ten99policy.entities
  .del('en_C9Z2DmfHSF') // Replace with an existing entity ID
  .then((response) => console.log(response))
  .catch((error) => console.error(error));

Contractors

Creating a Contractor

ten99policy.contractors
  .create({
    first_name: 'John',
    last_name: 'Doe',
    email: '[email protected]',
    phone: '415-111-1111',
    tax_identification: '123-456789',
    address: {
      country: 'USA',
      line1: '2211 Mission St',
      locality: 'San Francisco',
      region: 'CA',
      postalcode: '94110',
    },
  })
  .then((response) => console.log(response))
  .catch((error) => console.error(error));

Updating a Contractor

ten99policy.contractors
  .update('cn_tS3wR3UQ5q', { // Replace with an existing contractor ID
    email: '[email protected]',
    first_name: 'George',
  })
  .then((response) => console.log(response))
  .catch((error) => console.error(error));

Fetching the List of Contractors

ten99policy.contractors
  .list()
  .then((response) => console.log(response))
  .catch((error) => console.error(error));

Retrieving a Contractor

ten99policy.contractors
  .retrieve('cn_9TPKz6B9so') // Replace with an existing contractor ID
  .then((response) => console.log(response))
  .catch((error) => console.error(error));

Deleting a Contractor

ten99policy.contractors
  .del('cn_tS3wR3UQ5q') // Replace with an existing contractor ID
  .then((response) => console.log(response))
  .catch((error) => console.error(error));

Insurance Application Sessions

Creating an Insurance Application Session

ten99policy.applicationSessions
  .create({
    quote: 'qt_yVEnbNaWh6',
    success_url: 'http://example.com/success',
    cancel_url: 'http://example.com/cancel',
  })
  .then((response) => console.log(response))
  .catch((error) => console.error(error));

Updating a Session

ten99policy.applicationSessions
  .update('ias_01HZSB299T5D9SCNY98T8P10KC', { // Replace with an existing session ID
    success_url: 'http://example.com/success',
    cancel_url: 'http://example.com/cancel',
  })
  .then((response) => console.log(response))
  .catch((error) => console.error(error));

Fetching the List of Insurance Application Sessions

ten99policy.applicationSessions
  .list()
  .then((response) => console.log(response))
  .catch((error) => console.error(error));

Retrieving an Insurance Application Session

ten99policy.applicationSessions
  .retrieve('ias_01HZSB299T5D9SCNY98T8P10KC') // Replace with an existing session ID
  .then((response) => console.log(response))
  .catch((error) => console.error(error));

Jobs

Creating a Job

ten99policy.jobs
  .create({
    name: 'Truck driver',
    description: 'Requires a truck',
    duration_hours: 20,
    wage: 100,
    years_experience: 20,
    wage_type: 'flatfee',
    entity: 'en_FwZfQRe4aW',
    category_code: 'jc_MTqpkbkp6G',
  })
  .then((response) => console.log(response))
  .catch((error) => console.error(error));

Updating a Job

ten99policy.jobs
  .update('jb_C9Z2DmfHSF', { // Replace with an existing job ID
    name: 'Mechanic',
  })
  .then((response) => console.log(response))
  .catch((error) => console.error(error));

Fetching the List of Jobs

ten99policy.jobs
  .list()
  .then((response) => console.log(response))
  .catch((error) => console.error(error));

Retrieving a Job

ten99policy.jobs
  .retrieve('jb_C9Z2DmfHSF') // Replace with an existing job ID
  .then((response) => console.log(response))
  .catch((error) => console.error(error));

Deleting a Job

ten99policy.jobs
  .del('jb_C9Z2DmfHSF') // Replace with an existing job ID
  .then((response) => console.log(response))
  .catch((error) => console.error(error));

Policies

Creating a Policy

ten99policy.policies
  .create({
    quote_id: 'qt_UPmEfS6nNK',
    is_active: true,
  })
  .then((response) => console.log(response))
  .catch((error) => console.error(error));

Updating a Policy

ten99policy.policies
  .update('po_C9Z2DmfHSF', { // Replace with an existing policy ID
    is_active: false,
  })
  .then((response) => console.log(response))
  .catch((error) => console.error(error));

Fetching the List of Policies

ten99policy.policies
  .list()
  .then((response) => console.log(response))
  .catch((error) => console.error(error));

Retrieving a Policy

ten99policy.policies
  .retrieve('po_C9Z2DmfHSF') // Replace with an existing policy ID
  .then((response) => console.log(response))
  .catch((error) => console.error(error));

Deleting a Policy

ten99policy.policies
  .del('po_C9Z2DmfHSF') // Replace with an existing policy ID
  .then((response) => console.log(response))
  .catch((error) => console.error(error));

Quotes

Creating a Quote

ten99policy.quotes
  .create({
    job: 'jb_jsb9KEcTpc',
    contractor: 'cn_yJBbMeq9QA',
    coverage_type: ['general', 'workers-comp'],
  })
  .then((response) => console.log(response))
  .catch((error) => console.error(error));

Updating a Quote

ten99policy.quotes
  .update('qt_C9Z2DmfHSF', { // Replace with an existing quote ID
    name: 'Mechanic',
  })
  .then((response) => console.log(response))
  .catch((error) => console.error(error));

Fetching the List of Quotes

ten99policy.quotes
  .list()
  .then((response) => console.log(response))
  .catch((error) => console.error(error));

Retrieving a Quote

ten99policy.quotes
  .retrieve('qt_C9Z2DmfHSF') // Replace with an existing quote ID
  .then((response) => console.log(response))
  .catch((error) => console.error(error));

Assignments

Creating an Assignment

ten99policy.assignments
  .create({
    contractor: 'cn_kjLKMtApTv',
    job: 'jb_D6ZSaoa2MV',
  })
  .then((response) => console.log(response))
  .catch((error) => console.error(error));

Updating an Assignment

ten99policy.assignments
  .update('an_sF3yUB3BYY', { // Replace with an existing assignment ID
    contractor: 'cn_kjLKMtApTv',
  })
  .then((response) => console.log(response))
  .catch((error) => console.error(error));

Fetching the List of Assignments

ten99policy.assignments
  .list()
  .then((response) => console.log(response))
  .catch((error) => console.error(error));

Retrieving an Assignment

ten99policy.assignments
  .retrieve('as_sF3yUB3BYY') // Replace with an existing assignment ID
  .then((response) => console.log(response))
  .catch((error) => console.error(error));

Deleting an Assignment

ten99policy.assignments
  .del('as_xyz') // Replace with an existing assignment ID
  .then((response) => console.log(response))
  .catch((error) => console.error(error));

Invoices

Creating an Invoice

ten99policy.invoices
  .create({
    contractor: 'cn_AWcQPecvx5',
    job: 'jb_jW24jp6GYb',
    gross_pay: 1000,
    paycycle_startdate: 1725494400, // Unix timestamp
    paycycle_enddate: 1735494400,   // Unix timestamp
  })
  .then((response) => console.log(response))
  .catch((error) => console.error(error));

Updating an Invoice

ten99policy.invoices
  .update('in_m47rNFQ3PS', { // Replace with an existing invoice ID
    gross_pay: 1500,
  })
  .then((response) => console.log(response))
  .catch((error) => console.error(error));

Fetching the List of Invoices

ten99policy.invoices
  .list()
  .then((response) => console.log(response))
  .catch((error) => console.error(error));

Retrieving an Invoice

ten99policy.invoices
  .retrieve('in_m47rNFQ3PS') // Replace with an existing invoice ID
  .then((response) => console.log(response))
  .catch((error) => console.error(error));

Deleting an Invoice

ten99policy.invoices
  .del('in_m47rNFQ3PS') // Replace with an existing invoice ID
  .then((response) => console.log(response))
  .catch((error) => console.error(error));

Error Handling

The ten99policy library uses a promise-based structure and provides specific error classes for handling different error types. Handle potential errors using .catch() blocks and by checking the instance of the error.

const { InvalidInputError, GeneralError } = require('ten99policy');

// Example of handling errors when creating an entity
ten99policy.entities
  .create({
    name: 'New Entity',
    // ... other parameters
  })
  .then((response) => console.log(response))
  .catch((error) => {
    if (error instanceof InvalidInputError) {
      console.error('Invalid input provided:', error.message);
    } else if (error instanceof GeneralError) {
      console.error('A general error occurred:', error.message);
    } else {
      console.error('An unexpected error occurred:', error.message);
    }
  });

Additional Resources

Support

If you encounter any issues or have questions about using the ten99policy library, please open an issue on the GitHub repository or contact our support team at [email protected].

License

This library is distributed under the MIT License. See the LICENSE file in the repository for more information.


Note: Replace placeholder IDs (e.g., "en_C9Z2DmfHSF") with actual IDs from your 1099Policy account when running the code examples.