@gethydra/sdk 0.1.28 → 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 +160 -1
- package/dist/index.js +54 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1719,6 +1719,23 @@ interface components {
|
|
|
1719
1719
|
unit_price: number;
|
|
1720
1720
|
/** @example 5998 */
|
|
1721
1721
|
total: number;
|
|
1722
|
+
/**
|
|
1723
|
+
* @description Resolved discount in minor units.
|
|
1724
|
+
* @example 0
|
|
1725
|
+
*/
|
|
1726
|
+
discount_amount: number;
|
|
1727
|
+
/**
|
|
1728
|
+
* @example null
|
|
1729
|
+
* @enum {string|null}
|
|
1730
|
+
*/
|
|
1731
|
+
discount_type: "percentage" | "fixed_amount" | null;
|
|
1732
|
+
/**
|
|
1733
|
+
* @description Original input value. Percentage × 100 or pence.
|
|
1734
|
+
* @example null
|
|
1735
|
+
*/
|
|
1736
|
+
discount_value: number | null;
|
|
1737
|
+
/** @example null */
|
|
1738
|
+
discount_reason: string | null;
|
|
1722
1739
|
/**
|
|
1723
1740
|
* Format: date-time
|
|
1724
1741
|
* @example 2026-03-10T16:45:00.000Z
|
|
@@ -11569,6 +11586,22 @@ interface operations {
|
|
|
11569
11586
|
quantity: number;
|
|
11570
11587
|
/** @example 2999 */
|
|
11571
11588
|
unit_price?: number;
|
|
11589
|
+
/**
|
|
11590
|
+
* @description Type of discount applied to this line item.
|
|
11591
|
+
* @example percentage
|
|
11592
|
+
* @enum {string}
|
|
11593
|
+
*/
|
|
11594
|
+
discount_type?: "percentage" | "fixed_amount";
|
|
11595
|
+
/**
|
|
11596
|
+
* @description Discount input value. For percentage: value × 100 (1000 = 10%). For fixed_amount: pence.
|
|
11597
|
+
* @example 1000
|
|
11598
|
+
*/
|
|
11599
|
+
discount_value?: number;
|
|
11600
|
+
/**
|
|
11601
|
+
* @description Free-text reason for the line discount.
|
|
11602
|
+
* @example Damaged packaging
|
|
11603
|
+
*/
|
|
11604
|
+
discount_reason?: string;
|
|
11572
11605
|
}[];
|
|
11573
11606
|
/** @default [] */
|
|
11574
11607
|
custom_items?: {
|
|
@@ -11578,6 +11611,22 @@ interface operations {
|
|
|
11578
11611
|
quantity: number;
|
|
11579
11612
|
/** @example 1500 */
|
|
11580
11613
|
unit_price: number;
|
|
11614
|
+
/**
|
|
11615
|
+
* @description Type of discount applied to this custom line item.
|
|
11616
|
+
* @example percentage
|
|
11617
|
+
* @enum {string}
|
|
11618
|
+
*/
|
|
11619
|
+
discount_type?: "percentage" | "fixed_amount";
|
|
11620
|
+
/**
|
|
11621
|
+
* @description Discount input value. For percentage: value × 100 (1000 = 10%). For fixed_amount: pence.
|
|
11622
|
+
* @example 1000
|
|
11623
|
+
*/
|
|
11624
|
+
discount_value?: number;
|
|
11625
|
+
/**
|
|
11626
|
+
* @description Free-text reason for the line discount.
|
|
11627
|
+
* @example Staff discount
|
|
11628
|
+
*/
|
|
11629
|
+
discount_reason?: string;
|
|
11581
11630
|
}[];
|
|
11582
11631
|
shipping_address?: {
|
|
11583
11632
|
first_name?: string;
|
|
@@ -16348,6 +16397,10 @@ interface operations {
|
|
|
16348
16397
|
line_items: {
|
|
16349
16398
|
variant_id: string;
|
|
16350
16399
|
quantity: number;
|
|
16400
|
+
/** @enum {string} */
|
|
16401
|
+
discount_type?: "percentage" | "fixed_amount";
|
|
16402
|
+
discount_value?: number;
|
|
16403
|
+
discount_reason?: string;
|
|
16351
16404
|
}[];
|
|
16352
16405
|
location_id: string;
|
|
16353
16406
|
/** @default 0 */
|
|
@@ -20660,6 +20713,111 @@ declare class LookbooksResource {
|
|
|
20660
20713
|
}>;
|
|
20661
20714
|
}
|
|
20662
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
|
+
|
|
20663
20821
|
interface AppInfo {
|
|
20664
20822
|
/** Integration/plugin name (e.g. "MyShopTheme") */
|
|
20665
20823
|
name: string;
|
|
@@ -20743,6 +20901,7 @@ declare class Hydra {
|
|
|
20743
20901
|
readonly membershipPlans: MembershipPlansResource;
|
|
20744
20902
|
readonly bookings: BookingsResource;
|
|
20745
20903
|
readonly lookbooks: LookbooksResource;
|
|
20904
|
+
readonly giftCards: GiftCardsResource;
|
|
20746
20905
|
constructor(config: HydraConfig);
|
|
20747
20906
|
request<T>(method: string, path: string, options?: RequestOptions): Promise<T>;
|
|
20748
20907
|
/** Multipart upload for file-based endpoints (e.g. images) */
|
|
@@ -20824,4 +20983,4 @@ declare class HydraIdempotencyError extends HydraError {
|
|
|
20824
20983
|
constructor(body: HydraErrorBody, headers: Headers);
|
|
20825
20984
|
}
|
|
20826
20985
|
|
|
20827
|
-
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,
|