You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
1.7KB

  1. import { APICommonResponse, ApiId, HttpMethod, makeParam, request } from ".";
  2. import { getUrl } from "./url";
  3. export type Me = {
  4. customer_name: string;
  5. customer_name_kana: string;
  6. customer_name_kana_hankaku: string;
  7. email: string;
  8. zip_code: string;
  9. address: string;
  10. phone_no: string;
  11. customer_code: string;
  12. };
  13. type MeResponse = {
  14. data: Me;
  15. } & APICommonResponse;
  16. export const csrfToken = async () => {
  17. await request({
  18. url: getUrl(ApiId.CSRF_TOKEN),
  19. method: HttpMethod.GET,
  20. });
  21. };
  22. export const me = async () => {
  23. const res = await request<MeResponse>({
  24. url: getUrl(ApiId.ME),
  25. method: HttpMethod.GET,
  26. });
  27. return res;
  28. };
  29. export const login = async (param: { email: string; password: string }) => {
  30. const res = await request<MeResponse>({
  31. url: getUrl(ApiId.LOGIN),
  32. method: HttpMethod.POST,
  33. data: param,
  34. });
  35. return res;
  36. };
  37. export const logout = async () => {
  38. const res = await request({
  39. url: getUrl(ApiId.LOGOUT),
  40. method: HttpMethod.GET,
  41. });
  42. return res;
  43. };
  44. // -------パスワード設定開始---------------
  45. export type StartPasswordSettingRequest = {
  46. email: string;
  47. };
  48. export const startPasswordSetting = async (
  49. param: StartPasswordSettingRequest
  50. ) => {
  51. const res = await request({
  52. url: getUrl(ApiId.PASSWORD_SETTING_START),
  53. method: HttpMethod.POST,
  54. data: makeParam(param),
  55. });
  56. return res;
  57. };
  58. // -------パスワード設定認証---------------
  59. export type VerifyPasswordSettingRequest = {
  60. token: string;
  61. password: string;
  62. };
  63. export const verifyPasswordSetting = async (
  64. param: VerifyPasswordSettingRequest
  65. ) => {
  66. const res = await request({
  67. url: getUrl(ApiId.PASSWORD_SETTING_VERIFY),
  68. method: HttpMethod.POST,
  69. data: makeParam(param),
  70. });
  71. return res;
  72. };