-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
90 lines (77 loc) · 2.6 KB
/
main.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
86
87
88
89
90
import asyncio
import httpx
# Replace this with your API key
API_KEY = ""
async def main():
rate_quote = await post_rate_quote(
{
"RateQuote": {
"CODAmount": 0,
"Origin": {
"City": "Tampa",
"StateOrProvince": "FL",
"ZipOrPostalCode": "34655",
"CountryCode": "USA"
},
"Destination": {
"City": "Dayton",
"StateOrProvince": "OH",
"ZipOrPostalCode": "45414",
"CountryCode": "USA"
},
"Items": [
{
"Width": 4,
"Height": 4,
"Length": 4,
"Class": "65",
"Weight": 114
}
]
}
}
)
print(rate_quote)
async def get_pallet_types():
async with httpx.AsyncClient() as client:
response = await client.get(
"https://api.rlc.com/RateQuote/GetPalletTypes",
headers={"apiKey": f"{API_KEY}"},
)
response.raise_for_status()
return response.json()
async def get_pallet_types_by_points(origin_city, origin_zip, destination_city, destination_zip):
async with httpx.AsyncClient() as client:
response = await client.get(
"https://api.rlc.com/RateQuote/GetPalletTypesByPoints",
headers={"apiKey": f"{API_KEY}"},
params={
"originCity": origin_city,
"originZip": origin_zip,
"destinationCity": destination_city,
"destinationZip": destination_zip,
},
)
response.raise_for_status()
return response.json()
async def get_rate_quote(quote_number):
async with httpx.AsyncClient() as client:
response = await client.get(
"https://api.rlc.com/RateQuote",
headers={"apiKey": f"{API_KEY}"},
params={"quoteNumber": quote_number},
)
response.raise_for_status()
return response.json()
async def post_rate_quote(rate_quote_request):
async with httpx.AsyncClient() as client:
response = await client.post(
"https://api.rlc.com/RateQuote",
headers={"apiKey": f"{API_KEY}",
"Content-Type": "application/json"},
json=rate_quote_request,
)
response.raise_for_status()
return response.json()
if __name__ == "__main__":
asyncio.run(main())