Clear up API code a little

This commit is contained in:
Ben Goldsworthy 2020-11-08 17:37:26 +00:00
parent d0165eaf9e
commit bf8acced6c

View file

@ -61,12 +61,13 @@ export class ApiService {
this.setSessionKey(json.session_key);
this.setUserInfo(
json.email,
json.display_name || json.name
json.display_name || json.name,
);
this.setUserType(json.user_type);
return json;
}
));
)
);
}
public logout() {
@ -92,16 +93,28 @@ export class ApiService {
data.package_name = 'Foodloop Web';
data.version_code = 'dev';
data.version_number = 'dev';
console.log(this.apiUrl + '/feedback');
return this.http.post<any>(
this.apiUrl + '/feedback',
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) {
data.devicetoken = environment.deviceToken;
data.sender = localStorage.getItem('displayname');
return this.http.post<any>(
this.apiUrl + '/send-message',
data
@ -269,9 +282,7 @@ export class ApiService {
// Pulls user info to store locally on login
public setUserInfo(
email: string,
display_name: string) {
public setUserInfo(email: string, display_name: string) {
localStorage.setItem('email', email);
localStorage.setItem('displayname', display_name);
}