Skip to content

Instantly share code, notes, and snippets.

@johndiego
Created October 9, 2018 18:36
Show Gist options
  • Save johndiego/bad2a1279a60c2f63e5e4047463f91e9 to your computer and use it in GitHub Desktop.
Save johndiego/bad2a1279a60c2f63e5e4047463f91e9 to your computer and use it in GitHub Desktop.
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
@johndiego
Copy link
Author

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 = "INSERT INTO nextel_api_activation(msisdn, docNum, offerAmount, originalAmount,offerDueDate, returncode, message, caller) VALUES({0},{1},{2 },{3},{4 },{5 },{6 }, {7)")

#
user_object = {
    'returnCode' : returncode,
    'message' : data
}
with conn.cursor() as cur:
    query = None
    try:
        if called:
            query =  str_fromat.format("1","2","3","4","5","6","7","MEU CALLED VEM AQUI JUNTO COM OS OUTROS PARAMETROS")
        else:
            query =  str_fromat.format("1","2","3","4","5","6","7","MEU VALOR DEFAULT")

        # cur.execute(query)
        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