@spoot/hostfully-api 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.
- package/README.md +33 -0
- package/dist/src/AgenciesApi.d.ts +74 -0
- package/dist/src/AgenciesApi.js +37 -0
- package/dist/src/AmenitiesApi.d.ts +42 -0
- package/dist/src/AmenitiesApi.js +257 -0
- package/dist/src/FeesApi.d.ts +59 -0
- package/dist/src/FeesApi.js +87 -0
- package/dist/src/FetchTransport.d.ts +17 -0
- package/dist/src/FetchTransport.js +98 -0
- package/dist/src/HostfullyApi.d.ts +22 -0
- package/dist/src/HostfullyApi.js +44 -0
- package/dist/src/LeadsApi.d.ts +513 -0
- package/dist/src/LeadsApi.js +132 -0
- package/dist/src/MessagesApi.d.ts +64 -0
- package/dist/src/MessagesApi.js +59 -0
- package/dist/src/OrderApi.d.ts +453 -0
- package/dist/src/OrderApi.js +124 -0
- package/dist/src/PricingApi.d.ts +137 -0
- package/dist/src/PricingApi.js +204 -0
- package/dist/src/PropertiesApi.d.ts +251 -0
- package/dist/src/PropertiesApi.js +183 -0
- package/dist/src/RateLimiting.d.ts +6 -0
- package/dist/src/RateLimiting.js +50 -0
- package/dist/src/Transport.d.ts +13 -0
- package/dist/src/Transport.js +2 -0
- package/dist/src/enums.d.ts +7 -0
- package/dist/src/enums.js +167 -0
- package/dist/src/index.d.ts +12 -0
- package/dist/src/index.js +28 -0
- package/dist/src/pagination.d.ts +15 -0
- package/dist/src/pagination.js +19 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +31 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { Lead } from "./LeadsApi";
|
|
3
|
+
import { HostfullyApi } from "./HostfullyApi";
|
|
4
|
+
export declare class MessagesApi {
|
|
5
|
+
private readonly api;
|
|
6
|
+
constructor(api: HostfullyApi);
|
|
7
|
+
list(opts: {
|
|
8
|
+
lead: Lead;
|
|
9
|
+
limit?: number;
|
|
10
|
+
cursor?: string;
|
|
11
|
+
}): Promise<{
|
|
12
|
+
_paging: {
|
|
13
|
+
_limit: number;
|
|
14
|
+
_nextCursor: string | null;
|
|
15
|
+
};
|
|
16
|
+
_metadata: {
|
|
17
|
+
count: number;
|
|
18
|
+
};
|
|
19
|
+
messages: z.objectInputType<{
|
|
20
|
+
createdUtcDateTime: z.ZodString;
|
|
21
|
+
status: z.ZodEnum<["CREATED", "PENDING", "SENT", "FAILED"]>;
|
|
22
|
+
type: z.ZodEnum<["HOSTFULLY_PMP", "AIRBNB", "VRBO", "BOOKING_COM", "EMAIL", "SMS", "WHATSAPP"]>;
|
|
23
|
+
content: z.ZodObject<{
|
|
24
|
+
subject: z.ZodNullable<z.ZodString>;
|
|
25
|
+
text: z.ZodNullable<z.ZodString>;
|
|
26
|
+
}, "strip", z.ZodTypeAny, {
|
|
27
|
+
text: string | null;
|
|
28
|
+
subject: string | null;
|
|
29
|
+
}, {
|
|
30
|
+
text: string | null;
|
|
31
|
+
subject: string | null;
|
|
32
|
+
}>;
|
|
33
|
+
threadUid: z.ZodString;
|
|
34
|
+
}, z.ZodTypeAny, "passthrough">[];
|
|
35
|
+
}>;
|
|
36
|
+
scan(opts: {
|
|
37
|
+
lead: Lead;
|
|
38
|
+
perPage?: number;
|
|
39
|
+
}): AsyncGenerator<{
|
|
40
|
+
_paging: {
|
|
41
|
+
_limit: number;
|
|
42
|
+
_nextCursor: string | null;
|
|
43
|
+
};
|
|
44
|
+
_metadata: {
|
|
45
|
+
count: number;
|
|
46
|
+
};
|
|
47
|
+
messages: z.objectInputType<{
|
|
48
|
+
createdUtcDateTime: z.ZodString;
|
|
49
|
+
status: z.ZodEnum<["CREATED", "PENDING", "SENT", "FAILED"]>;
|
|
50
|
+
type: z.ZodEnum<["HOSTFULLY_PMP", "AIRBNB", "VRBO", "BOOKING_COM", "EMAIL", "SMS", "WHATSAPP"]>;
|
|
51
|
+
content: z.ZodObject<{
|
|
52
|
+
subject: z.ZodNullable<z.ZodString>;
|
|
53
|
+
text: z.ZodNullable<z.ZodString>;
|
|
54
|
+
}, "strip", z.ZodTypeAny, {
|
|
55
|
+
text: string | null;
|
|
56
|
+
subject: string | null;
|
|
57
|
+
}, {
|
|
58
|
+
text: string | null;
|
|
59
|
+
subject: string | null;
|
|
60
|
+
}>;
|
|
61
|
+
threadUid: z.ZodString;
|
|
62
|
+
}, z.ZodTypeAny, "passthrough">[];
|
|
63
|
+
}, void, unknown>;
|
|
64
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MessagesApi = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const pagination_1 = require("./pagination");
|
|
6
|
+
const MessageSchema = zod_1.z
|
|
7
|
+
.object({
|
|
8
|
+
createdUtcDateTime: zod_1.z.string(),
|
|
9
|
+
status: zod_1.z.enum(["CREATED", "PENDING", "SENT", "FAILED"]),
|
|
10
|
+
type: zod_1.z.enum([
|
|
11
|
+
"HOSTFULLY_PMP",
|
|
12
|
+
"AIRBNB",
|
|
13
|
+
"VRBO",
|
|
14
|
+
"BOOKING_COM",
|
|
15
|
+
"EMAIL",
|
|
16
|
+
"SMS",
|
|
17
|
+
"WHATSAPP",
|
|
18
|
+
]),
|
|
19
|
+
content: zod_1.z.object({
|
|
20
|
+
subject: zod_1.z.string().nullable(),
|
|
21
|
+
text: zod_1.z.string().nullable(),
|
|
22
|
+
}),
|
|
23
|
+
threadUid: zod_1.z.string(),
|
|
24
|
+
})
|
|
25
|
+
.passthrough();
|
|
26
|
+
class MessagesApi {
|
|
27
|
+
api;
|
|
28
|
+
constructor(api) {
|
|
29
|
+
this.api = api;
|
|
30
|
+
}
|
|
31
|
+
async list(opts) {
|
|
32
|
+
return await this.api.transport.fetch({
|
|
33
|
+
method: "GET",
|
|
34
|
+
path: `/api/v3.1/messages/${encodeURIComponent(opts.lead.uid)}`,
|
|
35
|
+
query: {
|
|
36
|
+
_limit: opts.limit?.toString(),
|
|
37
|
+
_cursor: opts.cursor,
|
|
38
|
+
},
|
|
39
|
+
response: zod_1.z.object({
|
|
40
|
+
messages: zod_1.z.array(MessageSchema),
|
|
41
|
+
_metadata: zod_1.z.object({
|
|
42
|
+
count: zod_1.z.number(),
|
|
43
|
+
}),
|
|
44
|
+
_paging: zod_1.z.object({
|
|
45
|
+
_limit: zod_1.z.number(),
|
|
46
|
+
_nextCursor: zod_1.z.string().nullable(),
|
|
47
|
+
}),
|
|
48
|
+
}),
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
async *scan(opts) {
|
|
52
|
+
console.log("Downloading all messages in conversation for lead", opts.lead.uid);
|
|
53
|
+
yield* (0, pagination_1.scan)(async (cursor) => {
|
|
54
|
+
console.log("Fetching messages", cursor);
|
|
55
|
+
return await this.list({ lead: opts.lead, limit: opts.perPage, cursor });
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.MessagesApi = MessagesApi;
|
|
@@ -0,0 +1,453 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { HostfullyApi } from "./HostfullyApi";
|
|
3
|
+
import { Lead } from "./LeadsApi";
|
|
4
|
+
export declare const OrderFee: z.ZodObject<{
|
|
5
|
+
uid: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
6
|
+
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
7
|
+
amountType: z.ZodOptional<z.ZodNullable<z.ZodEnum<["AMOUNT", "TAX"]>>>;
|
|
8
|
+
isEditable: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
9
|
+
netPrice: z.ZodNumber;
|
|
10
|
+
taxationRate: z.ZodNumber;
|
|
11
|
+
taxAmount: z.ZodNumber;
|
|
12
|
+
grossAmount: z.ZodNumber;
|
|
13
|
+
grossPrice: z.ZodNumber;
|
|
14
|
+
}, "strip", z.ZodTypeAny, {
|
|
15
|
+
taxationRate: number;
|
|
16
|
+
netPrice: number;
|
|
17
|
+
taxAmount: number;
|
|
18
|
+
grossAmount: number;
|
|
19
|
+
grossPrice: number;
|
|
20
|
+
name?: string | null | undefined;
|
|
21
|
+
uid?: string | null | undefined;
|
|
22
|
+
amountType?: "TAX" | "AMOUNT" | null | undefined;
|
|
23
|
+
isEditable?: boolean | null | undefined;
|
|
24
|
+
}, {
|
|
25
|
+
taxationRate: number;
|
|
26
|
+
netPrice: number;
|
|
27
|
+
taxAmount: number;
|
|
28
|
+
grossAmount: number;
|
|
29
|
+
grossPrice: number;
|
|
30
|
+
name?: string | null | undefined;
|
|
31
|
+
uid?: string | null | undefined;
|
|
32
|
+
amountType?: "TAX" | "AMOUNT" | null | undefined;
|
|
33
|
+
isEditable?: boolean | null | undefined;
|
|
34
|
+
}>;
|
|
35
|
+
export declare const OrderSchema: z.ZodObject<{
|
|
36
|
+
uid: z.ZodString;
|
|
37
|
+
leadUid: z.ZodString;
|
|
38
|
+
creationUtcDateTime: z.ZodString;
|
|
39
|
+
updatedUtcDateTime: z.ZodString;
|
|
40
|
+
rent: z.ZodObject<{
|
|
41
|
+
rentNetPrice: z.ZodNumber;
|
|
42
|
+
rentBreakdowns: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
43
|
+
nightlyAmount: z.ZodNumber;
|
|
44
|
+
nightlyDate: z.ZodString;
|
|
45
|
+
}, "strip", z.ZodTypeAny, {
|
|
46
|
+
nightlyAmount: number;
|
|
47
|
+
nightlyDate: string;
|
|
48
|
+
}, {
|
|
49
|
+
nightlyAmount: number;
|
|
50
|
+
nightlyDate: string;
|
|
51
|
+
}>, "many">>>;
|
|
52
|
+
extraGuestsNetPrice: z.ZodNumber;
|
|
53
|
+
listPrice: z.ZodNumber;
|
|
54
|
+
discount: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
55
|
+
discountCode: z.ZodString;
|
|
56
|
+
discountType: z.ZodEnum<["PERCENT", "AMOUNT"]>;
|
|
57
|
+
amount: z.ZodNumber;
|
|
58
|
+
percent: z.ZodNumber;
|
|
59
|
+
}, "strip", z.ZodTypeAny, {
|
|
60
|
+
amount: number;
|
|
61
|
+
discountCode: string;
|
|
62
|
+
discountType: "AMOUNT" | "PERCENT";
|
|
63
|
+
percent: number;
|
|
64
|
+
}, {
|
|
65
|
+
amount: number;
|
|
66
|
+
discountCode: string;
|
|
67
|
+
discountType: "AMOUNT" | "PERCENT";
|
|
68
|
+
percent: number;
|
|
69
|
+
}>>>;
|
|
70
|
+
netPrice: z.ZodNumber;
|
|
71
|
+
taxationRate: z.ZodNumber;
|
|
72
|
+
taxAmount: z.ZodNumber;
|
|
73
|
+
grossPrice: z.ZodNumber;
|
|
74
|
+
}, "strip", z.ZodTypeAny, {
|
|
75
|
+
taxationRate: number;
|
|
76
|
+
netPrice: number;
|
|
77
|
+
taxAmount: number;
|
|
78
|
+
grossPrice: number;
|
|
79
|
+
rentNetPrice: number;
|
|
80
|
+
extraGuestsNetPrice: number;
|
|
81
|
+
listPrice: number;
|
|
82
|
+
rentBreakdowns?: {
|
|
83
|
+
nightlyAmount: number;
|
|
84
|
+
nightlyDate: string;
|
|
85
|
+
}[] | null | undefined;
|
|
86
|
+
discount?: {
|
|
87
|
+
amount: number;
|
|
88
|
+
discountCode: string;
|
|
89
|
+
discountType: "AMOUNT" | "PERCENT";
|
|
90
|
+
percent: number;
|
|
91
|
+
} | null | undefined;
|
|
92
|
+
}, {
|
|
93
|
+
taxationRate: number;
|
|
94
|
+
netPrice: number;
|
|
95
|
+
taxAmount: number;
|
|
96
|
+
grossPrice: number;
|
|
97
|
+
rentNetPrice: number;
|
|
98
|
+
extraGuestsNetPrice: number;
|
|
99
|
+
listPrice: number;
|
|
100
|
+
rentBreakdowns?: {
|
|
101
|
+
nightlyAmount: number;
|
|
102
|
+
nightlyDate: string;
|
|
103
|
+
}[] | null | undefined;
|
|
104
|
+
discount?: {
|
|
105
|
+
amount: number;
|
|
106
|
+
discountCode: string;
|
|
107
|
+
discountType: "AMOUNT" | "PERCENT";
|
|
108
|
+
percent: number;
|
|
109
|
+
} | null | undefined;
|
|
110
|
+
}>;
|
|
111
|
+
securityDeposit: z.ZodNumber;
|
|
112
|
+
fees: z.ZodNullable<z.ZodObject<{
|
|
113
|
+
cleaningFee: z.ZodObject<{
|
|
114
|
+
uid: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
115
|
+
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
116
|
+
amountType: z.ZodOptional<z.ZodNullable<z.ZodEnum<["AMOUNT", "TAX"]>>>;
|
|
117
|
+
isEditable: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
118
|
+
netPrice: z.ZodNumber;
|
|
119
|
+
taxationRate: z.ZodNumber;
|
|
120
|
+
taxAmount: z.ZodNumber;
|
|
121
|
+
grossAmount: z.ZodNumber;
|
|
122
|
+
grossPrice: z.ZodNumber;
|
|
123
|
+
}, "strip", z.ZodTypeAny, {
|
|
124
|
+
taxationRate: number;
|
|
125
|
+
netPrice: number;
|
|
126
|
+
taxAmount: number;
|
|
127
|
+
grossAmount: number;
|
|
128
|
+
grossPrice: number;
|
|
129
|
+
name?: string | null | undefined;
|
|
130
|
+
uid?: string | null | undefined;
|
|
131
|
+
amountType?: "TAX" | "AMOUNT" | null | undefined;
|
|
132
|
+
isEditable?: boolean | null | undefined;
|
|
133
|
+
}, {
|
|
134
|
+
taxationRate: number;
|
|
135
|
+
netPrice: number;
|
|
136
|
+
taxAmount: number;
|
|
137
|
+
grossAmount: number;
|
|
138
|
+
grossPrice: number;
|
|
139
|
+
name?: string | null | undefined;
|
|
140
|
+
uid?: string | null | undefined;
|
|
141
|
+
amountType?: "TAX" | "AMOUNT" | null | undefined;
|
|
142
|
+
isEditable?: boolean | null | undefined;
|
|
143
|
+
}>;
|
|
144
|
+
otherFees: z.ZodArray<z.ZodObject<{
|
|
145
|
+
uid: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
146
|
+
name: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
147
|
+
amountType: z.ZodOptional<z.ZodNullable<z.ZodEnum<["AMOUNT", "TAX"]>>>;
|
|
148
|
+
isEditable: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
149
|
+
netPrice: z.ZodNumber;
|
|
150
|
+
taxationRate: z.ZodNumber;
|
|
151
|
+
taxAmount: z.ZodNumber;
|
|
152
|
+
grossAmount: z.ZodNumber;
|
|
153
|
+
grossPrice: z.ZodNumber;
|
|
154
|
+
}, "strip", z.ZodTypeAny, {
|
|
155
|
+
taxationRate: number;
|
|
156
|
+
netPrice: number;
|
|
157
|
+
taxAmount: number;
|
|
158
|
+
grossAmount: number;
|
|
159
|
+
grossPrice: number;
|
|
160
|
+
name?: string | null | undefined;
|
|
161
|
+
uid?: string | null | undefined;
|
|
162
|
+
amountType?: "TAX" | "AMOUNT" | null | undefined;
|
|
163
|
+
isEditable?: boolean | null | undefined;
|
|
164
|
+
}, {
|
|
165
|
+
taxationRate: number;
|
|
166
|
+
netPrice: number;
|
|
167
|
+
taxAmount: number;
|
|
168
|
+
grossAmount: number;
|
|
169
|
+
grossPrice: number;
|
|
170
|
+
name?: string | null | undefined;
|
|
171
|
+
uid?: string | null | undefined;
|
|
172
|
+
amountType?: "TAX" | "AMOUNT" | null | undefined;
|
|
173
|
+
isEditable?: boolean | null | undefined;
|
|
174
|
+
}>, "many">;
|
|
175
|
+
}, "strip", z.ZodTypeAny, {
|
|
176
|
+
cleaningFee: {
|
|
177
|
+
taxationRate: number;
|
|
178
|
+
netPrice: number;
|
|
179
|
+
taxAmount: number;
|
|
180
|
+
grossAmount: number;
|
|
181
|
+
grossPrice: number;
|
|
182
|
+
name?: string | null | undefined;
|
|
183
|
+
uid?: string | null | undefined;
|
|
184
|
+
amountType?: "TAX" | "AMOUNT" | null | undefined;
|
|
185
|
+
isEditable?: boolean | null | undefined;
|
|
186
|
+
};
|
|
187
|
+
otherFees: {
|
|
188
|
+
taxationRate: number;
|
|
189
|
+
netPrice: number;
|
|
190
|
+
taxAmount: number;
|
|
191
|
+
grossAmount: number;
|
|
192
|
+
grossPrice: number;
|
|
193
|
+
name?: string | null | undefined;
|
|
194
|
+
uid?: string | null | undefined;
|
|
195
|
+
amountType?: "TAX" | "AMOUNT" | null | undefined;
|
|
196
|
+
isEditable?: boolean | null | undefined;
|
|
197
|
+
}[];
|
|
198
|
+
}, {
|
|
199
|
+
cleaningFee: {
|
|
200
|
+
taxationRate: number;
|
|
201
|
+
netPrice: number;
|
|
202
|
+
taxAmount: number;
|
|
203
|
+
grossAmount: number;
|
|
204
|
+
grossPrice: number;
|
|
205
|
+
name?: string | null | undefined;
|
|
206
|
+
uid?: string | null | undefined;
|
|
207
|
+
amountType?: "TAX" | "AMOUNT" | null | undefined;
|
|
208
|
+
isEditable?: boolean | null | undefined;
|
|
209
|
+
};
|
|
210
|
+
otherFees: {
|
|
211
|
+
taxationRate: number;
|
|
212
|
+
netPrice: number;
|
|
213
|
+
taxAmount: number;
|
|
214
|
+
grossAmount: number;
|
|
215
|
+
grossPrice: number;
|
|
216
|
+
name?: string | null | undefined;
|
|
217
|
+
uid?: string | null | undefined;
|
|
218
|
+
amountType?: "TAX" | "AMOUNT" | null | undefined;
|
|
219
|
+
isEditable?: boolean | null | undefined;
|
|
220
|
+
}[];
|
|
221
|
+
}>>;
|
|
222
|
+
services: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
223
|
+
uid: z.ZodNullable<z.ZodString>;
|
|
224
|
+
title: z.ZodNullable<z.ZodString>;
|
|
225
|
+
grossPrice: z.ZodNullable<z.ZodNumber>;
|
|
226
|
+
quantity: z.ZodNullable<z.ZodNumber>;
|
|
227
|
+
quantityDescription: z.ZodNullable<z.ZodString>;
|
|
228
|
+
serviceUid: z.ZodNullable<z.ZodString>;
|
|
229
|
+
}, "strip", z.ZodTypeAny, {
|
|
230
|
+
uid: string | null;
|
|
231
|
+
grossPrice: number | null;
|
|
232
|
+
title: string | null;
|
|
233
|
+
quantity: number | null;
|
|
234
|
+
quantityDescription: string | null;
|
|
235
|
+
serviceUid: string | null;
|
|
236
|
+
}, {
|
|
237
|
+
uid: string | null;
|
|
238
|
+
grossPrice: number | null;
|
|
239
|
+
title: string | null;
|
|
240
|
+
quantity: number | null;
|
|
241
|
+
quantityDescription: string | null;
|
|
242
|
+
serviceUid: string | null;
|
|
243
|
+
}>, "many">>>;
|
|
244
|
+
adjustments: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
245
|
+
isPaid: z.ZodNullable<z.ZodBoolean>;
|
|
246
|
+
amount: z.ZodNullable<z.ZodNumber>;
|
|
247
|
+
}, "strip", z.ZodTypeAny, {
|
|
248
|
+
amount: number | null;
|
|
249
|
+
isPaid: boolean | null;
|
|
250
|
+
}, {
|
|
251
|
+
amount: number | null;
|
|
252
|
+
isPaid: boolean | null;
|
|
253
|
+
}>, "many">>>;
|
|
254
|
+
rateMultiplier: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
255
|
+
currency: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
256
|
+
totalAmount: z.ZodNumber;
|
|
257
|
+
totalTaxesAmount: z.ZodNumber;
|
|
258
|
+
channelCommission: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
259
|
+
amount: z.ZodNumber;
|
|
260
|
+
}, "strip", z.ZodTypeAny, {
|
|
261
|
+
amount: number;
|
|
262
|
+
}, {
|
|
263
|
+
amount: number;
|
|
264
|
+
}>>>;
|
|
265
|
+
adjustmentItems: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
266
|
+
uid: z.ZodString;
|
|
267
|
+
transactionType: z.ZodEnum<["CHARGE", "REFUND"]>;
|
|
268
|
+
adjustmentType: z.ZodEnum<["RENT", "TAX", "FEE", "SERVICE", "RESOLUTION"]>;
|
|
269
|
+
amount: z.ZodNumber;
|
|
270
|
+
note: z.ZodString;
|
|
271
|
+
createdUtcDateTime: z.ZodString;
|
|
272
|
+
externalId: z.ZodString;
|
|
273
|
+
}, "strip", z.ZodTypeAny, {
|
|
274
|
+
uid: string;
|
|
275
|
+
amount: number;
|
|
276
|
+
createdUtcDateTime: string;
|
|
277
|
+
transactionType: "CHARGE" | "REFUND";
|
|
278
|
+
adjustmentType: "RENT" | "TAX" | "FEE" | "SERVICE" | "RESOLUTION";
|
|
279
|
+
note: string;
|
|
280
|
+
externalId: string;
|
|
281
|
+
}, {
|
|
282
|
+
uid: string;
|
|
283
|
+
amount: number;
|
|
284
|
+
createdUtcDateTime: string;
|
|
285
|
+
transactionType: "CHARGE" | "REFUND";
|
|
286
|
+
adjustmentType: "RENT" | "TAX" | "FEE" | "SERVICE" | "RESOLUTION";
|
|
287
|
+
note: string;
|
|
288
|
+
externalId: string;
|
|
289
|
+
}>, "many">>>;
|
|
290
|
+
externalOrderId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
291
|
+
}, "strip", z.ZodTypeAny, {
|
|
292
|
+
uid: string;
|
|
293
|
+
leadUid: string;
|
|
294
|
+
fees: {
|
|
295
|
+
cleaningFee: {
|
|
296
|
+
taxationRate: number;
|
|
297
|
+
netPrice: number;
|
|
298
|
+
taxAmount: number;
|
|
299
|
+
grossAmount: number;
|
|
300
|
+
grossPrice: number;
|
|
301
|
+
name?: string | null | undefined;
|
|
302
|
+
uid?: string | null | undefined;
|
|
303
|
+
amountType?: "TAX" | "AMOUNT" | null | undefined;
|
|
304
|
+
isEditable?: boolean | null | undefined;
|
|
305
|
+
};
|
|
306
|
+
otherFees: {
|
|
307
|
+
taxationRate: number;
|
|
308
|
+
netPrice: number;
|
|
309
|
+
taxAmount: number;
|
|
310
|
+
grossAmount: number;
|
|
311
|
+
grossPrice: number;
|
|
312
|
+
name?: string | null | undefined;
|
|
313
|
+
uid?: string | null | undefined;
|
|
314
|
+
amountType?: "TAX" | "AMOUNT" | null | undefined;
|
|
315
|
+
isEditable?: boolean | null | undefined;
|
|
316
|
+
}[];
|
|
317
|
+
} | null;
|
|
318
|
+
updatedUtcDateTime: string;
|
|
319
|
+
creationUtcDateTime: string;
|
|
320
|
+
rent: {
|
|
321
|
+
taxationRate: number;
|
|
322
|
+
netPrice: number;
|
|
323
|
+
taxAmount: number;
|
|
324
|
+
grossPrice: number;
|
|
325
|
+
rentNetPrice: number;
|
|
326
|
+
extraGuestsNetPrice: number;
|
|
327
|
+
listPrice: number;
|
|
328
|
+
rentBreakdowns?: {
|
|
329
|
+
nightlyAmount: number;
|
|
330
|
+
nightlyDate: string;
|
|
331
|
+
}[] | null | undefined;
|
|
332
|
+
discount?: {
|
|
333
|
+
amount: number;
|
|
334
|
+
discountCode: string;
|
|
335
|
+
discountType: "AMOUNT" | "PERCENT";
|
|
336
|
+
percent: number;
|
|
337
|
+
} | null | undefined;
|
|
338
|
+
};
|
|
339
|
+
securityDeposit: number;
|
|
340
|
+
totalAmount: number;
|
|
341
|
+
totalTaxesAmount: number;
|
|
342
|
+
services?: {
|
|
343
|
+
uid: string | null;
|
|
344
|
+
grossPrice: number | null;
|
|
345
|
+
title: string | null;
|
|
346
|
+
quantity: number | null;
|
|
347
|
+
quantityDescription: string | null;
|
|
348
|
+
serviceUid: string | null;
|
|
349
|
+
}[] | null | undefined;
|
|
350
|
+
adjustments?: {
|
|
351
|
+
amount: number | null;
|
|
352
|
+
isPaid: boolean | null;
|
|
353
|
+
}[] | null | undefined;
|
|
354
|
+
rateMultiplier?: number | null | undefined;
|
|
355
|
+
currency?: string | null | undefined;
|
|
356
|
+
channelCommission?: {
|
|
357
|
+
amount: number;
|
|
358
|
+
} | null | undefined;
|
|
359
|
+
adjustmentItems?: {
|
|
360
|
+
uid: string;
|
|
361
|
+
amount: number;
|
|
362
|
+
createdUtcDateTime: string;
|
|
363
|
+
transactionType: "CHARGE" | "REFUND";
|
|
364
|
+
adjustmentType: "RENT" | "TAX" | "FEE" | "SERVICE" | "RESOLUTION";
|
|
365
|
+
note: string;
|
|
366
|
+
externalId: string;
|
|
367
|
+
}[] | null | undefined;
|
|
368
|
+
externalOrderId?: string | null | undefined;
|
|
369
|
+
}, {
|
|
370
|
+
uid: string;
|
|
371
|
+
leadUid: string;
|
|
372
|
+
fees: {
|
|
373
|
+
cleaningFee: {
|
|
374
|
+
taxationRate: number;
|
|
375
|
+
netPrice: number;
|
|
376
|
+
taxAmount: number;
|
|
377
|
+
grossAmount: number;
|
|
378
|
+
grossPrice: number;
|
|
379
|
+
name?: string | null | undefined;
|
|
380
|
+
uid?: string | null | undefined;
|
|
381
|
+
amountType?: "TAX" | "AMOUNT" | null | undefined;
|
|
382
|
+
isEditable?: boolean | null | undefined;
|
|
383
|
+
};
|
|
384
|
+
otherFees: {
|
|
385
|
+
taxationRate: number;
|
|
386
|
+
netPrice: number;
|
|
387
|
+
taxAmount: number;
|
|
388
|
+
grossAmount: number;
|
|
389
|
+
grossPrice: number;
|
|
390
|
+
name?: string | null | undefined;
|
|
391
|
+
uid?: string | null | undefined;
|
|
392
|
+
amountType?: "TAX" | "AMOUNT" | null | undefined;
|
|
393
|
+
isEditable?: boolean | null | undefined;
|
|
394
|
+
}[];
|
|
395
|
+
} | null;
|
|
396
|
+
updatedUtcDateTime: string;
|
|
397
|
+
creationUtcDateTime: string;
|
|
398
|
+
rent: {
|
|
399
|
+
taxationRate: number;
|
|
400
|
+
netPrice: number;
|
|
401
|
+
taxAmount: number;
|
|
402
|
+
grossPrice: number;
|
|
403
|
+
rentNetPrice: number;
|
|
404
|
+
extraGuestsNetPrice: number;
|
|
405
|
+
listPrice: number;
|
|
406
|
+
rentBreakdowns?: {
|
|
407
|
+
nightlyAmount: number;
|
|
408
|
+
nightlyDate: string;
|
|
409
|
+
}[] | null | undefined;
|
|
410
|
+
discount?: {
|
|
411
|
+
amount: number;
|
|
412
|
+
discountCode: string;
|
|
413
|
+
discountType: "AMOUNT" | "PERCENT";
|
|
414
|
+
percent: number;
|
|
415
|
+
} | null | undefined;
|
|
416
|
+
};
|
|
417
|
+
securityDeposit: number;
|
|
418
|
+
totalAmount: number;
|
|
419
|
+
totalTaxesAmount: number;
|
|
420
|
+
services?: {
|
|
421
|
+
uid: string | null;
|
|
422
|
+
grossPrice: number | null;
|
|
423
|
+
title: string | null;
|
|
424
|
+
quantity: number | null;
|
|
425
|
+
quantityDescription: string | null;
|
|
426
|
+
serviceUid: string | null;
|
|
427
|
+
}[] | null | undefined;
|
|
428
|
+
adjustments?: {
|
|
429
|
+
amount: number | null;
|
|
430
|
+
isPaid: boolean | null;
|
|
431
|
+
}[] | null | undefined;
|
|
432
|
+
rateMultiplier?: number | null | undefined;
|
|
433
|
+
currency?: string | null | undefined;
|
|
434
|
+
channelCommission?: {
|
|
435
|
+
amount: number;
|
|
436
|
+
} | null | undefined;
|
|
437
|
+
adjustmentItems?: {
|
|
438
|
+
uid: string;
|
|
439
|
+
amount: number;
|
|
440
|
+
createdUtcDateTime: string;
|
|
441
|
+
transactionType: "CHARGE" | "REFUND";
|
|
442
|
+
adjustmentType: "RENT" | "TAX" | "FEE" | "SERVICE" | "RESOLUTION";
|
|
443
|
+
note: string;
|
|
444
|
+
externalId: string;
|
|
445
|
+
}[] | null | undefined;
|
|
446
|
+
externalOrderId?: string | null | undefined;
|
|
447
|
+
}>;
|
|
448
|
+
export type Order = z.infer<typeof OrderSchema>;
|
|
449
|
+
export declare class OrderApi {
|
|
450
|
+
private readonly api;
|
|
451
|
+
constructor(api: HostfullyApi);
|
|
452
|
+
getForLead(lead: Lead): Promise<Order>;
|
|
453
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OrderApi = exports.OrderSchema = exports.OrderFee = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
exports.OrderFee = zod_1.z.object({
|
|
6
|
+
uid: zod_1.z.string().nullable().optional(),
|
|
7
|
+
name: zod_1.z.string().nullable().optional(),
|
|
8
|
+
amountType: zod_1.z.enum(["AMOUNT", "TAX"]).nullable().optional(),
|
|
9
|
+
isEditable: zod_1.z.boolean().nullable().optional(),
|
|
10
|
+
netPrice: zod_1.z.number(),
|
|
11
|
+
taxationRate: zod_1.z.number(),
|
|
12
|
+
taxAmount: zod_1.z.number(),
|
|
13
|
+
grossAmount: zod_1.z.number(),
|
|
14
|
+
grossPrice: zod_1.z.number(),
|
|
15
|
+
});
|
|
16
|
+
exports.OrderSchema = zod_1.z.object({
|
|
17
|
+
uid: zod_1.z.string(),
|
|
18
|
+
leadUid: zod_1.z.string(),
|
|
19
|
+
creationUtcDateTime: zod_1.z.string(),
|
|
20
|
+
updatedUtcDateTime: zod_1.z.string(),
|
|
21
|
+
rent: zod_1.z.object({
|
|
22
|
+
rentNetPrice: zod_1.z.number(),
|
|
23
|
+
rentBreakdowns: zod_1.z
|
|
24
|
+
.array(zod_1.z.object({
|
|
25
|
+
nightlyAmount: zod_1.z.number(),
|
|
26
|
+
nightlyDate: zod_1.z.string(),
|
|
27
|
+
}))
|
|
28
|
+
.nullable()
|
|
29
|
+
.optional(),
|
|
30
|
+
extraGuestsNetPrice: zod_1.z.number(),
|
|
31
|
+
listPrice: zod_1.z.number(),
|
|
32
|
+
discount: zod_1.z
|
|
33
|
+
.object({
|
|
34
|
+
discountCode: zod_1.z.string(),
|
|
35
|
+
discountType: zod_1.z.enum(["PERCENT", "AMOUNT"]),
|
|
36
|
+
amount: zod_1.z.number(),
|
|
37
|
+
percent: zod_1.z.number(),
|
|
38
|
+
})
|
|
39
|
+
.nullable()
|
|
40
|
+
.optional(),
|
|
41
|
+
netPrice: zod_1.z.number(),
|
|
42
|
+
taxationRate: zod_1.z.number(),
|
|
43
|
+
taxAmount: zod_1.z.number(),
|
|
44
|
+
grossPrice: zod_1.z.number(),
|
|
45
|
+
}),
|
|
46
|
+
securityDeposit: zod_1.z.number(),
|
|
47
|
+
fees: zod_1.z
|
|
48
|
+
.object({
|
|
49
|
+
cleaningFee: exports.OrderFee,
|
|
50
|
+
otherFees: zod_1.z.array(exports.OrderFee),
|
|
51
|
+
})
|
|
52
|
+
.nullable(),
|
|
53
|
+
services: zod_1.z
|
|
54
|
+
.array(zod_1.z.object({
|
|
55
|
+
uid: zod_1.z.string().nullable(),
|
|
56
|
+
title: zod_1.z.string().nullable(),
|
|
57
|
+
grossPrice: zod_1.z.number().nullable(),
|
|
58
|
+
quantity: zod_1.z.number().nullable(),
|
|
59
|
+
quantityDescription: zod_1.z.string().nullable(),
|
|
60
|
+
serviceUid: zod_1.z.string().nullable(),
|
|
61
|
+
}))
|
|
62
|
+
.nullable()
|
|
63
|
+
.optional(),
|
|
64
|
+
adjustments: zod_1.z
|
|
65
|
+
.array(zod_1.z.object({
|
|
66
|
+
isPaid: zod_1.z.boolean().nullable(),
|
|
67
|
+
amount: zod_1.z.number().nullable(),
|
|
68
|
+
}))
|
|
69
|
+
.nullable()
|
|
70
|
+
.optional(),
|
|
71
|
+
rateMultiplier: zod_1.z.number().nullable().optional(),
|
|
72
|
+
currency: zod_1.z.string().nullable().optional(),
|
|
73
|
+
totalAmount: zod_1.z.number(),
|
|
74
|
+
totalTaxesAmount: zod_1.z.number(),
|
|
75
|
+
channelCommission: zod_1.z
|
|
76
|
+
.object({
|
|
77
|
+
amount: zod_1.z.number(),
|
|
78
|
+
})
|
|
79
|
+
.nullable()
|
|
80
|
+
.optional(),
|
|
81
|
+
adjustmentItems: zod_1.z
|
|
82
|
+
.array(zod_1.z.object({
|
|
83
|
+
uid: zod_1.z.string(),
|
|
84
|
+
transactionType: zod_1.z.enum(["CHARGE", "REFUND"]),
|
|
85
|
+
adjustmentType: zod_1.z.enum(["RENT", "TAX", "FEE", "SERVICE", "RESOLUTION"]),
|
|
86
|
+
amount: zod_1.z.number(),
|
|
87
|
+
note: zod_1.z.string(),
|
|
88
|
+
createdUtcDateTime: zod_1.z.string(),
|
|
89
|
+
externalId: zod_1.z.string(),
|
|
90
|
+
}))
|
|
91
|
+
.nullable()
|
|
92
|
+
.optional(),
|
|
93
|
+
externalOrderId: zod_1.z.string().nullable().optional(),
|
|
94
|
+
});
|
|
95
|
+
class OrderApi {
|
|
96
|
+
api;
|
|
97
|
+
constructor(api) {
|
|
98
|
+
this.api = api;
|
|
99
|
+
}
|
|
100
|
+
async getForLead(lead) {
|
|
101
|
+
const { orders } = await this.api.transport.fetch({
|
|
102
|
+
method: "GET",
|
|
103
|
+
path: "/api/v3.2/orders",
|
|
104
|
+
query: {
|
|
105
|
+
leadUid: lead.uid,
|
|
106
|
+
},
|
|
107
|
+
response: zod_1.z.object({
|
|
108
|
+
orders: zod_1.z.array(exports.OrderSchema),
|
|
109
|
+
_metadata: zod_1.z.object({
|
|
110
|
+
count: zod_1.z.number(),
|
|
111
|
+
totalCount: zod_1.z.number().nullable(),
|
|
112
|
+
}),
|
|
113
|
+
}),
|
|
114
|
+
});
|
|
115
|
+
if (orders.length === 0) {
|
|
116
|
+
throw new Error("No orders found for lead");
|
|
117
|
+
}
|
|
118
|
+
if (orders.length > 1) {
|
|
119
|
+
throw new Error("Multiple orders found for lead");
|
|
120
|
+
}
|
|
121
|
+
return orders[0];
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
exports.OrderApi = OrderApi;
|