-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhotel.py
85 lines (78 loc) · 3.08 KB
/
hotel.py
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
from typing import List, Optional, Dict
from pydantic import BaseModel, field_validator, Field, HttpUrl
class Image(BaseModel):
link: HttpUrl
description: Optional[str] = None
class Amenities(BaseModel):
general: Optional[List[str]] = None
room: Optional[List[str]] = None
class Location(BaseModel):
address: Optional[str] = None
city: Optional[str] = None
country: Optional[str] = None
postal_code: Optional[str] = None
latitude: Optional[float] = None
longitude: Optional[float] = None
@field_validator('*', mode='before')
def empty_string_to_none(cls, v):
return None if v == '' else v
class HotelImages(BaseModel):
rooms: Optional[List[Image]] = None
site: Optional[List[Image]] = None
amenities: Optional[List[Image]] = None
class Hotel(BaseModel):
hotel_id: str = Field(..., alias="Id")
destination_id: int = Field(..., alias="DestinationId")
name: str = Field(..., alias="Name")
description: Optional[str] = None
location: Location
amenities: Optional[Amenities] = None
images: Optional[HotelImages] = None
booking_conditions: Optional[List[str]] = None
source: str = Field(..., alias="Source")
class Config:
populate_by_name = True
json_schema_extra = {
"example": {
"hotel_id": "iJhz",
"destination_id": 5432,
"name": "Beach Villas Singapore",
"description": "This 5 star hotel is located on the coastline of Singapore.",
"location": {
"address": "8 Sentosa Gateway, Beach Villas",
"city": "Singapore",
"country": "SG",
"postal_code": "098269",
"latitude": 1.264751,
"longitude": 103.824006
},
"facilities": ["Pool", "BusinessCenter", "WiFi", "DryCleaning", "Breakfast"],
"amenities": {
"general": ["outdoor pool", "business center", "childcare"],
"room": ["tv", "coffee machine", "kettle", "hair dryer", "iron"]
},
"images": {
"rooms": [
{
"link": "https://d2ey9sqrvkqdfs.cloudfront.net/0qZF/2.jpg",
"caption": "Double room"
},
{
"link": "https://d2ey9sqrvkqdfs.cloudfront.net/0qZF/3.jpg",
"caption": "Double room"
}
],
"site": [
{
"link": "https://d2ey9sqrvkqdfs.cloudfront.net/0qZF/1.jpg",
"caption": "Front"
}
]
},
"booking_conditions": [
"All children are welcome.",
"Pets are not allowed.",
"WiFi is available in all areas and is free of charge."
]
}
}