Example #1
0
 def get(self, request, account_id=None, call_sid=None):
     ctm_api = CTMAPI()
     audio_response = ctm_api.get_call_audio(account_id, call_sid, request)
     size = len(audio_response.content)
     response = HttpResponse(audio_response.content)
     response['Content-Type'] = 'audio/x-wav'
     response['Content-Length'] = size
     response['Accept-Ranges'] = 'bytes'
     response['Content-Range'] = audio_response.headers.get('Content-Range')
     return response
Example #2
0
 def handle(self, *args, **options):
     ctm_api = CTMAPI()
     response = ctm_api.get_all_accounts()
     # business = []
     # accounts = []
     for account_data in response.get('accounts'):
         business, created = Business.objects.get_or_create(
             name=account_data.get('name'))
         account, created = Account.objects.get_or_create(
             call_metrics_id=account_data.get('id'),
             defaults={
                 'name': account_data.get('name'),
                 'business': business
             })
Example #3
0
    def handle(self, *args, **options):
        ctm_api = CTMAPI()
        accounts = Account.objects.all()

        for account in accounts:

            users_data = ctm_api.get_all_users(account.call_metrics_id)

            for user_data in users_data:

                first_name, last_name = [
                    user_data.get('first_name'),
                    user_data.get('last_name')
                ]
                username = Profile.generate_username(first_name, last_name)
                email = user_data.get('email')
                user, created = User.objects.get_or_create(email=email,
                                                           defaults={
                                                               'first_name':
                                                               first_name,
                                                               'last_name':
                                                               last_name,
                                                               'username':
                                                               username
                                                           })

                if not created:
                    continue

                Token.objects.get_or_create(user=user)

                user.set_password('%spassword' % email)
                user.save()

                role = user_data.get('role')
                profile = Profile.objects.create(user=user)

                Membership.objects.create(profile=profile,
                                          role=role,
                                          account=account)
Example #4
0
 def get(self, request, account_id=None):
     ctm_api = CTMAPI()
     response = ctm_api.get_tags(account_id)
     return Response(response)
Example #5
0
 def post(self, request, account_id=None, call_id=None):
     data = request.data
     ctm_api = CTMAPI()
     response = ctm_api.update_call_sale(account_id, call_id, data)
     return Response(response)
Example #6
0
 def get(self, request, account_id=None):
     page = request.GET.get('page', 1)
     ctm_api = CTMAPI()
     response = ctm_api.get_calls(account_id, page, request.GET)
     return Response(response)
Example #7
0
 def get(self, request, account_id=None):
     ctm_api = CTMAPI()
     queryparams = request.GET
     response = ctm_api.get_calls_report(account_id, queryparams)
     return Response(response)