-
Notifications
You must be signed in to change notification settings - Fork 0
/
request.go
574 lines (502 loc) · 16 KB
/
request.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
package request
import (
"encoding/xml"
"github.com/bookingsuedtirol/mss-go/shared"
"golang.org/x/text/language"
)
// The boolean type for request data. This must be used instead of the
// standard "bool". Maps to 0/1 (which MSS expects) instead of "true"/"false"
type Bool bool
type Address struct {
Street string `xml:"street"`
ZIPCode string `xml:"zipcode"`
City string `xml:"city"`
// The ISO 3166 alpha-3 code
Country string `xml:"country"`
}
type Company struct {
Name string `xml:"name"`
TaxNumber string `xml:"taxnumber"`
RecipientCode string `xml:"recipient_code"`
Address *Address `xml:"address"`
}
type Coupon struct {
Code string `xml:"coupon_code"`
Type shared.CouponType `xml:"coupon_type"`
}
type Credentials struct {
User string `xml:"user"`
Password string `xml:"password"`
Source string `xml:"source"`
SourceID int `xml:"source_id"`
}
type StornoReason int
const (
StornoReasonUnknown StornoReason = iota
StornoReasonGuestUnavailable
StornoReasonPropertyRequestedCancellation
StornoReasonGuestChoseAnotherDestination
StornoReasonGuestChoseAnotherProperty
StornoReasonOther StornoReason = 99
)
var StornoReasons = []StornoReason{
StornoReasonUnknown,
StornoReasonGuestUnavailable,
StornoReasonPropertyRequestedCancellation,
StornoReasonGuestChoseAnotherDestination,
StornoReasonGuestChoseAnotherProperty,
StornoReasonOther,
}
type Data struct {
Guest *Guest `xml:"guest"`
Company *Company `xml:"company"`
Payment *Payment `xml:"payment"`
Note string `xml:"note"`
Details *Details `xml:"details"`
Form *Form `xml:"form"`
Tracking *Tracking `xml:"tracking"`
Insurance Bool `xml:"insurance"`
StornoReason StornoReason `xml:"storno_reason"`
StornoReasonText string `xml:"storno_reason_text"`
}
type Details struct {
ExtraPrices []ExtraPrice `xml:"extra_price"`
Coupon *Coupon `xml:"coupon"`
}
type ExtraPrice struct {
ID int `xml:"price_id"`
Amount float64 `xml:"price_amount"`
}
type Form struct {
URLSuccess string `xml:"url_success"`
URLFailure string `xml:"url_failure"`
}
type Guest struct {
Gender shared.Gender `xml:"gender"`
Prefix string `xml:"prefix"`
FirstName string `xml:"firstname"`
LastName string `xml:"lastname"`
Email string `xml:"email"`
Phone string `xml:"phone"`
Address *Address `xml:"address"`
Newsletter Bool `xml:"newsletter"`
}
type Method string
const (
MethodGetHotelList Method = "getHotelList"
MethodGetSpecialList Method = "getSpecialList"
MethodGetRoomList Method = "getRoomList"
MethodGetPriceList Method = "getPriceList"
MethodGetRoomAvailability Method = "getRoomAvailability"
MethodPrepareBooking Method = "prepareBooking"
MethodGetBooking Method = "getBooking"
MethodCancelBooking Method = "cancelBooking"
MethodCreateInquiry Method = "createInquiry"
MethodGetUserSources Method = "getUserSources"
MethodGetLocationList Method = "getLocationList"
MethodGetMasterpackagesList Method = "getMasterpackagesList"
MethodGetThemeList Method = "getThemeList"
MethodValidateCoupon Method = "validateCoupon"
)
var Methods = []Method{
MethodGetHotelList,
MethodGetSpecialList,
MethodGetRoomList,
MethodGetPriceList,
MethodGetRoomAvailability,
MethodPrepareBooking,
MethodGetBooking,
MethodCancelBooking,
MethodCreateInquiry,
MethodGetUserSources,
MethodGetLocationList,
MethodGetMasterpackagesList,
MethodGetThemeList,
MethodValidateCoupon,
}
type Header struct {
Credentials Credentials `xml:"credentials"`
Method Method `xml:"method"`
Paging *Paging `xml:"paging"`
ResultID string `xml:"result_id"`
}
type Logging struct {
Step string `xml:"step"`
}
type HotelDetails int
const (
HotelDetailsBasicInfo HotelDetails = 1 << iota
HotelDetailsThemes
HotelDetailsHotelFacilities
HotelDetailsShortDescription
HotelDetailsFullDescription
HotelDetailsGeographicInformation
HotelDetailsCoordinates
HotelDetailsAddress
HotelDetailsContacts
HotelDetailsPaymentOptionsForOnlineBooking
HotelDetailsPaymentOptionsAtHotel
HotelDetailsLogo
HotelDetailsHeaderImages
HotelDetailsGallery
HotelDetailsHotelMatching
HotelDetailsGeographicalInformationAsText
HotelDetailsHotelNavigatorData
HotelDetailsDetailedHotelFacilities
HotelDetailsLTSSpecificParameters
HotelDetailsSalesPoint
HotelDetailsCheckInOut
HotelDetailsSourceData
HotelDetailsBoardData HotelDetails = 2 << iota
HotelDetailsCouponServiceData
HotelDetailsRoomTypes HotelDetails = 8 << iota
)
var HotelDetailsList = []HotelDetails{
HotelDetailsBasicInfo,
HotelDetailsThemes,
HotelDetailsHotelFacilities,
HotelDetailsShortDescription,
HotelDetailsFullDescription,
HotelDetailsGeographicInformation,
HotelDetailsCoordinates,
HotelDetailsAddress,
HotelDetailsContacts,
HotelDetailsPaymentOptionsForOnlineBooking,
HotelDetailsPaymentOptionsAtHotel,
HotelDetailsLogo,
HotelDetailsHeaderImages,
HotelDetailsGallery,
HotelDetailsHotelMatching,
HotelDetailsGeographicalInformationAsText,
HotelDetailsHotelNavigatorData,
HotelDetailsDetailedHotelFacilities,
HotelDetailsLTSSpecificParameters,
HotelDetailsSalesPoint,
HotelDetailsCheckInOut,
HotelDetailsSourceData,
HotelDetailsBoardData,
HotelDetailsCouponServiceData,
HotelDetailsRoomTypes,
}
type OfferDetails int
const (
OfferDetailsBasicInfo OfferDetails = 1
OfferDetailsRoomCode OfferDetails = 4
OfferDetailsRoomTitle OfferDetails = 8
OfferDetailsPriceDetails OfferDetails = 16
OfferDetailsRoomImages OfferDetails = 32
OfferDetailsRoomFacilitiesFilter OfferDetails = 64
OfferDetailsRoomDescription OfferDetails = 256
OfferDetailsIncludedServices OfferDetails = 1024
OfferDetailsAdditionalServices OfferDetails = 2048
OfferDetailsRoomFacilitiesDetails OfferDetails = 4096
OfferDetailsPriceImages OfferDetails = 8192
OfferDetailsThemes OfferDetails = 16384
OfferDetailsRoomFeatures OfferDetails = 32768
OfferDetailsCancelPolicies OfferDetails = 262144
OfferDetailsPaymentTerms OfferDetails = 1048576
)
var OfferDetailsList = []OfferDetails{
OfferDetailsBasicInfo,
OfferDetailsRoomCode,
OfferDetailsRoomTitle,
OfferDetailsPriceDetails,
OfferDetailsRoomImages,
OfferDetailsRoomFacilitiesFilter,
OfferDetailsRoomDescription,
OfferDetailsIncludedServices,
OfferDetailsAdditionalServices,
OfferDetailsRoomFacilitiesDetails,
OfferDetailsPriceImages,
OfferDetailsThemes,
OfferDetailsRoomFeatures,
OfferDetailsCancelPolicies,
OfferDetailsPaymentTerms,
}
type RoomDetails int
const (
RoomDetailsBasicInfo RoomDetails = 4
RoomDetailsTitle RoomDetails = 8
RoomDetailsRoomImages RoomDetails = 32
RoomDetailsRoomFacilitiesFilter RoomDetails = 64
RoomDetailsRoomDescription RoomDetails = 256
RoomDetailsRoomFacilitiesDetails RoomDetails = 4096
RoomDetailsRoomFeatures RoomDetails = 32768
RoomDetailsRoomNumbers RoomDetails = 65536
)
var RoomDetailsList = []RoomDetails{
RoomDetailsBasicInfo,
RoomDetailsTitle,
RoomDetailsRoomImages,
RoomDetailsRoomFacilitiesFilter,
RoomDetailsRoomDescription,
RoomDetailsRoomFacilitiesDetails,
RoomDetailsRoomFeatures,
RoomDetailsRoomNumbers,
}
type SpecialDetails int
const (
SpecialDetailsBasicInfo SpecialDetails = 1 << iota
SpecialDetailsTitle
SpecialDetailsDescriptions
SpecialDetailsSeasons
SpecialDetailsImages
SpecialDetailsThemes
SpecialDetailsIncludedServices
SpecialDetailsHotelIncludedServices
SpecialDetailsHotelMandatoryServices
)
var SpecialDetailsList = []SpecialDetails{
SpecialDetailsBasicInfo,
SpecialDetailsTitle,
SpecialDetailsDescriptions,
SpecialDetailsSeasons,
SpecialDetailsImages,
SpecialDetailsThemes,
SpecialDetailsIncludedServices,
SpecialDetailsHotelIncludedServices,
SpecialDetailsHotelMandatoryServices,
}
type LTSBookable int
const (
LTSBookableOverridenByIgnoreBookability LTSBookable = iota
LTSBookableOnlyBookableLTSOffers
LTSBookableOnlyNonBookableLTSOffers
)
var LTSBookables = []LTSBookable{
LTSBookableOverridenByIgnoreBookability,
LTSBookableOnlyBookableLTSOffers,
LTSBookableOnlyNonBookableLTSOffers,
}
type PriceListDetails int
const (
PriceListDetailsBaseData PriceListDetails = 1
PriceListDetailsHeadlines PriceListDetails = 8
PriceListDetailsSeasons PriceListDetails = 4194304
)
var PriceListDetailsList = []PriceListDetails{
PriceListDetailsBaseData,
PriceListDetailsHeadlines,
PriceListDetailsSeasons,
}
type Options struct {
HotelDetails HotelDetails `xml:"hotel_details"`
OfferDetails OfferDetails `xml:"offer_details"`
RoomDetails RoomDetails `xml:"room_details"`
SpecialDetails SpecialDetails `xml:"special_details"`
PictureDate *shared.Date `xml:"picture_date"`
LTSBookable LTSBookable `xml:"lts_bookable"`
GetAvailability Bool `xml:"get_availability"`
GetRestrictions RestrictionsVersion `xml:"get_restrictions"`
GetRoomdetails Bool `xml:"get_roomdetails"`
GetMasterpackages Bool `xml:"get_masterpackages"`
BasePrice Bool `xml:"base_price"`
PriceListDetails PriceListDetails `xml:"pricelist_details"`
OnlySubscribedHotels Bool `xml:"only_subscribed_hotels"`
OnlyAvailable Bool `xml:"only_available"`
CheckRestrictions Bool `xml:"check_restrictions"`
}
type RestrictionsVersion string
// The old v1 is not supported by this library.
const RestrictionsVersion2 RestrictionsVersion = "v2"
type Order struct {
Field OrderField `xml:"field"`
Dir Direction `xml:"dir"`
}
type OrderField string
const (
OrderFieldDate OrderField = "date"
OrderFieldRand OrderField = "rand"
OrderFieldStars OrderField = "stars"
OrderFieldName OrderField = "name"
)
var OrderFields = []OrderField{
OrderFieldDate,
OrderFieldRand,
OrderFieldStars,
OrderFieldName,
}
type Direction string
const (
DirectionAsc Direction = "asc"
DirectionDesc Direction = "desc"
)
var Directions = []Direction{
DirectionAsc,
DirectionDesc,
}
type Paging struct {
Start int `xml:"start"`
Limit int `xml:"limit"`
}
type Payment struct {
Method shared.PaymentMethod `xml:"method"`
Invoice Bool `xml:"invoice"`
}
type Rateplan struct {
Code string `xml:"code"`
Source string `xml:"source"`
}
type Request struct {
Search *Search `xml:"search"`
Options *Options `xml:"options"`
Order *Order `xml:"order"`
Data *Data `xml:"data"`
Logging *Logging `xml:"logging"`
}
type Room struct {
OfferID int `xml:"offer_id"`
ID int `xml:"room_id,omitempty"`
Service shared.Board `xml:"service,omitempty"`
Type shared.RoomType `xml:"room_type"`
Seq int `xml:"room_seq"`
Persons []int `xml:"person"`
}
type Root struct {
XMLName xml.Name `xml:"root"`
Version string `xml:"version"`
Header Header `xml:"header"`
Request Request `xml:"request"`
}
type IDOfChannel string
const (
IDOfChannelHGV IDOfChannel = "hgv"
IDOfChannelLTS IDOfChannel = "lts"
IDOfChannelBookingCom IDOfChannel = "bok"
IDOfChannelHotelDe IDOfChannel = "htl"
IDOfChannelExpediaCom IDOfChannel = "exp"
IDOfChannelHrsCom IDOfChannel = "hrs"
IDOfChannelLTSPOS IDOfChannel = "pos"
IDOfChannelGoogle IDOfChannel = "gog"
)
var Languages = []language.Tag{
language.German,
language.Italian,
language.English,
language.Spanish,
language.French,
language.Russian,
language.Danish,
}
var IDOfChannels = []IDOfChannel{
IDOfChannelHGV,
IDOfChannelLTS,
IDOfChannelBookingCom,
IDOfChannelHotelDe,
IDOfChannelExpediaCom,
IDOfChannelHrsCom,
IDOfChannelLTSPOS,
IDOfChannelGoogle,
}
type Search struct {
Lang language.Tag `xml:"lang"`
ResultID string `xml:"result_id"`
Agent string `xml:"agent"`
IDs []int `xml:"id"`
Hotel *SearchHotel `xml:"search_hotel"`
Location *SearchLocation `xml:"search_location"`
Distance *SearchDistance `xml:"search_distance"`
Offer *SearchOffer `xml:"search_offer"`
LTS *shared.LTSData `xml:"search_lts"`
Special *SearchSpecial `xml:"search_special"`
Availability *SearchAvailability `xml:"search_availability"`
PriceList *SearchPriceList `xml:"search_pricelist"`
In []int `xml:"in"`
IDOfChannel IDOfChannel `xml:"id_ofchannel,omitempty"`
TransactionID string `xml:"transaction_id"`
BookingID int `xml:"booking_id"`
GuestEmail string `xml:"guest_email"`
RootID int `xml:"root_id"`
ExternalID int `xml:"external_id"`
Type shared.LocationType `xml:"typ"`
CouponCode string `xml:"coupon_code"`
CouponType *shared.CouponType `xml:"coupon_type"`
TotalPrice float64 `xml:"total_price"`
Arrival *shared.Date `xml:"arrival"`
Departure *shared.Date `xml:"departure"`
StornoID string `xml:"storno_id"`
}
type SearchAvailability struct {
DateFrom *shared.Date `xml:"date_from"`
DateTo *shared.Date `xml:"date_to"`
OfferIDs []int `xml:"offer_id"`
RoomIDs []int `xml:"room_id"`
Type shared.OfferType `xml:"typ"`
}
type SearchDistance struct {
Latitude float64 `xml:"latitude"`
Longitude float64 `xml:"longitude"`
Radius int `xml:"radius"`
}
type SearchHotel struct {
Name string `xml:"name"`
Types []shared.HotelType `xml:"type"`
Stars *Stars `xml:"stars"`
Feature shared.HotelFeature `xml:"feature"`
Theme shared.Theme `xml:"theme"`
RoomType shared.RoomType `xml:"room_type"`
}
type SearchLocation struct {
Locations []int `xml:"location"`
LocationsLTS []string `xml:"location_lts"`
}
type SearchOffer struct {
Arrival *shared.Date `xml:"arrival"`
Departure *shared.Date `xml:"departure"`
Service shared.Board `xml:"service"`
Feature int `xml:"feature,omitempty"`
ChannelIDs []string `xml:"channel_id"`
Rooms []Room `xml:"room"`
Type shared.OfferType `xml:"typ"`
Rateplan *Rateplan `xml:"rateplan"`
}
type ObjectFilter int
const (
ObjectFilterPriceList ObjectFilter = iota
ObjectFilterPackage
ObjectFilterSpecial
ObjectFilterDiscountOrSurcharge ObjectFilter = 4
)
var ObjectFilters = []ObjectFilter{
ObjectFilterPriceList,
ObjectFilterPackage,
ObjectFilterSpecial,
ObjectFilterDiscountOrSurcharge,
}
type SearchPriceList struct {
DateFrom *shared.Date `xml:"date_from"`
DateTo *shared.Date `xml:"date_to"`
Service shared.Board `xml:"service"`
RoomIDs []int `xml:"room_id"`
Type ObjectFilter `xml:"typ"`
}
type SearchSpecial struct {
OfferIDs []int `xml:"offer_id"`
DateFrom *shared.Date `xml:"date_from"`
DateTo *shared.Date `xml:"date_to"`
Themes []shared.ThemeID `xml:"theme"`
POIIDs []int `xml:"poi_id"`
POICats []int `xml:"poi_cat"`
Validity *Validity `xml:"validity"`
Type shared.SpecialType `xml:"typ"`
Premium shared.SpecialPremium `xml:"premium"`
Status int `xml:"status"`
}
type Stars struct {
Min shared.HotelStars `xml:"min"`
Max shared.HotelStars `xml:"max"`
}
type Tracking struct {
Partner string `xml:"partner"`
Media string `xml:"media"`
Campaign string `xml:"campaign"`
CompanyInfo string `xml:"companyinfo"`
}
type Validity struct {
Valid Bool `xml:"valid"`
Offers Bool `xml:"offers"`
Arrival *shared.Date `xml:"arrival"`
Departure *shared.Date `xml:"departure"`
Service shared.Board `xml:"service"`
Rooms []Room `xml:"room"`
}