mapflow-co-sdk 1.0.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.
@@ -0,0 +1,84 @@
1
+ import { MapFlowConfig, PaginatedResponse, Customer, CustomerCreate, CustomerUpdate, DeliveryLocation, DeliveryLocationCreate, DeliveryLocationUpdate, Warehouse, WarehouseCreate, WarehouseUpdate, GlobalCustomer, GlobalCustomerCreate, LocationContact, LocationContactCreate, LocationContactUpdate, LocationOpeningHours, LocationOpeningHoursCreate, LocationOpeningHoursUpdate, DeliveryItem, DeliveryItemCreate, DeliveryItemUpdate, DriverPicker, DriverPickerCreate, DriverPickerUpdate, Vehicle, VehicleCreate, VehicleUpdate, Tag, TagCreate, TagUpdate, Visit, VisitCreate, VisitUpdate, VisitProduct, VisitProductCreate, VisitProductUpdate, BulkActionRequest, BulkActionResponse } from './types';
2
+ export declare class MapFlowClient {
3
+ private client;
4
+ private apiKey;
5
+ constructor(config: MapFlowConfig);
6
+ private request;
7
+ listCustomers(params?: Record<string, any>): Promise<PaginatedResponse<Customer>>;
8
+ createCustomer(data: CustomerCreate): Promise<Customer>;
9
+ getCustomer(id: string): Promise<Customer>;
10
+ updateCustomer(id: string, data: CustomerUpdate): Promise<Customer>;
11
+ patchCustomer(id: string, data: Partial<CustomerUpdate>): Promise<Customer>;
12
+ deleteCustomer(id: string): Promise<void>;
13
+ customerBulkAction(action: BulkActionRequest): Promise<BulkActionResponse>;
14
+ listDeliveryLocations(params?: Record<string, any>): Promise<PaginatedResponse<DeliveryLocation>>;
15
+ createDeliveryLocation(data: DeliveryLocationCreate): Promise<DeliveryLocation>;
16
+ getDeliveryLocation(id: string): Promise<DeliveryLocation>;
17
+ updateDeliveryLocation(id: string, data: DeliveryLocationUpdate): Promise<DeliveryLocation>;
18
+ patchDeliveryLocation(id: string, data: Partial<DeliveryLocationUpdate>): Promise<DeliveryLocation>;
19
+ deleteDeliveryLocation(id: string): Promise<void>;
20
+ deliveryLocationBulkAction(action: BulkActionRequest): Promise<BulkActionResponse>;
21
+ listWarehouses(params?: Record<string, any>): Promise<PaginatedResponse<Warehouse>>;
22
+ createWarehouse(data: WarehouseCreate): Promise<Warehouse>;
23
+ getWarehouse(id: string): Promise<Warehouse>;
24
+ updateWarehouse(id: string, data: WarehouseUpdate): Promise<Warehouse>;
25
+ patchWarehouse(id: string, data: Partial<WarehouseUpdate>): Promise<Warehouse>;
26
+ deleteWarehouse(id: string): Promise<void>;
27
+ setDefaultWarehouse(id: string): Promise<Warehouse>;
28
+ warehouseBulkAction(action: BulkActionRequest): Promise<BulkActionResponse>;
29
+ createGlobalCustomer(data: GlobalCustomerCreate): Promise<GlobalCustomer>;
30
+ listContacts(params?: Record<string, any>): Promise<PaginatedResponse<LocationContact>>;
31
+ createContact(data: LocationContactCreate): Promise<LocationContact>;
32
+ getContact(id: string): Promise<LocationContact>;
33
+ updateContact(id: string, data: LocationContactUpdate): Promise<LocationContact>;
34
+ patchContact(id: string, data: Partial<LocationContactUpdate>): Promise<LocationContact>;
35
+ deleteContact(id: string): Promise<void>;
36
+ listOpeningHours(params?: Record<string, any>): Promise<PaginatedResponse<LocationOpeningHours>>;
37
+ createOpeningHours(data: LocationOpeningHoursCreate): Promise<LocationOpeningHours>;
38
+ getOpeningHours(id: string): Promise<LocationOpeningHours>;
39
+ updateOpeningHours(id: string, data: LocationOpeningHoursUpdate): Promise<LocationOpeningHours>;
40
+ patchOpeningHours(id: string, data: Partial<LocationOpeningHoursUpdate>): Promise<LocationOpeningHours>;
41
+ deleteOpeningHours(id: string): Promise<void>;
42
+ listDeliveryItems(params?: Record<string, any>): Promise<PaginatedResponse<DeliveryItem>>;
43
+ createDeliveryItem(data: DeliveryItemCreate): Promise<DeliveryItem>;
44
+ getDeliveryItem(id: string): Promise<DeliveryItem>;
45
+ updateDeliveryItem(id: string, data: DeliveryItemUpdate): Promise<DeliveryItem>;
46
+ patchDeliveryItem(id: string, data: Partial<DeliveryItemUpdate>): Promise<DeliveryItem>;
47
+ deleteDeliveryItem(id: string): Promise<void>;
48
+ deliveryItemBulkAction(action: BulkActionRequest): Promise<BulkActionResponse>;
49
+ listDrivers(params?: Record<string, any>): Promise<PaginatedResponse<DriverPicker>>;
50
+ createDriver(data: DriverPickerCreate): Promise<DriverPicker>;
51
+ getDriver(id: string): Promise<DriverPicker>;
52
+ updateDriver(id: string, data: DriverPickerUpdate): Promise<DriverPicker>;
53
+ patchDriver(id: string, data: Partial<DriverPickerUpdate>): Promise<DriverPicker>;
54
+ deleteDriver(id: string): Promise<void>;
55
+ listVehicles(params?: Record<string, any>): Promise<Vehicle[]>;
56
+ createVehicle(data: VehicleCreate): Promise<Vehicle>;
57
+ getVehicle(id: string): Promise<Vehicle>;
58
+ updateVehicle(id: string, data: VehicleUpdate): Promise<Vehicle>;
59
+ patchVehicle(id: string, data: Partial<VehicleUpdate>): Promise<Vehicle>;
60
+ deleteVehicle(id: string): Promise<void>;
61
+ vehicleBulkAction(action: BulkActionRequest): Promise<BulkActionResponse>;
62
+ listTags(params?: Record<string, any>): Promise<PaginatedResponse<Tag>>;
63
+ createTag(data: TagCreate): Promise<Tag>;
64
+ getTag(id: string): Promise<Tag>;
65
+ updateTag(id: string, data: TagUpdate): Promise<Tag>;
66
+ patchTag(id: string, data: Partial<TagUpdate>): Promise<Tag>;
67
+ deleteTag(id: string): Promise<void>;
68
+ tagBulkAction(action: BulkActionRequest): Promise<BulkActionResponse>;
69
+ listVisits(params?: Record<string, any>): Promise<PaginatedResponse<Visit>>;
70
+ createVisit(data: VisitCreate): Promise<Visit>;
71
+ getVisit(id: string): Promise<Visit>;
72
+ updateVisit(id: string, data: VisitUpdate): Promise<Visit>;
73
+ patchVisit(id: string, data: Partial<VisitUpdate>): Promise<Visit>;
74
+ deleteVisit(id: string): Promise<void>;
75
+ visitBulkAction(action: BulkActionRequest): Promise<BulkActionResponse>;
76
+ listVisitProducts(params?: Record<string, any>): Promise<PaginatedResponse<VisitProduct>>;
77
+ createVisitProduct(data: VisitProductCreate): Promise<VisitProduct>;
78
+ getVisitProduct(id: string): Promise<VisitProduct>;
79
+ updateVisitProduct(id: string, data: VisitProductUpdate): Promise<VisitProduct>;
80
+ patchVisitProduct(id: string, data: Partial<VisitProductUpdate>): Promise<VisitProduct>;
81
+ deleteVisitProduct(id: string): Promise<void>;
82
+ visitProductBulkAction(action: BulkActionRequest): Promise<BulkActionResponse>;
83
+ }
84
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,aAAa,EACb,iBAAiB,EACjB,QAAQ,EACR,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,sBAAsB,EACtB,sBAAsB,EACtB,SAAS,EACT,eAAe,EACf,eAAe,EACf,cAAc,EACd,oBAAoB,EACpB,eAAe,EACf,qBAAqB,EACrB,qBAAqB,EACrB,oBAAoB,EACpB,0BAA0B,EAC1B,0BAA0B,EAC1B,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAClB,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAClB,OAAO,EACP,aAAa,EACb,aAAa,EACb,GAAG,EACH,SAAS,EACT,SAAS,EACT,KAAK,EACL,WAAW,EACX,WAAW,EACX,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EACnB,MAAM,SAAS,CAAC;AAcjB,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAgB;IAC9B,OAAO,CAAC,MAAM,CAAS;gBAEX,MAAM,EAAE,aAAa;YA8DnB,OAAO;IAaf,aAAa,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC;IAQjF,cAAc,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,QAAQ,CAAC;IAQvD,WAAW,CAAC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AAG,OAAO,CAAC,YAAY,CAAC;IAQ/E,iBAAiB,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,kBAAkB,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC;IAQvF,kBAAkB,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAO7C,sBAAsB,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAOrF"}
package/dist/client.js ADDED
@@ -0,0 +1,581 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.MapFlowClient = void 0;
7
+ const axios_1 = __importDefault(require("axios"));
8
+ const errors_1 = require("./errors");
9
+ const DEFAULT_BASE_URL = 'https://api.mapflow.co';
10
+ const DEFAULT_TIMEOUT = 30000;
11
+ class MapFlowClient {
12
+ constructor(config) {
13
+ this.apiKey = config.apiKey;
14
+ this.client = axios_1.default.create({
15
+ baseURL: config.baseUrl || DEFAULT_BASE_URL,
16
+ timeout: config.timeout || DEFAULT_TIMEOUT,
17
+ headers: {
18
+ 'X-API-Key': this.apiKey,
19
+ 'Content-Type': 'application/json',
20
+ },
21
+ });
22
+ this.client.interceptors.response.use((response) => response, (error) => {
23
+ if (error.response) {
24
+ const { status, data } = error.response;
25
+ let message = data?.detail || data?.message || error.message;
26
+ if (data && typeof data === 'object' && !data.detail && !data.message) {
27
+ const errorMessages = [];
28
+ for (const [field, errors] of Object.entries(data)) {
29
+ if (Array.isArray(errors)) {
30
+ errorMessages.push(`${field}: ${errors.join(', ')}`);
31
+ }
32
+ else if (typeof errors === 'string') {
33
+ errorMessages.push(`${field}: ${errors}`);
34
+ }
35
+ }
36
+ if (errorMessages.length > 0) {
37
+ message = errorMessages.join('; ');
38
+ }
39
+ }
40
+ switch (status) {
41
+ case 400:
42
+ throw new errors_1.ValidationError(message, data);
43
+ case 401:
44
+ throw new errors_1.AuthenticationError(message, data);
45
+ case 403:
46
+ throw new errors_1.ForbiddenError(message, data);
47
+ case 404:
48
+ throw new errors_1.NotFoundError(message, data);
49
+ case 429:
50
+ throw new errors_1.RateLimitError(message, data);
51
+ case 500:
52
+ case 502:
53
+ case 503:
54
+ case 504:
55
+ throw new errors_1.ServerError(message, data);
56
+ default:
57
+ throw new errors_1.MapFlowError(message, status, data);
58
+ }
59
+ }
60
+ throw new errors_1.MapFlowError(error.message);
61
+ });
62
+ }
63
+ async request(config) {
64
+ if (config.url && !config.url.startsWith('/api/')) {
65
+ config.url = `/api/v1${config.url}`;
66
+ }
67
+ const response = await this.client.request(config);
68
+ return response.data;
69
+ }
70
+ async listCustomers(params) {
71
+ return this.request({
72
+ method: 'GET',
73
+ url: '/locations/customers/',
74
+ params,
75
+ });
76
+ }
77
+ async createCustomer(data) {
78
+ return this.request({
79
+ method: 'POST',
80
+ url: '/locations/customers/',
81
+ data,
82
+ });
83
+ }
84
+ async getCustomer(id) {
85
+ return this.request({
86
+ method: 'GET',
87
+ url: `/locations/customers/${id}/`,
88
+ });
89
+ }
90
+ async updateCustomer(id, data) {
91
+ return this.request({
92
+ method: 'PUT',
93
+ url: `/locations/customers/${id}/`,
94
+ data,
95
+ });
96
+ }
97
+ async patchCustomer(id, data) {
98
+ return this.request({
99
+ method: 'PATCH',
100
+ url: `/locations/customers/${id}/`,
101
+ data,
102
+ });
103
+ }
104
+ async deleteCustomer(id) {
105
+ await this.request({
106
+ method: 'DELETE',
107
+ url: `/locations/customers/${id}/`,
108
+ });
109
+ }
110
+ async customerBulkAction(action) {
111
+ return this.request({
112
+ method: 'POST',
113
+ url: '/locations/customers/bulk_action/',
114
+ data: action,
115
+ });
116
+ }
117
+ async listDeliveryLocations(params) {
118
+ return this.request({
119
+ method: 'GET',
120
+ url: '/locations/delivery-locations/',
121
+ params,
122
+ });
123
+ }
124
+ async createDeliveryLocation(data) {
125
+ return this.request({
126
+ method: 'POST',
127
+ url: '/locations/delivery-locations/',
128
+ data,
129
+ });
130
+ }
131
+ async getDeliveryLocation(id) {
132
+ return this.request({
133
+ method: 'GET',
134
+ url: `/locations/delivery-locations/${id}/`,
135
+ });
136
+ }
137
+ async updateDeliveryLocation(id, data) {
138
+ return this.request({
139
+ method: 'PUT',
140
+ url: `/locations/delivery-locations/${id}/`,
141
+ data,
142
+ });
143
+ }
144
+ async patchDeliveryLocation(id, data) {
145
+ return this.request({
146
+ method: 'PATCH',
147
+ url: `/locations/delivery-locations/${id}/`,
148
+ data,
149
+ });
150
+ }
151
+ async deleteDeliveryLocation(id) {
152
+ await this.request({
153
+ method: 'DELETE',
154
+ url: `/locations/delivery-locations/${id}/`,
155
+ });
156
+ }
157
+ async deliveryLocationBulkAction(action) {
158
+ return this.request({
159
+ method: 'POST',
160
+ url: '/locations/delivery-locations/bulk_action/',
161
+ data: action,
162
+ });
163
+ }
164
+ async listWarehouses(params) {
165
+ return this.request({
166
+ method: 'GET',
167
+ url: '/locations/warehouses/',
168
+ params,
169
+ });
170
+ }
171
+ async createWarehouse(data) {
172
+ return this.request({
173
+ method: 'POST',
174
+ url: '/locations/warehouses/',
175
+ data,
176
+ });
177
+ }
178
+ async getWarehouse(id) {
179
+ return this.request({
180
+ method: 'GET',
181
+ url: `/locations/warehouses/${id}/`,
182
+ });
183
+ }
184
+ async updateWarehouse(id, data) {
185
+ return this.request({
186
+ method: 'PUT',
187
+ url: `/locations/warehouses/${id}/`,
188
+ data,
189
+ });
190
+ }
191
+ async patchWarehouse(id, data) {
192
+ return this.request({
193
+ method: 'PATCH',
194
+ url: `/locations/warehouses/${id}/`,
195
+ data,
196
+ });
197
+ }
198
+ async deleteWarehouse(id) {
199
+ await this.request({
200
+ method: 'DELETE',
201
+ url: `/locations/warehouses/${id}/`,
202
+ });
203
+ }
204
+ async setDefaultWarehouse(id) {
205
+ return this.request({
206
+ method: 'POST',
207
+ url: `/locations/warehouses/${id}/set_default/`,
208
+ });
209
+ }
210
+ async warehouseBulkAction(action) {
211
+ return this.request({
212
+ method: 'POST',
213
+ url: '/locations/warehouses/bulk_action/',
214
+ data: action,
215
+ });
216
+ }
217
+ async createGlobalCustomer(data) {
218
+ return this.request({
219
+ method: 'POST',
220
+ url: '/locations/global-customers/',
221
+ data,
222
+ });
223
+ }
224
+ async listContacts(params) {
225
+ return this.request({
226
+ method: 'GET',
227
+ url: '/locations/contacts/',
228
+ params,
229
+ });
230
+ }
231
+ async createContact(data) {
232
+ return this.request({
233
+ method: 'POST',
234
+ url: '/locations/contacts/',
235
+ data,
236
+ });
237
+ }
238
+ async getContact(id) {
239
+ return this.request({
240
+ method: 'GET',
241
+ url: `/locations/contacts/${id}/`,
242
+ });
243
+ }
244
+ async updateContact(id, data) {
245
+ return this.request({
246
+ method: 'PUT',
247
+ url: `/locations/contacts/${id}/`,
248
+ data,
249
+ });
250
+ }
251
+ async patchContact(id, data) {
252
+ return this.request({
253
+ method: 'PATCH',
254
+ url: `/locations/contacts/${id}/`,
255
+ data,
256
+ });
257
+ }
258
+ async deleteContact(id) {
259
+ await this.request({
260
+ method: 'DELETE',
261
+ url: `/locations/contacts/${id}/`,
262
+ });
263
+ }
264
+ async listOpeningHours(params) {
265
+ return this.request({
266
+ method: 'GET',
267
+ url: '/locations/opening-hours/',
268
+ params,
269
+ });
270
+ }
271
+ async createOpeningHours(data) {
272
+ return this.request({
273
+ method: 'POST',
274
+ url: '/locations/opening-hours/',
275
+ data,
276
+ });
277
+ }
278
+ async getOpeningHours(id) {
279
+ return this.request({
280
+ method: 'GET',
281
+ url: `/locations/opening-hours/${id}/`,
282
+ });
283
+ }
284
+ async updateOpeningHours(id, data) {
285
+ return this.request({
286
+ method: 'PUT',
287
+ url: `/locations/opening-hours/${id}/`,
288
+ data,
289
+ });
290
+ }
291
+ async patchOpeningHours(id, data) {
292
+ return this.request({
293
+ method: 'PATCH',
294
+ url: `/locations/opening-hours/${id}/`,
295
+ data,
296
+ });
297
+ }
298
+ async deleteOpeningHours(id) {
299
+ await this.request({
300
+ method: 'DELETE',
301
+ url: `/locations/opening-hours/${id}/`,
302
+ });
303
+ }
304
+ async listDeliveryItems(params) {
305
+ return this.request({
306
+ method: 'GET',
307
+ url: '/catalog/delivery-items/',
308
+ params,
309
+ });
310
+ }
311
+ async createDeliveryItem(data) {
312
+ return this.request({
313
+ method: 'POST',
314
+ url: '/catalog/delivery-items/',
315
+ data,
316
+ });
317
+ }
318
+ async getDeliveryItem(id) {
319
+ return this.request({
320
+ method: 'GET',
321
+ url: `/catalog/delivery-items/${id}/`,
322
+ });
323
+ }
324
+ async updateDeliveryItem(id, data) {
325
+ return this.request({
326
+ method: 'PUT',
327
+ url: `/catalog/delivery-items/${id}/`,
328
+ data,
329
+ });
330
+ }
331
+ async patchDeliveryItem(id, data) {
332
+ return this.request({
333
+ method: 'PATCH',
334
+ url: `/catalog/delivery-items/${id}/`,
335
+ data,
336
+ });
337
+ }
338
+ async deleteDeliveryItem(id) {
339
+ await this.request({
340
+ method: 'DELETE',
341
+ url: `/catalog/delivery-items/${id}/`,
342
+ });
343
+ }
344
+ async deliveryItemBulkAction(action) {
345
+ return this.request({
346
+ method: 'POST',
347
+ url: '/catalog/delivery-items/bulk_action/',
348
+ data: action,
349
+ });
350
+ }
351
+ async listDrivers(params) {
352
+ return this.request({
353
+ method: 'GET',
354
+ url: '/drivers-pickers/people/',
355
+ params,
356
+ });
357
+ }
358
+ async createDriver(data) {
359
+ return this.request({
360
+ method: 'POST',
361
+ url: '/drivers-pickers/people/',
362
+ data,
363
+ });
364
+ }
365
+ async getDriver(id) {
366
+ return this.request({
367
+ method: 'GET',
368
+ url: `/drivers-pickers/people/${id}/`,
369
+ });
370
+ }
371
+ async updateDriver(id, data) {
372
+ return this.request({
373
+ method: 'PUT',
374
+ url: `/drivers-pickers/people/${id}/`,
375
+ data,
376
+ });
377
+ }
378
+ async patchDriver(id, data) {
379
+ return this.request({
380
+ method: 'PATCH',
381
+ url: `/drivers-pickers/people/${id}/`,
382
+ data,
383
+ });
384
+ }
385
+ async deleteDriver(id) {
386
+ await this.request({
387
+ method: 'DELETE',
388
+ url: `/drivers-pickers/people/${id}/`,
389
+ });
390
+ }
391
+ async listVehicles(params) {
392
+ return this.request({
393
+ method: 'GET',
394
+ url: '/vehicles/vehicles/',
395
+ params,
396
+ });
397
+ }
398
+ async createVehicle(data) {
399
+ return this.request({
400
+ method: 'POST',
401
+ url: '/vehicles/vehicles/',
402
+ data,
403
+ });
404
+ }
405
+ async getVehicle(id) {
406
+ return this.request({
407
+ method: 'GET',
408
+ url: `/vehicles/vehicles/${id}/`,
409
+ });
410
+ }
411
+ async updateVehicle(id, data) {
412
+ return this.request({
413
+ method: 'PUT',
414
+ url: `/vehicles/vehicles/${id}/`,
415
+ data,
416
+ });
417
+ }
418
+ async patchVehicle(id, data) {
419
+ return this.request({
420
+ method: 'PATCH',
421
+ url: `/vehicles/vehicles/${id}/`,
422
+ data,
423
+ });
424
+ }
425
+ async deleteVehicle(id) {
426
+ await this.request({
427
+ method: 'DELETE',
428
+ url: `/vehicles/vehicles/${id}/`,
429
+ });
430
+ }
431
+ async vehicleBulkAction(action) {
432
+ return this.request({
433
+ method: 'POST',
434
+ url: '/vehicles/vehicles/bulk_action/',
435
+ data: action,
436
+ });
437
+ }
438
+ async listTags(params) {
439
+ return this.request({
440
+ method: 'GET',
441
+ url: '/tags/visits/',
442
+ params,
443
+ });
444
+ }
445
+ async createTag(data) {
446
+ return this.request({
447
+ method: 'POST',
448
+ url: '/tags/visits/',
449
+ data,
450
+ });
451
+ }
452
+ async getTag(id) {
453
+ return this.request({
454
+ method: 'GET',
455
+ url: `/tags/visits/${id}/`,
456
+ });
457
+ }
458
+ async updateTag(id, data) {
459
+ return this.request({
460
+ method: 'PUT',
461
+ url: `/tags/visits/${id}/`,
462
+ data,
463
+ });
464
+ }
465
+ async patchTag(id, data) {
466
+ return this.request({
467
+ method: 'PATCH',
468
+ url: `/tags/visits/${id}/`,
469
+ data,
470
+ });
471
+ }
472
+ async deleteTag(id) {
473
+ await this.request({
474
+ method: 'DELETE',
475
+ url: `/tags/visits/${id}/`,
476
+ });
477
+ }
478
+ async tagBulkAction(action) {
479
+ return this.request({
480
+ method: 'POST',
481
+ url: '/tags/visits/bulk_action/',
482
+ data: action,
483
+ });
484
+ }
485
+ async listVisits(params) {
486
+ return this.request({
487
+ method: 'GET',
488
+ url: '/visits/',
489
+ params,
490
+ });
491
+ }
492
+ async createVisit(data) {
493
+ return this.request({
494
+ method: 'POST',
495
+ url: '/visits/',
496
+ data,
497
+ });
498
+ }
499
+ async getVisit(id) {
500
+ return this.request({
501
+ method: 'GET',
502
+ url: `/visits/${id}/`,
503
+ });
504
+ }
505
+ async updateVisit(id, data) {
506
+ return this.request({
507
+ method: 'PUT',
508
+ url: `/visits/${id}/`,
509
+ data,
510
+ });
511
+ }
512
+ async patchVisit(id, data) {
513
+ return this.request({
514
+ method: 'PATCH',
515
+ url: `/visits/${id}/`,
516
+ data,
517
+ });
518
+ }
519
+ async deleteVisit(id) {
520
+ await this.request({
521
+ method: 'DELETE',
522
+ url: `/visits/${id}/`,
523
+ });
524
+ }
525
+ async visitBulkAction(action) {
526
+ return this.request({
527
+ method: 'POST',
528
+ url: '/visits/bulk_action/',
529
+ data: action,
530
+ });
531
+ }
532
+ async listVisitProducts(params) {
533
+ return this.request({
534
+ method: 'GET',
535
+ url: '/visits/products/',
536
+ params,
537
+ });
538
+ }
539
+ async createVisitProduct(data) {
540
+ return this.request({
541
+ method: 'POST',
542
+ url: '/visits/products/',
543
+ data,
544
+ });
545
+ }
546
+ async getVisitProduct(id) {
547
+ return this.request({
548
+ method: 'GET',
549
+ url: `/visits/products/${id}/`,
550
+ });
551
+ }
552
+ async updateVisitProduct(id, data) {
553
+ return this.request({
554
+ method: 'PUT',
555
+ url: `/visits/products/${id}/`,
556
+ data,
557
+ });
558
+ }
559
+ async patchVisitProduct(id, data) {
560
+ return this.request({
561
+ method: 'PATCH',
562
+ url: `/visits/products/${id}/`,
563
+ data,
564
+ });
565
+ }
566
+ async deleteVisitProduct(id) {
567
+ await this.request({
568
+ method: 'DELETE',
569
+ url: `/visits/products/${id}/`,
570
+ });
571
+ }
572
+ async visitProductBulkAction(action) {
573
+ return this.request({
574
+ method: 'POST',
575
+ url: '/visits/products/bulk_action/',
576
+ data: action,
577
+ });
578
+ }
579
+ }
580
+ exports.MapFlowClient = MapFlowClient;
581
+ //# sourceMappingURL=client.js.map