Skip to content

Commit a214e49

Browse files
authored
Merge pull request #220 from hollyabrams/ups-oauth-custom-workflow
Added UPS custom workflow; updated OAuth carrier curls
2 parents 27be976 + 03d1282 commit a214e49

File tree

3 files changed

+26
-25
lines changed

3 files changed

+26
-25
lines changed

official/guides/create-carrier-curls/amazonshipping.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ curl -X POST https://api.easypost.com/v2/carrier_accounts/register_oauth \
55
"carrier_account_oauth_registrations": {
66
"type": "AmazonShippingAccount",
77
"description": "My Shipping Account (optional)",
8-
"reference": "Internal reference id (optional)"
8+
"reference": "Internal reference id (optional)",
9+
"return_to_url": "https://example.com (optional)"
910
}
1011
}'
Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,12 @@
1-
curl -X POST https://api.easypost.com/v2/carrier_accounts \
1+
curl -X POST https://api.easypost.com/v2/carrier_accounts/register_oauth \
22
-u "$EASYPOST_API_KEY": \
33
-H 'Content-Type: application/json' \
44
-d '{
5-
"carrier_account": {
5+
"carrier_account_oauth_registrations": {
66
"type": "UpsAccount",
7-
"description": "UpsAccount",
8-
"registration_data": {
9-
"account_number": "VALUE",
10-
"city": "VALUE",
11-
"company": "VALUE",
12-
"country": "VALUE",
13-
"email": "VALUE",
14-
"name": "VALUE",
15-
"phone": "VALUE",
16-
"postal_code": "VALUE",
17-
"state": "VALUE",
18-
"street1": "VALUE",
19-
"title": "VALUE",
20-
"website": "VALUE",
21-
"invoice_amount": "VALUE",
22-
"invoice_control_id": "VALUE",
23-
"invoice_currency": "VALUE",
24-
"invoice_date": "VALUE",
25-
"invoice_number": "VALUEr"
26-
}
7+
"account_number": "CUSTOMER UPS ACCOUNT NUMBER",
8+
"description": "CUSTOMER ACCOUNT DESCRIPTION (optional)",
9+
"reference": "UNIQUE ACCOUNT REFERENCE (optional)",
10+
"return_to_url": "https://example.com (optional)"
2711
}
2812
}'

tools/build_create_carrier_curl_requests/build_curls.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
"FedexSmartpostAccount",
1919
]
2020
UPS_CUSTOM_WORKFLOW_CARRIERS = [
21-
"UpsAccount",
2221
"UpsDapAccount",
2322
]
2423
CANADAPOST_CUSTOM_WORKFLOW_CARRIERS = [
2524
"CanadaPostAccount",
2625
]
2726
OAUTH_CUSTOM_WORKFLOW_CARRIERS = [
2827
"AmazonShippingAccount",
28+
"UpsAccount"
2929
]
3030
MAERSK_CUSTOM_WORKFLOW_CARRIERS = [
3131
"MaerskAccount"
@@ -188,13 +188,29 @@ def add_credential_structure(carrier_output: str, carrier: dict[str, str]) -> st
188188
carrier_output += END_CHARS
189189
carrier_output = carrier_output.replace(f"{LINE_BREAK_CHARS}{END_CHARS}", f"{END_CHARS}")
190190
return carrier_output
191+
# UPS OAuth
192+
elif carrier["type"] == "UpsAccount":
193+
carrier_account_json = {
194+
"carrier_account_oauth_registrations": {
195+
"type": "UpsAccount",
196+
"account_number": "CUSTOMER UPS ACCOUNT NUMBER",
197+
"description": "CUSTOMER ACCOUNT DESCRIPTION (optional)",
198+
"reference": "UNIQUE ACCOUNT REFERENCE (optional)",
199+
"return_to_url": "https://example.com (optional)"
200+
}
201+
}
202+
203+
carrier_output += f" -d '{json.dumps(carrier_account_json, indent=2)}'"
204+
carrier_output += END_CHARS
205+
return carrier_output
191206
# Amazon Shipping
192207
elif carrier["type"] in OAUTH_CUSTOM_WORKFLOW_CARRIERS:
193208
carrier_account_json = {
194209
"carrier_account_oauth_registrations": {
195210
"type": carrier["type"],
196211
"description": "My Shipping Account (optional)",
197-
"reference": "Internal reference id (optional)"
212+
"reference": "Internal reference id (optional)",
213+
"return_to_url": "https://example.com (optional)"
198214
}
199215
}
200216

0 commit comments

Comments
 (0)