Current Path : /storage/v11800/alliedessence/public_html/wp-content/plugins/lottiefiles/src/api/ |
Linux v11800 5.3.0-1023-aws #25~18.04.1-Ubuntu SMP Fri Jun 5 15:19:18 UTC 2020 aarch64
|
Current File : /storage/v11800/alliedessence/public_html/wp-content/plugins/lottiefiles/src/api/settings.ts |
/**
* Copyright 2022 Design Barn Inc.
*/
import apiFetch from '@wordpress/api-fetch';
import { IErrorProps } from '../admin/settings/interfaces';
import { IHNResponseProps } from '../admin/settings/reducer';
const path: string = '/lottiefiles/v1/settings/';
// Fetch settings via the REST API endpoint
export const getSettings = async (): Promise<IHNResponseProps | boolean | IErrorProps> => {
const data = await apiFetch({
path,
method: 'GET',
}).catch(err => ({ ...err, error: true }));
return data;
};
// Update settings via the REST API endpoint
export const updateSettings = async (data: unknown): Promise<IHNResponseProps> => {
const updatedData = apiFetch({
path,
data,
method: 'POST',
}).catch(err => ({ ...err, error: true }));
return updatedData;
};
// Delete settings via the REST API endpoint
export const deleteSettings = async (data: unknown): Promise<boolean> => {
const deleteData = apiFetch({
path,
data,
method: 'DELETE',
}).catch(err => ({ ...err, error: true }));
return deleteData;
};