Skip to main content

Python bindings for the ten99policy API

Project description

ten99policy Python Library

A Python 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 Python applications. It allows you to manage entities, contractors, jobs, policies, quotes, assignments, and more through the 1099Policy API.

Table of Contents

Installation

Install the package using pip:

pip install ten99policy

Configuration

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

import ten99policy

# Configuration variables
ten99policy.api_key = 'your_api_key_here'
ten99policy.environment = 'production'  # or 'sandbox' for testing
ten99policy.api_base = 'https://api.1099policy.com'  # Default API base URL
ten99policy.verify_ssl_certs = True  # Set to False if you encounter SSL issues
ten99policy.log = 'debug'  # Logging level ('debug' or 'info')

Configuration Parameters:

  • api_key: Your API key for authentication.
  • environment: The API environment to use ('production' or 'sandbox').
  • api_base: The base URL for API requests.
  • verify_ssl_certs: Whether to verify SSL certificates.
  • log: Logging level for console output ('debug' or 'info').

Usage

Entities

Creating an Entity

import ten99policy

resource = ten99policy.Entities.create(
    name="Brooklyn Bowl",
    coverage_limit={
        "aggregate_limit": "200000000",
        "occurrence_limit": "100000000",
    },
    address={
        "line1": "3639 18th St",
        "line2": "",
        "locality": "San Francisco",
        "region": "CA",
        "postalcode": "94110",
    },
    required_coverage=["general", "workers-comp"],
)

Updating an Entity

resource = ten99policy.Entities.modify(
    "en_C9Z2DmfHSF",  # Replace with an existing entity ID
    name="California Roll",
)

Fetching the List of Entities

resource = ten99policy.Entities.list()

Retrieving an Entity

resource = ten99policy.Entities.retrieve("en_BUcNa8jMrq")  # Replace with an existing entity ID

Deleting an Entity

resource = ten99policy.Entities.delete("en_C9Z2DmfHSF")  # Replace with an existing entity ID

Contractors

Creating a Contractor

resource = ten99policy.Contractors.create(
    first_name="John",
    last_name="Doe",
    email="john@doe.com",
    phone="415-111-1111",
    tax_identification="123-456789",
    address={
        "country": "USA",
        "line1": "2211 Mission St",
        "locality": "San Francisco",
        "region": "CA",
        "postalcode": "94110",
    },
)

Updating a Contractor

resource = ten99policy.Contractors.modify(
    "cn_tS3wR3UQ5q",  # Replace with an existing contractor ID
    email="john.doe@gmail.com",
    first_name="George",
)

Fetching the List of Contractors

resource = ten99policy.Contractors.list()

Retrieving a Contractor

resource = ten99policy.Contractors.retrieve("cn_9TPKz6B9so")  # Replace with an existing contractor ID

Deleting a Contractor

resource = ten99policy.Contractors.delete("cn_tS3wR3UQ5q")  # Replace with an existing contractor ID

Insurance Application Sessions

Creating an Insurance Application Session

resource = ten99policy.InsuranceApplicationSessions.create(
    quote="qt_yVEnbNaWh6",
    success_url="http://example.com/success",
    cancel_url="http://example.com/cancel",
)

Updating a Session

resource = ten99policy.InsuranceApplicationSessions.modify(
    "ias_01HZSB299T5D9SCNY98T8P10KC",  # Replace with an existing session ID
    success_url="http://example.com/success",
    cancel_url="http://example.com/cancel",
)

Fetching the List of Insurance Application Sessions

resource = ten99policy.InsuranceApplicationSessions.list()

Retrieving an Insurance Application Session

resource = ten99policy.InsuranceApplicationSessions.retrieve(
    "ias_01HZSB299T5D9SCNY98T8P10KC"  # Replace with an existing session ID
)

Jobs

Creating a Job

resource = 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",
)

Updating a Job

resource = ten99policy.Jobs.modify(
    "jb_C9Z2DmfHSF",  # Replace with an existing job ID
    name="Mechanic",
)

Fetching the List of Jobs

resource = ten99policy.Jobs.list()

Retrieving a Job

