-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathdelete_order.py
58 lines (50 loc) · 2.17 KB
/
delete_order.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
# -*- coding: utf-8 -*-
# codebeat:disable[ABC]
import argparse
from route4me import Route4Me
def main(api_key):
route4me = Route4Me(api_key)
order = route4me.order
url = "http://www.bk.com/restaurants/ny/new-york/106-fulton-st-17871.html"
data = {
'address_1': '106 Fulton St, Farmingdale, NY 11735, USA',
'cached_lat': 40.730730,
'cached_lng': -73.459283,
'address_alias': 'BK Restaurant #: 17871',
'EXT_FIELD_phone': '(212) 566-5132',
'day_scheduled_for_YYMMDD': '2016-07-01',
'EXT_FIELD_custom_data': {
'url': url
}
}
response = order.create_order(**data)
if isinstance(response, dict) and 'errors' in response.keys():
print('. '.join(response['errors']))
else:
print('Member ID:\t{0}'.format(response.get('member_id')))
print('Order ID:\t{0}'.format(response.get('order_id')))
print('Order Status ID:\t{0}'.format(response.get('order_status_id')))
print('In Route Count:\t{0}'.format(response.get('in_route_count')))
print('Day Added:\t{0}'.format(response.get('day_added_YYMMDD')))
print('Is Pending:\t{0}'.format(response.get('is_pending')))
print('Is Accepted:\t{0}'.format(response.get('is_accepted')))
print('Is Started:\t{0}'.format(response.get('is_started')))
print('Is Validated:\t{0}'.format(response.get('is_validated')))
print('Is Completed:\t{0}'.format(response.get('is_completed')))
print('********************************************************')
print('Deleting')
print('********************************************************')
order_id = response.get('order_id')
if order_id:
data = {'order_ids': [order_id]}
response = order.delete_order(**data)
print(response)
else:
print('Error Getting Order')
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Delete an Order')
parser.add_argument('--api_key', dest='api_key', help='Route4Me API KEY',
type=str, required=True)
args = parser.parse_args()
main(args.api_key)
# codebeat:enable[ABC]