Esempio n. 1
0
def request_callback(request):
	"""
	Request the callback
	:param request: HTTP request
	:return: HttpResponse instance
	"""
	from_number = CommonService.reduce_number(request.GET.get('cbFromNumber') or request.user.userprofile.sip)
	to_number = CommonService.reduce_number(request.GET.get('cbToNumber'))

	result = PBXDataService.request_callback(request.user, from_number, to_number)
	if result:
		return HttpResponse(status=200, content=result)

	return HttpResponse(status=500)
Esempio n. 2
0
def request_callback(request):
    """
	Request the callback
	:param request: HTTP request
	:return: HttpResponse instance
	"""
    from_number = CommonService.reduce_number(
        request.GET.get('cbFromNumber') or request.user.userprofile.sip)
    to_number = CommonService.reduce_number(request.GET.get('cbToNumber'))

    result = PBXDataService.request_callback(request.user, from_number,
                                             to_number)
    if result:
        return HttpResponse(status=200, content=result)

    return HttpResponse(status=500)
Esempio n. 3
0
def get_call_cost(request):
	"""
	Request to the api to get call cost by target phone number
	:param request: HTTP request
	:return: HttpResponse Instance
	"""
	to = request.GET.get('n')
	if not to:
		return HttpResponse(status=400)

	if len(to) < 6:
		return JsonResponse({'phone': to, 'notAvalible': True})

	result = PBXDataService.get_call_cost(request.user, CommonService.reduce_number(to))
	if result:
		result['phone'] = to
		return JsonResponse(result)

	return HttpResponse(status=500)
Esempio n. 4
0
def get_call_cost(request):
    """
	Request to the api to get call cost by target phone number
	:param request: HTTP request
	:return: HttpResponse Instance
	"""
    to = request.GET.get('n')
    if not to:
        return HttpResponse(status=400)

    if len(to) < 6:
        return JsonResponse({'phone': to, 'notAvalible': True})

    result = PBXDataService.get_call_cost(request.user,
                                          CommonService.reduce_number(to))
    if result:
        result['phone'] = to
        return JsonResponse(result)

    return HttpResponse(status=500)