def process_stream(state, message): json_message = json.loads(message.value) LOGGER.info("Message: " + json.dumps(json_message)) stream_id = inflection.pluralize( inflection.underscore(json_message['object'])) stream_state = state.get(stream_id, {}) if stream_state.get('last_synced', '') > json_message['time']: LOGGER.info("Skipping message due to previous timestamp: " + json_message['time']) return False stream = ordway_tap.configs.catalog.get_stream(stream_id) # Make sure stream is selected for record to print if stream and stream.is_selected(): map_method = map_methods[stream_id] if map_method['multi']: for record in map_method['method'](json_message['record']): print_record(stream_id, record) else: print_record(stream_id, map_method['method'](json_message['record'])) # Write the state message stream_state['last_synced'] = json_message['time'] state[stream_id] = stream_state singer.write_state(state)
def sync(timestamp): for payment_response in get_index_data('/api/v1/payments', params={'updated_date>': timestamp}): print_record('payments', map_payment_response(payment_response))
def sync(timestamp): for refund_response in get_index_data('/api/v1/refunds', params={'updated_date>': timestamp}): print_record('refunds', map_refund_response(refund_response))
def sync(timestamp): for customer_response in get_index_data( '/api/v1/customers', params={'updated_date>': timestamp}): print_record('customers', map_customer_response(customer_response))
def sync(timestamp): for rs_response in get_index_data('/api/v1/revenue_schedules', params={'updated_date>': timestamp}): print_record('revenue_schedules', map_rs_response(rs_response))
def sync(timestamp): for credit_response in get_index_data('/api/v1/credits', params={'updated_date>': timestamp}): print_record('credits', map_credit_response(credit_response))
def sync(timestamp): for invoice_response in get_index_data('/api/v1/invoices', params={'updated_date>': timestamp}): for invoice in map_invoice_response(invoice_response): print_record('invoices', invoice)
def sync(timestamp): for subscription_response in get_index_data( '/api/v1/subscriptions', params={'updated_date>': timestamp}): for subscription_with_plan in map_subscription_response( subscription_response): print_record('subscriptions', subscription_with_plan)
def sync(timestamp): for bs_response in get_index_data('/api/v1/billing_schedules', params={'updated_date>': timestamp}): print_record('billing_schedules', map_bs_response(bs_response))