Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Add gift cards support to SDK

Damian Legawiec938343fb8eae
diff --git a/sdk/src/client.ts b/sdk/src/client.ts
index 63e270a8f9..5617436da2 100644
--- a/sdk/src/client.ts
+++ b/sdk/src/client.ts
@@ -15,6 +15,7 @@ import type {
UpdateOrderParams,
AddressParams,
StoreCreditCard,
+ StoreGiftCard,
StoreProduct,
StoreOrder,
StoreLineItem,
@@ -720,6 +721,31 @@ export class SpreeClient {
delete: (id: string, options?: RequestOptions): Promise<void> =>
this.request<void>('DELETE', `/customer/credit_cards/${id}`, options),
},
+
+ /**
+ * Nested resource: Gift Cards
+ */
+ giftCards: {
+ /**
+ * List customer gift cards
+ * Returns gift cards associated with the current user, ordered by newest first
+ */
+ list: (
+ params?: ListParams,
+ options?: RequestOptions
+ ): Promise<PaginatedResponse<StoreGiftCard>> =>
+ this.request<PaginatedResponse<StoreGiftCard>>(
+ 'GET',
+ '/customer/gift_cards',
+ { ...options, params: params as Record<string, string | number | undefined> }
+ ),
+
+ /**
+ * Get a gift card by ID
+ */
+ get: (id: string, options?: RequestOptions): Promise<StoreGiftCard> =>
+ this.request<StoreGiftCard>('GET', `/customer/gift_cards/${id}`, options),
+ },
};
// ============================================
diff --git a/sdk/src/types/generated/StoreGiftCard.ts b/sdk/src/types/generated/StoreGiftCard.ts
new file mode 100644
index 0000000000..13f59059d5
--- /dev/null
+++ b/sdk/src/types/generated/StoreGiftCard.ts
@@ -0,0 +1,25 @@
+// Typelizer digest 32a508dcbf20ef41857f34dac3f70252
+//
+// DO NOT MODIFY: This file was automatically generated by Typelizer.
+
+type StoreGiftCard = {
+ id: string;
+ code: string;
+ state: string;
+ currency: string;
+ amount: number;
+ amount_used: number;
+ amount_authorized: number;
+ amount_remaining: number;
+ display_amount: string;
+ display_amount_used: string;
+ display_amount_remaining: string;
+ expires_at: string | null;
+ redeemed_at: string | null;
+ expired: boolean;
+ active: boolean;
+ created_at: string;
+ updated_at: string;
+}
+
+export default StoreGiftCard;
diff --git a/sdk/src/types/generated/index.ts b/sdk/src/types/generated/index.ts
index b33cb27e1a..59a0d6a7ba 100644
--- a/sdk/src/types/generated/index.ts
+++ b/sdk/src/types/generated/index.ts
@@ -1,4 +1,4 @@
-// Typelizer digest ca58ea9c80739b0f8d98caf2b78e9064
+// Typelizer digest f9e985a15c3fe9b074b8366f27a534f9
//
// DO NOT MODIFY: This file was automatically generated by Typelizer.
export type { default as StoreAddress } from './StoreAddress'
@@ -14,6 +14,7 @@ export type { default as StoreBase } from './StoreBase'
export type { default as StoreCountry } from './StoreCountry'
export type { default as StoreCreditCard } from './StoreCreditCard'
export type { default as StoreDigitalLink } from './StoreDigitalLink'
+export type { default as StoreGiftCard } from './StoreGiftCard'
export type { default as StoreImage } from './StoreImage'
export type { default as StoreLineItem } from './StoreLineItem'
export type { default as StoreMetafield } from './StoreMetafield'