Skip to content

Commit

Permalink
chore: validate and correct all Python examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Justintime50 committed Aug 31, 2022
1 parent 4c5bab1 commit 1875512
Show file tree
Hide file tree
Showing 89 changed files with 317 additions and 111 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
.DS_Store
.env
.idea
bin
*.egg-info
/checkstyle.jar
/easypost_java_style.xml
/vendor
bin
node_modules
venv
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ install-php:
## install-python - install Python dependencies
install-python:
$(PYTHON_BINARY) -m venv $(PYTHON_VIRTUAL_ENV)
$(PYTHON_VIRTUAL_BIN)/pip install -r requirements.txt
$(PYTHON_VIRTUAL_BIN)/pip install -e ."[dev]"

## install-ruby - installs Ruby dependencies
install-ruby:
Expand Down
4 changes: 2 additions & 2 deletions community/golang/concurrent_label_buy.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
/*
* Concurrently buy EasyPost Shipments via a CSV file
*
* Usage: EASYPOST_TEST_API_KEY=123... CSV=report.csv CARRIER_ACCOUNT_ID=ca_123... SERVICE=FEDEX_2_DAY CARRIER=FedEx go run concurrent_label_buy.go
* Usage: EASYPOST_API_KEY=123... CSV=report.csv CARRIER_ACCOUNT_ID=ca_123... SERVICE=FEDEX_2_DAY CARRIER=FedEx go run concurrent_label_buy.go
* Inspiration: https://stackoverflow.com/questions/33104192/how-to-run-10000-goroutines-in-parallel-where-each-routine-calls-an-api
* CSV Format: Do not include a header row. Match up the rows with the current-line indexes below (eg: Name: lines[current][0])
* Rate Limiting: Do not use more than 50 goroutines, do not try CSV's larger than 2000 records, pass Go, do not collect $200... ;)
Expand All @@ -32,7 +32,7 @@ func main() {
total := int32(0)

// Make request here
apiKey := os.Getenv("EASYPOST_TEST_API_KEY")
apiKey := os.Getenv("EASYPOST_API_KEY")

client := easypost.New(apiKey)

Expand Down
4 changes: 2 additions & 2 deletions community/golang/concurrent_refund.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
/*
* Concurrently refund EasyPost Shipments via a CSV file
*
* Usage: EASYPOST_TEST_API_KEY=123... CSV=report.csv go run concurrent_refund.go
* Usage: EASYPOST_API_KEY=123... CSV=report.csv go run concurrent_refund.go
* Inspiration: https://stackoverflow.com/questions/33104192/how-to-run-10000-goroutines-in-parallel-where-each-routine-calls-an-api
* CSV Format: Provide a single shipment ID per line in column 0 (1st column) with no other data
* Rate Limiting: Do not use more than 50 goroutines, do not try CSV's larger than 2000 records, pass Go, do not collect $200... ;)
Expand All @@ -30,7 +30,7 @@ func main() {
total := int32(0)

// Setup the EasyPost API Client
apiKey := os.Getenv("EASYPOST_TEST_API_KEY")
apiKey := os.Getenv("EASYPOST_API_KEY")

client := easypost.New(apiKey)

Expand Down
4 changes: 2 additions & 2 deletions community/golang/concurrent_shipment_scanform.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
/*
* Concurrently scanform shipments from a batch. Great for bypassing scanform errors when there are only a couple of troubled shipments in a large batch
*
* Usage: EASYPOST_TEST_API_KEY=123... BATCH=batch_123... go run concurrent_shipment_scanform.go
* Usage: EASYPOST_API_KEY=123... BATCH=batch_123... go run concurrent_shipment_scanform.go
* Inspiration: https://stackoverflow.com/questions/33104192/how-to-run-10000-goroutines-in-parallel-where-each-routine-calls-an-api
*/

