Commit 27792f80 authored by Luis Acosta's avatar Luis Acosta

version Version 1.0.5

parent 648a3538
.env
venv
__pycache__
import requests import requests
import json import json
class Callcenter: class Callcenter:
def __init__(self,api_key,url): def __init__(self,api_key,url,user_center_id):
self.url=url self.url=url
# Paso 1: Hacer un POST para obtener el token # Paso 1: Hacer un POST para obtener el token
requests.packages.urllib3.disable_warnings() requests.packages.urllib3.disable_warnings()
...@@ -11,7 +11,7 @@ class Callcenter: ...@@ -11,7 +11,7 @@ class Callcenter:
self.token = response.json()["token"] self.token = response.json()["token"]
# Paso 2: Enviar un GET con el token obtenido en el encabezado y obtener la Cookie # Paso 2: Enviar un GET con el token obtenido en el encabezado y obtener la Cookie
self.user_center_id = 42 self.user_center_id = user_center_id
url_center = f"{self.url}/api/centers/select/{self.user_center_id}" url_center = f"{self.url}/api/centers/select/{self.user_center_id}"
headers = {"CCAuthorization": f"Bearer {self.token}"} headers = {"CCAuthorization": f"Bearer {self.token}"}
response = requests.get(url_center, headers=headers, verify=False) response = requests.get(url_center, headers=headers, verify=False)
......
...@@ -17,8 +17,15 @@ db_call_center = os.getenv("DB_NAME_CALL_CENTER") ...@@ -17,8 +17,15 @@ db_call_center = os.getenv("DB_NAME_CALL_CENTER")
#db_name_cdr = os.getenv("DB_NAME_CDR") #db_name_cdr = os.getenv("DB_NAME_CDR")
db_name_hiper_service = os.getenv("DB_NAME_HIPER_SERVICE") db_name_hiper_service = os.getenv("DB_NAME_HIPER_SERVICE")
cc_url = 'https://mxcc-gruposerviandina.hiperpbx.com' #cc_url = 'https://mxcc-gruposerviandina.hiperpbx.com'
api_key = '07j3FHMnDNrIV43A2eB8BlNEDEf1FVXQQtDuNm82jaPANIetnYTiL97QzenOdlbGKEqyd8rtD0HQWtaQ' #cc_url = 'https://mxcc-serviandina-marcimex.hiperpbx.com'
#api_key = '07j3FHMnDNrIV43A2eB8BlNEDEf1FVXQQtDuNm82jaPANIetnYTiL97QzenOdlbGKEqyd8rtD0HQWtaQ'
cc_url = os.getenv("URL_CC")
api_key = os.getenv("API_KEY_CC")
user_center_id = os.getenv("CENTER_ID_CC")
print(timedelta(minutes=int(os.getenv("JWT_ACCESS_TOKEN_EXPIRES",5))))
hm_url ='https://mxme.hiperpbx.com' hm_url ='https://mxme.hiperpbx.com'
hm_api_key ='c4ce8a7f84c01674d573d4df5cf2e410' hm_api_key ='c4ce8a7f84c01674d573d4df5cf2e410'
hm_email ='serviceaccount@serviandina.com' hm_email ='serviceaccount@serviandina.com'
...@@ -152,7 +159,7 @@ def Generate_Campaign(): ...@@ -152,7 +159,7 @@ def Generate_Campaign():
actualizar_campaign = db_cc.actualizar("update campaign set datetime_init = %s, datetime_end = %s, daytime_init = %s, daytime_end = %s, estatus = %s where id = %s ",(f'{str(date_ini_camp)}',f'{str(date_fin_camp)}',f'{str(time_ini_camp)}',f'{str(time_fin_camp)}',f'{camp_status}',f'{camp_id_search}')) actualizar_campaign = db_cc.actualizar("update campaign set datetime_init = %s, datetime_end = %s, daytime_init = %s, daytime_end = %s, estatus = %s where id = %s ",(f'{str(date_ini_camp)}',f'{str(date_fin_camp)}',f'{str(time_ini_camp)}',f'{str(time_fin_camp)}',f'{camp_status}',f'{camp_id_search}'))
#Conectar al CC2 para insertar datos en la la campaña #Conectar al CC2 para insertar datos en la la campaña
callcenter = Callcenter(api_key, cc_url) callcenter = Callcenter(api_key, cc_url, user_center_id)
#id_campaign= 87 #Modificar por el valor ingresado #id_campaign= 87 #Modificar por el valor ingresado
response = callcenter.search_campaing(camp_id_search) response = callcenter.search_campaing(camp_id_search)
data = response.json()['id'] data = response.json()['id']
...@@ -166,7 +173,7 @@ def Generate_Campaign(): ...@@ -166,7 +173,7 @@ def Generate_Campaign():
#return jsonify({"mensaje": f"Camp Ingreso Datos: {camp_data_input} Camp Resultado: {camp_data_search} Comparacion: {result} Resgistros: {payload}"}), 200 #return jsonify({"mensaje": f"Camp Ingreso Datos: {camp_data_input} Camp Resultado: {camp_data_search} Comparacion: {result} Resgistros: {payload}"}), 200
return jsonify({"mensaje": f"Campaing ,ID: {camp_id_search} Name: {camp_name_search} Status: {camp_status_search} Registros Ingresados"}), 200 return jsonify({"mensaje": f"Campaing ,ID: {camp_id_search} Name: {camp_name_search} Status: {camp_status_search} Registros Ingresados"}), 200
else: else:
callcenter = Callcenter(api_key, cc_url) callcenter = Callcenter(api_key, cc_url, user_center_id)
cread_camp=callcenter.created_campaing(camp_name,date_ini_camp,time_ini_camp,date_fin_camp,time_fin_camp,campaign_queue,camp_obsv) cread_camp=callcenter.created_campaing(camp_name,date_ini_camp,time_ini_camp,date_fin_camp,time_fin_camp,campaign_queue,camp_obsv)
#print(cread_camp) #print(cread_camp)
id_camp =json.loads(cread_camp)["id"] id_camp =json.loads(cread_camp)["id"]
...@@ -218,7 +225,8 @@ def Consult_Campaign(): ...@@ -218,7 +225,8 @@ def Consult_Campaign():
campaign_date_ini=request_data["date_in"] campaign_date_ini=request_data["date_in"]
campaign_date_fin=request_data["date_out"] campaign_date_fin=request_data["date_out"]
#Buscar Campaña #Buscar Campaña
callcenter = Callcenter(api_key, cc_url) print(cc_url)
callcenter = Callcenter(api_key, cc_url, user_center_id)
consult_calls=callcenter.consult_campaing(campaign_id,campaign_date_ini,campaign_date_fin) consult_calls=callcenter.consult_campaing(campaign_id,campaign_date_ini,campaign_date_fin)
data_response = json.loads(consult_calls)["hydra:member"] data_response = json.loads(consult_calls)["hydra:member"]
message = {'responce': data_response} message = {'responce': data_response}
......
This diff is collapsed.
...@@ -121,112 +121,67 @@ def validate_keys(data): ...@@ -121,112 +121,67 @@ def validate_keys(data):
def find_name_position(name): def find_name_position(name):
dictionary = { dictionary = {
"2000": "Benenaula Choco Margoth Elizabeth", "2017" : "Paucar Tapia Dennis Andres",
"2001": "Campoverde Samaniego Bryan Andres", "2018" : "Hurtado Tocache Mayra Biviana",
"2002": "Contreras Guillermo Laura Fernanda", "2019" : "Bermeo Cajamarca Tania Marcela ",
"2003": "Cuenca Sanchez Carmen Maria", "2020" : "Sojos Bermeo Lourdes Maricela",
"2004": "Granados Tomala Ileana Gabriela", "2021" : "Robles Guerra Jhoanna Maricela",
"2005": "Guissella Alejandrina Ortega Alvarez", "2022" : "Ortega Leon Maria Daniela",
"2006": "Henry Esteban Urdiales Landy", "2023" : "Peralta Jaramillo Michelle Catalina",
"2007": "Jaramillo Calle Josseline Cristina", "2024" : "Zambrano Santiak Maria Dolores ",
"2008": "Maza Guaman Rosa Salome", "2025" : "Bravo Andrade Willy Luis",
"2009": "Jhon Byron Paula Calle", "2026" : "Barbecho Arias Alba Janneth",
"2010": "Rodriguez Pena Andrea Del Cisne", "2027" : "Calderon Sucuzhanay Eliza Katherine",
"2011": "Santiago Sebastian Carpio Aviles", "2028" : "Jara Caceres Virginia Carolina",
"2012": "Vera Luzuriaga Viviana Carolina", "2030" : "Sanchez Zhagnay Angel Marcelo",
"2013": "Tapia Yunga Jaime Adrian", "2031" : "Gomez Ochoa Cristian Gabriel",
"2014": "Godoy Zambrano Katiusca", "2032" : "Leon Duenas Valeria Estefania ",
"2015": "Alexandra Estefania Villa Torres", "2033" : "Cardenas Torres Madelyne Coraima",
"2016": "Delgado Baque Gabriela Elizabeth", "2034" : "Samaniego Gonzaga Camila Nicole ",
"2017": "Paucar Tapia Dennis Andres", "2035" : "Suarez Bacuilima Andres Santiago",
"2018": "Hurtado Tocache Mayra Biviana", "2037" : "Tapia Penaloza Andreina De Los Angeles",
"2019": "Bermeo Cajamarca Tania Marcela", "2038" : "Flores Lopez Christian Nicolas ",
"2020": "Sojos Bermeo Lourdes Maricela", "2040" : "Faican Vasquez Jennifer Eliana",
"2021": "Robles Guerra Jhoanna Maricela", "2041" : "Villa Torres Joseline Andrea ",
"2022": "Ortega Leon Maria Daniela", "2042" : "Penafiel Rodas Karen Salome ",
"2023": "Peralta Jaramillo Michelle Catalina", "2043" : "Jaramillo Gonzaga Evelin Lizbeth ",
"2024": "Zambrano Santiak Maria Dolores", "2044" : "Gabriela Elizabeth Ochoa Fajardo",
"2025": "Bravo Andrade Willy Luis", "2045" : "Christopher Brian Chang Tapia",
"2026": "Barbecho Arias Alba Janneth", "2046" : "Maria Guadalupe Arias Asmal",
"2027": "Calderon Sucuzhanay Eliza Katherine", "2047" : "Christian Adrian Lopez Durazno",
"2028": "Jara Caceres Virginia Carolina", "2050" : "Matute Segarra Miriam Viviana ",
"2029": "Vintimilla Vasconez Maria Angelica", "2051" : "Arevalo Jara Gabriela Alexandra",
"2030": "Sanchez Zhagnay Angel Marcelo", "2052" : "Araujo Segovia Erika Patricia",
"2031": "Gomez Ochoa Cristian Gabriel", "2053" : "Cabrera Arteaga Andreina Estefania",
"2032": "Leon Duenas Valeria Estefania", "2054" : "Caguana Laime Jhoanna Maribel",
"2033": "Cardenas Torres Madelyne Coraima", "2055" : "Crespo Pizarro Paola Fernanda",
"2034": "Samaniego Gonzaga Camila Nicole", "2056" : "Esparza Ayala Pablo Andres",
"2035": "Suarez Bacuilima Andres Santiago", "2057" : "Espana Marcia",
"2036": "Marin Auquilla Rodrigo Fernando", "2058" : "Mendoza Avila Andres Fabricio",
"2037": "Tapia Penaloza Andreina De Los Angeles", "2059" : "Naula Cardenas Paola Cecibel",
"2038": "Flores Lopez Christian Nicolas", "2060" : "Nieto Guerrero Rolando Estuardo",
"2039": "Sarmiento Verdugo Diana Patricia", "2061" : "Ordonez Plaza Arturo Xavier",
"2040": "Faican Vasquez Jennifer Eliana", "2062" : "Parra Reyes Andres Remigio",
"2041": "Villa Torres Joseline Andrea", "2063" : "Ramon Rodas Katherine Fernanda",
"2042": "Penafiel Rodas Karen Salome", "2064" : "Rodriguez Rodriguez Paul Esteban",
"2043": "Jaramillo Gonzaga Evelin Lizbeth", "2065" : "Romero Calero Stefania Magdalena",
"2044": "Gabriela Elizabeth Ochoa Fajardo", "2066" : "Tenezaca Maza Adriana Nube",
"2045": "Christopher Brian Chang Tapia", "2067" : "Uzhca Gonzalez Jessica Karina",
"2046": "Maria Guadalupe Arias Asmal", "2068" : "Velez Arcentales Jenny Isabel",
"2047": "Christian Adrian Lopez Durazno", "2069" : "Yanez Arevalo Maria Belen",
"2048": "Buncay Dutan Natalia Gabriela", "2070" : "Baculima Bueno Jessica Priscila",
"2049": "Francisco Javier Arevalo Rosas", "2071" : "Bermeo Zuna Diego Alejandro",
"2050": "Matute Segarra Miriam Viviana", "2072" : "Carchi Ordonez Gabriela Elizabeth",
"2051": "Arevalo Jara Gabriela Alexandra", "2073" : "Lata Sinchi Ana Lucia",
"2052": "Araujo Segovia Erika Patricia", "2074" : "Maita Robles John Christian",
"2053": "Cabrera Arteaga Andreina Estefania", "2075" : "Mejia Lojano Gloria Beatriz",
"2054": "Caguana Laime Jhoanna Maribel", "2076" : "Morales Figueroa Miriam Susana",
"2055": "Crespo Pizarro Paola Fernanda", "2077" : "Murillo Pinos Ana Lucia",
"2056": "Esparza Ayala Pablo Andres", "2078" : "Romero Carpio Joseline Lorena",
"2057": "Espana Marcia", "2079" : "Ulloa Vintimilla Hernan Marcelo",
"2058": "Mendoza Avila Andres Fabricio", "2080" : "Valdivieso Aviles Jessica Daniela",
"2059": "Naula Cardenas Paola Cecibel", "2081" : "Vasquez Sari Tatiana Cecibel",
"2060": "Nieto Guerrero Rolando Estuardo", "2082" : "Vivar Rivadeneira Susana Elizabeth"
"2061": "Ordonez Plaza Arturo Xavier",
"2062": "Parra Reyes Andres Remigio",
"2063": "Ramon Rodas Katherine Fernanda",
"2064": "Rodriguez Rodriguez Paul Esteban",
"2065": "Romero Calero Stefania Magdalena",
"2066": "Tenezaca Maza Adriana Nube",
"2067": "Uzhca Gonzalez Jessica Karina",
"2068": "Velez Arcentales Jenny Isabel",
"2069": "Yanez Arevalo Maria Belen",
"2070": "Baculima Bueno Jessica Priscila",
"2071": "Bermeo Zuna Diego Alejandro",
"2072": "Carchi Ordonez Gabriela Elizabeth",
"2073": "Lata Sinchi Ana Lucia",
"2074": "Maita Robles John Christian",
"2075": "Mejia Lojano Gloria Beatriz",
"2076": "Morales Figueroa Miriam Susana",
"2077": "Murillo Pinos Ana Lucia",
"2078": "Romero Carpio Joseline Lorena",
"2079": "Ulloa Vintimilla Hernan Marcelo",
"2080": "Valdivieso Aviles Jessica Daniela",
"2081": "Vasquez Sari Tatiana Cecibel",
"2082": "Vivar Rivadeneira Susana Elizabeth",
"2083": "Barrera Barrera Edgar Lizandro",
"2084": "Gonzalez Gonzalez Wilmer David",
"2085": "Guaman Bazan Blanca Gladys",
"2086": "Guaman Fernandez Mercy Gabriela",
"2087": "Gutierrez Calle Maricela Janeth",
"2088": "Munoz Perez Carmen Gardenia",
"2089": "Piedra Piedra Martha Cecila",
"2090": "Tobar Cruz Alisson Joan",
"2091": "Ulloa Yunga Martha Lucia",
"2092": "Pillajo Vanegas Jorge Luis",
"2093": "Velez Montenegro Nohemy Veronica",
"2094": "Tandazo Hernandez Estefania",
"2095": "Byron Lopez",
"2096": "Greta Andrade",
"2097": "Janeth Mendez",
"2098": "Maria Elena Cardenas",
"2099": "Byron Benavides",
"2100": "Katerine Pauzhi",
"2101": "Andrea Guanuchi",
"2102": "Paul Carpio",
"2103": "Maria Belen Ochoa",
"2104": "Christian Cando",
"2105": "Marcimex Jhon Byron Paula Calle"
} }
for key, value in dictionary.items(): for key, value in dictionary.items():
if value == name: if value == name:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment