Example #1
0
def send_sms(username, password, account, phoneNumber, text, activationDate = None):
    """
        Send a text msg to a phone over an account given
    """
    try:
        account = Customer.check_customer_and_credit(username, password, account)
    except OutOfCredit:
        return ACCOUNT_NO_CREDIT 
    if account < 0:
        return account
    if not activationDate:
        activationDate = datetime.datetime.now()
    phoneNumber = check_mobile(phoneNumber)
    if phoneNumber < 0:
        return phoneNumber
    return Message.create_one(text, phoneNumber, activationDate, account)
Example #2
0
def send_sms_many(username, password, account, phoneList, text, activationDate = None):
    """
        Send a text msg to a many phones over an account given
    """
    try:
        account = Customer.check_customer_and_credit (username, password, account, len(phoneList))
    except OutOfCredit:
        return [ACCOUNT_NO_CREDIT]
    if account < 0:
        return [account]
    activationDate = datetime.datetime.now ()
    idlist = []
    for phone in phoneList:
        if check_mobile(phone) < 0:
            return [-50] # FIXME: cambiar esto por MobileErrorException cuando se implemente
    for phone in phoneList:
        phone = phone.strip()
        idlist.append(Message.create_one (text, phone, activationDate, account))
    return idlist