@instockng/api-client 1.0.22 → 1.0.25

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.
@@ -3,11 +3,9 @@
3
3
  *
4
4
  * These are the actual data-fetching functions used by hooks.
5
5
  * They can also be imported directly in Server Components.
6
- *
7
- * API URL is hardcoded to https://oms-api.instock.ng
8
6
  */
9
7
  import { createRpcClients } from '../rpc-client';
10
- const API_URL = 'https://oms-api.instock.ng';
8
+ import { API_BASE_URL } from '../provider';
11
9
  /**
12
10
  * Fetch a cart by ID
13
11
  *
@@ -15,7 +13,7 @@ const API_URL = 'https://oms-api.instock.ng';
15
13
  * @returns Cart with items, brand, and delivery zone
16
14
  */
17
15
  export async function fetchCart(cartId) {
18
- const clients = createRpcClients(API_URL);
16
+ const clients = createRpcClients(API_BASE_URL);
19
17
  const res = await clients.carts[':id'].$get({
20
18
  param: { id: cartId },
21
19
  });
@@ -31,7 +29,7 @@ export async function fetchCart(cartId) {
31
29
  * @returns Newly created cart
32
30
  */
33
31
  export async function createCart(brandSlug) {
34
- const clients = createRpcClients(API_URL);
32
+ const clients = createRpcClients(API_BASE_URL);
35
33
  const res = await clients.carts.index.$post({
36
34
  json: { brandSlug },
37
35
  });
@@ -48,7 +46,7 @@ export async function createCart(brandSlug) {
48
46
  * @returns Updated cart
49
47
  */
50
48
  export async function updateCart(cartId, data) {
51
- const clients = createRpcClients(API_URL);
49
+ const clients = createRpcClients(API_BASE_URL);
52
50
  const res = await clients.carts[':id'].$patch({
53
51
  param: { id: cartId },
54
52
  // @ts-expect-error - Hono RPC type inference issue
@@ -72,7 +70,7 @@ export async function updateCart(cartId, data) {
72
70
  * @returns Updated cart
73
71
  */
74
72
  export async function addCartItem(cartId, sku, quantity, fbc, fbp, ttp, ttclid) {
75
- const clients = createRpcClients(API_URL);
73
+ const clients = createRpcClients(API_BASE_URL);
76
74
  const res = await clients.carts[':id'].items.$post({
77
75
  param: { id: cartId },
78
76
  // @ts-expect-error - Hono RPC type inference issue
@@ -92,7 +90,7 @@ export async function addCartItem(cartId, sku, quantity, fbc, fbp, ttp, ttclid)
92
90
  * @returns Updated cart
93
91
  */
94
92
  export async function updateCartItem(cartId, itemId, quantity) {
95
- const clients = createRpcClients(API_URL);
93
+ const clients = createRpcClients(API_BASE_URL);
96
94
  const res = await clients.carts[':id'].items[':itemId'].$patch({
97
95
  param: { id: cartId, itemId },
98
96
  // @ts-expect-error - Hono RPC type inference issue
@@ -111,7 +109,7 @@ export async function updateCartItem(cartId, itemId, quantity) {
111
109
  * @returns Updated cart
112
110
  */
113
111
  export async function removeCartItem(cartId, itemId) {
114
- const clients = createRpcClients(API_URL);
112
+ const clients = createRpcClients(API_BASE_URL);
115
113
  const res = await clients.carts[':id'].items[':itemId'].$delete({
116
114
  param: { id: cartId, itemId },
117
115
  });
@@ -128,7 +126,7 @@ export async function removeCartItem(cartId, itemId) {
128
126
  * @returns Updated cart
129
127
  */
130
128
  export async function applyDiscount(cartId, code) {
131
- const clients = createRpcClients(API_URL);
129
+ const clients = createRpcClients(API_BASE_URL);
132
130
  const res = await clients.carts[':id']['apply-discount'].$post({
133
131
  param: { id: cartId },
134
132
  // @ts-expect-error - Hono RPC type inference issue
@@ -146,7 +144,7 @@ export async function applyDiscount(cartId, code) {
146
144
  * @returns Updated cart
147
145
  */
148
146
  export async function removeDiscount(cartId) {
149
- const clients = createRpcClients(API_URL);
147
+ const clients = createRpcClients(API_BASE_URL);
150
148
  const res = await clients.carts[':id']['remove-discount'].$post({
151
149
  param: { id: cartId },
152
150
  });
@@ -163,7 +161,7 @@ export async function removeDiscount(cartId) {
163
161
  * @returns Created order
164
162
  */
165
163
  export async function checkoutCart(cartId, checkoutData) {
166
- const clients = createRpcClients(API_URL);
164
+ const clients = createRpcClients(API_BASE_URL);
167
165
  const res = await clients.carts[':id'].checkout.$post({
168
166
  param: { id: cartId },
169
167
  // @ts-expect-error - Hono RPC type inference issue
@@ -182,7 +180,7 @@ export async function checkoutCart(cartId, checkoutData) {
182
180
  * @returns Array of recommended products from the same brand
183
181
  */
184
182
  export async function fetchCartRecommendations(cartId, limit) {
185
- const clients = createRpcClients(API_URL);
183
+ const clients = createRpcClients(API_BASE_URL);
186
184
  const res = await clients.carts[':id'].recommendations.$get({
187
185
  param: { id: cartId },
188
186
  // @ts-ignore - Hono RPC type inference issue with query parameters
@@ -3,8 +3,6 @@
3
3
  *
4
4
  * These are the actual data-fetching functions used by hooks.
5
5
  * They can also be imported directly in Server Components.
6
- *
7
- * API URL is hardcoded to https://oms-api.instock.ng
8
6
  */
9
7
  /**
10
8
  * Fetch delivery zones
@@ -3,11 +3,9 @@
3
3
  *
4
4
  * These are the actual data-fetching functions used by hooks.
5
5
  * They can also be imported directly in Server Components.
6
- *
7
- * API URL is hardcoded to https://oms-api.instock.ng
8
6
  */
9
7
  import { createRpcClients } from '../rpc-client';
10
- const API_URL = 'https://oms-api.instock.ng';
8
+ import { API_BASE_URL } from '../provider';
11
9
  /**
12
10
  * Fetch delivery zones
13
11
  *
@@ -15,7 +13,7 @@ const API_URL = 'https://oms-api.instock.ng';
15
13
  * @returns List of delivery zones with states
16
14
  */
17
15
  export async function fetchDeliveryZones(brandId) {
18
- const clients = createRpcClients(API_URL);
16
+ const clients = createRpcClients(API_BASE_URL);
19
17
  const res = await clients.deliveryZones.index.$get({
20
18
  query: brandId ? { brandId } : {},
21
19
  });