def sync_appointments(): """Sync all appointments """ endpoint = 'appointments' bookmark_property = 'updated_at' filters = ['past', 'upcoming'] singer.write_schema(endpoint, tap_utils.load_schema(endpoint), ["id"], bookmark_properties=[bookmark_property]) for fil in filters: sync_appointments_by_filter(bookmark_property, fil)
def sync_leads(): """ Sync leads data and call out to per-filter sync """ bookmark_property = 'updated_at' endpoint = 'leads' singer.write_schema(endpoint, tap_utils.load_schema(endpoint), ["id"], bookmark_properties=[bookmark_property]) filters = get_filters(endpoint) for fil in filters: sync_leads_by_filter(bookmark_property, fil)
def sync_deals(): """ Sync deals for every view """ bookmark_property = 'updated_at' endpoint = 'deals' singer.write_schema(endpoint, tap_utils.load_schema(endpoint), ["id"], bookmark_properties=[bookmark_property]) filters = get_filters(endpoint) for fil in filters: sync_deals_by_filter(bookmark_property, fil)
def sync_tasks(): """ Sync all task based on filters """ endpoint = 'tasks' bookmark_property = 'updated_at' singer.write_schema(endpoint, tap_utils.load_schema(endpoint), ["id"], bookmark_properties=[bookmark_property]) # Hardcoded task filters filters = ['open', 'due today', 'due tomorrow', 'overdue', 'completed'] for fil in filters: sync_tasks_by_filter(bookmark_property, fil)
def sync_current_endpoint_data_stream(endpoint): """ Sync current data resource. Standard schema is kept as columns, Custom fields are saved as JSON content :return: """ bookmark_property = 'updated_at' schema = tap_utils.load_schema(endpoint) singer.write_schema(endpoint, schema, ["id"], bookmark_properties=[bookmark_property]) filters = get_filters(endpoint) for fil in filters: sync_current_endpoint_by_filter(bookmark_property, fil)
def sync_contacts(): """ Sync Sales Accounts Data, Standard schema is kept as columns, Custom fields are saved as JSON content """ bookmark_property = 'updated_at' endpoint = 'contacts' schema = tap_utils.load_schema(endpoint) singer.write_schema(endpoint, schema, ["id"], bookmark_properties=[bookmark_property]) filters = get_filters(endpoint) for fil in filters: sync_contacts_by_filter(bookmark_property, fil)
def sync_sales_activities(): """Sync all sales activities, call out to individual filters """ bookmark_property = 'updated_at' endpoint = 'sales_activities' state_entity = endpoint start = get_start(state_entity) singer.write_schema(endpoint, tap_utils.load_schema(endpoint), ["id"], bookmark_properties=[bookmark_property]) sales = gen_request(get_url(endpoint)) for sale in sales: if sale[bookmark_property] >= start: LOGGER.info("Sale {}: Syncing details".format(sale['id'])) singer.write_record("sale_activities", sale, time_extracted=singer.utils.now())
def sync_owners_all(): """ Sync Owners from contacts,deals, leads, accounts, Custom fields are saved as JSON content """ bookmark_property = 'id' endpoint = 'owners' schema = tap_utils.load_schema('owners') singer.write_schema(endpoint, schema, ["id"], bookmark_properties=[bookmark_property]) for owner in owners: state_entity = "owner" + "_" + str(owner['id']) if state_entity not in STATE: LOGGER.info("Owner {}: Syncing details".format(owner['id'])) singer.write_record("owners", owner, time_extracted=singer.utils.now()) tap_utils.update_state(STATE, state_entity, owner['id']) singer.write_state(STATE)