Add WCNotice and WCNoticeList types

This commit is contained in:
Thomas Roberts 2024-04-11 11:13:26 +01:00
parent 68065a8c11
commit f750fb5238
No known key found for this signature in database
GPG Key ID: 0262BEBCBE336365
1 changed files with 14 additions and 0 deletions

View File

@ -3,6 +3,19 @@
*/
import type { CartResponse } from './cart-response';
// The notice added from wc_get_notices contains only the notice text an any additional data.
export interface WCNotice {
data?: Record< string, string >;
notice?: string;
}
// The array of notices returned from wc_get_notices contains three members, one for each type of notice.
export interface WCNoticeList {
notice?: WCNotice[];
error?: WCNotice[];
success?: WCNotice[];
}
// This is the standard API response data when an error is returned.
export type ApiErrorResponse = {
code: string;
@ -17,6 +30,7 @@ export type ApiErrorResponseData = {
details: Record< string, ApiErrorResponseDataDetails >;
// Some endpoints return cart data to update the client.
cart?: CartResponse | undefined;
notices?: WCNoticeList;
} | null;
// The details object lists individual errors for each field.