Beispiel #1
0
def create(company_id, contact_id):
    hubspot = create_client()
    association = PublicAssociation(
        _from=PublicObjectId(id=company_id),
        to=PublicObjectId(id=contact_id),
        type=AssociationType.COMPANY_TO_CONTACT,
    )
    batch_input_public_association = BatchInputPublicAssociation(inputs=[association])
    hubspot.crm.associations.batch_api.create(
        ObjectType.COMPANIES,
        ObjectType.CONTACTS,
        batch_input_public_association=batch_input_public_association,
    )
    session[SessionKey.ACTION_PERFORMED] = "created"

    return redirect(url_for("associations.list", company_id=company_id))
Beispiel #2
0
def request_hs_contact_assos(hubspot, hs_id, key):
    time.sleep(0.33)
    res = hubspot.crm.associations.batch_api.read(
        from_object_type=key,
        to_object_type='contact',
        batch_input_public_object_id=BatchInputPublicObjectId(
            inputs=[PublicObjectId(id=hs_id)]))

    return res
Beispiel #3
0
 def extract_ids(data):
     ids = []
     for obj in data:
         ids.append(PublicObjectId(id=obj.id))
     return ids