starta.apiclient 1.37.7115 → 1.37.7119

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,4 +1,4 @@
1
- import { StartaRequestRunner, OrderStatus, OrderRepeatSettings } from '../../types';
1
+ import { StartaRequestRunner, OrderStatus, OrderData, CreateOrderData } from '../../types';
2
2
  export default class Orders {
3
3
  private _requestRunner;
4
4
  constructor(requestRunner: StartaRequestRunner);
@@ -22,89 +22,16 @@ export default class Orders {
22
22
  searchQuery?: string;
23
23
  }): Promise<import("../../types").StartaResponse>;
24
24
  isTimeSlotAvailable(organizationLogin: string, { executor, starttime, endtime, skipOrderId, scheduleId, resources, }: {
25
- executor: string;
25
+ scheduleId: string;
26
26
  starttime: string;
27
27
  endtime: string;
28
+ executor?: string;
28
29
  skipOrderId?: string;
29
- scheduleId: string;
30
30
  resources?: Array<string>;
31
31
  }): Promise<import("../../types").StartaResponse>;
32
32
  get(organizationOrCustomerLogin: string, orderId: any): Promise<import("../../types").StartaResponse>;
33
- add(organizationLogin: string, { products, usedMaterials, starttime, endtime, customerId, scheduleId, status, repeatSettings, discountType, discount, organizationComment, }: {
34
- products: Array<{
35
- type: string;
36
- id: string;
37
- executors?: Array<string>;
38
- amount?: number;
39
- price?: number;
40
- duration?: number;
41
- timeOffset?: number;
42
- warehouseId?: string;
43
- resources?: Array<string>;
44
- }>;
45
- usedMaterials?: Array<{
46
- serviceId: string;
47
- techcardId?: string;
48
- steps?: Array<{
49
- name: string;
50
- items: Array<{
51
- type: 'product';
52
- warehouseId: string;
53
- productId: string;
54
- amount: number;
55
- } | {
56
- type: 'comment';
57
- comment: string;
58
- }>;
59
- }>;
60
- }>;
61
- starttime?: any;
62
- endtime?: any;
63
- customerId: any;
64
- scheduleId?: any;
65
- status?: OrderStatus;
66
- repeatSettings?: OrderRepeatSettings;
67
- discountType?: 'relative' | 'absolute';
68
- discount?: number;
69
- organizationComment?: string;
70
- }): Promise<import("../../types").StartaResponse>;
71
- update(organizationLogin: string, orderId: string, { products, usedMaterials, starttime, endtime, scheduleId, status, repeatSettings, discountType, discount, organizationComment, }: {
72
- products: Array<{
73
- type: string;
74
- id: string;
75
- executors?: Array<string>;
76
- amount?: number;
77
- price?: number;
78
- duration?: number;
79
- timeOffset?: number;
80
- warehouseId?: string;
81
- resources?: Array<string>;
82
- }>;
83
- usedMaterials?: Array<{
84
- serviceId: string;
85
- techcardId?: string;
86
- steps?: Array<{
87
- name: string;
88
- items: Array<{
89
- type: 'product';
90
- warehouseId: string;
91
- productId: string;
92
- amount: number;
93
- } | {
94
- type: 'comment';
95
- comment: string;
96
- }>;
97
- }>;
98
- }>;
99
- starttime?: any;
100
- endtime?: any;
101
- scheduleId?: any;
102
- status?: OrderStatus;
103
- repeatSettings?: OrderRepeatSettings;
104
- discountType?: 'relative' | 'absolute';
105
- discount?: number;
106
- organizationComment?: string;
107
- }): Promise<import("../../types").StartaResponse>;
33
+ add(organizationLogin: string, { products, usedMaterials, customerId, scheduleId, status, repeatSettings, organizationComment, }: CreateOrderData): Promise<import("../../types").StartaResponse>;
34
+ update(organizationLogin: string, orderId: string, { products, usedMaterials, scheduleId, status, repeatSettings, organizationComment, }: OrderData): Promise<import("../../types").StartaResponse>;
108
35
  delete(organizationLogin: string, orderId: string): Promise<import("../../types").StartaResponse>;
109
36
  setConfirmation(organizationOrCustomerLogin: string, orderId: string, { isConfirmed }: {
110
37
  isConfirmed: boolean;
@@ -44,39 +44,31 @@ class Orders {
44
44
  method: 'GET',
45
45
  });
46
46
  }
