Beispiel #1
0
from infusionsoft.library import Infusionsoft

infusionsoft = Infusionsoft('Infusionsoft Account Name', 'API Key Goes Here')

# Example 1: Add Contact
#----------------------------------------------------------------------------------------
contact = {'FirstName' : 'John', 'LastName' : 'Doe', 'Email' : '*****@*****.**'}
print infusionsoft.ContactService('add', contact)

# Example 2: Merge two duplicate contacts
#----------------------------------------------------------------------------------------
contactId = 56
duplicateContactId = 57
print infusionsoft.ContactService('merge', contactId, duplicateContactId)

# Example 3: Query a contact using data service
#----------------------------------------------------------------------------------------
table = 'Contact'
returnFields = ['Id', 'FirstName']
query = {'FirstName' : 'John'}
limit = 10
page = 0
print infusionsoft.DataService('query', table, limit, page, query, returnFields)

# Example 4: Return a products inventory using product service
#----------------------------------------------------------------------------------------
productId = 1
print infusionsoft.ProductService('getInventory', productId)

# Example 5: Charge an invoice using the invoice service
#----------------------------------------------------------------------------------------
        ifs.DataService('update', 'ContactAction', action.get('Id'),
                        {'ContactId': orig_id})

    # Reassign opportunities
    opps = get_table(ifs, 'Lead', query={'ContactID': dupe_id}, fields=['Id'])
    for opp in opps:
        ifs.DataService('update', 'Lead', opp.get('Id'),
                        {'ContactID': orig_id})

    # Reapply tags
    tags = get_table(ifs,
                     'ContactGroupAssign',
                     query={'ContactId': dupe_id},
                     fields=['GroupId'])
    for tag in tags:
        ifs.ContactService('addToGroup', orig_id, tag.get('GroupId'))

    # Update company fields
    fields = {}
    for field in company_fields:
        if orig_comp.get(field) or dupe_comp.get(field):
            fields[field] = orig_comp.get(field) or dupe_comp.get(field)
    ifs.DataService('update', 'Company', orig_id, fields)

    # Delete dupe company
    ifs.DataService('delete', 'Company', dupe_id)
    print("{} deleted and merged with {}.".format(dupe_id, orig_id))
    deleted_companies += [dupe_id]

print(datetime.datetime.now() - start)
Beispiel #3
0
                values=','.join(df['Industry'].dropna().unique())
            )['Name']
            APIMAPPING['Salesperson'] = create_custom_field(
                ifs,
                'Salesperson',
                fieldtype='Text',
            )['Name']
            APIMAPPING['Customer_Prospect_Dormant'] = create_custom_field(
                ifs,
                'Customer/Prospect/Dormant',
                fieldtype='Select',
                values=','.join(df['Customer_Prospect_Dormant'].dropna().unique())
            )['Name']
            APIMAPPING['Service of Interest'] = create_custom_field(
                ifs,
                'Product/Solution of Interest',
                fieldtype='Select',
                values=','.join(df['Service of Interest'].dropna().unique())
            )['Name']

            df.rename(APIMAPPING,axis='columns',inplace=True)
            for contact in df.to_dict('records'):
                resp = ifs.ContactService(
                    'add',
                    contact,
                )
                if contact.get('Email'):
                    ifs.APIEmailService('optIn',contact['Email'],'FranServ Import')
                if isinstance(resp, tuple):
                    raise ValueError(
                        f'InfusionsoftAPIError: {resp}')