changes in service
This commit is contained in:
@ -11,6 +11,9 @@ HEROES = [
|
||||
]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def get_heroes():
|
||||
if HEROES:
|
||||
return HEROES
|
||||
@ -27,6 +30,9 @@ def get_hero(id=None):
|
||||
def put_hero(id=None, hero=None):
|
||||
try:
|
||||
heroToUpdate = next(x for x in HEROES if x["id"] == id)
|
||||
checkNewName = next((x for x in HEROES if x["name"] == hero["name"]), None)
|
||||
if (checkNewName):
|
||||
return 'Duplicate name', 403
|
||||
heroToUpdate["name"] = hero["name"]
|
||||
return 'Hero updated', 200
|
||||
except StopIteration:
|
||||
|
Reference in New Issue
Block a user