A Python library for interacting with the 1099Policy API.
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.
- Installation
- Configuration
- Usage
- Error Handling
- Additional Resources
- Support
- License
Install the package using pip
:
pip install ten99policy
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'
).
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"],
)
resource = ten99policy.Entities.modify(
"en_C9Z2DmfHSF", # Replace with an existing entity ID
name="California Roll",
)
resource = ten99policy.Entities.list()
resource = ten99policy.Entities.retrieve("en_BUcNa8jMrq") # Replace with an existing entity ID
resource = ten99policy.Entities.delete("en_C9Z2DmfHSF") # Replace with an existing entity ID
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",
},
)
resource = ten99policy.Contractors.modify(
"cn_tS3wR3UQ5q", # Replace with an existing contractor ID
email="john.doe@gmail.com",
first_name="George",
)
resource = ten99policy.Contractors.list()
resource = ten99policy.Contractors.retrieve("cn_9TPKz6B9so") # Replace with an existing contractor ID
resource = ten99policy.Contractors.delete("cn_tS3wR3UQ5q") # Replace with an existing contractor ID
resource = ten99policy.InsuranceApplicationSessions.create(
quote="qt_yVEnbNaWh6",
success_url="http://example.com/success",
cancel_url="http://example.com/cancel",
)
resource = ten99policy.InsuranceApplicationSessions.modify(
"ias_01HZSB299T5D9SCNY98T8P10KC", # Replace with an existing session ID
success_url="http://example.com/success",
cancel_url="http://example.com/cancel",
)
resource = ten99policy.InsuranceApplicationSessions.list()
resource = ten99policy.InsuranceApplicationSessions.retrieve(
"ias_01HZSB299T5D9SCNY98T8P10KC" # Replace with an existing session ID
)
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",
)
resource = ten99policy.Jobs.modify(
"jb_C9Z2DmfHSF", # Replace with an existing job ID
name="Mechanic",
)
resource = ten99policy.Jobs.list()
resource = ten99policy.Jobs.retrieve("jb_C9Z2DmfHSF") # Replace with an existing job ID
resource = ten99policy.Jobs.delete("jb_C9Z2DmfHSF") # Replace with an existing job ID
resource = ten99policy.Policies.create(
quote_id="qt_UPmEfS6nNK",
is_active=True,
)
resource = ten99policy.Policies.modify(
"po_C9Z2DmfHSF", # Replace with an existing policy ID
is_active=False,
)
resource = ten99policy.Policies.list()
resource = ten99policy.Policies.retrieve("po_C9Z2DmfHSF") # Replace with an existing policy ID
resource = ten99policy.Policies.delete("po_C9Z2DmfHSF") # Replace with an existing policy ID
resource = ten99policy.Quotes.create(
job="jb_jsb9KEcTpc",
contractor="cn_yJBbMeq9QA",
coverage_type=["general", "workers-comp"],
)
resource = ten99policy.Quotes.modify(
"qt_C9Z2DmfHSF", # Replace with an existing quote ID
name="Mechanic",
)
resource = ten99policy.Quotes.list()
resource = ten99policy.Quotes.retrieve("qt_C9Z2DmfHSF") # Replace with an existing quote ID
resource = ten99policy.Assignments.create(
contractor="cn_kjLKMtApTv",
job="jb_D6ZSaoa2MV",
)
resource = ten99policy.Assignments.modify(
"as_sF3yUB3BYY", # Replace with an existing assignment ID
contractor="cn_kjLKMtApTv",
)
resource = ten99policy.Assignments.list()
resource = ten99policy.Assignments.retrieve("as_sF3yUB3BYY") # Replace with an existing assignment ID
resource = ten99policy.Assignments.delete("as_xyz") # Replace with an existing assignment ID
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}")
- 1099Policy Website: https://www.1099policy.com
- API Documentation: https://www.1099policy.com/docs
- Developer Guide: https://docs.1099policy.com
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.
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.