Expand All @@ -27,7 +27,7 @@ func main() {
total := int32(0)

// Setup EasyPost API key
apiKey := os.Getenv("EASYPOST_TEST_API_KEY")
apiKey := os.Getenv("EASYPOST_API_KEY")

client := easypost.New(apiKey)

Expand Down
4 changes: 2 additions & 2 deletions official/docs/curl/pickups/create-pickup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ curl -X POST https://api.easypost.com/v2/pickups \
-d '{
"pickup": {
"reference": "my-first-pickup",
"min_datetime": "2014-10-20 17:10:00",
"max_datetime": "2014-10-21 10:30:00",
"min_datetime": "2022-10-01 10:30:00",
"max_datetime": "2022-10-02 10:30:00",
"shipment": "shp_...",
"address": "adr_...",
"is_account_address": "false",
Expand Down
4 changes: 2 additions & 2 deletions official/docs/curl/reports/create-report.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ curl -X POST https://api.easypost.com/v2/reports/payment_log \
-u "$EASYPOST_API_KEY": \
-H 'Content-Type: application/json' \
-d '{
"start_date": "2016-10-01",
"end_date": "2016-10-31"
"start_date": "2022-10-01",
"end_date": "2022-10-31"
}'
4 changes: 3 additions & 1 deletion official/docs/python/addresses/create_address.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os

import easypost


easypost.api_key = "EASYPOST_API_KEY"
easypost.api_key = os.getenv("EASYPOST_API_KEY")

address = easypost.Address.create(
street1="417 MONTGOMERY ST",
Expand Down
4 changes: 3 additions & 1 deletion official/docs/python/addresses/create_and_verify_address.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os

import easypost


easypost.api_key = "EASYPOST_API_KEY"
easypost.api_key = os.getenv("EASYPOST_API_KEY")

address = easypost.Address.create_and_verify(
street1="417 Montgomery Street",
Expand Down
4 changes: 3 additions & 1 deletion official/docs/python/addresses/create_verified_address.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os

import easypost


easypost.api_key = "EASYPOST_API_KEY"
easypost.api_key = os.getenv("EASYPOST_API_KEY")

address = easypost.Address.create(
verify=True,
Expand Down
4 changes: 3 additions & 1 deletion official/docs/python/addresses/retrieve_address.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os

import easypost


easypost.api_key = "EASYPOST_API_KEY"
easypost.api_key = os.getenv("EASYPOST_API_KEY")

address = easypost.Address.retrieve("adr_...")

Expand Down
4 changes: 3 additions & 1 deletion official/docs/python/addresses/retrieve_address_list.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os

import easypost


easypost.api_key = "EASYPOST_API_KEY"
easypost.api_key = os.getenv("EASYPOST_API_KEY")

addresses = easypost.Address.all(page_size=5)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os

import easypost


easypost.api_key = "EASYPOST_API_KEY"
easypost.api_key = os.getenv("EASYPOST_API_KEY")

address = easypost.Address.create(
verify_strict=True,
Expand Down
4 changes: 3 additions & 1 deletion official/docs/python/addresses/verify_existing_address.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os

import easypost


easypost.api_key = "EASYPOST_API_KEY"
easypost.api_key = os.getenv("EASYPOST_API_KEY")

address = easypost.Address.create(
street1="417 MONTGOMERY ST",
Expand Down
4 changes: 3 additions & 1 deletion official/docs/python/api_keys/retrieve_api_keys.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os

import easypost


easypost.api_key = "EASYPOST_API_KEY"
easypost.api_key = os.getenv("EASYPOST_API_KEY")

api_keys = easypost.User.all_api_keys()

Expand Down
4 changes: 3 additions & 1 deletion official/docs/python/batches/add_shipments_to_batch.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os

import easypost


easypost.api_key = "EASYPOST_API_KEY"
easypost.api_key = os.getenv("EASYPOST_API_KEY")

batch = easypost.Batch.retrieve("batch_...")

Expand Down
4 changes: 3 additions & 1 deletion official/docs/python/batches/buy_batch.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os

import easypost


easypost.api_key = "EASYPOST_API_KEY"
easypost.api_key = os.getenv("EASYPOST_API_KEY")

batch = easypost.Batch.retrieve("batch_...")

Expand Down
4 changes: 3 additions & 1 deletion official/docs/python/batches/create_batch.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os

import easypost


easypost.api_key = "EASYPOST_API_KEY"
easypost.api_key = os.getenv("EASYPOST_API_KEY")

batch = easypost.Batch.create(
shipments=[
Expand Down
4 changes: 3 additions & 1 deletion official/docs/python/batches/create_label_for_batch.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os

import easypost


easypost.api_key = "EASYPOST_API_KEY"
easypost.api_key = os.getenv("EASYPOST_API_KEY")

batch = easypost.Batch.retrieve("batch_...")

Expand Down
4 changes: 3 additions & 1 deletion official/docs/python/batches/manifest_batch.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os

import easypost


easypost.api_key = "EASYPOST_API_KEY"
easypost.api_key = os.getenv("EASYPOST_API_KEY")

batch = easypost.Batch.retrieve("batch_...")

Expand Down
4 changes: 3 additions & 1 deletion official/docs/python/batches/remove_shipment_from_batch.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os

import easypost


easypost.api_key = "EASYPOST_API_KEY"
easypost.api_key = os.getenv("EASYPOST_API_KEY")

batch = easypost.Batch.retrieve("batch_...")

Expand Down
4 changes: 3 additions & 1 deletion official/docs/python/batches/retrieve_batch.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os

import easypost


easypost.api_key = "EASYPOST_API_KEY"
easypost.api_key = os.getenv("EASYPOST_API_KEY")

batch = easypost.Batch.retrieve("batch_...")

Expand Down
4 changes: 3 additions & 1 deletion official/docs/python/batches/retrieve_batch_list.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os

import easypost


easypost.api_key = "EASYPOST_API_KEY"
easypost.api_key = os.getenv("EASYPOST_API_KEY")

batches = easypost.Batch.all(page_size=5)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os

import easypost


easypost.api_key = "EASYPOST_API_KEY"
easypost.api_key = os.getenv("EASYPOST_API_KEY")

billing = easypost.Billing.fund_wallet(
amount="2000",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os

import easypost


easypost.api_key = "EASYPOST_API_KEY"
easypost.api_key = os.getenv("EASYPOST_API_KEY")

success = easypost.Billing.delete_payment_method(primary_or_secondary="primary")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os

import easypost


easypost.api_key = "EASYPOST_API_KEY"
easypost.api_key = os.getenv("EASYPOST_API_KEY")

payment_methods = easypost.Billing.retrieve_payment_methods()

Expand Down
4 changes: 3 additions & 1 deletion official/docs/python/brand/update_brand.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os

import easypost


easypost.api_key = "EASYPOST_API_KEY"
easypost.api_key = os.getenv("EASYPOST_API_KEY")

user = easypost.User.retrieve_me()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os

import easypost


easypost.api_key = "EASYPOST_API_KEY"
easypost.api_key = os.getenv("EASYPOST_API_KEY")

carrier_account = easypost.CarrierAccount.create(
type="DhlEcsAccount",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os

import easypost


easypost.api_key = "EASYPOST_API_KEY"
easypost.api_key = os.getenv("EASYPOST_API_KEY")

carrier_account = easypost.CarrierAccount.retrieve("ca_...")
carrier_account.delete()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os

import easypost


easypost.api_key = "EASYPOST_API_KEY"
easypost.api_key = os.getenv("EASYPOST_API_KEY")

carrier_account = easypost.CarrierAccount.retrieve("ca_...")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os

import easypost


easypost.api_key = "EASYPOST_API_KEY"
easypost.api_key = os.getenv("EASYPOST_API_KEY")

carrier_accounts = easypost.CarrierAccount.all()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os

import easypost


easypost.api_key = "EASYPOST_API_KEY"
easypost.api_key = os.getenv("EASYPOST_API_KEY")

carrier_account = easypost.CarrierAccount.retrieve("ca_...")

Expand Down
4 changes: 3 additions & 1 deletion official/docs/python/carrier_types/retrieve_carrier_type.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os

import easypost


easypost.api_key = "EASYPOST_API_KEY"
easypost.api_key = os.getenv("EASYPOST_API_KEY")

carrier_types = easypost.CarrierAccount.types()

Expand Down
6 changes: 5 additions & 1 deletion official/docs/python/customs_info/create_customs_info.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os

import easypost


easypost.api_key = "EASYPOST_API_KEY"
easypost.api_key = os.getenv("EASYPOST_API_KEY")

customs_info = easypost.CustomsInfo.create(
eel_pfc="NOEEI 30.37(a)",
Expand All @@ -21,3 +23,5 @@
}
],
)

print(customs_info)
Loading

0 comments on commit 1875512

Please sign in to comment.