resource = ten99policy.Jobs.retrieve("jb_C9Z2DmfHSF")  # Replace with an existing job ID

Deleting a Job

resource = ten99policy.Jobs.delete("jb_C9Z2DmfHSF")  # Replace with an existing job ID

Policies

Creating a Policy

resource = ten99policy.Policies.create(
    quote_id="qt_UPmEfS6nNK",
    is_active=True,
)

Updating a Policy

resource = ten99policy.Policies.modify(
    "po_C9Z2DmfHSF",  # Replace with an existing policy ID
    is_active=False,
)

Fetching the List of Policies

resource = ten99policy.Policies.list()

Retrieving a Policy

resource = ten99policy.Policies.retrieve("po_C9Z2DmfHSF")  # Replace with an existing policy ID

Deleting a Policy

resource = ten99policy.Policies.delete("po_C9Z2DmfHSF")  # Replace with an existing policy ID

Quotes

Creating a Quote

resource = ten99policy.Quotes.create(
    job="jb_jsb9KEcTpc",
    contractor="cn_yJBbMeq9QA",
    coverage_type=["general", "workers-comp"],
)

Updating a Quote

resource = ten99policy.Quotes.modify(
    "qt_C9Z2DmfHSF",  # Replace with an existing quote ID
    name="Mechanic",
)

Fetching the List of Quotes

resource = ten99policy.Quotes.list()

Retrieving a Quote

resource = ten99policy.Quotes.retrieve("qt_C9Z2DmfHSF")  # Replace with an existing quote ID

Assignments

Creating an Assignment

resource = ten99policy.Assignments.create(
    contractor="cn_kjLKMtApTv",
    job="jb_D6ZSaoa2MV",
)

Updating an Assignment

resource = ten99policy.Assignments.modify(
    "as_sF3yUB3BYY",  # Replace with an existing assignment ID
    contractor="cn_kjLKMtApTv",
)

Fetching the List of Assignments

resource = ten99policy.Assignments.list()

Retrieving an Assignment

resource = ten99policy.Assignments.retrieve("as_sF3yUB3BYY")  # Replace with an existing assignment ID

Deleting an Assignment

resource = ten99policy.Assignments.delete("as_xyz")  # Replace with an existing assignment ID

Error Handling

The ten99policy library raises exceptions for API errors. Use try-except blocks to handle potential errors gracefully.

try:
    resource = ten99policy.Entities.create(
        name="New Entity",
        # ... other parameters
    )
except ten99policy.error.APIError as e:
    print(f"API Error: {e}")
except ten99policy.error.AuthenticationError as e:
    print(f"Authentication Error: {e}")
except Exception as e:
    print(f"An unexpected error occurred: {e}")

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 support@1099policy.com.

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ten99policy-1.1.7.tar.gz (51.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ten99policy-1.1.7-py2.py3-none-any.whl (53.2 kB view details)

Uploaded Python 2Python 3

File details

Details for the file ten99policy-1.1.7.tar.gz.

File metadata

  • Download URL: ten99policy-1.1.7.tar.gz
  • Upload date:
  • Size: 51.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.18

File hashes

Hashes for ten99policy-1.1.7.tar.gz
Algorithm Hash digest
SHA256 0def2afafb4b16d91519ab9935c21ed776f17b68b3d921acd140cfb0c507fccf
MD5 536b42500273057a08c9adaa4de48419
BLAKE2b-256 f59a915949ec31e65fd5410321504d54747e6c91dbd2ae2d4fb94bae6950b8b0

See more details on using hashes here.

File details

Details for the file ten99policy-1.1.7-py2.py3-none-any.whl.

File metadata

  • Download URL: ten99policy-1.1.7-py2.py3-none-any.whl
  • Upload date:
  • Size: 53.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.18

File hashes

Hashes for ten99policy-1.1.7-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 c8eea2e82911c18dc3569272ce0ad4781d8d78c123b16fe04fc9ad3d067782ca
MD5 eb63e99d19c75a4705fb0e8a484e5759
BLAKE2b-256 d34333327eaf788656165be83ee0217cf724d5def4db4b626c2241b51ff7a484

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page