Clear up API code a little
This commit is contained in:
parent
7ef690a6a8
commit
cca9cee657
1 changed files with 28 additions and 17 deletions
|
@ -61,12 +61,13 @@ export class ApiService {
|
||||||
this.setSessionKey(json.session_key);
|
this.setSessionKey(json.session_key);
|
||||||
this.setUserInfo(
|
this.setUserInfo(
|
||||||
json.email,
|
json.email,
|
||||||
json.display_name || json.name
|
json.display_name || json.name,
|
||||||
);
|
);
|
||||||
this.setUserType(json.user_type);
|
this.setUserType(json.user_type);
|
||||||
return json;
|
return json;
|
||||||
}
|
}
|
||||||
));
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public logout() {
|
public logout() {
|
||||||
|
@ -92,16 +93,28 @@ export class ApiService {
|
||||||
data.package_name = 'Foodloop Web';
|
data.package_name = 'Foodloop Web';
|
||||||
data.version_code = 'dev';
|
data.version_code = 'dev';
|
||||||
data.version_number = 'dev';
|
data.version_number = 'dev';
|
||||||
console.log(this.apiUrl + '/feedback');
|
|
||||||
return this.http.post<any>(
|
return this.http.post<any>(
|
||||||
this.apiUrl + '/feedback',
|
this.apiUrl + '/feedback',
|
||||||
data
|
data
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sends push notifications
|
// Push notifications
|
||||||
|
|
||||||
|
public addDeviceToken(data) {
|
||||||
|
const key = this.sessionKey;
|
||||||
|
return this.http.post<any>(
|
||||||
|
this.apiUrl + '/add-device-token',
|
||||||
|
{
|
||||||
|
session_key: key,
|
||||||
|
token: data
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public sendMessage(data) {
|
public sendMessage(data) {
|
||||||
|
data.devicetoken = environment.deviceToken;
|
||||||
|
data.sender = localStorage.getItem('displayname');
|
||||||
return this.http.post<any>(
|
return this.http.post<any>(
|
||||||
this.apiUrl + '/send-message',
|
this.apiUrl + '/send-message',
|
||||||
data
|
data
|
||||||
|
@ -269,9 +282,7 @@ export class ApiService {
|
||||||
|
|
||||||
// Pulls user info to store locally on login
|
// Pulls user info to store locally on login
|
||||||
|
|
||||||
public setUserInfo(
|
public setUserInfo(email: string, display_name: string) {
|
||||||
email: string,
|
|
||||||
display_name: string) {
|
|
||||||
localStorage.setItem('email', email);
|
localStorage.setItem('email', email);
|
||||||
localStorage.setItem('displayname', display_name);
|
localStorage.setItem('displayname', display_name);
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue