Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
W
Webservice Marcimex
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Luis Acosta
Webservice Marcimex
Commits
61dd0635
Commit
61dd0635
authored
Dec 24, 2024
by
Luis Acosta
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Version 1.0.3
parent
52cfc855
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
31 deletions
+27
-31
app.py
app.py
+27
-31
No files found.
app.py
View file @
61dd0635
...
...
@@ -22,7 +22,7 @@ api_key = '07j3FHMnDNrIV43A2eB8BlNEDEf1FVXQQtDuNm82jaPANIetnYTiL97QzenOdlbGKEqy
app
=
Flask
(
__name__
)
app
=
Flask
(
__name__
)
app
.
config
[
"JWT_SECRET_KEY"
]
=
os
.
getenv
(
"JWT_SECRET_KEY"
,
"clave_por_defecto"
)
app
.
config
[
"JWT_ACCESS_TOKEN_EXPIRES"
]
=
timedelta
(
minutes
=
int
(
os
.
getenv
(
"JWT_ACCESS_TOKEN_EXPIRES"
,
5
)))
app
.
config
[
"JWT_REFRESH_TOKEN_EXPIRES"
]
=
timedelta
(
days
=
int
(
os
.
getenv
(
"JWT_REFRESH_TOKEN_EXPIRES"
,
1
)))
...
...
@@ -35,8 +35,8 @@ fecha_hora = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
#formato_convertir_fecha = "%d/%m/%Y %H:%M:%S"
@
app
.
route
(
'/'
)
def
home
():
return
jsonify
({
"
Mensaje"
:
"Hola"
}),
200
def
home
():
return
jsonify
({
"
error"
:
"Error Access"
}),
401
#return jsonify(resultado)
@
app
.
route
(
'/login'
,
methods
=
[
'POST'
])
...
...
@@ -89,8 +89,8 @@ def Generate_Campaign():
time_fin_camp
=
date_fin_check
[
2
]
if
(
date_ini_result
==
True
&
date_fin_result
==
True
):
#Chequear diferencias de Tiempos entre ambas fechas y horas
date_in
=
str
(
date_ini_camp
)
+
' '
+
str
(
time_ini_camp
)
date_out
=
str
(
date_fin_camp
)
+
' '
+
str
(
time_fin_camp
)
date_in
=
str
(
date_ini_camp
)
+
' '
+
str
(
time_ini_camp
)
date_out
=
str
(
date_fin_camp
)
+
' '
+
str
(
time_fin_camp
)
check_date
=
check_date_in_out
(
date_in
,
date_out
)
if
(
check_date
==
False
):
return
jsonify
({
"mensaje"
:
f
"Error al generar Campaing , {campaign_name}! Fecha y Hora Inicial debe ser menor a Fecha y Hora Final"
}),
401
...
...
@@ -112,13 +112,13 @@ def Generate_Campaign():
return
jsonify
({
"mensaje"
:
f
"Error al generar Campaing , {campaign_name}! Status Invalido de Campaña"
}),
401
#Validar nombres permitidos en observaciones
check_name_obsv
=
limpiar_texto
(
campaign_observ
)
check_name_obsv_result
=
check_name_obsv
[
0
]
check_name_obsv_result
=
check_name_obsv
[
0
]
if
(
check_name_obsv_result
==
True
):
camp_obsv
=
check_name_obsv
[
1
]
else
:
return
jsonify
({
"mensaje"
:
f
"Error al generar Campaing , {campaign_name}! Formato Invalido Observaciones"
}),
401
#Validar Campo Fields campo 0 =phone resto string
check_fields
=
valid_array_fields
(
campaign_fields
)
check_fields
=
valid_array_fields
(
campaign_fields
)
if
(
check_fields
[
0
]
==
True
):
check_field_cant
=
check_fields
[
1
]
check_field_data
=
check_fields
[
2
]
...
...
@@ -156,16 +156,16 @@ def Generate_Campaign():
#Update de registros en la campaña
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
callcenter
=
Callcenter
(
api_key
,
cc_url
)
#id_campaign= 87 #Modificar por el valor ingresado
response
=
callcenter
.
search_campaing
(
camp_id_search
)
data
=
response
.
json
()[
'id'
]
insert
=
callcenter
.
insert_number_campaing
(
data
,
campaign_fields
,
campaign_data
)
print
(
insert
)
#
print(insert)
data_response
=
json
.
loads
(
insert
)[
"status"
]
db_cc
.
cerrar
()
#return jsonify({{payload}}), 200
#return jsonify({"mensaje": f"Camp Ingreso Datos: {camp_data_input} Camp Resultado: {camp_data_search} Comparacion: {result} Resgistros: {payload}"}), 200
...
...
@@ -173,8 +173,8 @@ def Generate_Campaign():
else
:
callcenter
=
Callcenter
(
api_key
,
cc_url
)
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)
return
jsonify
({
"mensaje"
:
f
"No Encontrado Campaing , {camp_name}! Se debe crear una campaña"
}),
401
@
app
.
route
(
'/Consult_Campaign'
,
methods
=
[
'GET'
])
...
...
@@ -186,16 +186,16 @@ def Consult_Campaign():
db
.
cerrar
()
request_data
=
request
.
get_json
()
dataCollection
=
request_data
[
"dataCollection"
]
campaign_id
=
request_data
[
"id_campaign"
]
campaign_id
=
request_data
[
"id_campaign"
]
campaign_date_ini
=
request_data
[
"date_in"
]
campaign_date_fin
=
request_data
[
"date_out"
]
#Buscar Campaña
callcenter
=
Callcenter
(
api_key
,
cc_url
)
consult_calls
=
callcenter
.
consult_campaing
(
campaign_id
,
campaign_date_ini
,
campaign_date_fin
)
data_response
=
json
.
loads
(
consult_calls
)[
"hydra:member"
]
print
(
data_response
)
#
print(data_response)
raw_json
=
data_response
[
0
]
#return jsonify({"mensaje": f"Datos Ingresados , {dataCollection} ;{campaign_id};{campaign_date_ini};{campaign_date_fin}"}), 401
return
jsonify
(
f
"{raw_json}"
,
200
)
...
...
@@ -204,7 +204,7 @@ def Consult_Campaign():
def
token_caducado
(
header
,
payload
):
return
jsonify
({
"error"
:
"El token ha caducado. Inicia sesión nuevamente."
}),
401
}),
401
@
jwt
.
unauthorized_loader
def
token_no_proporcionado
(
callback
):
return
jsonify
({
...
...
@@ -235,16 +235,16 @@ def acceso():
else
:
return
jsonify
({
"message"
:
"DataCollection: Not Found"
}),
401
else
:
return
jsonify
({
"message"
:
"ERROR: Unauthorized"
}),
401
return
jsonify
({
"message"
:
"ERROR: Unauthorized"
}),
401
# if auth == 'Bearer cGJ4OnMzWFRnM0hTQ1Y1R':
# request_data = request.get_json()
# if 'dataCollection' in request_data:
# data_collection = request_data['dataCollection']
#
# data_collection = request_data['dataCollection']
#
# if (data_collection=='crm_insert_campaing'):
# id_campaign = request_data['id_campaign']
# fields = request_data['fields']
...
...
@@ -255,14 +255,10 @@ def acceso():
# return 'Invalid Data Coellections'
# else:
# return jsonify({"message": "ERROR: Unauthorized"}), 401
#return auth
if
__name__
==
'__main__'
:
app
.
run
(
debug
=
True
,
host
=
'0.0.0.0'
)
#return auth
if
__name__
==
'__main__'
:
app
.
run
(
debug
=
True
,
host
=
'0.0.0.0'
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment