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.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);
|
||||
}
|
||||
|
|
Reference in a new issue