From c57a2511d84297c17df7e04445d909281c08c779 Mon Sep 17 00:00:00 2001 From: Lukian Date: Fri, 27 Dec 2024 13:55:21 +0100 Subject: [PATCH] Added client scripts --- .gitignore => api/.gitignore | 0 Dockerfile => api/Dockerfile | 0 api/{ => api}/companies.js | 0 api/{ => api}/hello.js | 0 api/{ => api}/shareholders.js | 0 api/{ => api}/shares.js | 0 config.json => api/config.json | 0 docker-compose.yml => api/docker-compose.yml | 0 index.js => api/index.js | 0 {libs => api/libs}/mysql.js | 0 package-lock.json => api/package-lock.json | 0 package.json => api/package.json | 0 client/actionnaire.py | 51 ++++++++++++++++++++ client/entreprise.py | 36 ++++++++++++++ 14 files changed, 87 insertions(+) rename .gitignore => api/.gitignore (100%) rename Dockerfile => api/Dockerfile (100%) rename api/{ => api}/companies.js (100%) rename api/{ => api}/hello.js (100%) rename api/{ => api}/shareholders.js (100%) rename api/{ => api}/shares.js (100%) rename config.json => api/config.json (100%) rename docker-compose.yml => api/docker-compose.yml (100%) rename index.js => api/index.js (100%) rename {libs => api/libs}/mysql.js (100%) rename package-lock.json => api/package-lock.json (100%) rename package.json => api/package.json (100%) create mode 100644 client/actionnaire.py create mode 100644 client/entreprise.py diff --git a/.gitignore b/api/.gitignore similarity index 100% rename from .gitignore rename to api/.gitignore diff --git a/Dockerfile b/api/Dockerfile similarity index 100% rename from Dockerfile rename to api/Dockerfile diff --git a/api/companies.js b/api/api/companies.js similarity index 100% rename from api/companies.js rename to api/api/companies.js diff --git a/api/hello.js b/api/api/hello.js similarity index 100% rename from api/hello.js rename to api/api/hello.js diff --git a/api/shareholders.js b/api/api/shareholders.js similarity index 100% rename from api/shareholders.js rename to api/api/shareholders.js diff --git a/api/shares.js b/api/api/shares.js similarity index 100% rename from api/shares.js rename to api/api/shares.js diff --git a/config.json b/api/config.json similarity index 100% rename from config.json rename to api/config.json diff --git a/docker-compose.yml b/api/docker-compose.yml similarity index 100% rename from docker-compose.yml rename to api/docker-compose.yml diff --git a/index.js b/api/index.js similarity index 100% rename from index.js rename to api/index.js diff --git a/libs/mysql.js b/api/libs/mysql.js similarity index 100% rename from libs/mysql.js rename to api/libs/mysql.js diff --git a/package-lock.json b/api/package-lock.json similarity index 100% rename from package-lock.json rename to api/package-lock.json diff --git a/package.json b/api/package.json similarity index 100% rename from package.json rename to api/package.json diff --git a/client/actionnaire.py b/client/actionnaire.py new file mode 100644 index 0000000..b522be8 --- /dev/null +++ b/client/actionnaire.py @@ -0,0 +1,51 @@ +import requests + +"""Achat d'une action par un actionnaire à une entreprise + input : + - idBuyer : identifiant de l'actionnaire + - idShare : identifiant de l'action +""" +def buy(idBuyer, idShare): + url = '192.168.200.15/api/shares/buy' + obj={'id':idBuyer,'share_id':idShare} + r = requests.post(url, json=obj) + print(r.text) + +"""Affichage les actions possédées par un actionnaire + input : + - idBuyer : identifiant de l'actionnaire +""" +def showSharesOf(idBuyer): + url = '192.168.200.15/api/shareholders/'+idBuyer+'/shares' + r = requests.get(url) + print(r.text) + +"""Affichage les informations d'une actions + input : + - idShare : identifiant de l'action +""" +def showShare(idShare): + url = '192.168.200.15/api/shares/'+idShare + r = requests.get(url) + print(r.text) + +"""Affichage les actions en circulation sur le marché (possédées ou en vente) """ +def showAllShares(): + url = '192.168.200.15/api/shares' + r = requests.get(url) + print(r.text) + +"""Affichage les informations sur un actionnaire + input : + - idBuyer : identifiant de l'actionnaire +""" +def showInfoBuyer(idBuyer): + url='192.168.200.15/api/shareholders/'+idBuyer + r=requests.get(url) + print(r.text) + +"""Affichage tous les actionnaires """ +def showAllBuyers(): + url='192.168.200.15/api/shareholders/' + r=requests.get(url) + print(r.text) \ No newline at end of file diff --git a/client/entreprise.py b/client/entreprise.py new file mode 100644 index 0000000..4ecbd93 --- /dev/null +++ b/client/entreprise.py @@ -0,0 +1,36 @@ +import requests + +"""Affichage des actions mises en vente par une entreprise + input : + - idComp : Identifiant de l'entreprise +""" +def showShares(idComp): + url = '192.168.200.15/api/companies/'+idComp+'/shares' + r = requests.get(url) + print(r.text) + +"""Création d'une action par une entreprise + input : + - idComp : identifiant de l'entreprise + - price : prix de l'action sur le marché +""" +def newShare(idComp, price): + url = '192.168.200.15/api/shares/emmit' + obj={'id':idComp,'price':price} + r = requests.post(url, json=obj) + print(r.text) + +"""Affichage des informations d'une enteprise + input : + - idComp : identifiant de l'entreprise +""" +def showInfoComp(idComp): + url='192.168.200.15/api/companies/'+idComp + r=requests.get(url) + print(r.text) + +"""Affichage les enteprises """ +def showComp(): + url='192.168.200.15/api/companies/' + r=requests.get(url) + print(r.text) \ No newline at end of file