2017-09-04 06:30:18 +00:00
|
|
|
import { get, post, put } from "./baseApi";
|
2017-09-03 22:24:43 +00:00
|
|
|
|
2017-09-04 06:30:18 +00:00
|
|
|
/**
|
|
|
|
* Function wrapping GET request for getting user data
|
|
|
|
*/
|
2017-09-03 22:24:43 +00:00
|
|
|
export function getSelfUser() {
|
|
|
|
return get("/user/").then(resp => Promise.resolve(resp));
|
|
|
|
}
|
2017-09-04 06:30:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function wrapping POST request for initializing User Info
|
|
|
|
* @param {string} phone_number - user's phone number
|
|
|
|
*/
|
|
|
|
export function createUserInfo(phone_number) {
|
|
|
|
return post("/userinfo/", { phone_number }).then(resp =>
|
|
|
|
Promise.resolve(resp)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function wrapping PUT request for updating User Info
|
|
|
|
* @param {string} username - username for user
|
|
|
|
* @param {string} phone_number - user's phone number
|
|
|
|
*/
|
|
|
|
export function updateUserInfo(username, phone_number) {
|
|
|
|
return put(`/userinfo/${username}/`, { phone_number }).then(resp =>
|
|
|
|
Promise.resolve(resp)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function wrapping POST request for creating a client
|
|
|
|
* @param {string} business_number - user's client business number
|
|
|
|
*/
|
|
|
|
export function createClient(business_number) {
|
|
|
|
return post("/client/", { business_number }).then(resp =>
|
|
|
|
Promise.resolve(resp)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function wrapping PUT request for updating a client
|
|
|
|
* @param {string} username - username for user
|
|
|
|
* @param {*} business_number - user's client business number
|
|
|
|
*/
|
|
|
|
export function updateClient(username, business_number) {
|
|
|
|
return put(`/client/${username}/`, { business_number }).then(resp =>
|
|
|
|
Promise.resolve(resp)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function wrapping POST request for creating a provider
|
|
|
|
* @param {string} sin - user's provider sin
|
|
|
|
*/
|
|
|
|
export function createProvider(sin) {
|
|
|
|
return post("/provider/", { sin }).then(resp => Promise.resolve(resp));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function wrapping PUT request for updating a provider
|
|
|
|
* @param {string} username - username for user
|
|
|
|
* @param {*} sin - user's provider sin
|
|
|
|
*/
|
|
|
|
export function updateProvider(username, sin) {
|
|
|
|
return put(`/provider/${username}/`, { sin }).then(resp =>
|
|
|
|
Promise.resolve(resp)
|
|
|
|
);
|
|
|
|
}
|