caremyway-client/src/api/user.api.js

70 lines
1.9 KiB
JavaScript
Raw Permalink Normal View History

import { get, post, put } from "./baseApi";
/**
* Function wrapping GET request for getting user data
*/
export function getSelfUser() {
return get("/user/").then(resp => Promise.resolve(resp));
}
/**
* 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)
);
}