Commit d2636220 by Javier

Erratas

parent b1b0e0d7
...@@ -213,43 +213,47 @@ def create_account(account: Account = Depends()): ...@@ -213,43 +213,47 @@ def create_account(account: Account = Depends()):
""" """
plan_id, offer_id = encode_rate(account.rate) if not mbilling.functions.get_user(account.number):
plan_id, offer_id = encode_rate(account.rate)
# Generación de la Cuenta
try:
password = mbilling.functions.create_user(
phone_number=account.number,
name=account.name,
surname=account.surname,
pbx=account.pbx_address,
plan_id=plan_id,
offer_id=offer_id
)
if not account.pbx_address: # Generación de la Cuenta
response = ConnectionData( try:
account=account.number, password=password) password = mbilling.functions.create_user(
else: phone_number=account.number,
response = ConnectionData( name=account.name,
account=account.number, surname=account.surname,
password=password, pbx=account.pbx_address,
peer_details=f'type = friend username = {account.number} host = 192.168.2.84 nat = force_rport, comedia qualify = yes insecure = invite, port', plan_id=plan_id,
user_details='type = friend host = 192.168.2.84 nat = force_rport, comedia qualify = yes insecure = invite, port' offer_id=offer_id
) )
# Recarga Inicial de Cuenta if not account.pbx_address:
if account.initial_balance > 0.0: response = ConnectionData(
mbilling.functions.add_balance( account=account.number, password=password)
account.number, account.initial_balance, description=Refill.INICIAL) else:
response = ConnectionData(
account=account.number,
password=password,
peer_details=f'type = friend username = {account.number} host = 192.168.2.84 nat = force_rport, comedia qualify = yes insecure = invite, port',
user_details='type = friend host = 192.168.2.84 nat = force_rport, comedia qualify = yes insecure = invite, port'
)
# Recarga Inicial de Cuenta
if account.initial_balance > 0.0:
mbilling.functions.add_balance(
account.number, account.initial_balance, description=Refill.INICIAL)
except mbilling.functions.MagnusCommandError as e: except mbilling.functions.MagnusCommandError as e:
response = JSONResponse( response = JSONResponse(
content={ content={
'error': 'Se ha producido un error en Magnus durante la ejecución del comando.', 'error': 'Se ha producido un error en Magnus durante la ejecución del comando.',
'description': str(e), 'description': str(e),
}, },
status_code=400 status_code=400
) )
else:
response = JSONResponse(content={'error' : 'El número ya está registrado en MagnusBilling'}, status_code=409)
return response return response
......
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