Files
nobat724_front/services/response.js
T
hamedandClaude Opus 4.8 811882ea05 fix(appointment): align request layer with real backend contract
- getAppointmentSlots uses doctor_uuid + date (was doctor_id, which the
  backend rejects with دکتر یافت نشد).
- postAppointmentPayment posts to /api/v1/payment/appointment (was the
  nonexistent /api/v1/payment).
- Remove getAppointmentNotAvailable: the not-available route does not
  exist (404); disabled dates come from the slots response.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-15 15:35:43 +03:30

138 lines
4.9 KiB
JavaScript

import { removeTokenHead } from "@/helper";
import api from "./api";
export const request = {
sendCode: (mobile, captcha_token) =>
api.post(
"api/v1/user/send-code",
{
mobile,
captcha_token,
},
removeTokenHead
),
getToken: (grant_type, client_id, client_secret, uuid, code, scope = "nobat724") => {
const formData = new URLSearchParams();
formData.append("grant_type", grant_type);
formData.append("client_id", client_id);
formData.append("client_secret", client_secret);
formData.append("uuid", uuid);
formData.append("code", code);
formData.append("scope", scope);
return api.post("oauth/token", formData, {
headers: {
"Content-Type": "application/x-www-form-urlencoded",
Authorization: "",
},
});
},
postRefreshToken: (formData) => {
return api.post("oauth/token", formData, {
headers: {
"Content-Type": "application/x-www-form-urlencoded",
Authorization: "",
},
});
},
getUserProfile: (uuid) => api.get(`/api/v1/user-profile/${uuid}`, { requireAuth: true }),
postUserProfile: (data) => api.post("api/v1/user-profile", data, { requireAuth: true }),
patchUserProfile: (data, uuid) =>
api.patch(`api/v1/user-profile/${uuid}`, data, { requireAuth: true }),
getUserInfo: (headers) => api.get("oauth/userinfo", { ...headers, requireAuth: true }),
getInsuranceType: (page = 1, limit = 10) =>
api.get(`api/v1/categorys/insurance_type?page=${page}&limit=${limit}`, removeTokenHead),
getSupplementaryInsurance: (page = 1, limit = 100) =>
api.get(`api/v1/categorys/supplementary_insurance?page=${page}&limit=${limit}`, removeTokenHead),
getDoctors: (params) =>
api.get("api/v1/doctors", {
params,
headers: {
Authorization: "",
},
}),
getAppointmentWeeklySchedule: (uuid) =>
api.get(`api/v1/appointment-settings/weekly-schedule/${uuid}`),
postAppointmentWeeklySchedule: () =>
api.post("api/v1/appointment-settings/weekly-schedule/"),
patchAppointmentWeeklySchedule: (uuid) =>
api.patch(`api/v1/appointment-settings/weekly-schedule/${uuid}`),
deleteAppointmentWeeklySchedule: (uuid) =>
api.delete(`api/v1/appointment-settings/weekly-schedule/${uuid}`),
getAppointmentSlots: (doctor_uuid, date) =>
api.get(
`api/v1/appointment-slots?doctor_uuid=${doctor_uuid}&date=${date}`,
removeTokenHead
),
postAppointment: (data) => api.post(`api/v1/appointment`, data, { requireAuth: true }),
getMyAppointments: (userId, params) => api.get(`api/v1/appointment/my-appointments/${userId}`, { params, requireAuth: true }),
postAppointmentPayment: (data) =>
api.post(`api/v1/payment/appointment`, data, { requireAuth: true }),
getPayment: (uuid) => api.get(`api/v1/payment/${uuid}`, { requireAuth: true }),
getMyPayments: (userId, params) => api.get(`api/v1/payment/my-payments/${userId}`, { params, requireAuth: true }),
postDoctor: (data) => api.post("api/v1/doctor", data),
postImageUpload: (data) =>
api.post("file/upload/clinic_pro/doctor/field_image", data, {
headers: {
"Content-Type": "application/octet-stream",
"Content-Disposition": `file; filename="${data.name}"`,
"X-CSRF-Token": "",
},
}),
getDoctorServices: () =>
api.get("api/v1/categorys/doctor_services", removeTokenHead),
postDoctorComment: (data) => api.post("api/v1/clinicpro/comment", data),
getDoctorRate: (uuid) => api.get(`api/v1/clinicpro/rate/${uuid}`),
postDoctorRate: (data) => api.post("api/v1/clinicpro/rate", data),
patchDoctorRate: (data, uuid) =>
api.patch(`api/v1/clinicpro/rate/${uuid}`, data),
postCommentsLike: (data) => api.post("/api/v1/clinicpro/like", data),
getClinicList: (params) =>
api.get("/api/v1/clinics", {
params,
headers: {
Authorization: "",
},
}),
getDoctorAddress: (location_id) =>
api.get(`api/v1/clinic-pro/doctor-address/${location_id}`, removeTokenHead),
getBlogs: (params) =>
api.get("api/v1/blogs", {
params,
headers: {
Authorization: "",
},
}),
getBlogTags: (params) =>
api.get("api/v1/categorys/tag", {
params,
headers: {
Authorization: "",
},
}),
getTopBlogs: () =>
api.get("api/v1/blogs/top", {
headers: {
Authorization: "",
},
}),
getSingleBlog: (uuid) =>
api.get(`api/v1/blog/${uuid}`, {
headers: {
Authorization: "",
},
}),
getRepresentationInfo: (uuid) =>
api.get(`api/v1/representation/${uuid}`, { requireAuth: true }),
getRepresentationDashboardMonthly: (uuid, year, month) =>
api.get(`api/v1/representation/${uuid}/dashboard/monthly`, {
params: { year, month },
requireAuth: true,
}),
getRepresentationDashboardYearly: (uuid, year) =>
api.get(`api/v1/representation/${uuid}/dashboard/yearly`, {
params: { year },
requireAuth: true,
}),
};