Example #1
0
def create_billable_for_sms(msg, backend_api, delay=True, **kwargs):
    try:
        from corehq.apps.sms.api import store_billable
        store_billable.delay(msg)
    except Exception as e:
        logging.error("%s backend contacted, but errors in creating billable for incoming message. Error: %s" %
                      (backend_api, e))
Example #2
0
def create_billable_for_sms(msg, backend_api, delay=True, **kwargs):
    try:
        from corehq.apps.sms.api import store_billable
        store_billable.delay(msg)
    except Exception as e:
        logging.error(
            "%s backend contacted, but errors in creating billable for incoming message. Error: %s"
            % (backend_api, e))
Example #3
0
def handle_successful_processing_attempt(msg):
    utcnow = datetime.utcnow()
    msg.num_processing_attempts += 1
    msg.processed = True
    msg.processed_timestamp = utcnow
    if msg.direction == OUTGOING:
        msg.date = utcnow
    msg.save()
    if msg.direction == OUTGOING:
        store_billable.delay(msg)
Example #4
0
def handle_successful_processing_attempt(msg):
    utcnow = datetime.utcnow()
    msg.num_processing_attempts += 1
    msg.processed = True
    msg.processed_timestamp = utcnow
    if msg.direction == OUTGOING:
        msg.date = utcnow
    msg.save()
    if msg.direction == OUTGOING:
        store_billable.delay(msg)
Example #5
0
def create_billable_for_sms(msg, backend_api, delay=True, **kwargs):
    try:
        from hqbilling.tasks import bill_client_for_sms
        from hqbilling.models import API_TO_BILLABLE
        msg.save()
        billable_class = API_TO_BILLABLE.get(backend_api)
        if delay:
            bill_client_for_sms.delay(billable_class, msg._id, **kwargs)
        else:
            bill_client_for_sms(billable_class, msg._id, **kwargs)
        from corehq.apps.sms.api import store_billable
        store_billable.delay(msg)
    except Exception as e:
        logging.error("%s backend contacted, but errors in creating billable for incoming message. Error: %s" %
                      (backend_api, e))
Example #6
0
def create_billable_for_sms(msg, backend_api, delay=True, **kwargs):
    try:
        from hqbilling.tasks import bill_client_for_sms
        from hqbilling.models import API_TO_BILLABLE
        msg.save()
        billable_class = API_TO_BILLABLE.get(backend_api)
        if delay:
            bill_client_for_sms.delay(billable_class, msg._id, **kwargs)
        else:
            bill_client_for_sms(billable_class, msg._id, **kwargs)
        from corehq.apps.sms.api import store_billable
        store_billable.delay(msg)
    except Exception as e:
        logging.error(
            "%s backend contacted, but errors in creating billable for incoming message. Error: %s"
            % (backend_api, e))