@gethydra/sdk 0.1.29 → 0.1.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -20713,6 +20713,111 @@ declare class LookbooksResource {
20713
20713
  }>;
20714
20714
  }
20715
20715
 
20716
+ /** Gift card object returned by the API. */
20717
+ interface GiftCard {
20718
+ id: string;
20719
+ code: string;
20720
+ status: 'active' | 'deactivated';
20721
+ initial_balance: number;
20722
+ current_balance: number;
20723
+ currency: string;
20724
+ customer_id: string | null;
20725
+ source_order_id: string | null;
20726
+ recipient_email: string | null;
20727
+ recipient_name: string | null;
20728
+ sender_name: string | null;
20729
+ personal_message: string | null;
20730
+ note: string | null;
20731
+ expires_at: string | null;
20732
+ deactivated_at: string | null;
20733
+ metadata: Record<string, string | number>;
20734
+ created_at: string;
20735
+ updated_at: string;
20736
+ }
20737
+ /** Gift card transaction object returned by the API. */
20738
+ interface GiftCardTransaction {
20739
+ id: string;
20740
+ gift_card_id: string;
20741
+ type: 'credit' | 'debit' | 'refund';
20742
+ amount: number;
20743
+ balance_after: number;
20744
+ reason: string;
20745
+ note: string | null;
20746
+ related_order_id: string | null;
20747
+ related_refund_id: string | null;
20748
+ metadata: Record<string, string | number>;
20749
+ created_at: string;
20750
+ updated_at: string;
20751
+ }
20752
+ /** Reduced lookup response (safe for storefront/POS). */
20753
+ interface GiftCardLookup {
20754
+ current_balance: number;
20755
+ currency: string;
20756
+ status: 'active' | 'deactivated';
20757
+ expires_at: string | null;
20758
+ }
20759
+ type ListGiftCardsParams = {
20760
+ limit?: number;
20761
+ cursor?: string;
20762
+ sort?: 'created_at' | 'updated_at';
20763
+ order?: 'asc' | 'desc';
20764
+ status?: 'active' | 'deactivated';
20765
+ customer_id?: string;
20766
+ };
20767
+ type ListGiftCardTransactionsParams = {
20768
+ limit?: number;
20769
+ cursor?: string;
20770
+ sort?: 'created_at' | 'updated_at';
20771
+ order?: 'asc' | 'desc';
20772
+ };
20773
+ interface CreateGiftCardBody {
20774
+ initial_balance: number;
20775
+ currency?: string;
20776
+ customer_id?: string;
20777
+ recipient_email?: string;
20778
+ recipient_name?: string;
20779
+ sender_name?: string;
20780
+ personal_message?: string;
20781
+ note?: string;
20782
+ expires_at?: string;
20783
+ metadata?: Record<string, string | number>;
20784
+ }
20785
+ interface UpdateGiftCardBody {
20786
+ note?: string | null;
20787
+ expires_at?: string | null;
20788
+ recipient_email?: string | null;
20789
+ recipient_name?: string | null;
20790
+ sender_name?: string | null;
20791
+ personal_message?: string | null;
20792
+ metadata?: Record<string, string | number>;
20793
+ }
20794
+ interface CreditDebitBody {
20795
+ amount: number;
20796
+ note?: string;
20797
+ }
20798
+ declare class GiftCardsResource {
20799
+ private client;
20800
+ constructor(client: Hydra);
20801
+ list(params?: ListGiftCardsParams): Promise<ListResponse<GiftCard>>;
20802
+ iterate(params?: Omit<ListGiftCardsParams, 'cursor'>, options?: PaginateOptions): AsyncGenerator<GiftCard, void, undefined>;
20803
+ toArray(params?: Omit<ListGiftCardsParams, 'cursor'>, options?: PaginateOptions & {
20804
+ limit?: number;
20805
+ }): Promise<GiftCard[]>;
20806
+ get(id: string): Promise<DataResponse<GiftCard>>;
20807
+ create(body: CreateGiftCardBody, options?: ResourceRequestOptions): Promise<DataResponse<GiftCard>>;
20808
+ update(id: string, body: UpdateGiftCardBody): Promise<DataResponse<GiftCard>>;
20809
+ deactivate(id: string): Promise<DataResponse<GiftCard>>;
20810
+ listTransactions(id: string, params?: ListGiftCardTransactionsParams): Promise<ListResponse<GiftCardTransaction>>;
20811
+ iterateTransactions(id: string, params?: Omit<ListGiftCardTransactionsParams, 'cursor'>, options?: PaginateOptions): AsyncGenerator<GiftCardTransaction, void, undefined>;
20812
+ transactionsToArray(id: string, params?: Omit<ListGiftCardTransactionsParams, 'cursor'>, options?: PaginateOptions & {
20813
+ limit?: number;
20814
+ }): Promise<GiftCardTransaction[]>;
20815
+ credit(id: string, body: CreditDebitBody, options?: ResourceRequestOptions): Promise<DataResponse<GiftCard>>;
20816
+ debit(id: string, body: CreditDebitBody, options?: ResourceRequestOptions): Promise<DataResponse<GiftCard>>;
20817
+ /** Look up a gift card by code (publishable key OK). */
20818
+ lookup(code: string): Promise<DataResponse<GiftCardLookup>>;
20819
+ }
20820
+
20716
20821
  interface AppInfo {
20717
20822
  /** Integration/plugin name (e.g. "MyShopTheme") */
20718
20823
  name: string;
@@ -20796,6 +20901,7 @@ declare class Hydra {
20796
20901
  readonly membershipPlans: MembershipPlansResource;
20797
20902
  readonly bookings: BookingsResource;
20798
20903
  readonly lookbooks: LookbooksResource;
20904
+ readonly giftCards: GiftCardsResource;
20799
20905
  constructor(config: HydraConfig);
20800
20906
  request<T>(method: string, path: string, options?: RequestOptions): Promise<T>;
20801
20907
  /** Multipart upload for file-based endpoints (e.g. images) */
@@ -20877,4 +20983,4 @@ declare class HydraIdempotencyError extends HydraError {
20877
20983
  constructor(body: HydraErrorBody, headers: Headers);
20878
20984
  }
20879
20985
 
20880
- export { AddressesResource, type AnalyticsActionItems$1 as AnalyticsActionItems, type AnalyticsOrdersSeries$1 as AnalyticsOrdersSeries, AnalyticsResource, type AnalyticsSummary$1 as AnalyticsSummary, type AnalyticsTimeSeries$1 as AnalyticsTimeSeries, type AnalyticsTopProduct$1 as AnalyticsTopProduct, type AppInfo, type Appointment$1 as Appointment, type AvailabilityOverride$1 as AvailabilityOverride, BookingsResource, type Cart$1 as Cart, type CartItem, CartResource, type Channel$1 as Channel, ChannelsResource, type CheckoutCreate$1 as CheckoutCreate, type CheckoutGet$1 as CheckoutGet, type CheckoutListItem$1 as CheckoutListItem, CheckoutResource, CheckoutsResource, type Collection$1 as Collection, CollectionsResource, CompaniesResource, type Company$1 as Company, ContentCategoriesResource, type ContentCategory$1 as ContentCategory, type Customer$1 as Customer, type CustomerGroup$1 as CustomerGroup, CustomerGroupsResource, type CustomerMembership$1 as CustomerMembership, type CustomerPhoto$1 as CustomerPhoto, CustomerPhotosResource, CustomersResource, type DataResponse, type DayAvailability$1 as DayAvailability, type Discount$1 as Discount, DiscountsResource, type DraftOrder$1 as DraftOrder, DraftOrdersResource, type ExchangeRate$1 as ExchangeRate, ExchangeRatesResource, type Fulfillment$1 as Fulfillment, type FulfillmentOrder$2 as FulfillmentOrder, FulfillmentOrdersResource, FulfillmentsResource, type GenerateVariantsResult$1 as GenerateVariantsResult, Hydra, HydraAuthenticationError, type HydraConfig, HydraConnectionError, HydraError, type HydraErrorBody, HydraIdempotencyError, HydraNotFoundError, HydraPermissionError, HydraRateLimitError, HydraValidationError, type Image$2 as Image, ImagesResource, IntegrationsResource, type InventoryLevel$1 as InventoryLevel, InventoryResource, type ListResponse, type Location$1 as Location, LocationsResource, type Lookbook$1 as Lookbook, type LookbookTag$1 as LookbookTag, LookbooksResource, type MembershipPlan$1 as MembershipPlan, MembershipPlansResource, MetafieldsResource, type NotificationLog$1 as NotificationLog, NotificationsResource, type Order$2 as Order, OrdersResource, type PaginateOptions, type Pagination, type Post$1 as Post, PostsResource, type Product$1 as Product, type ProductStats$1 as ProductStats, ProductsResource, type Promotion$1 as Promotion, PromotionsResource, type PurchaseOrder$1 as PurchaseOrder, PurchaseOrdersResource, type Redirect$1 as Redirect, RedirectsResource, type Refund$1 as Refund, RefundsResource, type RequestOptions, type ResourceRequestOptions, type Return$1 as Return, ReturnsResource, SearchResource, type ShippingRate$1 as ShippingRate, ShippingResource, type ShippingZone$1 as ShippingZone, type Slot, type Store$1 as Store, StoreCreditResource, StoreResource, type SuggestedSlot$1 as SuggestedSlot, type Tag$1 as Tag, TagsResource, type TaxExemption$1 as TaxExemption, type TaxGroup$1 as TaxGroup, type TaxRate$1 as TaxRate, TaxResource, type Variant$2 as Variant, type VariantPrice$1 as VariantPrice, VariantsResource, type Webhook$1 as Webhook, WebhooksResource, paginate, toArray };
20986
+ export { AddressesResource, type AnalyticsActionItems$1 as AnalyticsActionItems, type AnalyticsOrdersSeries$1 as AnalyticsOrdersSeries, AnalyticsResource, type AnalyticsSummary$1 as AnalyticsSummary, type AnalyticsTimeSeries$1 as AnalyticsTimeSeries, type AnalyticsTopProduct$1 as AnalyticsTopProduct, type AppInfo, type Appointment$1 as Appointment, type AvailabilityOverride$1 as AvailabilityOverride, BookingsResource, type Cart$1 as Cart, type CartItem, CartResource, type Channel$1 as Channel, ChannelsResource, type CheckoutCreate$1 as CheckoutCreate, type CheckoutGet$1 as CheckoutGet, type CheckoutListItem$1 as CheckoutListItem, CheckoutResource, CheckoutsResource, type Collection$1 as Collection, CollectionsResource, CompaniesResource, type Company$1 as Company, ContentCategoriesResource, type ContentCategory$1 as ContentCategory, type CreateGiftCardBody, type Customer$1 as Customer, type CustomerGroup$1 as CustomerGroup, CustomerGroupsResource, type CustomerMembership$1 as CustomerMembership, type CustomerPhoto$1 as CustomerPhoto, CustomerPhotosResource, CustomersResource, type DataResponse, type DayAvailability$1 as DayAvailability, type Discount$1 as Discount, DiscountsResource, type DraftOrder$1 as DraftOrder, DraftOrdersResource, type ExchangeRate$1 as ExchangeRate, ExchangeRatesResource, type Fulfillment$1 as Fulfillment, type FulfillmentOrder$2 as FulfillmentOrder, FulfillmentOrdersResource, FulfillmentsResource, type GenerateVariantsResult$1 as GenerateVariantsResult, type GiftCard, type CreditDebitBody as GiftCardCreditDebitBody, type GiftCardLookup, type GiftCardTransaction, GiftCardsResource, Hydra, HydraAuthenticationError, type HydraConfig, HydraConnectionError, HydraError, type HydraErrorBody, HydraIdempotencyError, HydraNotFoundError, HydraPermissionError, HydraRateLimitError, HydraValidationError, type Image$2 as Image, ImagesResource, IntegrationsResource, type InventoryLevel$1 as InventoryLevel, InventoryResource, type ListGiftCardTransactionsParams, type ListGiftCardsParams, type ListResponse, type Location$1 as Location, LocationsResource, type Lookbook$1 as Lookbook, type LookbookTag$1 as LookbookTag, LookbooksResource, type MembershipPlan$1 as MembershipPlan, MembershipPlansResource, MetafieldsResource, type NotificationLog$1 as NotificationLog, NotificationsResource, type Order$2 as Order, OrdersResource, type PaginateOptions, type Pagination, type Post$1 as Post, PostsResource, type Product$1 as Product, type ProductStats$1 as ProductStats, ProductsResource, type Promotion$1 as Promotion, PromotionsResource, type PurchaseOrder$1 as PurchaseOrder, PurchaseOrdersResource, type Redirect$1 as Redirect, RedirectsResource, type Refund$1 as Refund, RefundsResource, type RequestOptions, type ResourceRequestOptions, type Return$1 as Return, ReturnsResource, SearchResource, type ShippingRate$1 as ShippingRate, ShippingResource, type ShippingZone$1 as ShippingZone, type Slot, type Store$1 as Store, StoreCreditResource, StoreResource, type SuggestedSlot$1 as SuggestedSlot, type Tag$1 as Tag, TagsResource, type TaxExemption$1 as TaxExemption, type TaxGroup$1 as TaxGroup, type TaxRate$1 as TaxRate, TaxResource, type UpdateGiftCardBody, type Variant$2 as Variant, type VariantPrice$1 as VariantPrice, VariantsResource, type Webhook$1 as Webhook, WebhooksResource, paginate, toArray };
package/dist/index.js CHANGED
@@ -1746,6 +1746,57 @@ var LookbooksResource = class {
1746
1746
  }
1747
1747
  };
1748
1748
 
1749
+ // src/resources/gift-cards.ts
1750
+ var GiftCardsResource = class {
1751
+ constructor(client) {
1752
+ this.client = client;
1753
+ }
1754
+ client;
1755
+ async list(params) {
1756
+ return this.client.request("GET", "/v1/gift-cards", { params });
1757
+ }
1758
+ iterate(params, options) {
1759
+ return paginate((cursor) => this.list({ ...params, cursor }), options);
1760
+ }
1761
+ async toArray(params, options) {
1762
+ return toArray(this.iterate(params, options), options);
1763
+ }
1764
+ async get(id) {
1765
+ return this.client.request("GET", `/v1/gift-cards/${id}`);
1766
+ }
1767
+ async create(body, options) {
1768
+ return this.client.request("POST", "/v1/gift-cards", { body, ...options });
1769
+ }
1770
+ async update(id, body) {
1771
+ return this.client.request("PUT", `/v1/gift-cards/${id}`, { body });
1772
+ }
1773
+ async deactivate(id) {
1774
+ return this.client.request("POST", `/v1/gift-cards/${id}/deactivate`);
1775
+ }
1776
+ async listTransactions(id, params) {
1777
+ return this.client.request("GET", `/v1/gift-cards/${id}/transactions`, { params });
1778
+ }
1779
+ iterateTransactions(id, params, options) {
1780
+ return paginate(
1781
+ (cursor) => this.listTransactions(id, { ...params, cursor }),
1782
+ options
1783
+ );
1784
+ }
1785
+ async transactionsToArray(id, params, options) {
1786
+ return toArray(this.iterateTransactions(id, params, options), options);
1787
+ }
1788
+ async credit(id, body, options) {
1789
+ return this.client.request("POST", `/v1/gift-cards/${id}/credit`, { body, ...options });
1790
+ }
1791
+ async debit(id, body, options) {
1792
+ return this.client.request("POST", `/v1/gift-cards/${id}/debit`, { body, ...options });
1793
+ }
1794
+ /** Look up a gift card by code (publishable key OK). */
1795
+ async lookup(code) {
1796
+ return this.client.request("GET", "/v1/gift-cards/lookup", { params: { code } });
1797
+ }
1798
+ };
1799
+
1749
1800
  // src/client.ts
1750
1801
  var SDK_VERSION = "0.1.0";
1751
1802
  var INITIAL_RETRY_DELAY = 0.5;
@@ -1830,6 +1881,8 @@ var Hydra = class {
1830
1881
  bookings = new BookingsResource(this);
1831
1882
  // P10: Lookbooks
1832
1883
  lookbooks = new LookbooksResource(this);
1884
+ // P11: Gift Cards
1885
+ giftCards = new GiftCardsResource(this);
1833
1886
  constructor(config) {
1834
1887
  for (const key of Object.keys(config)) {
1835
1888
  if (!VALID_CONFIG_KEYS.has(key)) {
@@ -2054,6 +2107,7 @@ export {
2054
2107
  ExchangeRatesResource,
2055
2108
  FulfillmentOrdersResource,
2056
2109
  FulfillmentsResource,
2110
+ GiftCardsResource,
2057
2111
  Hydra,
2058
2112
  HydraAuthenticationError,
2059
2113
  HydraConnectionError,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gethydra/sdk",
3
- "version": "0.1.29",
3
+ "version": "0.1.30",
4
4
  "description": "Official TypeScript SDK for the Hydra Commerce API",
5
5
  "license": "MIT",
6
6
  "author": "Grant Capital Group",