Пример #1
0
def subscribe_to_bill_updates():

    r = twiml.Response()

    bill_id = read_context('bill_id')
    if not bill_id:
        r.redirect(url_for('.bills'))
        return r

    bill = data.get_bill_by_id(bill_id)
    if not bill:
        r.say("No bill was found matching %s" % bill_id)
        r.redirect(url_for('.bills'))
        return r

    if 'from' in g.call:

        params = {
            'phone': g.call['from'],
            'interest_type': 'item',
            'item_type': 'bill',
            'item_id': bill_id,
            'source': 'call_on_congress',
        }

        if data.subscribe_to_bill_updates(**params):
            r.say('You have been subscribed. A confirmation message has been sent to %s.' % " ".join(g.call['from'][1:]))
        else:
            r.say('Sorry, there was an error subscribing you.')

    else:
        r.say('Sorry, we were unable to identify your phone number.')

    r.redirect(url_for('.bills'))
    return str(r)
Пример #2
0
def test_scout():
    r = twiml.Response()
    params = {
        'phone': g.request_params.get('phone', '6173140966'),
        'interest_type': 'item',
        'item_type': 'bill',
        'item_id': g.request_params.get('item_id', 'hr4310-112'),
        'source': 'call_on_congress',
    }
    if data.subscribe_to_bill_updates(**params):
        r.say('You are subscribed. A confirmation message was sent to')
        r.say('%s' % params['phone'])
    else:
        r.say("""We're sorry, there was an error subscribing you.""")

    return str(r)