def bootstrap_smsgh_gateway(apps=None):
    default_currency, _ = (apps.get_model("accounting", "Currency") if apps else Currency).objects.get_or_create(
        code=settings.DEFAULT_CURRENCY
    )
    sms_gateway_fee_class = apps.get_model("smsbillables", "SmsGatewayFee") if apps else SmsGatewayFee
    sms_gateway_fee_criteria_class = (
        apps.get_model("smsbillables", "SmsGatewayFeeCriteria") if apps else SmsGatewayFeeCriteria
    )

    SmsGatewayFee.create_new(
        SMSGHBackend.get_api_id(),
        INCOMING,
        Decimal("0.0"),
        currency=default_currency,
        fee_class=sms_gateway_fee_class,
        criteria_class=sms_gateway_fee_criteria_class,
    )

    SmsGatewayFee.create_new(
        SMSGHBackend.get_api_id(),
        OUTGOING,
        Decimal("0.0"),
        currency=default_currency,
        fee_class=sms_gateway_fee_class,
        criteria_class=sms_gateway_fee_criteria_class,
    )

    logger.info("Updated SMSGH gateway fees.")
示例#2
0
    def get(self, request, api_key, *args, **kwargs):
        msg = request.GET.get('msg', None)
        snr = request.GET.get('snr', None)
        # We don't have a place to put this right now, but leaving it here
        # so we remember the parameter name in case we need it later
        to = request.GET.get('to', None)

        if not msg or not snr:
            return HttpResponseBadRequest("ERROR: Missing msg or snr")

        incoming(snr, msg, SMSGHBackend.get_api_id())
        return HttpResponse("")