Example #1
0
def sign_in():
    # log signin
    data = request.get_json()
    
    if data:
        store_event('sign_in', data)
    return 'sign_in success'
Example #2
0
def sign_in():
    # log signin
    data = request.get_json()

    if data:
        store_event('sign_in', data)
    return 'sign_in success'
Example #3
0
def connect_callee():
    data = request.get_json()
    callee, phone = get_callee()
    if os.environ.get('PRODUCTION') is None:
        phone = config.get('TEST_CALLEE')
    calls.send_signal(data['sessionId'], phone)
    
    event_data = {'caller': data, 'callee': callee, 'phone': phone}
    store_event('connect_callee', event_data)
    return jsonify(callee)
Example #4
0
def connect_callee():
    data = request.get_json()
    callee, phone = get_callee()
    if os.environ.get('PRODUCTION') is None:
        phone = config.get('TEST_CALLEE')
    calls.send_signal(data['sessionId'], phone)

    event_data = {'caller': data, 'callee': callee, 'phone': phone}
    store_event('connect_callee', event_data)
    return jsonify(callee)
Example #5
0
 def outer_fn(*args, **kwargs):
     utc_offset_hours = int(config.get('TIMEZONE_UTC_OFFSET'))
     utc_offset = timedelta(seconds=60*60*utc_offset_hours)
     hour = (datetime.utcnow() + utc_offset).time().hour
     call_time_start = int(config.get('CALL_TIME_START', 9))  # open at 9am by default
     call_time_end = int(config.get('CALL_TIME_END', 21))  # close at 9pm by default
     if hour < call_time_end and hour >= call_time_start:
         return inner_fn(*args, **kwargs)
     try:
         request_data = request.get_json()
     except:
         request_data = {}
     event_data = {
         'path': request.path,
         'endpoint': request.endpoint,
         'request_data': request_data
     }
     store_event('after_hours', event_data)
     return jsonify(error='after_hours')
Example #6
0
def save_call():
    raw_data = request.get_json()
    # check key
    callee_id = raw_data['callee']['id']
    callee_key = raw_data['callee']['key']
    if not check_key(callee_id, callee_key):
        return 'failed'
    source_data = {
        'callee': CALLEES[callee_id],
        'caller': raw_data['caller'],
        'call': raw_data['callInfo'],
    }
    call_data_config = config.get('CALL_DATA_FORM')
    data = {}
    for field_source_name, field_source_values in call_data_config['fields'].iteritems():
        for k,v in field_source_values.iteritems():
            data[k] = source_data[field_source_name].get(v, '')
    url = call_data_config['url']
    requests.post(url, data=data)
    store_event('save_call', {'raw_data': raw_data, 'saved_data': data})
    return 'saved'
Example #7
0
 def outer_fn(*args, **kwargs):
     utc_offset_hours = int(config.get('TIMEZONE_UTC_OFFSET'))
     utc_offset = timedelta(seconds=60 * 60 * utc_offset_hours)
     hour = (datetime.utcnow() + utc_offset).time().hour
     call_time_start = int(config.get('CALL_TIME_START',
                                      9))  # open at 9am by default
     call_time_end = int(config.get('CALL_TIME_END',
                                    21))  # close at 9pm by default
     if hour < call_time_end and hour >= call_time_start:
         return inner_fn(*args, **kwargs)
     try:
         request_data = request.get_json()
     except:
         request_data = {}
     event_data = {
         'path': request.path,
         'endpoint': request.endpoint,
         'request_data': request_data
     }
     store_event('after_hours', event_data)
     return jsonify(error='after_hours')
Example #8
0
def save_call():
    raw_data = request.get_json()
    # check key
    callee_id = raw_data['callee']['id']
    callee_key = raw_data['callee']['key']
    if not check_key(callee_id, callee_key):
        return 'failed'
    source_data = {
        'callee': CALLEES[callee_id],
        'caller': raw_data['caller'],
        'call': raw_data['callInfo'],
    }
    call_data_config = config.get('CALL_DATA_FORM')
    data = {}
    for field_source_name, field_source_values in call_data_config[
            'fields'].iteritems():
        for k, v in field_source_values.iteritems():
            data[k] = source_data[field_source_name].get(v, '')
    url = call_data_config['url']
    requests.post(url, data=data)
    store_event('save_call', {'raw_data': raw_data, 'saved_data': data})
    return 'saved'
Example #9
0
def connect_caller():
    data = request.get_json()
    data['session_id'] = calls.make_call(data['phoneNumber'])
    store_event('connect_caller', data)
    return jsonify(sessionId=data['session_id'])
Example #10
0
def connect_caller():
    data = request.get_json()
    data['session_id'] = calls.make_call(data['phoneNumber'])
    store_event('connect_caller', data)
    return jsonify(sessionId=data['session_id'])