FitTrackee/mpwo_client/src/mwpoApi/user.js

79 lines
1.7 KiB
JavaScript
Raw Normal View History

2018-05-28 12:35:17 +02:00
import { apiUrl, createRequest } from '../utils'
2018-04-29 17:02:08 +02:00
export default class MpwoApiUser {
static login(email, password) {
2018-05-28 12:35:17 +02:00
const params = {
url: `${apiUrl}auth/login`,
method: 'POST',
2018-05-28 12:35:17 +02:00
noAuthorization: true,
body: {
email: email,
password: password,
2018-05-28 12:35:17 +02:00
},
type: 'application/json',
}
return createRequest(params)
}
2018-04-29 17:02:08 +02:00
2018-01-01 11:10:39 +01:00
static register(username, email, password, passwordConf) {
2018-05-28 12:35:17 +02:00
const params = {
url: `${apiUrl}auth/register`,
method: 'POST',
2018-05-28 12:35:17 +02:00
noAuthorization: true,
body: {
username: username,
email: email,
password: password,
2018-01-01 11:10:39 +01:00
password_conf: passwordConf,
2018-05-28 12:35:17 +02:00
},
type: 'application/json',
}
return createRequest(params)
}
2018-04-29 17:02:08 +02:00
static getProfile() {
2018-05-28 12:35:17 +02:00
const params = {
url: `${apiUrl}auth/profile`,
method: 'GET',
2018-05-28 12:35:17 +02:00
type: 'application/json',
}
return createRequest(params)
}
2018-04-29 17:02:08 +02:00
2018-01-01 16:59:46 +01:00
static updateProfile(form) {
2018-05-28 12:35:17 +02:00
const params = {
url: `${apiUrl}auth/profile/edit`,
2018-01-01 16:59:46 +01:00
method: 'POST',
2018-05-28 12:35:17 +02:00
body: {
2018-01-01 16:59:46 +01:00
first_name: form.firstName,
last_name: form.lastName,
bio: form.bio,
location: form.location,
2018-01-01 17:50:12 +01:00
birth_date: form.birthDate,
password: form.password,
password_conf: form.passwordConf,
2018-05-28 12:35:17 +02:00
},
type: 'application/json',
}
return createRequest(params)
2018-01-01 16:59:46 +01:00
}
2018-04-29 17:02:08 +02:00
2018-01-01 21:54:03 +01:00
static updatePicture(form) {
2018-05-28 12:35:17 +02:00
const params = {
url: `${apiUrl}auth/picture`,
2018-01-01 21:54:03 +01:00
method: 'POST',
body: form,
2018-05-28 12:35:17 +02:00
}
return createRequest(params)
2018-01-01 21:54:03 +01:00
}
2018-04-29 17:02:08 +02:00
2018-01-01 21:54:03 +01:00
static deletePicture() {
2018-05-28 12:35:17 +02:00
const params = {
url: `${apiUrl}auth/picture`,
2018-01-01 21:54:03 +01:00
method: 'DELETE',
2018-05-28 12:35:17 +02:00
}
return createRequest(params)
2018-01-01 21:54:03 +01:00
}
}