PluginProbe
Yatra – Travel Booking & Tour Operator Software / trunk
Yatra – Travel Booking & Tour Operator Software vtrunk
3.0.14 3.0.14.1 3.0.14.2 3.0.12 3.0.13 3.0.11 3.0.10 3.0.9 3.0.8 3.0.7 3.0.6 3.0.5 3.0.5.1 3.0.4 3.0.3 3.0.2.9 3.0.2.7 3.0.2.8 3.0.2.6 trunk 1.0.0 2.0.0 2.0.1 2.0.10 2.0.11 All 82 releases
yatra / resources / js / api / settings-api.ts

settings-api.ts in Yatra – Travel Booking & Tour Operator Software trunk, at resources/js/api/settings-api.ts

67 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Centralized REST calls for plugin settings (`/settings`).
3 */
4
5 import { apiClient } from "../lib/api-client";
6 import { API_ENDPOINTS } from "../lib/api-endpoints";
7 import { unwrapApiPayload } from "../lib/unwrap-api-payload";
8
9 export type CoreEmailTemplatePreviewPayload = {
10 template_key: string;
11 subject: string;
12 body: string;
13 /** Optional Yatra trip ID — merges real trip_name, trip_url, trip_id into preview samples. */
14 trip_id?: number;
15 };
16
17 export type EmailPreviewResult = {
18 subject: string;
19 body: string;
20 };
21
22 export async function fetchSettings(): Promise<Record<string, unknown>> {
23 return unwrapApiPayload<Record<string, unknown>>(
24 await apiClient.get(API_ENDPOINTS.SETTINGS),
25 );
26 }
27
28 export async function saveSettings(
29 data: Record<string, unknown>,
30 ): Promise<unknown> {
31 return apiClient.put(API_ENDPOINTS.SETTINGS, data);
32 }
33
34 export async function previewCoreEmailTemplate(
35 payload: CoreEmailTemplatePreviewPayload,
36 ): Promise<EmailPreviewResult> {
37 const response = await apiClient.post(
38 API_ENDPOINTS.SETTINGS_EMAIL_TEMPLATE_PREVIEW,
39 payload,
40 );
41 return unwrapApiPayload<EmailPreviewResult>(response);
42 }
43
44 export async function fetchWordPressPages(): Promise<unknown> {
45 return apiClient.get(API_ENDPOINTS.SETTINGS_PAGES);
46 }
47
48 export async function postFlushRewriteRules(): Promise<unknown> {
49 return apiClient.post(API_ENDPOINTS.SETTINGS_FLUSH_REWRITE_RULES);
50 }
51
52 export async function fetchBookingPageShortcodeStatus(
53 pageId: number,
54 ): Promise<unknown> {
55 return apiClient.get(API_ENDPOINTS.SETTINGS_CHECK_SHORTCODE(pageId));
56 }
57
58 export async function postInsertBookingShortcode(
59 pageId: number,
60 ): Promise<unknown> {
61 return apiClient.post(API_ENDPOINTS.SETTINGS_INSERT_SHORTCODE(pageId));
62 }
63
64 export async function fetchPaymentGatewayDefinitions(): Promise<unknown> {
65 return apiClient.get(API_ENDPOINTS.PAYMENT_GATEWAY_DEFINITIONS);
66 }
67