From 59107f82c2e5074618d2d26a9b4d8d2fa3a06bbb Mon Sep 17 00:00:00 2001 From: Ignat Prokopovich Date: Thu, 13 Jun 2024 01:40:20 +0300 Subject: [PATCH] fix: add error response types to account, cart and subscriptions api (#178) --- types/index.d.ts | 92 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 69 insertions(+), 23 deletions(-) diff --git a/types/index.d.ts b/types/index.d.ts index c56a33a..206d46c 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -28,7 +28,6 @@ import { import { Settings } from './settings'; import { Subscription } from './subscription'; import { Invoice } from './invoice'; -import { ShipmentRating } from './shipment_rating'; export * from './account'; export * from './attribute'; @@ -128,6 +127,19 @@ export interface ItemDiscount { amount?: number; } +export interface SwellError { + code: string; + message: string; +} + +export interface ServerError { + error: SwellError; +} + +export interface ErrorResponse { + errors: Record; +} + export const version: string; export function init( @@ -137,7 +149,7 @@ export function init( ): void; export namespace account { - export function create(input: Account): Promise; + export function create(input: Account): Promise; export function login( user: string, @@ -145,8 +157,8 @@ export namespace account { ): Promise; export function logout(): Promise; - export function recover(input: object): Promise; - export function update(input: Account): Promise; + export function recover(input: object): Promise; + export function update(input: Account): Promise; export function get(query?: object): Promise; export function listAddresses( @@ -158,16 +170,28 @@ export namespace account { input?: object, ): Promise>; - export function createAddress(input: Address): Promise
; - export function updateAddress(id: string, input: Address): Promise
; - export function deleteAddress(id: string): Promise
; + export function createAddress( + input: Address, + ): Promise
; + + export function updateAddress( + id: string, + input: Address, + ): Promise
; + + export function deleteAddress(id: string): Promise
; export function listCards(query?: object): Promise>; /** @deprecated use `listCards` instead */ export function getCards(query?: object): Promise>; - export function createCard(input: Card): Promise; - export function updateCard(id: string, input: Card): Promise; - export function deleteCard(id: string): Promise; + export function createCard(input: Card): Promise; + + export function updateCard( + id: string, + input: Card, + ): Promise; + + export function deleteCard(id: string): Promise; export function listOrders(query?: object): Promise>; /** @deprecated use `listOrders` instead */ @@ -189,20 +213,26 @@ export namespace card { export namespace cart { export function get(): Promise; - export function update(input: object): Promise; + export function update(input: object): Promise; export function recover(input: string): Promise; export function getSettings(): Promise; - export function getShippingRates(): Promise; + export function getShippingRates(): Promise; - export function addItem(input: Partial): Promise; - export function setItems(input: Partial[]): Promise; - export function removeItem(id: string): Promise; + export function addItem( + input: Partial, + ): Promise; + + export function setItems( + input: Partial[], + ): Promise; + + export function removeItem(id: string): Promise; export function updateItem( id: string, input: Partial, - ): Promise; + ): Promise; export function applyCoupon(code: string): Promise; export function removeCoupon(): Promise; @@ -211,7 +241,7 @@ export namespace cart { export function removeGiftcard(id: string): Promise; export function submitOrder(): Promise; - export function getOrder(checkoutId?: string): Promise; + export function getOrder(checkoutId?: string): Promise; } export namespace categories { @@ -276,7 +306,7 @@ export namespace payment { klarna?: InputPaymentRedirect; }): Promise; - export function authenticate(id: string): Promise; + export function authenticate(id: string): Promise; export function resetAsyncPayment(id: string): Promise; export function createIntent(input: { @@ -361,20 +391,36 @@ export namespace settings { } export namespace subscriptions { - export function create(input: object): Promise; - export function update(id: string, input: object): Promise; + export function create(input: object): Promise; + + export function update( + id: string, + input: object, + ): Promise; + export function list(query?: object): Promise>; export function get(id: string, query?: object): Promise; - export function addItem(id: string, input: object): Promise; + export function addItem( + id: string, + input: object, + ): Promise; + + export function setItems( + id: string, + input: object[], + ): Promise; export function updateItem( id: string, itemId: string, input: object, - ): Promise; + ): Promise; - export function removeItem(id: string, itemId: string): Promise; + export function removeItem( + id: string, + itemId: string, + ): Promise; } export namespace invoices {