@commercengine/storefront-sdk 0.3.2 → 0.3.4

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.
@@ -223,7 +223,11 @@ export class StorefrontAPIClient {
223
223
  if (error) {
224
224
  return { data: null, error };
225
225
  }
226
- // data will be defined for 2xx responses
226
+ // If response has content, return it directly
227
+ if (data && data.content !== undefined) {
228
+ return { data: data.content, error: null };
229
+ }
230
+ // If no content, return the response object (with message, success, etc.)
227
231
  return { data: data, error: null };
228
232
  }
229
233
  catch (err) {
@@ -1,4 +1,4 @@
1
- import type { ApiResult, ShippingMethodsBody, ShippingMethodsContent } from "../types/storefront-api-types";
1
+ import type { ApiResult, CheckDeliveryAvailabilityPathParams, CheckDeliveryAvailabilityResponse, ShippingMethodsBody, ShippingMethodsContent } from "../types/storefront-api-types";
2
2
  import { StorefrontAPIClient } from "./client";
3
3
  /**
4
4
  * Client for interacting with shipping endpoints
@@ -11,4 +11,11 @@ export declare class ShippingClient extends StorefrontAPIClient {
11
11
  * @returns Promise with shipping options
12
12
  */
13
13
  getShippingMethods(body: ShippingMethodsBody): Promise<ApiResult<ShippingMethodsContent>>;
14
+ /**
15
+ * Check pincode deliverability
16
+ *
17
+ * @param pathParams - Path parameters
18
+ * @returns Promise with pincode deliverability result
19
+ */
20
+ checkPincodeDeliverability(pathParams: CheckDeliveryAvailabilityPathParams): Promise<ApiResult<CheckDeliveryAvailabilityResponse>>;
14
21
  }
@@ -14,4 +14,17 @@ export class ShippingClient extends StorefrontAPIClient {
14
14
  body: body,
15
15
  }));
16
16
  }
17
+ /**
18
+ * Check pincode deliverability
19
+ *
20
+ * @param pathParams - Path parameters
21
+ * @returns Promise with pincode deliverability result
22
+ */
23
+ async checkPincodeDeliverability(pathParams) {
24
+ return this.executeRequest(() => this.client.GET("/shipment/pincode-serviceability/{pincode}", {
25
+ params: {
26
+ path: pathParams,
27
+ },
28
+ }));
29
+ }
17
30
  }
@@ -1,10 +1,6 @@
1
1
  import type { paths } from './storefront';
2
2
  export type ApiResult<T> = {
3
- data: {
4
- message?: string;
5
- success?: boolean;
6
- content?: T;
7
- };
3
+ data: T;
8
4
  error: null;
9
5
  } | {
10
6
  data: null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@commercengine/storefront-sdk",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "description": "TypeScript SDK for the Storefront API",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",