Created
October 9, 2018 18:36
-
-
Save johndiego/bad2a1279a60c2f63e5e4047463f91e9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gravaCode = event['params']['path']['msisdn']['returncode']['message']['caller'] | |
if returncode == 0: | |
if gravaCode == 0: | |
print('N3Rmonitor msgOK') | |
elif returncode == 999999: | |
print(f'returncode: {returncode}') | |
print(f'mensagem: {data}') | |
print(f"mensagem: {dadosassinante['msisdn']}") | |
print(f'caller: {gravaCode}') | |
print('N3Rmonitor msgERROTECNICO') | |
else: | |
print(f'returncode: {returncode}') | |
print(f'mensagem: {data}') | |
print(f"mensagem: {dadosassinante['msisdn']}") | |
print(f'caller: {gravaCode}') | |
print('N3Rmonitor msgNOTOK') | |
return responseJSON(returncode, data) | |
###################################### | |
### Funcao de montagem do JSON ### | |
###################################### | |
def responseJSON(returncode, data): | |
# Responde Object JSON para a Nextel | |
str_fromat = f"IINSERT INTO nextel_api_activation(msisdn, docNum, offerAmount, originalAmount,offerDueDate, returncode, message, caller) VALUES({msisdn: },{docNum: },{offerAmount: },{originalAmount: },{offerDueDate: },{returncode: },{message: }, {caller: })".format('') | |
# | |
user_object = { | |
'returnCode' : returncode, | |
'message' : data | |
} | |
with conn.cursor() as cur: | |
try: | |
if called: | |
str_fromat ??????? | |
else: | |
str_fromat = f"INSERT INTO nextel_api_activation (msisdn, docNum, offerAmount, originalAmount, offerDueDate, returncode, message, caller) valeus('{msisdn:}', '{docnum:}', '{offerAmount:}', '{originalAmount:}', '{offerDueDate:}', '{returncode:}', '{message:}', '{caller:}')".format('not suplied') | |
# sql = f"INSERT INTO nextel_api_activation (msisdn, docNum, offerAmount, originalAmount, offerDueDate, returncode, message, caller) valeus('{msisdn}', '{docnum}', '{offerAmount}', '{originalAmount}', '{offerDueDate}', '{returncode}', '{message}', '{caller}')" | |
# cur.execute(sql) | |
except MySQLError as my: | |
conn.rollback() | |
print(my) | |
print("Tente novamente!") | |
return False | |
conn.commit() | |
return True | |
return user_object |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
######################################
Funcao de montagem do JSON
######################################
def responseJSON(returncode, data):
# Responde Object JSON para a Nextel
str_fromat = "INSERT INTO nextel_api_activation(msisdn, docNum, offerAmount, originalAmount,offerDueDate, returncode, message, caller) VALUES({0},{1},{2 },{3},{4 },{5 },{6 }, {7)")