Coverage for api/proscai/contact.py: 43%
33 statements
« prev ^ index » next coverage.py v6.4.4, created at 2024-01-12 11:16 -0600
« prev ^ index » next coverage.py v6.4.4, created at 2024-01-12 11:16 -0600
1import requests
2import jwt
3import json
4import base64
5from time import sleep
6from apps.local_models.models import JWTToken
7from api.proscai.auth import BaseAPIClient
8from django.conf import settings
9from .errors import send_email, log_error
10from .utils import get_next_clicod
11from django.utils import timezone
12from django.core.exceptions import ValidationError
15PROSCAI_CONN = getattr(settings, "PROSCAI_CONN", None)
20DATA_DICT = {
21 "nombre": None,
22 "cargo": None,
23 "telefono1": None,
24}
28def create_contact(data_dict):
29 print('data dict desde create contact', data_dict)
31 auth_client = BaseAPIClient()
32 token = JWTToken.objects.last()
33 clicod=data_dict.pop('clicod')
34 url = f"https://pas.proscai.com/v1/clientes/{clicod}/contactos/"
35 print(url)
36 data = json.dumps(data_dict, default=str, indent=4)
37 json_data = str(data)
38 headers = {
39 "Authorization": "Bearer {}".format(token.token),
40 "Content-Type": "application/json",
41 "ConexionAuth": PROSCAI_CONN,
42 }
44 try:
45 print('estoy por hacer el post de contactos')
46 r = requests.post(url, data=json_data, headers=headers)
47 print(r.content)
48 except Exception as e:
49 print('ups, tuve un excption en contactos')
50 print(e)
52 if r.ok:
53 return 200