generated from lucien/api-template
Fix owner ID reference in share purchase logic; clean up comments and add sleep in main execution
This commit is contained in:
parent
9b0985c33c
commit
f351b4c31f
3 changed files with 3 additions and 35 deletions
|
@ -4,36 +4,22 @@ from random import randint
|
|||
|
||||
HOST = "http://192.168.200.15/"
|
||||
|
||||
"""Affichage des actions mises en vente par une entreprise
|
||||
input :
|
||||
- idComp : Identifiant de l'entreprise
|
||||
"""
|
||||
def getShares(idComp):
|
||||
url = HOST + 'api/companies/'+idComp+'/shares'
|
||||
r = requests.get(url)
|
||||
return r.json()
|
||||
|
||||
"""Création d'une action par une entreprise
|
||||
input :
|
||||
- idComp : identifiant de l'entreprise
|
||||
- price : prix de l'action sur le marché
|
||||
"""
|
||||
def emitShare(idComp, price):
|
||||
url = HOST + 'api/shares/emit'
|
||||
obj={'company_id':idComp,'price':price}
|
||||
r = requests.post(url, json=obj)
|
||||
return r.json()
|
||||
|
||||
"""Affichage des informations d'une enteprise
|
||||
input :
|
||||
- idComp : identifiant de l'entreprise
|
||||
"""
|
||||
def getCompany(idComp):
|
||||
url = HOST + 'api/companies/'+idComp
|
||||
r=requests.get(url)
|
||||
return r.json()
|
||||
|
||||
"""Affichage les enteprises """
|
||||
def getCompanies():
|
||||
url = HOST + 'api/companies/'
|
||||
r=requests.get(url)
|
||||
|
@ -46,6 +32,7 @@ if __name__ == "__main__":
|
|||
price = randint(20, 2000)
|
||||
for i in range(randint(0, 4)):
|
||||
emitShare(randint(0, len(companies) - 1), price)
|
||||
sleep(1)
|
||||
|
||||
sleep(30)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue