Example #1
0
def get_status(username, password, id):
    """
        Return msg status given by his id
    """
    customer = Customer.get_customer (username, password)
    if customer < 0:
        return [str(FAIL_STATUS), "Customer error, please check your customer id and password"]
    l = SMSHistory.check_id (customer, id)
    if l:
        return [str(l[0]), str(l[1])]
    return [str(NONE_STATUS), "Msg %s not found on system, try it later" % id]
Example #2
0
def get_accounts(username, password):
    """
        Get all accounts for a given user after check him
    """
    customer = Customer.get_customer (username, password)
    if customer < 0:
        return customer

    acc = []
    for i in customer.get_accounts ():
        acc.append (i.name)
    return acc
Example #3
0
def get_channels (username, password):
    """
        Return all channels for this user
    """
    customer = Customer.get_customer (username, password)
    if customer < 0:
        return customer

    channels = []
    for i in customer.get_channels ():
        channels.append (i.name)
    return channels
Example #4
0
def update_incoming(username, password, last_update, last_id):
    customer = Customer.get_customer (username, password)
    access = Access.objects.filter(capabilities__in = Capabilities.objects.filter(typeSMS = 'Repliable'), account__customer = customer)
    last = datetime.datetime.strptime(last_update, '%d/%m/%Y %H:%M:%S')
    out = []
    for imsg in IncomingMessage.objects.filter(account__access__in = access, receivedDate__gt = last):
        imsg.processedDate = datetime.datetime.now()
        imsg.processed = True
        imsg.save()
        out.append("%s$%s$%s$" % (imsg.mobile, imsg.receivedDate, imsg.body.plainTxt))
    for rmsg in ResponseMessage.objects.filter(message__account__access__in = access, id__gt = last_id):
        out.append("%s$%s$%s$%s" % (rmsg.message.mobile, rmsg.receivedDate, rmsg.body, rmsg.message.id))
    return out