diff --git a/bob_party/src/services/conversationService/loaderConversationApi.ts b/bob_party/src/services/conversationService/loaderConversationApi.ts index e0ef596..8480add 100644 --- a/bob_party/src/services/conversationService/loaderConversationApi.ts +++ b/bob_party/src/services/conversationService/loaderConversationApi.ts @@ -9,6 +9,8 @@ export class LoaderConversationApi implements ILoaderConversation{ private axios = require('axios').default; + private baseUrl = "https://codefirst.iut.uca.fr/containers/BOB_PARTEAM-api-bobParty/index.php/" + loadAllConversation(): Promise { throw new Error("Method not implemented."); } @@ -18,7 +20,7 @@ export class LoaderConversationApi implements ILoaderConversation{ async loadByUser(u: User): Promise { let tabConv:Conversation[]=[]; - const url='http://localhost:8888/api-rest/index.php/getConversations/' +u.getId(); + const url=this.baseUrl+'getConversations/' +u.getId(); await this.axios({ method: 'get', url: url, diff --git a/bob_party/src/services/conversationService/saverConversationApi.ts b/bob_party/src/services/conversationService/saverConversationApi.ts index 96d5f7b..2b8e90e 100644 --- a/bob_party/src/services/conversationService/saverConversationApi.ts +++ b/bob_party/src/services/conversationService/saverConversationApi.ts @@ -9,10 +9,12 @@ export class SaverConversationApi implements ISaverConversation{ private axios = require('axios').default; + private baseUrl = "https://codefirst.iut.uca.fr/containers/BOB_PARTEAM-api-bobParty/index.php/" + async saveConversation(name: string, user:User, tabId:number[], firstMessage:string, messageDate:Date): Promise{ let conv:Conversation | null=null; - let url='http://localhost:8888/api-rest/index.php/postConversation/' + name + "/" +user.getId(); + let url= this.baseUrl + 'postConversation/' + name + "/" +user.getId(); tabId.forEach(id => { url=url + "," + id; }); @@ -47,7 +49,7 @@ export class SaverConversationApi implements ISaverConversation{ async addMessage(idConv:number, content: string, messageDate:Date, user: User): Promise { let message:Message | null=null; - let url='http://localhost:8888/api-rest/index.php/addMessageToConversation/' + content + "/" + user.getId() + "/" + idConv + "/" + messageDate.toISOString().split('T')[0] + " " + messageDate.getHours() + ":" + messageDate.getMinutes() + ":" + messageDate.getSeconds(); + let url=this.baseUrl+ 'addMessageToConversation/' + content + "/" + user.getId() + "/" + idConv + "/" + messageDate.toISOString().split('T')[0] + " " + messageDate.getHours() + ":" + messageDate.getMinutes() + ":" + messageDate.getSeconds(); await this.axios({ method: 'put', url: url, @@ -63,7 +65,7 @@ export class SaverConversationApi implements ISaverConversation{ throw new Error("Method not implemented."); } async deleteUserToConversation(c: Conversation, u: User): Promise { - let url='http://localhost:8888/api-rest/index.php/deleteUserFromConversation/' + c.getId() + "/" +u.getId(); + let url=this.baseUrl+'deleteUserFromConversation/' + c.getId() + "/" +u.getId(); await this.axios({ method: 'put', url: url, @@ -72,7 +74,7 @@ export class SaverConversationApi implements ISaverConversation{ async deleteConversation(c: Conversation): Promise { - let url='http://localhost:8888/api-rest/index.php/deleteConversation/' + c.getId(); + let url=this.baseUrl+'deleteConversation/' + c.getId(); await this.axios({ method: 'delete', url: url, diff --git a/bob_party/src/services/gameService/loaderGameApi.ts b/bob_party/src/services/gameService/loaderGameApi.ts index 5e664de..8f5cb27 100644 --- a/bob_party/src/services/gameService/loaderGameApi.ts +++ b/bob_party/src/services/gameService/loaderGameApi.ts @@ -8,10 +8,11 @@ export default class LoaderGameApi implements ILoaderGame{ private axios = require('axios').default; + private baseUrl = "https://codefirst.iut.uca.fr/containers/BOB_PARTEAM-api-bobParty/index.php/" async loadAllGames(): Promise { let tab: Game[]=[]; - const url="http://localhost:8888/api-rest/index.php/getGames"; + const url=this.baseUrl+"http://localhost:8888/api-rest/index.php/getGames"; await this.axios({ method: 'get', url: url, @@ -48,7 +49,7 @@ export default class LoaderGameApi implements ILoaderGame{ } async loadByID(id: number): Promise { let game: Game|null=null; - const url="http://localhost:8888/api-rest/index.php/getGameById/" + id; + const url=this.baseUrl + "getGameById/" + id; await this.axios({ method: 'get', url: url, diff --git a/bob_party/src/services/matchServices/loaderMatchApi.ts b/bob_party/src/services/matchServices/loaderMatchApi.ts index 35621e7..c40777d 100644 --- a/bob_party/src/services/matchServices/loaderMatchApi.ts +++ b/bob_party/src/services/matchServices/loaderMatchApi.ts @@ -12,6 +12,8 @@ export default class LoaderMatchApi implements ILoaderMatch{ private axios = require('axios').default; + private baseUrl = "https://codefirst.iut.uca.fr/containers/BOB_PARTEAM-api-bobParty/index.php/" + async loadAllMatch(): Promise { throw new Error("Method not implemented."); @@ -19,7 +21,7 @@ export default class LoaderMatchApi implements ILoaderMatch{ async loadByID(id: number): Promise { let match:Match|null=null; - const url='http://localhost:8888/api-rest/index.php/getMatchById/' + id; + const url=this.baseUrl + 'getMatchById/' + id; await this.axios({ method: 'get', url: url, diff --git a/bob_party/src/services/matchServices/saverMatchApi.ts b/bob_party/src/services/matchServices/saverMatchApi.ts index 7c314b1..c79183f 100644 --- a/bob_party/src/services/matchServices/saverMatchApi.ts +++ b/bob_party/src/services/matchServices/saverMatchApi.ts @@ -12,11 +12,15 @@ import { MANAGER_MATCH } from "../../../appManagers"; export default class SaverMatchApi implements ISaverMatch{ + private axios = require('axios').default; + private baseUrl = "https://codefirst.iut.uca.fr/containers/BOB_PARTEAM-api-bobParty/index.php/" + + async saveMatch(u:User, g:Game): Promise { let id=0; - let url='http://localhost:8888/api-rest/index.php/postMatch/' + g.id + "/" + u.id; + let url=this.baseUrl + 'postMatch/' + g.id + "/" + u.id; await this.axios({ method: 'post', url: url, @@ -32,7 +36,7 @@ export default class SaverMatchApi implements ISaverMatch{ } async deleteMatch(m: Match): Promise { - let url='http://localhost:8888/api-rest/index.php/deleteMatch/' + m.getCode(); + let url=this.baseUrl + 'deleteMatch/' + m.getCode(); await this.axios({ method: 'delete', url: url, @@ -40,16 +44,20 @@ export default class SaverMatchApi implements ISaverMatch{ } async deleteUserFromMatch(u: User): Promise { - let url='http://localhost:8888/api-rest/deleteUserFromMatch.php/' + u.id; + let url=this.baseUrl + 'deleteUserFromMatch.php/' + u.id; await this.axios({ method: 'put', url: url, }); } + updateMatch(m: Match): Promise { + throw new Error("Method not implemented."); + } + async joinMatch(u:User, id:number): Promise{ let match:Match|null=null; - let url='http://localhost:8888/api-rest/index.php/addUserToMatch/' + id + "/" + u.id; + let url=this.baseUrl + 'addUserToMatch/' + id + "/" + u.id; await MANAGER_MATCH.getLoaderMatch().loadByID(id).then(async (response)=>{ if (response!==undefined && response !== null){ diff --git a/bob_party/src/services/skinService/loaderSkinApi.ts b/bob_party/src/services/skinService/loaderSkinApi.ts index d6e4113..1c257dc 100644 --- a/bob_party/src/services/skinService/loaderSkinApi.ts +++ b/bob_party/src/services/skinService/loaderSkinApi.ts @@ -5,13 +5,16 @@ export default class LoaderSkinApi implements ILoaderSkin{ private axios = require('axios').default; + private baseUrl = "https://codefirst.iut.uca.fr/containers/BOB_PARTEAM-api-bobParty/index.php/" + + /** * loadAllSkin methode that load every Skin from the data management system * return an array of Skin */ async loadAllSkin(): Promise{ let tabSkin: Skin[]=[]; - const url='http://localhost:8888/api-rest/index.php/getSkins'; + const url=this.baseUrl+'getSkins'; await this.axios({ method: 'get', url: url, @@ -33,7 +36,7 @@ export default class LoaderSkinApi implements ILoaderSkin{ */ async loadByID(id:number): Promise{ let skin: Skin | null= null; - const url='http://localhost:8888/api-rest/index.php/getSkins'; + const url=this.baseUrl + 'getSkins'; await this.axios({ method: 'get', url: url, diff --git a/bob_party/src/services/userServices/loaderUserApi.ts b/bob_party/src/services/userServices/loaderUserApi.ts index 037fef9..2800387 100644 --- a/bob_party/src/services/userServices/loaderUserApi.ts +++ b/bob_party/src/services/userServices/loaderUserApi.ts @@ -4,24 +4,13 @@ import { Skin } from "../../core/skin"; import { User } from "../../core/User/user"; import ILoaderUser from "./ILoaderUser"; -class Test{ - public completed:boolean; - public id: number; - public title: String; - public userId: number; - - constructor(completed: boolean, id:number, title:String, userId: number){ - this.completed=completed; - this.id=id; - this.title=title; - this.userId=userId; - } -} export default class LoaderUserApi implements ILoaderUser{ private axios = require('axios').default; + private baseUrl = "https://codefirst.iut.uca.fr/containers/BOB_PARTEAM-api-bobParty/index.php/" + async loadAllUser() : Promise { throw new Error("Method not implemented."); @@ -30,7 +19,7 @@ export default class LoaderUserApi implements ILoaderUser{ async loadByID(id: number): Promise { let us:User | null=null; - const url='http://localhost:8888/api-rest/index.php/getUserById/'+ id; + const url=this.baseUrl + 'getUserById/'+ id; await this.axios({ method: 'get', url: url, @@ -46,7 +35,7 @@ export default class LoaderUserApi implements ILoaderUser{ async loadByUsername(username: string): Promise { let us:User | null=null; - const url='http://localhost:8888/api-rest/index.php/getUserByUsername/'+ username; + const url=this.baseUrl + 'getUserByUsername/'+ username; await this.axios({ method: 'get', url: url, @@ -61,7 +50,7 @@ export default class LoaderUserApi implements ILoaderUser{ async loadByUsernamePassword(username: string, password: string): Promise{ let us:User | null=null; - const url='http://localhost:8888/api-rest/index.php/getUserForConnection/'+ username + "/" + password; + const url=this.baseUrl + 'getUserForConnection/'+ username + "/" + password; await this.axios({ method: 'get', url: url, diff --git a/bob_party/src/services/userServices/saverUserApi.ts b/bob_party/src/services/userServices/saverUserApi.ts index 5550c90..c89f675 100644 --- a/bob_party/src/services/userServices/saverUserApi.ts +++ b/bob_party/src/services/userServices/saverUserApi.ts @@ -8,9 +8,11 @@ export default class SaverUserApi implements ISaverUser{ private axios = require('axios').default; + private baseUrl = "https://codefirst.iut.uca.fr/containers/BOB_PARTEAM-api-bobParty/index.php/" + async saveUser(username:string, password:string, nationality:string, sexe:string, date:Date): Promise { let us:User|null=null; - const url='http://localhost:8888/api-rest/index.php/postUser/'+ username + "/" + password + "/" + nationality + "/" + sexe + "/" + date.toISOString().split('T')[0] ; + const url=this.baseUrl + 'postUser/'+ username + "/" + password + "/" + nationality + "/" + sexe + "/" + date.toISOString().split('T')[0] ; await this.axios({ method: 'post', url: url, @@ -24,7 +26,7 @@ export default class SaverUserApi implements ISaverUser{ } async updateUser(u: User): Promise { let us:User|null=null; - const url='http://localhost:8888/api-rest/index.php/putUser/'+ u.getId() + "/" + u.getUsername() + "/" + u.getPassword() + "/" + u.getSexe() + "/" + u.getNationality() + "/" + u.getCurrentCoins() + "/" + u.getTotalCoins() + "/" + u.getGamesPlayed() + "/" + u.getCurrentSkin().getSkinId(); + const url=this.baseUrl + 'putUser/'+ u.getId() + "/" + u.getUsername() + "/" + u.getPassword() + "/" + u.getSexe() + "/" + u.getNationality() + "/" + u.getCurrentCoins() + "/" + u.getTotalCoins() + "/" + u.getGamesPlayed() + "/" + u.getCurrentSkin().getSkinId(); await this.axios({ method: 'put', url: url, @@ -33,7 +35,7 @@ export default class SaverUserApi implements ISaverUser{ async addSkinList(u: User, s:Skin): Promise { let us:User|null=null; - const url='http://localhost:8888/api-rest/index.php/putSkinList/'+ u.getId() + "/" + s.getSkinId(); + const url=this.baseUrl + 'putSkinList/'+ u.getId() + "/" + s.getSkinId(); await this.axios({ method: 'put', url: url,