예제 #1
0
def release_number(id=None, phone_number=None):
    number = Number()
    numbers = Number.find()
    for number in numbers:
        if number == id:
            number.destroy()
            print('{} has been removed from your account'.format(
                number.phone_number))
    if id not in numbers:
        print("not a valid id")
예제 #2
0
def buy_number(name=None, phone_number=None,
               area_code=None, phone_number_type='local'):
    number = Number()
    number.name = name
    number.phone_number = phone_number
    number.area_code = area_code
    number.phone_number_type = phone_number_type
    number.buy()
    return number
예제 #3
0
def find_number():
    numbers = Number.available(country_code='US',
                               number_type='local',
                               area_code='651',
                               in_postal_code=None,
                               in_region=None,
                               limit=5)
    for number in numbers:
        print(number.name, number.phone_number_type, number.phone_number)
예제 #4
0
def list_available_numbers(country_code='US', number_type='local',
                           area_code='913', in_postal_code=None,
                           in_region=None, limit=5):
    numbers = Number.available(
        country_code=country_code,
        number_type=number_type,
        area_code=area_code,
        in_postal_code=in_postal_code,
        in_region=in_region,
        limit=limit)
    for number in numbers:
        yield number
예제 #5
0
def buy_number(phone_number=None, phone_number_type='local'):

    number = Number()
    number.phone_number = phone_number
    number.phone_number_type = phone_number_type
    number.buy()
    print('You bought {}'.format(phone_number))
예제 #6
0
def list_numbers():
    numbers = Number.find()
    for number in numbers:
        print(number.id, number.name, number.phone_number_type,
              number.phone_number)
예제 #7
0
def update_number_name(id, name=None):
    number = Number.find(id)
    number.name = name
    number.save()
    return number
예제 #8
0
def list_associated_numbers():
    numbers = Number.find()
    for number in numbers:
        yield number