Python bindings for the ten99policy API
Project description
ten99policy Python Library
A Python library for interacting with the 1099Policy API.
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
- Configuration
- Usage
- Error Handling
- Additional Resources
- Support
- License
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
- 1099Policy Website: https://www.1099policy.com
- API Documentation: https://www.1099policy.com/docs
- Developer Guide: https://docs.1099policy.com
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ten99policy-1.1.8.tar.gz.
File metadata
- Download URL: ten99policy-1.1.8.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee24157929dac7acafba9f0481e1c5edfd124f95a90c2e729b6f4fee3f827234
|
|
| MD5 |
48e436ff8090eddf5b3b254d3259315a
|
|
| BLAKE2b-256 |
bc8c1b80a7c4bd209b374ea84e38299fefc2fe27488c2fb4d6627c24a29a494d
|
File details
Details for the file ten99policy-1.1.8-py2.py3-none-any.whl.
File metadata
- Download URL: ten99policy-1.1.8-py2.py3-none-any.whl
- Upload date:
- Size: 53.3 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
823d6fab5e41e9a01048ead789e0309f7f05d913326915da3cdc54967adb1fd5
|
|
| MD5 |
9d86a9fade6150ac8cc7e4b6f0f91243
|
|
| BLAKE2b-256 |
b20abe3a3324c98e2d6d3f27863e655d1f41271ce2c49f4274e3f7d5d96e4396
|