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 {
|
2017-12-25 17:45:28 +01:00
|
|
|
|
|
|
|
static login(email, password) {
|
2018-05-28 12:35:17 +02:00
|
|
|
const params = {
|
|
|
|
url: `${apiUrl}auth/login`,
|
2017-12-25 17:45:28 +01:00
|
|
|
method: 'POST',
|
2018-05-28 12:35:17 +02:00
|
|
|
noAuthorization: true,
|
|
|
|
body: {
|
2017-12-25 17:45:28 +01:00
|
|
|
email: email,
|
|
|
|
password: password,
|
2018-05-28 12:35:17 +02:00
|
|
|
},
|
|
|
|
type: 'application/json',
|
|
|
|
}
|
|
|
|
return createRequest(params)
|
2017-12-25 17:45:28 +01:00
|
|
|
}
|
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`,
|
2017-12-25 17:45:28 +01:00
|
|
|
method: 'POST',
|
2018-05-28 12:35:17 +02:00
|
|
|
noAuthorization: true,
|
|
|
|
body: {
|
2017-12-25 17:45:28 +01:00
|
|
|
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)
|
2017-12-25 17:45:28 +01:00
|
|
|
}
|
2018-04-29 17:02:08 +02:00
|
|
|
|
2017-12-25 17:45:28 +01:00
|
|
|
static getProfile() {
|
2018-05-28 12:35:17 +02:00
|
|
|
const params = {
|
|
|
|
url: `${apiUrl}auth/profile`,
|
2017-12-25 17:45:28 +01:00
|
|
|
method: 'GET',
|
2018-05-28 12:35:17 +02:00
|
|
|
type: 'application/json',
|
|
|
|
}
|
|
|
|
return createRequest(params)
|
2017-12-25 17:45:28 +01:00
|
|
|
}
|
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
|
|
|
}
|
2017-12-25 17:45:28 +01:00
|
|
|
}
|