A Python wrapper for the HubSpot contacts and contact properties API
Project description
# HubbyPy
`HubbyPy` is a wrapper for HubSpot's contact properties and contacts API. It is particularly useful for web applications where you want to sync information about your users with HubSpot.
## Getting Set Up
```python
hs_user_property_manager = UserPropertyManager(
groups=[
{
'name': 'your_org',
'displayName': 'Your API Data'
}
]
)
hubspot = HubSpot(
api_key='add your key here',
user_property_manager=hs_user_property_manager
)
```
## Accessor Properties
```python
hs_user_property_manager.add_prop(
AccessorProperty(
name='email',
native_type='varchar',
accessor='email',
built_in=True
)
)
hs_user_property_manager.add_prop(
AccessorProperty(
name='your_org_company_id',
label='Your Company: Account id',
group_name='your_org',
native_type='varchar',
accessor='company.id'
)
)
hs_user_property_manager.add_prop(
AccessorProperty(
name='your_org_current_period_end',
label='Your Company: Subscription End',
group_name='your_org',
native_type='datetime',
accessor='company.stripe_customer.current_subscription.current_period_end'
)
)
```
## Function Properties
```python
hs_user_property_manager.add_prop(
FunctionProperty(
name='your_org_last_sync',
label='Company: Last Sync',
group_name='your_org',
native_type='datetime',
func=timezone.now,
send_user=False
)
)
def get_user_lifecycle_stage(user):
try:
if user.company and user.company.stripe_customer.current_subscription.is_trialing:
return 'opportunity'
if user.company and user.company.stripe_customer.current_subscription.status == 'active':
return 'customer'
except AttributeError as err:
logger.error('[HUBSPOT] could not get subscription, error: {}'.format(err))
return 'lead'
hs_user_property_manager.add_prop(
FunctionProperty(
name='lifecyclestage',
native_type='varchar',
func=get_user_lifecycle_stage,
send_user=True,
built_in=True
)
)
```
## Constant Properties
```python
# Constant Properties
hs_user_property_manager.add_prop(
ConstantProperty(
name='your_org_created_by_you',
label='Your Company: Our App Created',
group_name='your_org',
native_type='bool',
value=True
)
)
```
`HubbyPy` is a wrapper for HubSpot's contact properties and contacts API. It is particularly useful for web applications where you want to sync information about your users with HubSpot.
## Getting Set Up
```python
hs_user_property_manager = UserPropertyManager(
groups=[
{
'name': 'your_org',
'displayName': 'Your API Data'
}
]
)
hubspot = HubSpot(
api_key='add your key here',
user_property_manager=hs_user_property_manager
)
```
## Accessor Properties
```python
hs_user_property_manager.add_prop(
AccessorProperty(
name='email',
native_type='varchar',
accessor='email',
built_in=True
)
)
hs_user_property_manager.add_prop(
AccessorProperty(
name='your_org_company_id',
label='Your Company: Account id',
group_name='your_org',
native_type='varchar',
accessor='company.id'
)
)
hs_user_property_manager.add_prop(
AccessorProperty(
name='your_org_current_period_end',
label='Your Company: Subscription End',
group_name='your_org',
native_type='datetime',
accessor='company.stripe_customer.current_subscription.current_period_end'
)
)
```
## Function Properties
```python
hs_user_property_manager.add_prop(
FunctionProperty(
name='your_org_last_sync',
label='Company: Last Sync',
group_name='your_org',
native_type='datetime',
func=timezone.now,
send_user=False
)
)
def get_user_lifecycle_stage(user):
try:
if user.company and user.company.stripe_customer.current_subscription.is_trialing:
return 'opportunity'
if user.company and user.company.stripe_customer.current_subscription.status == 'active':
return 'customer'
except AttributeError as err:
logger.error('[HUBSPOT] could not get subscription, error: {}'.format(err))
return 'lead'
hs_user_property_manager.add_prop(
FunctionProperty(
name='lifecyclestage',
native_type='varchar',
func=get_user_lifecycle_stage,
send_user=True,
built_in=True
)
)
```
## Constant Properties
```python
# Constant Properties
hs_user_property_manager.add_prop(
ConstantProperty(
name='your_org_created_by_you',
label='Your Company: Our App Created',
group_name='your_org',
native_type='bool',
value=True
)
)
```
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
hubbypy-0.1.8.tar.gz
(6.5 kB
view details)
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
hubbypy-0.1.8-py3-none-any.whl
(14.4 kB
view details)
File details
Details for the file hubbypy-0.1.8.tar.gz.
File metadata
- Download URL: hubbypy-0.1.8.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
922783a9da895bb9577319aeee6add24af002625850dc65977938e3732a93947
|
|
| MD5 |
028ad78b21c76fa78c9edb49bb84a307
|
|
| BLAKE2b-256 |
3f045432e239fd70af3beb365a881a35024a3e1f61145a53ddb76af0d632188f
|
File details
Details for the file hubbypy-0.1.8-py3-none-any.whl.
File metadata
- Download URL: hubbypy-0.1.8-py3-none-any.whl
- Upload date:
- Size: 14.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
696e99bdea997266b1c209bfbb16a99c57363cdaf9b682525c578b911fe77112
|
|
| MD5 |
4ed498898fa03aa4bada1f331b7f4ee8
|
|
| BLAKE2b-256 |
1502681ef6874c42f97105cd1b47aa35beb4d6b29f321ed84367ffd6b80352a1
|