@longvansoftware/service-js-client 1.7.8 → 1.8.0

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.
@@ -1,2 +1,3 @@
1
1
  export declare const CREATE_ORDER: import("graphql").DocumentNode;
2
2
  export declare const UPDATE_QUANTITY_V2: import("graphql").DocumentNode;
3
+ export declare const ADD_TO_CART: import("graphql").DocumentNode;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UPDATE_QUANTITY_V2 = exports.CREATE_ORDER = void 0;
3
+ exports.ADD_TO_CART = exports.UPDATE_QUANTITY_V2 = exports.CREATE_ORDER = void 0;
4
4
  const graphql_tag_1 = require("graphql-tag");
5
5
  exports.CREATE_ORDER = (0, graphql_tag_1.gql) `
6
6
  mutation CreateOrder($input: CreateOrderInput!) {
@@ -270,3 +270,75 @@ exports.UPDATE_QUANTITY_V2 = (0, graphql_tag_1.gql) `
270
270
  }
271
271
  }
272
272
  `;
273
+ exports.ADD_TO_CART = (0, graphql_tag_1.gql) `
274
+ mutation AddToCart($serviceId: String!, $actorId: String!, $cartId: String) {
275
+ addToCart(serviceId: $serviceId, actorId: $actorId, cartId: $cartId) {
276
+ order {
277
+ financialStatus
278
+ orderStatus
279
+ ownerName
280
+ ownerEmail
281
+ ownerPhone
282
+ ownerPartyId
283
+ orderId
284
+ id
285
+ createdAt
286
+ currentTotalPrice {
287
+ amount
288
+ currencyCode
289
+ }
290
+ createdStamp
291
+ }
292
+ lineItems {
293
+ orderLineItem {
294
+ unitType
295
+ customAttributes {
296
+ key
297
+ value
298
+ }
299
+ id
300
+ orderItemId
301
+ quantity
302
+ totalVAT {
303
+ amount
304
+ currencyCode
305
+ }
306
+ variant {
307
+ id
308
+ price {
309
+ amount
310
+ currencyCode
311
+ }
312
+ product {
313
+ id
314
+ title
315
+ }
316
+ title
317
+ unitPrice {
318
+ amount
319
+ currencyCode
320
+ }
321
+ }
322
+ productOptions {
323
+ idOption
324
+ name
325
+ value
326
+ title
327
+ }
328
+ resourceItems {
329
+ name
330
+ quantity
331
+ unit
332
+ productId
333
+ }
334
+ resourceConfigs {
335
+ name
336
+ quantity
337
+ unit
338
+ productId
339
+ }
340
+ }
341
+ }
342
+ }
343
+ }
344
+ `;
@@ -72,6 +72,7 @@ export declare class OrderService extends Service {
72
72
  * @throws If an error occurs while updating the customer and shipping address.
73
73
  */
74
74
  updateCustomerAndShippingAddress(orderId: string, customerData: string, shippingAddress: string): Promise<any>;
75
+ updateCustomerInOrder(orderId: string, customerData: any): Promise<any>;
75
76
  /**
76
77
  * Retrieves the order line items for a specific order.
77
78
  * @param partnerId - The partner ID.
@@ -184,6 +184,21 @@ class OrderService extends serviceSDK_1.Service {
184
184
  }
185
185
  });
186
186
  }
187
+ updateCustomerInOrder(orderId, customerData) {
188
+ return __awaiter(this, void 0, void 0, function* () {
189
+ const endpoint = `/front/orders/${this.orgId}/${orderId}/customerInfo`;
190
+ const method = "PUT";
191
+ const requestData = Object.assign({}, customerData);
192
+ try {
193
+ const response = yield this.restApiCallWithToken(endpoint, method, requestData);
194
+ return response;
195
+ }
196
+ catch (error) {
197
+ console.log(`Error in updateCustomerInOrder: ${error}`);
198
+ throw error;
199
+ }
200
+ });
201
+ }
187
202
  /**
188
203
  * Retrieves the order line items for a specific order.
189
204
  * @param partnerId - The partner ID.
@@ -8,4 +8,5 @@ export declare class OrderGraphQLService extends Service {
8
8
  updateQuantityV2(payload: any): Promise<any>;
9
9
  getOrderLineItemByServiceId(serviceId: string): Promise<any>;
10
10
  getOrderByServiceId(serviceId: string): Promise<any>;
11
+ addToCart(serviceId: string, actorId: string, cartId: string): Promise<any>;
11
12
  }
@@ -102,5 +102,23 @@ class OrderGraphQLService extends serviceSDK_1.Service {
102
102
  }
103
103
  });
104
104
  }
105
+ addToCart(serviceId, actorId, cartId) {
106
+ return __awaiter(this, void 0, void 0, function* () {
107
+ const mutation = mutations_1.ADD_TO_CART;
108
+ const variables = {
109
+ serviceId,
110
+ actorId,
111
+ cartId
112
+ };
113
+ try {
114
+ const response = yield this.graphqlMutationV2(mutation, variables);
115
+ return response.addToCart;
116
+ }
117
+ catch (error) {
118
+ console.log(`Error in addToCart: ${error}`);
119
+ throw error;
120
+ }
121
+ });
122
+ }
105
123
  }
106
124
  exports.OrderGraphQLService = OrderGraphQLService;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longvansoftware/service-js-client",
3
- "version": "1.7.8",
3
+ "version": "1.8.0",
4
4
  "main": "dist/src/index.js",
5
5
  "types": "dist/src/index.d.ts",
6
6
  "files": [