47
- add(organizationLogin, { products, usedMaterials, starttime, endtime, customerId, scheduleId, status = 'new', repeatSettings, discountType, discount, organizationComment, }) {
47
+ add(organizationLogin, { products, usedMaterials, customerId, scheduleId, status = 'new', repeatSettings, organizationComment, }) {
48
48
  return this._requestRunner.performRequest({
49
49
  url: `accounts/${organizationLogin}/orders`,
50
50
  method: 'POST',
51
51
  body: {
52
52
  products,
53
53
  usedMaterials,
54
- starttime,
55
- endtime,
56
54
  customerId,
57
55
  scheduleId,
58
56
  status,
59
57
  repeatSettings,
60
- discountType,
61
- discount,
62
58
  organizationComment,
63
59
  },
64
60
  });
65
61
  }
66
- update(organizationLogin, orderId, { products, usedMaterials, starttime, endtime, scheduleId, status, repeatSettings, discountType, discount, organizationComment, }) {
62
+ update(organizationLogin, orderId, { products, usedMaterials, scheduleId, status, repeatSettings, organizationComment, }) {
67
63
  return this._requestRunner.performRequest({
68
64
  url: `accounts/${organizationLogin}/orders/${orderId}`,
69
65
  method: 'PUT',
70
66
  body: {
71
67
  products,
72
68
  usedMaterials,
73
- starttime,
74
- endtime,
75
69
  scheduleId,
76
70
  status,
77
71
  repeatSettings,
78
- discountType,
79
- discount,
80
72
  organizationComment,
81
73
  },
82
74
  });
@@ -6,13 +6,9 @@ export default class Public {
6
6
  getContact(organizationLogin: string, contactIndex: number, recaptchaToken?: string): Promise<import("../../types").StartaResponse>;
7
7
  getAvailableTimeSlots(organizationLogin: string, { products, month, scheduleId, }: {
8
8
  products: Array<{
9
- type: any;
10
- id: any;
9
+ type: 'service' | 'product';
10
+ id: string;
11
11
  executors?: Array<string>;
12
- amount?: number;
13
- timeOffset?: number;
14
- price?: number;
15
- duration?: number;
16
12
  }>;
17
13
  month: string;
18
14
  scheduleId: string;
@@ -25,8 +21,8 @@ export default class Public {
25
21
  getLastFeedbacks(organizationLogin: string): Promise<import("../../types").StartaResponse>;
26
22
  createOrder(organizationLogin: any, { products, starttime, scheduleId, customerInfo, customerComment, }: {
27
23
  products: Array<{
28
- type: any;
29
- id: any;
24
+ type: 'service' | 'product';
25
+ id: string;
30
26
  executors?: Array<string>;
31
27
  amount?: number;
32
28
  timeOffset?: number;
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const _helpers_1 = require("../_helpers");
4
3
  class Public {
5
4
  constructor(requestRunner) {
6
5
  this._requestRunner = requestRunner;
@@ -20,12 +19,13 @@ class Public {
20
19
  }
21
20
  getAvailableTimeSlots(organizationLogin, { products, month, scheduleId, }) {
22
21
  return this._requestRunner.performRequest({
23
- url: `accounts/${organizationLogin}/public/availableTimeSlots${(0, _helpers_1.buildQuery)({
22
+ url: `accounts/${organizationLogin}/public/availableTimeSlots`,
23
+ method: 'POST',
24
+ body: {
24
25
  month,
25
26
  scheduleId,
26
- products: JSON.stringify(products),
27
- })}`,
28
- method: 'GET',
27
+ products,
28
+ },
29
29
  });
30
30
  }
31
31
  cancelOrder(organizationLogin, orderId) {
package/lib/types.d.ts CHANGED
@@ -168,6 +168,46 @@ export type TechcardSteps = Array<{
168
168
  comment: string;
169
169
  }>;
170
170
  }>;
171
+ export type OrderData = {
172
+ products: Array<OrderItem>;
173
+ usedMaterials?: OrderUsedMaterials;
174
+ scheduleId: string;
175
+ status?: OrderStatus;
176
+ repeatSettings?: OrderRepeatSettings;
177
+ organizationComment?: string;
178
+ };
179
+ export type CreateOrderData = OrderData & {
180
+ customerId: string;
181
+ };
182
+ export type OrderItem = {
183
+ type: 'service' | 'product' | 'roomRent' | 'seminar';
184
+ id: string;
185
+ starttime: string;
186
+ endtime: string;
187
+ executors?: Array<string>;
188
+ amount?: number;
189
+ price?: number;
190
+ warehouseId?: string;
191
+ resources?: Array<string>;
192
+ discountType?: 'relative' | 'absolute';
193
+ discount?: number;
194
+ };
195
+ export type OrderUsedMaterials = Array<{
196
+ serviceId: string;
197
+ techcardId?: string;
198
+ steps?: Array<{
199
+ name: string;
200
+ items: Array<{
201
+ type: 'product';
202
+ warehouseId: string;
203
+ productId: string;
204
+ amount: number;
205
+ } | {
206
+ type: 'comment';
207
+ comment: string;
208
+ }>;
209
+ }>;
210
+ }>;
171
211
  export type CriteriaCondition = {
172
212
  what: 'turnover' | 'profit' | 'quantity';
173
213
  forWhat: 'all' | 'services' | 'products';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "starta.apiclient",
3
- "version": "1.37.7115",
3
+ "version": "1.37.7119",
4
4
  "main": "./lib/index.js",
5
5
  "description": "Wrapper for starta.one api",
6
6
  "author": "Collaboracia OÜ",