masterypath-sdk 0.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.
- package/.dev.vars +2 -0
- package/.wrangler/state/v3/kv/miniflare-KVNamespaceObject/1e4db3c9171af17397cf90ef2f593be5a4b69af562e75c7443bac364b5ee13ff.sqlite +0 -0
- package/.wrangler/state/v3/kv/miniflare-KVNamespaceObject/1e4db3c9171af17397cf90ef2f593be5a4b69af562e75c7443bac364b5ee13ff.sqlite-shm +0 -0
- package/.wrangler/state/v3/kv/miniflare-KVNamespaceObject/1e4db3c9171af17397cf90ef2f593be5a4b69af562e75c7443bac364b5ee13ff.sqlite-wal +0 -0
- package/.wrangler/state/v3/kv/miniflare-KVNamespaceObject/56b105fd2dc4b3fb6c5747ff7b4382eed21869d8565e2efa721c0ed2f32718cb.sqlite +0 -0
- package/.wrangler/state/v3/kv/miniflare-KVNamespaceObject/56b105fd2dc4b3fb6c5747ff7b4382eed21869d8565e2efa721c0ed2f32718cb.sqlite-shm +0 -0
- package/.wrangler/state/v3/kv/miniflare-KVNamespaceObject/56b105fd2dc4b3fb6c5747ff7b4382eed21869d8565e2efa721c0ed2f32718cb.sqlite-wal +0 -0
- package/.wrangler/state/v3/kv/miniflare-KVNamespaceObject/65c29bc0e70a4606712fbbe4f60c7608395ec7d433afc750ae710de59fa6a710.sqlite +0 -0
- package/.wrangler/state/v3/kv/miniflare-KVNamespaceObject/65c29bc0e70a4606712fbbe4f60c7608395ec7d433afc750ae710de59fa6a710.sqlite-shm +0 -0
- package/.wrangler/state/v3/kv/miniflare-KVNamespaceObject/65c29bc0e70a4606712fbbe4f60c7608395ec7d433afc750ae710de59fa6a710.sqlite-wal +0 -0
- package/dist/MasterypathSDK.d.ts +18 -0
- package/dist/MasterypathSDK.d.ts.map +1 -0
- package/dist/MasterypathSDK.js +19 -0
- package/dist/MasterypathSDK.js.map +1 -0
- package/dist/cli/cli.d.ts +3 -0
- package/dist/cli/cli.d.ts.map +1 -0
- package/dist/cli/cli.js +52 -0
- package/dist/cli/cli.js.map +1 -0
- package/dist/cli/commands/chat.d.ts +4 -0
- package/dist/cli/commands/chat.d.ts.map +1 -0
- package/dist/cli/commands/chat.js +321 -0
- package/dist/cli/commands/chat.js.map +1 -0
- package/dist/cli/commands/company-services.d.ts +4 -0
- package/dist/cli/commands/company-services.d.ts.map +1 -0
- package/dist/cli/commands/company-services.js +167 -0
- package/dist/cli/commands/company-services.js.map +1 -0
- package/dist/cli/commands/organizations.d.ts +4 -0
- package/dist/cli/commands/organizations.d.ts.map +1 -0
- package/dist/cli/commands/organizations.js +341 -0
- package/dist/cli/commands/organizations.js.map +1 -0
- package/dist/cli/commands/public-api.d.ts +4 -0
- package/dist/cli/commands/public-api.d.ts.map +1 -0
- package/dist/cli/commands/public-api.js +70 -0
- package/dist/cli/commands/public-api.js.map +1 -0
- package/dist/cli/commands/uploads.d.ts +4 -0
- package/dist/cli/commands/uploads.d.ts.map +1 -0
- package/dist/cli/commands/uploads.js +25 -0
- package/dist/cli/commands/uploads.js.map +1 -0
- package/dist/cli/commands/users.d.ts +4 -0
- package/dist/cli/commands/users.d.ts.map +1 -0
- package/dist/cli/commands/users.js +296 -0
- package/dist/cli/commands/users.js.map +1 -0
- package/dist/cli/config.d.ts +3 -0
- package/dist/cli/config.d.ts.map +1 -0
- package/dist/cli/config.js +24 -0
- package/dist/cli/config.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +10 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/output.d.ts +3 -0
- package/dist/cli/output.d.ts.map +1 -0
- package/dist/cli/output.js +58 -0
- package/dist/cli/output.js.map +1 -0
- package/dist/clients/BaseClient.d.ts +7 -0
- package/dist/clients/BaseClient.d.ts.map +1 -0
- package/dist/clients/BaseClient.js +60 -0
- package/dist/clients/BaseClient.js.map +1 -0
- package/dist/clients/HttpClient.d.ts +6 -0
- package/dist/clients/HttpClient.d.ts.map +1 -0
- package/dist/clients/HttpClient.js +7 -0
- package/dist/clients/HttpClient.js.map +1 -0
- package/dist/config/types.d.ts +24 -0
- package/dist/config/types.d.ts.map +1 -0
- package/dist/config/types.js +2 -0
- package/dist/config/types.js.map +1 -0
- package/dist/domains/chat/ChatClient.d.ts +24 -0
- package/dist/domains/chat/ChatClient.d.ts.map +1 -0
- package/dist/domains/chat/ChatClient.js +347 -0
- package/dist/domains/chat/ChatClient.js.map +1 -0
- package/dist/domains/chat/types.d.ts +104 -0
- package/dist/domains/chat/types.d.ts.map +1 -0
- package/dist/domains/chat/types.js +2 -0
- package/dist/domains/chat/types.js.map +1 -0
- package/dist/domains/company-services/CompanyServicesClient.d.ts +16 -0
- package/dist/domains/company-services/CompanyServicesClient.d.ts.map +1 -0
- package/dist/domains/company-services/CompanyServicesClient.js +116 -0
- package/dist/domains/company-services/CompanyServicesClient.js.map +1 -0
- package/dist/domains/containers/ContainersClient.d.ts +65 -0
- package/dist/domains/containers/ContainersClient.d.ts.map +1 -0
- package/dist/domains/containers/ContainersClient.js +404 -0
- package/dist/domains/containers/ContainersClient.js.map +1 -0
- package/dist/domains/index.d.ts +8 -0
- package/dist/domains/index.d.ts.map +1 -0
- package/dist/domains/index.js +5 -0
- package/dist/domains/index.js.map +1 -0
- package/dist/domains/listings/ListingsClient.d.ts +14 -0
- package/dist/domains/listings/ListingsClient.d.ts.map +1 -0
- package/dist/domains/listings/ListingsClient.js +92 -0
- package/dist/domains/listings/ListingsClient.js.map +1 -0
- package/dist/domains/merchants/MerchantsClient.d.ts +33 -0
- package/dist/domains/merchants/MerchantsClient.d.ts.map +1 -0
- package/dist/domains/merchants/MerchantsClient.js +330 -0
- package/dist/domains/merchants/MerchantsClient.js.map +1 -0
- package/dist/domains/orders/OrdersClient.d.ts +96 -0
- package/dist/domains/orders/OrdersClient.d.ts.map +1 -0
- package/dist/domains/orders/OrdersClient.js +664 -0
- package/dist/domains/orders/OrdersClient.js.map +1 -0
- package/dist/domains/orders/types.d.ts +46 -0
- package/dist/domains/orders/types.d.ts.map +1 -0
- package/dist/domains/orders/types.js +2 -0
- package/dist/domains/orders/types.js.map +1 -0
- package/dist/domains/organizations/OrganizationsClient.d.ts +22 -0
- package/dist/domains/organizations/OrganizationsClient.d.ts.map +1 -0
- package/dist/domains/organizations/OrganizationsClient.js +191 -0
- package/dist/domains/organizations/OrganizationsClient.js.map +1 -0
- package/dist/domains/plants/PlantsClient.d.ts +35 -0
- package/dist/domains/plants/PlantsClient.d.ts.map +1 -0
- package/dist/domains/plants/PlantsClient.js +76 -0
- package/dist/domains/plants/PlantsClient.js.map +1 -0
- package/dist/domains/products/ProductsClient.d.ts +14 -0
- package/dist/domains/products/ProductsClient.d.ts.map +1 -0
- package/dist/domains/products/ProductsClient.js +91 -0
- package/dist/domains/products/ProductsClient.js.map +1 -0
- package/dist/domains/public-api/PublicApiClient.d.ts +14 -0
- package/dist/domains/public-api/PublicApiClient.d.ts.map +1 -0
- package/dist/domains/public-api/PublicApiClient.js +48 -0
- package/dist/domains/public-api/PublicApiClient.js.map +1 -0
- package/dist/domains/uploads/UploadsClient.d.ts +29 -0
- package/dist/domains/uploads/UploadsClient.d.ts.map +1 -0
- package/dist/domains/uploads/UploadsClient.js +50 -0
- package/dist/domains/uploads/UploadsClient.js.map +1 -0
- package/dist/domains/usdazones/UsdazonesClient.d.ts +8 -0
- package/dist/domains/usdazones/UsdazonesClient.d.ts.map +1 -0
- package/dist/domains/usdazones/UsdazonesClient.js +17 -0
- package/dist/domains/usdazones/UsdazonesClient.js.map +1 -0
- package/dist/domains/users/UsersClient.d.ts +22 -0
- package/dist/domains/users/UsersClient.d.ts.map +1 -0
- package/dist/domains/users/UsersClient.js +183 -0
- package/dist/domains/users/UsersClient.js.map +1 -0
- package/dist/domains/users/types.d.ts +59 -0
- package/dist/domains/users/types.d.ts.map +1 -0
- package/dist/domains/users/types.js +2 -0
- package/dist/domains/users/types.js.map +1 -0
- package/dist/generated/graphql.d.ts +1750 -0
- package/dist/generated/graphql.d.ts.map +1 -0
- package/dist/generated/graphql.js +51 -0
- package/dist/generated/graphql.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/shared/fulfillmentWindows.d.ts +12 -0
- package/dist/shared/fulfillmentWindows.d.ts.map +1 -0
- package/dist/shared/fulfillmentWindows.js +35 -0
- package/dist/shared/fulfillmentWindows.js.map +1 -0
- package/dist/utils/errors.d.ts +28 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +23 -0
- package/dist/utils/errors.js.map +1 -0
- package/package.json +49 -0
|
@@ -0,0 +1,664 @@
|
|
|
1
|
+
import { print } from 'graphql';
|
|
2
|
+
import { CreateBatchOrderDocument, GetOrderDocument, GetBatchOrderPreviewDocument, CreatePaymentIntentsDocument, CreatePaymentIntentDocument, ConfirmFulfillmentWindowDocument, RequestFulfillmentWindowConfirmationDocument, AddItemsToFulfillmentRequestDocument, UpdateFrStatusEnRouteDocument, UpdateCustomerEnRouteDocument, UpdateFrStatusReadyDocument, UpdateFrStatusFilledDocument, UpdateFrStatusFailedAttemptDocument, CancelFulfillmentRequestDocument, GetFulfillmentRequestItemsDocument, GetMilestonesForQuoteDocument, GetMilestoneDocument, MarkMilestoneReadyForPaymentDocument, AuthorizeMilestonePaymentDocument, CaptureMilestonePaymentDocument, GetFulfillmentRequestDocument, GetPaymentDocument, CapturePaymentDocument, CloseEscrowDocument, RemoveItemsFromFulfillmentRequestDocument, AmendLateFulfillmentRequestDocument, CreateServiceQuoteDocument, UpdateServiceQuoteDocument, CreateTimeAndMaterialsPaymentIntentDocument, CaptureTimeAndMaterialsPaymentDocument, RequestTimeAndMaterialsPaymentDocument, AuthorizeTimeAndMaterialsPaymentDocument, GetTimeAndMaterialsBillingRequestsDocument, GetMerchantByHandleDocument, DisputePaymentDocument, ResolveDisputeDocument, AddDisputeMessageDocument, CreateTimeAndMaterialsServiceQuoteDocument, UpdateTimeAndMaterialsServiceQuoteDocument, SubmitTimeLogForTandMQuoteDocument, SubmitMaterialReceiptForTandMQuoteDocument, GetTimeAndMaterialsServiceQuoteDocument, GetTimeLogsForTandMQuoteDocument, GetMaterialReceiptsForTandMQuoteDocument, CalculateTimeAndMaterialsAmountDocument, } from '../../generated/graphql';
|
|
3
|
+
export class OrdersClient {
|
|
4
|
+
constructor(httpClient) {
|
|
5
|
+
this.httpClient = httpClient;
|
|
6
|
+
this.merchantIdCache = new Map();
|
|
7
|
+
}
|
|
8
|
+
async getMerchantIdFromHandle(merchantHandle) {
|
|
9
|
+
if (this.merchantIdCache.has(merchantHandle)) {
|
|
10
|
+
return this.merchantIdCache.get(merchantHandle);
|
|
11
|
+
}
|
|
12
|
+
const response = await this.httpClient.request('/graphql-merchants', {
|
|
13
|
+
query: print(GetMerchantByHandleDocument),
|
|
14
|
+
variables: {
|
|
15
|
+
handle: merchantHandle,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
if (!response.data?.getMerchantByHandle?.id) {
|
|
19
|
+
throw new Error(`Merchant not found for handle: ${merchantHandle}`);
|
|
20
|
+
}
|
|
21
|
+
const merchantId = response.data.getMerchantByHandle.id;
|
|
22
|
+
this.merchantIdCache.set(merchantHandle, merchantId);
|
|
23
|
+
return merchantId;
|
|
24
|
+
}
|
|
25
|
+
async getMerchantIdFromHandleInternal(merchantHandle) {
|
|
26
|
+
return this.getMerchantIdFromHandle(merchantHandle);
|
|
27
|
+
}
|
|
28
|
+
async createBatchOrder(merchantHandle, input) {
|
|
29
|
+
const response = await this.httpClient.request('/graphql-orders', {
|
|
30
|
+
query: print(CreateBatchOrderDocument),
|
|
31
|
+
variables: {
|
|
32
|
+
merchantHandle,
|
|
33
|
+
input,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
if (!response.data?.createBatchOrder) {
|
|
37
|
+
throw new Error('Failed to create batch order: No data returned');
|
|
38
|
+
}
|
|
39
|
+
return response.data.createBatchOrder;
|
|
40
|
+
}
|
|
41
|
+
async getOrder(merchantHandle, orderId) {
|
|
42
|
+
const response = await this.httpClient.request('/graphql-orders', {
|
|
43
|
+
query: print(GetOrderDocument),
|
|
44
|
+
variables: {
|
|
45
|
+
merchantHandle,
|
|
46
|
+
orderId,
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
return response.data?.getOrder ?? null;
|
|
50
|
+
}
|
|
51
|
+
async getFulfillmentRequest(merchantHandle, fulfillmentId) {
|
|
52
|
+
const response = await this.httpClient.request('/graphql-orders', {
|
|
53
|
+
query: print(GetFulfillmentRequestDocument),
|
|
54
|
+
variables: {
|
|
55
|
+
merchantHandle,
|
|
56
|
+
fulfillmentId,
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
return response.data?.getFulfillmentRequest ?? null;
|
|
60
|
+
}
|
|
61
|
+
async getPayment(merchantHandle, paymentId) {
|
|
62
|
+
const response = await this.httpClient.request('/graphql-orders', {
|
|
63
|
+
query: print(GetPaymentDocument),
|
|
64
|
+
variables: {
|
|
65
|
+
merchantHandle,
|
|
66
|
+
paymentId,
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
return response.data?.getPayment ?? null;
|
|
70
|
+
}
|
|
71
|
+
async getBatchOrderPreview(merchantHandle, input) {
|
|
72
|
+
const response = await this.httpClient.request('/graphql-orders', {
|
|
73
|
+
query: print(GetBatchOrderPreviewDocument),
|
|
74
|
+
variables: {
|
|
75
|
+
merchantHandle,
|
|
76
|
+
input,
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
if (!response.data?.getBatchOrderPreview) {
|
|
80
|
+
throw new Error('Failed to get batch order preview: No data returned');
|
|
81
|
+
}
|
|
82
|
+
return response.data.getBatchOrderPreview;
|
|
83
|
+
}
|
|
84
|
+
async createPaymentIntents(merchantHandle, batchOrderId, options) {
|
|
85
|
+
const response = await this.httpClient.request('/graphql-orders', {
|
|
86
|
+
query: print(CreatePaymentIntentsDocument),
|
|
87
|
+
variables: {
|
|
88
|
+
merchantHandle,
|
|
89
|
+
batchOrderId,
|
|
90
|
+
paymentMethodId: options?.paymentMethodId,
|
|
91
|
+
fulfillmentWindowsOffered: options?.fulfillmentWindowsOffered,
|
|
92
|
+
location: options?.location,
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
if (!response.data?.createPaymentIntents) {
|
|
96
|
+
throw new Error('Failed to create payment intents: No data returned');
|
|
97
|
+
}
|
|
98
|
+
return response.data.createPaymentIntents;
|
|
99
|
+
}
|
|
100
|
+
async createPaymentIntent(merchantHandle, orderId, options) {
|
|
101
|
+
const response = await this.httpClient.request('/graphql-orders', {
|
|
102
|
+
query: print(CreatePaymentIntentDocument),
|
|
103
|
+
variables: {
|
|
104
|
+
merchantHandle,
|
|
105
|
+
orderId,
|
|
106
|
+
paymentMethodId: options?.paymentMethodId,
|
|
107
|
+
fulfillmentWindowsOffered: options?.fulfillmentWindowsOffered,
|
|
108
|
+
location: options?.location,
|
|
109
|
+
cancelExistingPayments: options?.cancelExistingPayments,
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
if (!response.data?.createPaymentIntent) {
|
|
113
|
+
throw new Error('Failed to create payment intent: No data returned');
|
|
114
|
+
}
|
|
115
|
+
return response.data.createPaymentIntent;
|
|
116
|
+
}
|
|
117
|
+
async confirmFulfillmentWindow(merchantHandle, fulfillmentId) {
|
|
118
|
+
const response = await this.httpClient.request('/graphql-orders', {
|
|
119
|
+
query: print(ConfirmFulfillmentWindowDocument),
|
|
120
|
+
variables: {
|
|
121
|
+
merchantHandle,
|
|
122
|
+
fulfillmentId,
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
if (response.data?.confirmFulfillmentWindow === undefined) {
|
|
126
|
+
throw new Error('Failed to confirm fulfillment window: No data returned');
|
|
127
|
+
}
|
|
128
|
+
return response.data.confirmFulfillmentWindow;
|
|
129
|
+
}
|
|
130
|
+
async requestFulfillmentWindowConfirmation(merchantHandle, fulfillmentId, requestingConfirmationFrom) {
|
|
131
|
+
const response = await this.httpClient.request('/graphql-orders', {
|
|
132
|
+
query: print(RequestFulfillmentWindowConfirmationDocument),
|
|
133
|
+
variables: {
|
|
134
|
+
merchantHandle,
|
|
135
|
+
fulfillmentId,
|
|
136
|
+
requestingConfirmationFrom,
|
|
137
|
+
},
|
|
138
|
+
});
|
|
139
|
+
if (response.data?.requestFulfillmentWindowConfirmation === undefined) {
|
|
140
|
+
throw new Error('Failed to request fulfillment window confirmation: No data returned');
|
|
141
|
+
}
|
|
142
|
+
return response.data.requestFulfillmentWindowConfirmation;
|
|
143
|
+
}
|
|
144
|
+
async addItemsToFulfillmentRequest(merchantHandle, fulfillmentId, items) {
|
|
145
|
+
const merchantId = await this.getMerchantIdFromHandleInternal(merchantHandle);
|
|
146
|
+
const response = await this.httpClient.request('/graphql-orders', {
|
|
147
|
+
query: print(AddItemsToFulfillmentRequestDocument),
|
|
148
|
+
variables: {
|
|
149
|
+
merchantHandle,
|
|
150
|
+
fulfillmentId,
|
|
151
|
+
items,
|
|
152
|
+
},
|
|
153
|
+
}, merchantId);
|
|
154
|
+
if (!response.data?.addItemsToFulfillmentRequest) {
|
|
155
|
+
throw new Error('Failed to add items to fulfillment request: No data returned');
|
|
156
|
+
}
|
|
157
|
+
return response.data.addItemsToFulfillmentRequest;
|
|
158
|
+
}
|
|
159
|
+
async removeItemsFromFulfillmentRequest(merchantHandle, fulfillmentId, itemIds) {
|
|
160
|
+
const merchantId = await this.getMerchantIdFromHandleInternal(merchantHandle);
|
|
161
|
+
const response = await this.httpClient.request('/graphql-orders', {
|
|
162
|
+
query: print(RemoveItemsFromFulfillmentRequestDocument),
|
|
163
|
+
variables: {
|
|
164
|
+
merchantHandle,
|
|
165
|
+
fulfillmentId,
|
|
166
|
+
itemIds,
|
|
167
|
+
},
|
|
168
|
+
}, merchantId);
|
|
169
|
+
if (response.data?.removeItemsFromFulfillmentRequest === undefined) {
|
|
170
|
+
throw new Error('Failed to remove items from fulfillment request: No data returned');
|
|
171
|
+
}
|
|
172
|
+
return response.data.removeItemsFromFulfillmentRequest;
|
|
173
|
+
}
|
|
174
|
+
async updateFrStatusEnRoute(merchantHandle, fulfillmentId) {
|
|
175
|
+
const merchantId = await this.getMerchantIdFromHandleInternal(merchantHandle);
|
|
176
|
+
const response = await this.httpClient.request('/graphql-orders', {
|
|
177
|
+
query: print(UpdateFrStatusEnRouteDocument),
|
|
178
|
+
variables: {
|
|
179
|
+
merchantHandle,
|
|
180
|
+
fulfillmentId,
|
|
181
|
+
},
|
|
182
|
+
}, merchantId);
|
|
183
|
+
if (response.data?.updateFrStatusEnRoute === undefined) {
|
|
184
|
+
throw new Error('Failed to update fulfillment status to en_route: No data returned');
|
|
185
|
+
}
|
|
186
|
+
return response.data.updateFrStatusEnRoute;
|
|
187
|
+
}
|
|
188
|
+
async updateCustomerEnRoute(merchantHandle, fulfillmentId) {
|
|
189
|
+
const merchantId = await this.getMerchantIdFromHandleInternal(merchantHandle);
|
|
190
|
+
const response = await this.httpClient.request('/graphql-orders', {
|
|
191
|
+
query: print(UpdateCustomerEnRouteDocument),
|
|
192
|
+
variables: {
|
|
193
|
+
merchantHandle,
|
|
194
|
+
fulfillmentId,
|
|
195
|
+
},
|
|
196
|
+
}, merchantId);
|
|
197
|
+
if (response.data?.updateCustomerEnRoute === undefined) {
|
|
198
|
+
throw new Error('Failed to update customer en-route status: No data returned');
|
|
199
|
+
}
|
|
200
|
+
return response.data.updateCustomerEnRoute;
|
|
201
|
+
}
|
|
202
|
+
async updateFrStatusReady(merchantHandle, fulfillmentId) {
|
|
203
|
+
const merchantId = await this.getMerchantIdFromHandleInternal(merchantHandle);
|
|
204
|
+
const response = await this.httpClient.request('/graphql-orders', {
|
|
205
|
+
query: print(UpdateFrStatusReadyDocument),
|
|
206
|
+
variables: {
|
|
207
|
+
merchantHandle,
|
|
208
|
+
fulfillmentId,
|
|
209
|
+
},
|
|
210
|
+
}, merchantId);
|
|
211
|
+
if (response.data?.updateFrStatusReady === undefined) {
|
|
212
|
+
throw new Error('Failed to update fulfillment status to ready: No data returned');
|
|
213
|
+
}
|
|
214
|
+
return response.data.updateFrStatusReady;
|
|
215
|
+
}
|
|
216
|
+
async updateFrStatusFilled(merchantHandle, fulfillmentId) {
|
|
217
|
+
const merchantId = await this.getMerchantIdFromHandleInternal(merchantHandle);
|
|
218
|
+
const response = await this.httpClient.request('/graphql-orders', {
|
|
219
|
+
query: print(UpdateFrStatusFilledDocument),
|
|
220
|
+
variables: {
|
|
221
|
+
merchantHandle,
|
|
222
|
+
fulfillmentId,
|
|
223
|
+
},
|
|
224
|
+
}, merchantId);
|
|
225
|
+
if (response.data?.updateFrStatusFilled === undefined) {
|
|
226
|
+
throw new Error('Failed to update fulfillment status to filled: No data returned');
|
|
227
|
+
}
|
|
228
|
+
return response.data.updateFrStatusFilled;
|
|
229
|
+
}
|
|
230
|
+
async updateFrStatusFailedAttempt(merchantHandle, fulfillmentId) {
|
|
231
|
+
const merchantId = await this.getMerchantIdFromHandleInternal(merchantHandle);
|
|
232
|
+
const response = await this.httpClient.request('/graphql-orders', {
|
|
233
|
+
query: print(UpdateFrStatusFailedAttemptDocument),
|
|
234
|
+
variables: {
|
|
235
|
+
merchantHandle,
|
|
236
|
+
fulfillmentId,
|
|
237
|
+
},
|
|
238
|
+
}, merchantId);
|
|
239
|
+
if (response.data?.updateFrStatusFailedAttempt === undefined) {
|
|
240
|
+
throw new Error('Failed to update fulfillment status to failed attempt: No data returned');
|
|
241
|
+
}
|
|
242
|
+
return response.data.updateFrStatusFailedAttempt;
|
|
243
|
+
}
|
|
244
|
+
async cancelFulfillmentRequest(merchantHandle, fulfillmentId, reason) {
|
|
245
|
+
const merchantId = await this.getMerchantIdFromHandleInternal(merchantHandle);
|
|
246
|
+
const response = await this.httpClient.request('/graphql-orders', {
|
|
247
|
+
query: print(CancelFulfillmentRequestDocument),
|
|
248
|
+
variables: {
|
|
249
|
+
merchantHandle,
|
|
250
|
+
fulfillmentId,
|
|
251
|
+
reason,
|
|
252
|
+
},
|
|
253
|
+
}, merchantId);
|
|
254
|
+
if (response.data?.cancelFulfillmentRequest === undefined) {
|
|
255
|
+
throw new Error('Failed to cancel fulfillment request: No data returned');
|
|
256
|
+
}
|
|
257
|
+
return response.data.cancelFulfillmentRequest;
|
|
258
|
+
}
|
|
259
|
+
async getFulfillmentRequestItems(merchantHandle, fulfillmentId) {
|
|
260
|
+
const merchantId = await this.getMerchantIdFromHandleInternal(merchantHandle);
|
|
261
|
+
const response = await this.httpClient.request('/graphql-orders', {
|
|
262
|
+
query: print(GetFulfillmentRequestItemsDocument),
|
|
263
|
+
variables: {
|
|
264
|
+
merchantHandle,
|
|
265
|
+
fulfillmentId,
|
|
266
|
+
},
|
|
267
|
+
}, merchantId);
|
|
268
|
+
if (response.data?.getFulfillmentRequestItems === undefined) {
|
|
269
|
+
throw new Error('Failed to get fulfillment request items: No data returned');
|
|
270
|
+
}
|
|
271
|
+
return response.data.getFulfillmentRequestItems;
|
|
272
|
+
}
|
|
273
|
+
async capturePayment(merchantHandle, orderId, fulfillmentRequestId) {
|
|
274
|
+
const merchantId = await this.getMerchantIdFromHandleInternal(merchantHandle);
|
|
275
|
+
const response = await this.httpClient.request('/graphql-orders', {
|
|
276
|
+
query: print(CapturePaymentDocument),
|
|
277
|
+
variables: {
|
|
278
|
+
merchantHandle,
|
|
279
|
+
orderId,
|
|
280
|
+
fulfillmentRequestId,
|
|
281
|
+
},
|
|
282
|
+
}, merchantId);
|
|
283
|
+
if (!response.data?.capturePayment) {
|
|
284
|
+
throw new Error('Failed to capture payment: No data returned');
|
|
285
|
+
}
|
|
286
|
+
return response.data.capturePayment;
|
|
287
|
+
}
|
|
288
|
+
async closeEscrow(merchantHandle, paymentId) {
|
|
289
|
+
const merchantId = await this.getMerchantIdFromHandleInternal(merchantHandle);
|
|
290
|
+
const response = await this.httpClient.request('/graphql-orders', {
|
|
291
|
+
query: print(CloseEscrowDocument),
|
|
292
|
+
variables: {
|
|
293
|
+
merchantHandle,
|
|
294
|
+
paymentId,
|
|
295
|
+
},
|
|
296
|
+
}, merchantId);
|
|
297
|
+
if (!response.data?.closeEscrow) {
|
|
298
|
+
throw new Error('Failed to close escrow: No data returned');
|
|
299
|
+
}
|
|
300
|
+
return response.data.closeEscrow;
|
|
301
|
+
}
|
|
302
|
+
async disputePayment(merchantHandle, input) {
|
|
303
|
+
const response = await this.httpClient.request('/graphql-orders', {
|
|
304
|
+
query: print(DisputePaymentDocument),
|
|
305
|
+
variables: {
|
|
306
|
+
merchantHandle,
|
|
307
|
+
input,
|
|
308
|
+
},
|
|
309
|
+
});
|
|
310
|
+
if (!response.data?.disputePayment) {
|
|
311
|
+
throw new Error('Failed to dispute payment: No data returned');
|
|
312
|
+
}
|
|
313
|
+
return response.data.disputePayment;
|
|
314
|
+
}
|
|
315
|
+
async resolveDispute(merchantHandle, input) {
|
|
316
|
+
const merchantId = await this.getMerchantIdFromHandleInternal(merchantHandle);
|
|
317
|
+
const response = await this.httpClient.request('/graphql-orders', {
|
|
318
|
+
query: print(ResolveDisputeDocument),
|
|
319
|
+
variables: {
|
|
320
|
+
merchantHandle,
|
|
321
|
+
input,
|
|
322
|
+
},
|
|
323
|
+
}, merchantId);
|
|
324
|
+
if (!response.data?.resolveDispute) {
|
|
325
|
+
throw new Error('Failed to resolve dispute: No data returned');
|
|
326
|
+
}
|
|
327
|
+
return response.data.resolveDispute;
|
|
328
|
+
}
|
|
329
|
+
async addDisputeMessage(merchantHandle, disputeId, message) {
|
|
330
|
+
const merchantId = await this.getMerchantIdFromHandleInternal(merchantHandle);
|
|
331
|
+
const response = await this.httpClient.request('/graphql-orders', {
|
|
332
|
+
query: print(AddDisputeMessageDocument),
|
|
333
|
+
variables: {
|
|
334
|
+
merchantHandle,
|
|
335
|
+
disputeId,
|
|
336
|
+
message,
|
|
337
|
+
},
|
|
338
|
+
}, merchantId);
|
|
339
|
+
if (response.data?.addDisputeMessage === undefined) {
|
|
340
|
+
throw new Error('Failed to add dispute message: No data returned');
|
|
341
|
+
}
|
|
342
|
+
return response.data.addDisputeMessage;
|
|
343
|
+
}
|
|
344
|
+
async amendLateFulfillmentRequest(merchantHandle, fulfillmentId, options) {
|
|
345
|
+
const merchantId = await this.getMerchantIdFromHandleInternal(merchantHandle);
|
|
346
|
+
const response = await this.httpClient.request('/graphql-orders', {
|
|
347
|
+
query: print(AmendLateFulfillmentRequestDocument),
|
|
348
|
+
variables: {
|
|
349
|
+
merchantHandle,
|
|
350
|
+
fulfillmentId,
|
|
351
|
+
compensationAmountUsd: options?.compensationAmountUsd,
|
|
352
|
+
customerMessage: options?.customerMessage,
|
|
353
|
+
merchantMessage: options?.merchantMessage,
|
|
354
|
+
fulfillmentWindowsOffered: options?.fulfillmentWindowsOffered,
|
|
355
|
+
},
|
|
356
|
+
}, merchantId);
|
|
357
|
+
if (!response.data?.amendLateFulfillmentRequest) {
|
|
358
|
+
throw new Error('Failed to amend late fulfillment request: No data returned');
|
|
359
|
+
}
|
|
360
|
+
return response.data.amendLateFulfillmentRequest;
|
|
361
|
+
}
|
|
362
|
+
async createServiceQuote(merchantHandle, input) {
|
|
363
|
+
const merchantId = await this.getMerchantIdFromHandleInternal(merchantHandle);
|
|
364
|
+
const response = await this.httpClient.request('/graphql-orders', {
|
|
365
|
+
query: print(CreateServiceQuoteDocument),
|
|
366
|
+
variables: {
|
|
367
|
+
merchantHandle,
|
|
368
|
+
input,
|
|
369
|
+
},
|
|
370
|
+
}, merchantId);
|
|
371
|
+
if (!response.data?.createServiceQuote) {
|
|
372
|
+
throw new Error('Failed to create service quote: No data returned');
|
|
373
|
+
}
|
|
374
|
+
return response.data.createServiceQuote;
|
|
375
|
+
}
|
|
376
|
+
async updateServiceQuote(merchantHandle, input) {
|
|
377
|
+
const merchantId = await this.getMerchantIdFromHandleInternal(merchantHandle);
|
|
378
|
+
const response = await this.httpClient.request('/graphql-orders', {
|
|
379
|
+
query: print(UpdateServiceQuoteDocument),
|
|
380
|
+
variables: {
|
|
381
|
+
merchantHandle,
|
|
382
|
+
input,
|
|
383
|
+
},
|
|
384
|
+
}, merchantId);
|
|
385
|
+
if (!response.data?.updateServiceQuote) {
|
|
386
|
+
throw new Error('Failed to update service quote: No data returned');
|
|
387
|
+
}
|
|
388
|
+
return response.data.updateServiceQuote;
|
|
389
|
+
}
|
|
390
|
+
async getMilestonesForQuote(merchantHandle, quoteId) {
|
|
391
|
+
const merchantId = await this.getMerchantIdFromHandleInternal(merchantHandle);
|
|
392
|
+
const response = await this.httpClient.request('/graphql-orders', {
|
|
393
|
+
query: print(GetMilestonesForQuoteDocument),
|
|
394
|
+
variables: {
|
|
395
|
+
merchantHandle,
|
|
396
|
+
quoteId,
|
|
397
|
+
},
|
|
398
|
+
}, merchantId);
|
|
399
|
+
if (!response.data?.getMilestonesForQuote) {
|
|
400
|
+
throw new Error('Failed to get milestones for quote: No data returned');
|
|
401
|
+
}
|
|
402
|
+
return response.data.getMilestonesForQuote;
|
|
403
|
+
}
|
|
404
|
+
async getMilestone(merchantHandle, milestoneId) {
|
|
405
|
+
const merchantId = await this.getMerchantIdFromHandleInternal(merchantHandle);
|
|
406
|
+
const response = await this.httpClient.request('/graphql-orders', {
|
|
407
|
+
query: print(GetMilestoneDocument),
|
|
408
|
+
variables: {
|
|
409
|
+
merchantHandle,
|
|
410
|
+
milestoneId,
|
|
411
|
+
},
|
|
412
|
+
}, merchantId);
|
|
413
|
+
if (response.data?.getMilestone === undefined) {
|
|
414
|
+
throw new Error('Failed to get milestone: No data returned');
|
|
415
|
+
}
|
|
416
|
+
return response.data.getMilestone;
|
|
417
|
+
}
|
|
418
|
+
async markMilestoneReadyForPayment(merchantHandle, milestoneId) {
|
|
419
|
+
const merchantId = await this.getMerchantIdFromHandleInternal(merchantHandle);
|
|
420
|
+
const response = await this.httpClient.request('/graphql-orders', {
|
|
421
|
+
query: print(MarkMilestoneReadyForPaymentDocument),
|
|
422
|
+
variables: {
|
|
423
|
+
merchantHandle,
|
|
424
|
+
milestoneId,
|
|
425
|
+
},
|
|
426
|
+
}, merchantId);
|
|
427
|
+
if (!response.data?.markMilestoneReadyForPayment) {
|
|
428
|
+
throw new Error('Failed to mark milestone ready for payment: No data returned');
|
|
429
|
+
}
|
|
430
|
+
return response.data.markMilestoneReadyForPayment;
|
|
431
|
+
}
|
|
432
|
+
async authorizeMilestonePayment(merchantHandle, milestoneId, paymentMethodId, location) {
|
|
433
|
+
const merchantId = await this.getMerchantIdFromHandleInternal(merchantHandle);
|
|
434
|
+
const response = await this.httpClient.request('/graphql-orders', {
|
|
435
|
+
query: print(AuthorizeMilestonePaymentDocument),
|
|
436
|
+
variables: {
|
|
437
|
+
merchantHandle,
|
|
438
|
+
milestoneId,
|
|
439
|
+
paymentMethodId,
|
|
440
|
+
location,
|
|
441
|
+
},
|
|
442
|
+
}, merchantId);
|
|
443
|
+
if (!response.data?.authorizeMilestonePayment) {
|
|
444
|
+
throw new Error('Failed to authorize milestone payment: No data returned');
|
|
445
|
+
}
|
|
446
|
+
return response.data.authorizeMilestonePayment;
|
|
447
|
+
}
|
|
448
|
+
async captureMilestonePayment(merchantHandle, milestoneId) {
|
|
449
|
+
const merchantId = await this.getMerchantIdFromHandleInternal(merchantHandle);
|
|
450
|
+
const response = await this.httpClient.request('/graphql-orders', {
|
|
451
|
+
query: print(CaptureMilestonePaymentDocument),
|
|
452
|
+
variables: {
|
|
453
|
+
merchantHandle,
|
|
454
|
+
milestoneId,
|
|
455
|
+
},
|
|
456
|
+
}, merchantId);
|
|
457
|
+
if (!response.data?.captureMilestonePayment) {
|
|
458
|
+
throw new Error('Failed to capture milestone payment: No data returned');
|
|
459
|
+
}
|
|
460
|
+
return response.data.captureMilestonePayment;
|
|
461
|
+
}
|
|
462
|
+
async createTimeAndMaterialsServiceQuote(merchantHandle, input) {
|
|
463
|
+
const merchantId = await this.getMerchantIdFromHandleInternal(merchantHandle);
|
|
464
|
+
const graphqlInput = {
|
|
465
|
+
orderId: input.orderId,
|
|
466
|
+
title: input.title,
|
|
467
|
+
description: input.description,
|
|
468
|
+
hourlyRateUsd: input.hourlyRateUsd,
|
|
469
|
+
maxAmountUsd: input.maxAmountUsd,
|
|
470
|
+
...(input.expiresInHours !== undefined && {
|
|
471
|
+
expiresInHours: input.expiresInHours,
|
|
472
|
+
}),
|
|
473
|
+
};
|
|
474
|
+
const response = await this.httpClient.request('/graphql-orders', {
|
|
475
|
+
query: print(CreateTimeAndMaterialsServiceQuoteDocument),
|
|
476
|
+
variables: {
|
|
477
|
+
input: graphqlInput,
|
|
478
|
+
},
|
|
479
|
+
}, merchantId);
|
|
480
|
+
if (!response.data?.createTimeAndMaterialsServiceQuote) {
|
|
481
|
+
throw new Error('Failed to create T&M service quote: No data returned');
|
|
482
|
+
}
|
|
483
|
+
return response.data.createTimeAndMaterialsServiceQuote;
|
|
484
|
+
}
|
|
485
|
+
async submitTimeLogForTandMQuote(merchantHandle, quoteId, input) {
|
|
486
|
+
const merchantId = await this.getMerchantIdFromHandleInternal(merchantHandle);
|
|
487
|
+
const response = await this.httpClient.request('/graphql-orders', {
|
|
488
|
+
query: print(SubmitTimeLogForTandMQuoteDocument),
|
|
489
|
+
variables: {
|
|
490
|
+
merchantHandle,
|
|
491
|
+
quoteId,
|
|
492
|
+
input,
|
|
493
|
+
},
|
|
494
|
+
}, merchantId);
|
|
495
|
+
if (!response.data?.submitTimeLogForTandMQuote) {
|
|
496
|
+
throw new Error('Failed to submit time log: No data returned');
|
|
497
|
+
}
|
|
498
|
+
return response.data.submitTimeLogForTandMQuote;
|
|
499
|
+
}
|
|
500
|
+
async submitMaterialReceiptForTandMQuote(merchantHandle, quoteId, input) {
|
|
501
|
+
const merchantId = await this.getMerchantIdFromHandleInternal(merchantHandle);
|
|
502
|
+
const response = await this.httpClient.request('/graphql-orders', {
|
|
503
|
+
query: print(SubmitMaterialReceiptForTandMQuoteDocument),
|
|
504
|
+
variables: {
|
|
505
|
+
merchantHandle,
|
|
506
|
+
quoteId,
|
|
507
|
+
input,
|
|
508
|
+
},
|
|
509
|
+
}, merchantId);
|
|
510
|
+
if (!response.data?.submitMaterialReceiptForTandMQuote) {
|
|
511
|
+
throw new Error('Failed to submit material receipt: No data returned');
|
|
512
|
+
}
|
|
513
|
+
return response.data.submitMaterialReceiptForTandMQuote;
|
|
514
|
+
}
|
|
515
|
+
async getTimeLogsForTandMQuote(merchantHandle, quoteId) {
|
|
516
|
+
const merchantId = await this.getMerchantIdFromHandleInternal(merchantHandle);
|
|
517
|
+
const response = await this.httpClient.request('/graphql-orders', {
|
|
518
|
+
query: print(GetTimeLogsForTandMQuoteDocument),
|
|
519
|
+
variables: {
|
|
520
|
+
merchantHandle,
|
|
521
|
+
quoteId,
|
|
522
|
+
},
|
|
523
|
+
}, merchantId);
|
|
524
|
+
if (!response.data?.getTimeLogsForTandMQuote) {
|
|
525
|
+
throw new Error('Failed to get time logs for T&M quote: No data returned');
|
|
526
|
+
}
|
|
527
|
+
return response.data.getTimeLogsForTandMQuote;
|
|
528
|
+
}
|
|
529
|
+
async getMaterialReceiptsForTandMQuote(merchantHandle, quoteId) {
|
|
530
|
+
const merchantId = await this.getMerchantIdFromHandleInternal(merchantHandle);
|
|
531
|
+
const response = await this.httpClient.request('/graphql-orders', {
|
|
532
|
+
query: print(GetMaterialReceiptsForTandMQuoteDocument),
|
|
533
|
+
variables: {
|
|
534
|
+
merchantHandle,
|
|
535
|
+
quoteId,
|
|
536
|
+
},
|
|
537
|
+
}, merchantId);
|
|
538
|
+
if (!response.data?.getMaterialReceiptsForTandMQuote) {
|
|
539
|
+
throw new Error('Failed to get material receipts for T&M quote: No data returned');
|
|
540
|
+
}
|
|
541
|
+
return response.data.getMaterialReceiptsForTandMQuote;
|
|
542
|
+
}
|
|
543
|
+
async getTimeAndMaterialsServiceQuote(merchantHandle, orderId) {
|
|
544
|
+
const merchantId = await this.getMerchantIdFromHandleInternal(merchantHandle);
|
|
545
|
+
const response = await this.httpClient.request('/graphql-orders', {
|
|
546
|
+
query: print(GetTimeAndMaterialsServiceQuoteDocument),
|
|
547
|
+
variables: {
|
|
548
|
+
merchantHandle,
|
|
549
|
+
orderId,
|
|
550
|
+
},
|
|
551
|
+
}, merchantId);
|
|
552
|
+
if (!response.data?.getTimeAndMaterialsServiceQuote) {
|
|
553
|
+
throw new Error('Failed to get T&M service quote: No data returned');
|
|
554
|
+
}
|
|
555
|
+
return response.data.getTimeAndMaterialsServiceQuote;
|
|
556
|
+
}
|
|
557
|
+
async calculateTimeAndMaterialsAmount(merchantHandle, quoteId) {
|
|
558
|
+
const merchantId = await this.getMerchantIdFromHandleInternal(merchantHandle);
|
|
559
|
+
const response = await this.httpClient.request('/graphql-orders', {
|
|
560
|
+
query: print(CalculateTimeAndMaterialsAmountDocument),
|
|
561
|
+
variables: {
|
|
562
|
+
merchantHandle,
|
|
563
|
+
quoteId,
|
|
564
|
+
},
|
|
565
|
+
}, merchantId);
|
|
566
|
+
if (response.data?.calculateTimeAndMaterialsAmount === undefined) {
|
|
567
|
+
throw new Error('Failed to calculate T&M amount: No data returned');
|
|
568
|
+
}
|
|
569
|
+
return response.data.calculateTimeAndMaterialsAmount;
|
|
570
|
+
}
|
|
571
|
+
async updateTimeAndMaterialsServiceQuote(merchantHandle, input) {
|
|
572
|
+
const merchantId = await this.getMerchantIdFromHandleInternal(merchantHandle);
|
|
573
|
+
const response = await this.httpClient.request('/graphql-orders', {
|
|
574
|
+
query: print(UpdateTimeAndMaterialsServiceQuoteDocument),
|
|
575
|
+
variables: {
|
|
576
|
+
merchantHandle,
|
|
577
|
+
input,
|
|
578
|
+
},
|
|
579
|
+
}, merchantId);
|
|
580
|
+
if (!response.data?.updateTimeAndMaterialsServiceQuote) {
|
|
581
|
+
throw new Error('Failed to update T&M service quote: No data returned');
|
|
582
|
+
}
|
|
583
|
+
return response.data.updateTimeAndMaterialsServiceQuote;
|
|
584
|
+
}
|
|
585
|
+
async createTimeAndMaterialsPaymentIntent(merchantHandle, orderId, paymentMethodId, location) {
|
|
586
|
+
const merchantId = await this.getMerchantIdFromHandleInternal(merchantHandle);
|
|
587
|
+
const response = await this.httpClient.request('/graphql-orders', {
|
|
588
|
+
query: print(CreateTimeAndMaterialsPaymentIntentDocument),
|
|
589
|
+
variables: {
|
|
590
|
+
merchantHandle,
|
|
591
|
+
orderId,
|
|
592
|
+
paymentMethodId,
|
|
593
|
+
location,
|
|
594
|
+
},
|
|
595
|
+
}, merchantId);
|
|
596
|
+
if (!response.data?.createTimeAndMaterialsPaymentIntent) {
|
|
597
|
+
throw new Error('Failed to create T&M payment intent: No data returned');
|
|
598
|
+
}
|
|
599
|
+
return response.data.createTimeAndMaterialsPaymentIntent;
|
|
600
|
+
}
|
|
601
|
+
async requestTimeAndMaterialsPayment(merchantHandle, quoteId, description, amountUsd) {
|
|
602
|
+
const merchantId = await this.getMerchantIdFromHandleInternal(merchantHandle);
|
|
603
|
+
const response = await this.httpClient.request('/graphql-orders', {
|
|
604
|
+
query: print(RequestTimeAndMaterialsPaymentDocument),
|
|
605
|
+
variables: {
|
|
606
|
+
merchantHandle,
|
|
607
|
+
quoteId,
|
|
608
|
+
input: {
|
|
609
|
+
description,
|
|
610
|
+
amountUsd,
|
|
611
|
+
},
|
|
612
|
+
},
|
|
613
|
+
}, merchantId);
|
|
614
|
+
if (!response.data?.requestTimeAndMaterialsPayment) {
|
|
615
|
+
throw new Error('Failed to request T&M payment: No data returned');
|
|
616
|
+
}
|
|
617
|
+
return response.data.requestTimeAndMaterialsPayment;
|
|
618
|
+
}
|
|
619
|
+
async authorizeTimeAndMaterialsPayment(merchantHandle, billingRequestId, paymentMethodId, location) {
|
|
620
|
+
const merchantId = await this.getMerchantIdFromHandleInternal(merchantHandle);
|
|
621
|
+
const response = await this.httpClient.request('/graphql-orders', {
|
|
622
|
+
query: print(AuthorizeTimeAndMaterialsPaymentDocument),
|
|
623
|
+
variables: {
|
|
624
|
+
merchantHandle,
|
|
625
|
+
billingRequestId,
|
|
626
|
+
paymentMethodId,
|
|
627
|
+
location,
|
|
628
|
+
},
|
|
629
|
+
}, merchantId);
|
|
630
|
+
if (!response.data?.authorizeTimeAndMaterialsPayment) {
|
|
631
|
+
throw new Error('Failed to authorize T&M payment: No data returned');
|
|
632
|
+
}
|
|
633
|
+
return response.data.authorizeTimeAndMaterialsPayment;
|
|
634
|
+
}
|
|
635
|
+
async captureTimeAndMaterialsPayment(merchantHandle, billingRequestId) {
|
|
636
|
+
const merchantId = await this.getMerchantIdFromHandleInternal(merchantHandle);
|
|
637
|
+
const response = await this.httpClient.request('/graphql-orders', {
|
|
638
|
+
query: print(CaptureTimeAndMaterialsPaymentDocument),
|
|
639
|
+
variables: {
|
|
640
|
+
merchantHandle,
|
|
641
|
+
billingRequestId,
|
|
642
|
+
},
|
|
643
|
+
}, merchantId);
|
|
644
|
+
if (!response.data?.captureTimeAndMaterialsPayment) {
|
|
645
|
+
throw new Error('Failed to capture T&M payment: No data returned');
|
|
646
|
+
}
|
|
647
|
+
return response.data.captureTimeAndMaterialsPayment;
|
|
648
|
+
}
|
|
649
|
+
async getTimeAndMaterialsBillingRequests(merchantHandle, quoteId) {
|
|
650
|
+
const merchantId = await this.getMerchantIdFromHandleInternal(merchantHandle);
|
|
651
|
+
const response = await this.httpClient.request('/graphql-orders', {
|
|
652
|
+
query: print(GetTimeAndMaterialsBillingRequestsDocument),
|
|
653
|
+
variables: {
|
|
654
|
+
merchantHandle,
|
|
655
|
+
quoteId,
|
|
656
|
+
},
|
|
657
|
+
}, merchantId);
|
|
658
|
+
if (!response.data?.getTimeAndMaterialsBillingRequests) {
|
|
659
|
+
throw new Error('Failed to get T&M billing requests: No data returned');
|
|
660
|
+
}
|
|
661
|
+
return response.data.getTimeAndMaterialsBillingRequests;
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
//# sourceMappingURL=OrdersClient.js.map
|