@longvansoftware/storefront-js-client 0.0.2 → 1.0.1

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.
Files changed (51) hide show
  1. package/dist/config/config.d.ts +18 -0
  2. package/dist/config/config.js +21 -0
  3. package/dist/src/graphql/auth/mutations.d.ts +7 -0
  4. package/dist/src/graphql/auth/mutations.js +99 -0
  5. package/dist/src/graphql/crm/mutations.d.ts +6 -0
  6. package/dist/src/graphql/crm/mutations.js +258 -0
  7. package/dist/src/graphql/crm/queries.d.ts +3 -0
  8. package/dist/src/graphql/crm/queries.js +155 -0
  9. package/dist/src/graphql/payment/mutations.d.ts +1 -0
  10. package/dist/src/graphql/payment/mutations.js +35 -0
  11. package/dist/src/graphql/payment/queries.d.ts +1 -0
  12. package/dist/src/graphql/payment/queries.js +12 -0
  13. package/dist/src/graphql/product/mutations.d.ts +0 -0
  14. package/dist/src/graphql/product/mutations.js +1 -0
  15. package/dist/src/graphql/product/queries.d.ts +10 -0
  16. package/dist/src/graphql/product/queries.js +415 -0
  17. package/dist/src/graphql/user/mutations.d.ts +3 -0
  18. package/dist/src/graphql/user/mutations.js +87 -0
  19. package/dist/src/graphql/user/queries.d.ts +3 -0
  20. package/dist/src/graphql/user/queries.js +67 -0
  21. package/dist/src/index.d.ts +1 -0
  22. package/dist/src/index.js +5 -0
  23. package/dist/src/lib/SDK.d.ts +28 -0
  24. package/dist/src/lib/SDK.js +43 -0
  25. package/dist/src/lib/auth/index.d.ts +26 -0
  26. package/dist/src/lib/auth/index.js +54 -0
  27. package/dist/src/lib/crm/index.d.ts +14 -0
  28. package/dist/src/lib/crm/index.js +185 -0
  29. package/dist/src/lib/order/index.d.ts +87 -0
  30. package/dist/src/lib/order/index.js +209 -0
  31. package/dist/src/lib/payment/index.d.ts +6 -0
  32. package/dist/src/lib/payment/index.js +50 -0
  33. package/dist/src/lib/product/index.d.ts +36 -0
  34. package/dist/src/lib/product/index.js +116 -0
  35. package/dist/src/lib/service.d.ts +14 -0
  36. package/dist/src/lib/service.js +97 -0
  37. package/dist/src/lib/user/index.d.ts +11 -0
  38. package/dist/src/lib/user/index.js +135 -0
  39. package/dist/src/types/auth.d.ts +82 -0
  40. package/dist/src/types/auth.js +2 -0
  41. package/dist/src/types/crm.d.ts +219 -0
  42. package/dist/src/types/crm.js +2 -0
  43. package/dist/src/types/order.d.ts +7 -0
  44. package/dist/src/types/order.js +2 -0
  45. package/dist/src/types/product.d.ts +61 -0
  46. package/dist/src/types/product.js +2 -0
  47. package/dist/src/types/user.d.ts +49 -0
  48. package/dist/src/types/user.js +2 -0
  49. package/dist/src/utils/helpers.d.ts +4 -0
  50. package/dist/src/utils/helpers.js +41 -0
  51. package/package.json +25 -19
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.AuthService = void 0;
13
+ const service_1 = require("../service");
14
+ const mutations_1 = require("../../graphql/auth/mutations");
15
+ /**
16
+ * Represents the authentication service.
17
+ */
18
+ class AuthService extends service_1.Service {
19
+ /**
20
+ * Constructs a new ProductService instance.
21
+ * @param endpoint - The endpoint URL for the service.
22
+ * @param orgId - The organization ID.
23
+ * @param storeId - The store ID.
24
+ */
25
+ constructor(endpoint, orgId, storeId) {
26
+ super(endpoint, orgId, storeId);
27
+ }
28
+ /**
29
+ * Logs in a user with the provided login request.
30
+ * @param loginRequest - The login request object.
31
+ * @returns A promise that resolves to the login response.
32
+ */
33
+ login(loginRequest) {
34
+ return __awaiter(this, void 0, void 0, function* () {
35
+ const variables = {
36
+ loginRequest: Object.assign({ orgId: this.orgId }, loginRequest),
37
+ };
38
+ const data = yield this.graphqlMutation(mutations_1.LOGIN_MUTATION, variables);
39
+ return data.login;
40
+ });
41
+ }
42
+ /**
43
+ * Registers a new user with the provided register request.
44
+ * @param registerRequest - The register request object.
45
+ * @returns A promise that resolves when the registration is successful.
46
+ */
47
+ register(registerRequest) {
48
+ return __awaiter(this, void 0, void 0, function* () {
49
+ const variables = { registerRequest };
50
+ yield this.graphqlMutation(mutations_1.REGISTER_MUTATION, variables);
51
+ });
52
+ }
53
+ }
54
+ exports.AuthService = AuthService;
@@ -0,0 +1,14 @@
1
+ import { AddOpportunityRequest, GetOpportunityRequest } from '../../types/crm';
2
+ import { Service } from '../service';
3
+ export declare class CrmService extends Service {
4
+ constructor(endpoint: string, orgId: string, storeId: string);
5
+ addOpportunity(addOpportunityRequest: AddOpportunityRequest, performerId: string): Promise<any>;
6
+ getListOpportunity(performerId: string, getOpportunityRequest: GetOpportunityRequest): Promise<any>;
7
+ getListTodo(workEffortId: string[]): Promise<any>;
8
+ getListWorkEffortType(id: string): Promise<any>;
9
+ updateStatusAttachmentById(performerId: string, attachmentId: string, status: string): Promise<any>;
10
+ updateWorkEffortDescription(performerId: string, workEffortId: string, description: string): Promise<any>;
11
+ updateWorkEffortName(performerId: string, workEffortId: string, name: string): Promise<any>;
12
+ updateWorkEffortStatus(performerId: string, workEffortId: string, source: string, status: string): Promise<any>;
13
+ addAttachmentForWorkEffort(performerId: string, workEffortId: string, attachments: [{}]): Promise<any>;
14
+ }
@@ -0,0 +1,185 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.CrmService = void 0;
13
+ const mutations_1 = require("../../graphql/crm/mutations");
14
+ const queries_1 = require("../../graphql/crm/queries");
15
+ const service_1 = require("../service");
16
+ class CrmService extends service_1.Service {
17
+ constructor(endpoint, orgId, storeId) {
18
+ super(endpoint, orgId, storeId);
19
+ }
20
+ addOpportunity(addOpportunityRequest, performerId) {
21
+ return __awaiter(this, void 0, void 0, function* () {
22
+ const mutation = mutations_1.ADD_OPPORTUNITY_MUTATION;
23
+ const variables = {
24
+ partyId: this.orgId,
25
+ addOpportunityRequest,
26
+ performerId,
27
+ };
28
+ try {
29
+ const response = yield this.graphqlMutation(mutation, variables);
30
+ return response.addOpportunity;
31
+ }
32
+ catch (error) {
33
+ console.log(`Error in addOpportunity: ${error}`);
34
+ throw error;
35
+ }
36
+ });
37
+ }
38
+ getListOpportunity(performerId, getOpportunityRequest) {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ const query = queries_1.GET_LIST_OPPORTUNITY_QUERY;
41
+ const variables = {
42
+ partyId: this.orgId,
43
+ performerId,
44
+ getOpportunityRequest,
45
+ };
46
+ try {
47
+ const response = yield this.graphqlQuery(query, variables);
48
+ return response.getListOpportunity;
49
+ }
50
+ catch (error) {
51
+ console.log(`Error in getListOpportunity: ${error}`);
52
+ throw error;
53
+ }
54
+ });
55
+ }
56
+ getListTodo(workEffortId) {
57
+ return __awaiter(this, void 0, void 0, function* () {
58
+ const query = queries_1.GET_LIST_TODO;
59
+ const variables = {
60
+ partyId: this.orgId,
61
+ workEffortId
62
+ };
63
+ try {
64
+ const response = yield this.graphqlQuery(query, variables);
65
+ return response.getListTodo;
66
+ }
67
+ catch (error) {
68
+ console.log(`Error in getListTodo: ${error}`);
69
+ throw error;
70
+ }
71
+ });
72
+ }
73
+ getListWorkEffortType(id) {
74
+ return __awaiter(this, void 0, void 0, function* () {
75
+ const query = queries_1.GET_LIST_WORK_EFFORT_TYPE;
76
+ const variables = {
77
+ partyId: this.orgId,
78
+ id
79
+ };
80
+ try {
81
+ const response = yield this.graphqlQuery(query, variables);
82
+ return response.getListWorkEffortType;
83
+ }
84
+ catch (error) {
85
+ console.log(`Error in getListWorkEffortType: ${error}`);
86
+ throw error;
87
+ }
88
+ });
89
+ }
90
+ updateStatusAttachmentById(performerId, attachmentId, status) {
91
+ return __awaiter(this, void 0, void 0, function* () {
92
+ const mutation = mutations_1.UPDATE_STATUS_ATTACHMENT_BY_ID;
93
+ const variables = {
94
+ performerId,
95
+ attachmentId,
96
+ status
97
+ };
98
+ try {
99
+ const response = yield this.graphqlMutation(mutation, variables);
100
+ return response.updateStatusAttachmentById;
101
+ }
102
+ catch (error) {
103
+ console.log(`Error in updateStatusAttachmentById: ${error}`);
104
+ throw error;
105
+ }
106
+ });
107
+ }
108
+ updateWorkEffortDescription(performerId, workEffortId, description) {
109
+ return __awaiter(this, void 0, void 0, function* () {
110
+ const mutation = mutations_1.UPDATE_WORK_EFFORT_DESCRIPTION;
111
+ const variables = {
112
+ performerId,
113
+ workEffortId,
114
+ description
115
+ };
116
+ try {
117
+ const response = yield this.graphqlMutation(mutation, variables);
118
+ return response.updateWorkEffortDescription;
119
+ }
120
+ catch (error) {
121
+ console.log(`Error in updateWorkEffortDescription: ${error}`);
122
+ throw error;
123
+ }
124
+ });
125
+ }
126
+ updateWorkEffortName(performerId, workEffortId, name) {
127
+ return __awaiter(this, void 0, void 0, function* () {
128
+ const mutation = mutations_1.UPDATE_WORK_EFFORT_NAME;
129
+ const variables = {
130
+ partyId: this.orgId,
131
+ performerId,
132
+ workEffortId,
133
+ newName: name
134
+ };
135
+ try {
136
+ const response = yield this.graphqlMutation(mutation, variables);
137
+ return response.updateWorkEffortName;
138
+ }
139
+ catch (error) {
140
+ console.log(`Error in updateWorkEffortName: ${error}`);
141
+ throw error;
142
+ }
143
+ });
144
+ }
145
+ updateWorkEffortStatus(performerId, workEffortId, source, status) {
146
+ return __awaiter(this, void 0, void 0, function* () {
147
+ const mutation = mutations_1.UPDATE_WORK_EFFORT_STATUS;
148
+ const variables = {
149
+ partyId: this.orgId,
150
+ performerId,
151
+ workEffortId,
152
+ source,
153
+ status
154
+ };
155
+ try {
156
+ const response = yield this.graphqlMutation(mutation, variables);
157
+ return response.updateWorkEffortStatus;
158
+ }
159
+ catch (error) {
160
+ console.log(`Error in updateWorkEffortStatus: ${error}`);
161
+ throw error;
162
+ }
163
+ });
164
+ }
165
+ addAttachmentForWorkEffort(performerId, workEffortId, attachments) {
166
+ return __awaiter(this, void 0, void 0, function* () {
167
+ const mutation = mutations_1.ADD_ATTACHMENT_FOR_WORK_EFFORT;
168
+ const variables = {
169
+ partyId: this.orgId,
170
+ performerId,
171
+ workEffortId,
172
+ attachments,
173
+ };
174
+ try {
175
+ const response = yield this.graphqlMutation(mutation, variables);
176
+ return response.addAttachmentForWorkEffort;
177
+ }
178
+ catch (error) {
179
+ console.log(`Error in addAttachmentForWorkEffort: ${error}`);
180
+ throw error;
181
+ }
182
+ });
183
+ }
184
+ }
185
+ exports.CrmService = CrmService;
@@ -0,0 +1,87 @@
1
+ import { LineItem } from "../../types/order";
2
+ import { Service } from "../service";
3
+ /**
4
+ * Represents a service for managing orders.
5
+ */
6
+ export declare class OrderService extends Service {
7
+ /**
8
+ * Constructs a new OrderService instance.
9
+ * @param endpoint - The endpoint URL for the service.
10
+ * @param orgId - The organization ID.
11
+ * @param storeId - The store ID.
12
+ */
13
+ constructor(endpoint: string, orgId: string, storeId: string);
14
+ /**
15
+ * Creates a new order.
16
+ * @param orderData - The data for the order.
17
+ * @param platform - The platform for the order.
18
+ * @param createDraft - Indicates whether to create a draft order.
19
+ * @returns A promise that resolves with the created order.
20
+ * @throws If an error occurs while creating the order.
21
+ */
22
+ createOrder(orderData: any, platform: string, createDraft: boolean): Promise<any>;
23
+ /**
24
+ * Creates a temporary order.
25
+ *
26
+ * @param orderData - The data for the order.
27
+ * @param platform - The platform for the order.
28
+ * @returns A promise that resolves to the response from the server.
29
+ * @throws If an error occurs during the API call.
30
+ */
31
+ createOrderTemp(orderData: any, platform: string): Promise<any>;
32
+ /**
33
+ * Completes multiple orders.
34
+ * @param orderIds - The IDs of the orders to complete.
35
+ * @returns A promise that resolves when the orders are completed.
36
+ * @throws If an error occurs while completing the orders.
37
+ */
38
+ completeOrder(orderIds: string[]): Promise<any>;
39
+ /**
40
+ * Adds a voucher to an order.
41
+ * @param orderId - The ID of the order.
42
+ * @param voucherCode - The voucher code.
43
+ * @returns A promise that resolves when the voucher is added.
44
+ * @throws If an error occurs while adding the voucher.
45
+ */
46
+ addVoucher(orderId: string, voucherCode: string): Promise<any>;
47
+ /**
48
+ * Removes a voucher from an order.
49
+ * @param orderId - The ID of the order.
50
+ * @param voucherCode - The voucher code.
51
+ * @returns A promise that resolves when the voucher is removed.
52
+ * @throws If an error occurs while removing the voucher.
53
+ */
54
+ removeVoucher(orderId: string, voucherCode: string): Promise<any>;
55
+ /**
56
+ * Updates the VAT (Value Added Tax) for an order.
57
+ * @param orderId - The ID of the order.
58
+ * @param vatFee - The VAT fee.
59
+ * @param vatType - The VAT type. (e.g., VALUE_GOODS, PRODUCT, etc. )
60
+ * @returns A promise that resolves when the VAT is updated.
61
+ * @throws If an error occurs while updating the VAT.
62
+ */
63
+ updateVAT(orderId: string, vatFee: number, vatType: string): Promise<any>;
64
+ /**
65
+ * Updates the customer and shipping address for an order.
66
+ * @param orderId - The ID of the order.
67
+ * @param customerData - The data for the customer.
68
+ * @param shippingAddress - The shipping address.
69
+ * @returns A promise that resolves when the customer and shipping address are updated.
70
+ * @throws If an error occurs while updating the customer and shipping address.
71
+ */
72
+ updateCustomerAndShippingAddress(orderId: string, customerData: string, shippingAddress: string): Promise<any>;
73
+ /**
74
+ * Retrieves the order line items for a specific order.
75
+ * @param partnerId - The partner ID.
76
+ * @returns A promise that resolves with the order line items.
77
+ * @throws If an error occurs while retrieving the order line items.
78
+ */
79
+ /**
80
+ * Adds order line items to an order.
81
+ * @param orderId - The ID of the order.
82
+ * @param lineItems - The line items to add.
83
+ * @returns A promise that resolves when the line items are added.
84
+ * @throws If an error occurs while adding the line items.
85
+ */
86
+ addOrderLineItems(orderId: string, lineItems: LineItem[]): Promise<any>;
87
+ }
@@ -0,0 +1,209 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.OrderService = void 0;
13
+ const service_1 = require("../service");
14
+ /**
15
+ * Represents a service for managing orders.
16
+ */
17
+ class OrderService extends service_1.Service {
18
+ /**
19
+ * Constructs a new OrderService instance.
20
+ * @param endpoint - The endpoint URL for the service.
21
+ * @param orgId - The organization ID.
22
+ * @param storeId - The store ID.
23
+ */
24
+ constructor(endpoint, orgId, storeId) {
25
+ super(endpoint, orgId, storeId);
26
+ }
27
+ /**
28
+ * Creates a new order.
29
+ * @param orderData - The data for the order.
30
+ * @param platform - The platform for the order.
31
+ * @param createDraft - Indicates whether to create a draft order.
32
+ * @returns A promise that resolves with the created order.
33
+ * @throws If an error occurs while creating the order.
34
+ */
35
+ createOrder(orderData, platform, createDraft) {
36
+ return __awaiter(this, void 0, void 0, function* () {
37
+ const endpoint = `/orders/${this.orgId}/${this.storeId}/${platform}?create_draft=${createDraft}`; // Replace with your actual endpoint
38
+ const method = "POST";
39
+ try {
40
+ const response = yield this.restApiCallWithToken(endpoint, method, orderData);
41
+ return response;
42
+ }
43
+ catch (error) {
44
+ console.log(`Error in createOrder: ${error}`);
45
+ throw error;
46
+ }
47
+ });
48
+ }
49
+ /**
50
+ * Creates a temporary order.
51
+ *
52
+ * @param orderData - The data for the order.
53
+ * @param platform - The platform for the order.
54
+ * @returns A promise that resolves to the response from the server.
55
+ * @throws If an error occurs during the API call.
56
+ */
57
+ createOrderTemp(orderData, platform) {
58
+ return __awaiter(this, void 0, void 0, function* () {
59
+ const endpoint = `/orders/${this.orgId}/${this.storeId}/${platform}/temp`; // Replace with your actual endpoint
60
+ const method = "POST";
61
+ try {
62
+ const response = yield this.restApiCallWithToken(endpoint, method, orderData);
63
+ return response;
64
+ }
65
+ catch (error) {
66
+ console.log(`Error in createOrder: ${error}`);
67
+ throw error;
68
+ }
69
+ });
70
+ }
71
+ /**
72
+ * Completes multiple orders.
73
+ * @param orderIds - The IDs of the orders to complete.
74
+ * @returns A promise that resolves when the orders are completed.
75
+ * @throws If an error occurs while completing the orders.
76
+ */
77
+ completeOrder(orderIds) {
78
+ return __awaiter(this, void 0, void 0, function* () {
79
+ const endpoint = `/orders/${this.orgId}/${this.storeId}/complete?order_ids=${orderIds.join(",")}`; // Replace with your actual endpoint
80
+ const method = "PUT";
81
+ try {
82
+ const response = yield this.restApiCallWithToken(endpoint, method);
83
+ return response;
84
+ }
85
+ catch (error) {
86
+ console.log(`Error in completeOrder: ${error}`);
87
+ throw error;
88
+ }
89
+ });
90
+ }
91
+ /**
92
+ * Adds a voucher to an order.
93
+ * @param orderId - The ID of the order.
94
+ * @param voucherCode - The voucher code.
95
+ * @returns A promise that resolves when the voucher is added.
96
+ * @throws If an error occurs while adding the voucher.
97
+ */
98
+ addVoucher(orderId, voucherCode) {
99
+ return __awaiter(this, void 0, void 0, function* () {
100
+ const endpoint = `/orders/${this.orgId}/${orderId}/voucher/${voucherCode}`;
101
+ const method = "POST";
102
+ try {
103
+ const response = yield this.restApiCallWithToken(endpoint, method);
104
+ return response;
105
+ }
106
+ catch (error) {
107
+ console.log(`Error in addVoucher: ${error}`);
108
+ throw error;
109
+ }
110
+ });
111
+ }
112
+ /**
113
+ * Removes a voucher from an order.
114
+ * @param orderId - The ID of the order.
115
+ * @param voucherCode - The voucher code.
116
+ * @returns A promise that resolves when the voucher is removed.
117
+ * @throws If an error occurs while removing the voucher.
118
+ */
119
+ removeVoucher(orderId, voucherCode) {
120
+ return __awaiter(this, void 0, void 0, function* () {
121
+ const endpoint = `/orders/${this.orgId}/${orderId}/voucher/${voucherCode}`;
122
+ const method = "DELETE";
123
+ try {
124
+ const response = yield this.restApiCallWithToken(endpoint, method);
125
+ return response;
126
+ }
127
+ catch (error) {
128
+ console.log(`Error in removeVoucher: ${error}`);
129
+ throw error;
130
+ }
131
+ });
132
+ }
133
+ /**
134
+ * Updates the VAT (Value Added Tax) for an order.
135
+ * @param orderId - The ID of the order.
136
+ * @param vatFee - The VAT fee.
137
+ * @param vatType - The VAT type. (e.g., VALUE_GOODS, PRODUCT, etc. )
138
+ * @returns A promise that resolves when the VAT is updated.
139
+ * @throws If an error occurs while updating the VAT.
140
+ */
141
+ updateVAT(orderId, vatFee, vatType) {
142
+ return __awaiter(this, void 0, void 0, function* () {
143
+ const endpoint = `/v2/orders/${this.orgId}/${orderId}/vat?vat_fee=${vatFee}&vat_type=${vatType}`;
144
+ const method = "PUT";
145
+ try {
146
+ const response = yield this.restApiCallWithToken(endpoint, method);
147
+ return response;
148
+ }
149
+ catch (error) {
150
+ console.log(`Error in updateVAT: ${error}`);
151
+ throw error;
152
+ }
153
+ });
154
+ }
155
+ /**
156
+ * Updates the customer and shipping address for an order.
157
+ * @param orderId - The ID of the order.
158
+ * @param customerData - The data for the customer.
159
+ * @param shippingAddress - The shipping address.
160
+ * @returns A promise that resolves when the customer and shipping address are updated.
161
+ * @throws If an error occurs while updating the customer and shipping address.
162
+ */
163
+ updateCustomerAndShippingAddress(orderId, customerData, shippingAddress) {
164
+ return __awaiter(this, void 0, void 0, function* () {
165
+ const endpoint = `/orders/FOX/${orderId}/customer`;
166
+ const method = "PUT";
167
+ const requestData = {
168
+ customer: customerData,
169
+ shipping_address: shippingAddress,
170
+ };
171
+ try {
172
+ const response = yield this.restApiCallWithToken(endpoint, method, requestData);
173
+ return response;
174
+ }
175
+ catch (error) {
176
+ console.log(`Error in updateCustomerAndShippingAddress: ${error}`);
177
+ throw error;
178
+ }
179
+ });
180
+ }
181
+ /**
182
+ * Retrieves the order line items for a specific order.
183
+ * @param partnerId - The partner ID.
184
+ * @returns A promise that resolves with the order line items.
185
+ * @throws If an error occurs while retrieving the order line items.
186
+ */
187
+ /**
188
+ * Adds order line items to an order.
189
+ * @param orderId - The ID of the order.
190
+ * @param lineItems - The line items to add.
191
+ * @returns A promise that resolves when the line items are added.
192
+ * @throws If an error occurs while adding the line items.
193
+ */
194
+ addOrderLineItems(orderId, lineItems) {
195
+ return __awaiter(this, void 0, void 0, function* () {
196
+ const endpoint = `/v2/orders/${this.orgId}/${this.storeId}/${orderId}/orderLineItem`;
197
+ const method = "POST";
198
+ try {
199
+ const response = yield this.restApiCallWithToken(endpoint, method, lineItems);
200
+ return response;
201
+ }
202
+ catch (error) {
203
+ console.log(`Error in addOrderLineItems: ${error}`);
204
+ throw error;
205
+ }
206
+ });
207
+ }
208
+ }
209
+ exports.OrderService = OrderService;
@@ -0,0 +1,6 @@
1
+ import { Service } from "../service";
2
+ export declare class PaymentService extends Service {
3
+ constructor(endpoint: string, orgId: string, storeId: string);
4
+ getPaymentMethod(): Promise<any>;
5
+ createPaymentOrder(paymentOrderData: any): Promise<any>;
6
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.PaymentService = void 0;
13
+ const mutations_1 = require("../../graphql/payment/mutations");
14
+ const queries_1 = require("../../graphql/payment/queries");
15
+ const service_1 = require("../service");
16
+ class PaymentService extends service_1.Service {
17
+ constructor(endpoint, orgId, storeId) {
18
+ super(endpoint, orgId, storeId);
19
+ }
20
+ getPaymentMethod() {
21
+ return __awaiter(this, void 0, void 0, function* () {
22
+ const query = queries_1.GET_PAYMENT_METHOD;
23
+ const variables = {
24
+ orgId: this.orgId,
25
+ };
26
+ try {
27
+ const response = yield this.graphqlQuery(query, variables);
28
+ return response.paymentMethod;
29
+ }
30
+ catch (error) {
31
+ console.log(`Error fetching get payment method: ${error}`);
32
+ throw error;
33
+ }
34
+ });
35
+ }
36
+ createPaymentOrder(paymentOrderData) {
37
+ return __awaiter(this, void 0, void 0, function* () {
38
+ const data = Object.assign({ orgId: this.orgId, storeId: this.storeId }, paymentOrderData);
39
+ try {
40
+ const response = yield this.graphqlMutation(mutations_1.CREATE_PAYMENT_ORDER_MUTATION, data);
41
+ return response.data.createPaymentOrder;
42
+ }
43
+ catch (error) {
44
+ console.log(`Error in createPaymentOrder: ${error}`);
45
+ throw error;
46
+ }
47
+ });
48
+ }
49
+ }
50
+ exports.PaymentService = PaymentService;
@@ -0,0 +1,36 @@
1
+ import { Service } from "../service";
2
+ import { Product } from "../../types/product";
3
+ /**
4
+ * Service class for managing product-related operations.
5
+ */
6
+ export declare class ProductService extends Service {
7
+ /**
8
+ * Constructs a new ProductService instance.
9
+ * @param endpoint - The endpoint URL for the service.
10
+ * @param orgId - The organization ID.
11
+ * @param storeId - The store ID.
12
+ */
13
+ constructor(endpoint: string, orgId: string, storeId: string);
14
+ /**
15
+ * Retrieves a product by its ID.
16
+ * @param productId - The ID of the product.
17
+ * @returns A promise that resolves to the product.
18
+ * @throws If an error occurs while fetching the product.
19
+ */
20
+ getProductById(productId: string): Promise<any>;
21
+ /**
22
+ * Retrieves a product by its slug.
23
+ * @param slug - The slug of the product.
24
+ * @returns A promise that resolves to the product.
25
+ * @throws If an error occurs while fetching the product.
26
+ */
27
+ getProductBySlug(slug: string): Promise<Product>;
28
+ /**
29
+ * Retrieves simple products based on the provided variables.
30
+ * @param variables - The variables for the query.
31
+ * @returns A promise that resolves to the simple products.
32
+ * @throws If an error occurs while fetching the simple products.
33
+ */
34
+ getSimpleProducts(variables: any): Promise<Product[] | null>;
35
+ getProductOption(productId: string): Promise<any>;
36
+ }