-
Notifications
You must be signed in to change notification settings - Fork 1
/
TODO.txt
155 lines (123 loc) · 5.22 KB
/
TODO.txt
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
// TO FIX
QuandooDatetime
@staticmethod
def now():
qdt = QuandooDatetime(datetime.now())
qdt += timedelta(minutes=QuandooDatetime.TIME_RESOLUTION)
return qdt
class Merchant(QuandooModel):
def __init__(self, data, agent):
if type(data) == dict:
self.id = data["id"]
self.name = data["name"]
address_vals = [i if i in data["location"]["address"].keys() else "" for i in ['number', 'street', 'city', 'country']]
address_vals[1] = " ".join(address_vals[:1])
address_vals = address_vals[1:]
self.address = ", ".join(address_vals)
else:
self.id = data
self.agent = agent
super().__init__(data)
def create_reservation(...):
# remove json.dumps(extra_info)
def create_reservation(self, customer, pax: int, qdt: QuandooDatetime, area_id=None, order_id=None, extra_info=None, reservation_tags=[]):
data = {
"reservation": {
"merchantId": self.id,
"capacity": pax,
"dateTime": qdt.get_qdt()
},
"customer": customer.to_json(),
"tracking": {
"agent": {
"id": self.agent.agent_id
}
}
}
if area_id is not None:
data["reservation"]["areaId"] = area_id
if order_id is not None:
data["reservation"]["orderId"] = order_id
if extra_info is not None:
data["reservation"]["extraInfo"] = extra_info
if reservation_tags:
data["reservation"]['reservationTags'] = reservation_tags
request = urljoin(self.agent.url, "reservations")
response = requests.put(request, headers=self.agent.headers, json=data)
if response.status_code == 200:
return NewReservation(json.loads(response.text), self.agent)
raise PoorResponse(response.status_code, json.loads(response.text), request)
def get_reservation_tags(self):
request = urljoin(self.agent.url, 'merchants', self.id, 'reservation_tags')
response = requests.put(request, headers=self.agent.headers)
if response.status_code == 200:
return json.dumps(json.loads(response.text), indent=4)
raise PoorResponse(response.status_code, json.loads(response.text), request
)
def get_reviews(self, offset=0, limit=10):
params = {
"offset": offset,
"limit": limit
}
request = urljoin(self.agent.url, "merchants", self.id, "reviews")
response = requests.get(request, headers=self.agent.headers, params=params)
if response.status_code == 200:
return json.dumps(json.loads(response.text), indent=4)
raise PoorResponse(response.status_code, json.loads(response.text), request)
class Reservation(QuandooModel):
def __init__(self, data, agent):
if type(data) == dict:
self.id = data["id"]
self.number = data["number"]
self.quandooId = data["quandooId"]
self.status = data["status"]
self.date = QuandooDatetime.parse_str_qdt(data["startTime"])
self.startTime = QuandooDatetime.parse_str_qdt(data["startTime"])
self.endTime = QuandooDatetime.parse_str_qdt(data["endTime"])
self.capacity = data["capacity"]
self.merchantId = data["merchantId"]
self.customerId = data["customerId"]
self.extraInfo = data["extraInfo"]
self.createdAt = data["createdAt"]
self.updatedAt = data["updatedAt"]
else:
self.id = data
self.agent = agent
super().__init__(data)
def _update(self, new_status: str=None, new_capacity: int=None, new_area_id: int=None, new_start_time: QuandooDatetime=None, reservation_tags=[]):
data = {
"reservation": {}
}
if new_status is not None:
data["reservation"]["status"] = new_status
if new_capacity is not None:
data["reservation"]["capacity"] = new_capacity
if new_area_id is not None:
data["reservation"]["areaId"] = new_area_id
if new_start_time is not None:
data["reservation"]["dateTime"] = new_start_time.get_qdt()
if reservation_tags:
data["reservation"]['reservationTags'] = reservation_tags
request = urljoin(self.agent.url, "reservations", self.id)
response = requests.patch(request, headers=self.agent.headers, json=data)
if response.status_code == 200:
# TO DO
# Change instance variables - by new fetch or local change?
# new fetch is slower vs local change needs to re calc endTime
return
raise PoorResponse(response.status_code, json.loads(response.text), request)
-----------------------------------------------------------------------------------------------------------------------------
// TO DO
customer.get_reservations()
Merchant
merchant.similar()
marchant.settings()
address fix
reservation.get_menu()
reservation.create_preorder()
reservation.get_preorders()
reservation.update_preorder()
Review
agent.create_review()
agent.get_review()
agent.update_review()