def new(company_id): hubspot = create_client() company = hubspot.crm.companies.basic_api.get_by_id(company_id) search_request = PublicObjectSearchRequest( sorts=[ { "propertyName": "createdate", "direction": "DESCENDING", } ] ) search = request.args.get("search") if search: filter = Filter( property_name="email", operator="EQ", value=search, ) search_request.filter_groups = [FilterGroup(filters=[filter])] contacts_page = hubspot.crm.contacts.search_api.do_search( public_object_search_request=search_request ) return render_template( "associations/new.html", search=search, company=company, contacts=contacts_page.results, )
def new(company_id): hubspot = create_client() company = hubspot.crm().companies().basic_api().get_by_id(company_id) search_request = PublicObjectSearchRequest( sorts=[{ 'propertyName': 'createdate', 'direction': 'DESCENDING', }]) search = request.args.get('search') if search: filter = Filter( property_name='email', operator='EQ', value=search, ) search_request.filter_groups = [FilterGroup(filters=[filter])] contacts_page = hubspot.crm().contacts().search_api().do_search( public_object_search_request=search_request) return render_template('associations/new.html', search=search, company=company, contacts=contacts_page.results)
def get_all_previous_campaigns(hubspot, properties, pc_asso_key): filters = [ FilterGroup( [Filter(property_name='campaign_id', operator='HAS_PROPERTY')]) ] search_obj = PublicObjectSearchRequest(filter_groups=filters, properties=properties, limit=100, after=0) data = get_all_hs_results(hubspot, search_obj, 'objects', pc_asso_key) return data
def get_all_companies(hubspot, properties): filters = [ FilterGroup([ Filter(property_name='num_associated_contacts', operator='GTE', value=1) ]) ] search_obj = PublicObjectSearchRequest(filter_groups=filters, properties=properties, limit=100, after=0) data = get_all_hs_results(hubspot, search_obj, 'companies') return data
def list(): hubspot = create_client() search_request = PublicObjectSearchRequest( sorts=[{ "propertyName": "createdate", "direction": "DESCENDING", }]) contacts_page = hubspot.crm.contacts.search_api.do_search( public_object_search_request=search_request) return render_template( "contacts/list.html", contacts=contacts_page.results, action_performed=session.pop(SessionKey.ACTION_PERFORMED, None), )
def list(): hubspot = create_client() search_request = PublicObjectSearchRequest( sorts=[{ 'propertyName': 'createdate', 'direction': 'DESCENDING', }]) contacts_page = hubspot.crm().contacts().search_api().do_search( public_object_search_request=search_request) return render_template( 'contacts/list.html', contacts=contacts_page.results, action_performed=session.pop(SessionKey.ACTION_PERFORMED, None), )
def search_next_contacts_batch(after, limit, search_query): filter_ = Filter(property_name="hs_object_id", operator="GT", value=after) filter_groups = [FilterGroup(filters=[filter_])] public_object_search_request = PublicObjectSearchRequest( query=search_query, limit=limit, filter_groups=filter_groups, sorts=[{ "propertyName": "hs_object_id", "direction": "ASCENDING" }], ) response = hubspot.crm.contacts.search_api.do_search( public_object_search_request=public_object_search_request, ) return response.results
def search(): hubspot = create_client() search = request.args.get("search") filter = Filter( property_name="email", operator="EQ", value=search, ) filter_group = FilterGroup(filters=[filter]) public_object_search_request = PublicObjectSearchRequest( filter_groups=[filter_group], ) contacts_page = hubspot.crm.contacts.search_api.do_search( public_object_search_request=public_object_search_request) return render_template("contacts/list.html", contacts=contacts_page.results, search=search)
def search(): hubspot = create_client() search = request.args.get('search') filter = Filter( property_name='email', operator='EQ', value=search, ) filter_group = FilterGroup(filters=[filter]) public_object_search_request = PublicObjectSearchRequest( filter_groups=[filter_group], ) contacts_page = hubspot.crm().contacts().search_api().do_search( public_object_search_request=public_object_search_request) return render_template('contacts/list.html', contacts=contacts_page.results, search=search)
def get_all_hs_contacts(hubspot, d_teams, properties): data = [] for k, l in d_teams.items(): for team_id in l: # Gte data for targeted team filters = [ FilterGroup([ Filter(property_name='hubspot_team_id', operator='EQ', value=team_id) ]) ] search_obj = PublicObjectSearchRequest(filter_groups=filters, properties=properties, limit=100, after=0) part_data = get_all_hs_results(hubspot, search_obj, 'contacts') # Update data data.extend([{"team": k, **v_} for k_, v_ in part_data.items()]) return pd.DataFrame(data).rename(columns={'hs_object_id': 'id_obj'})