Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] Add .http files for API call references #127

Merged
merged 2 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions community/docs/http_files/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
These are `.http` files representing examples of HTTP requests that can be made to the API.

They can be run using the [REST Client](https://marketplace.visualstudio.com/items?itemName=humao.rest-client) extension
in Visual Studio Code or the [HTTP Client](https://www.jetbrains.com/help/idea/http-client-in-product-code-editor.html)
in JetBrains IDEs. They can also be exported as cURL commands.
100 changes: 100 additions & 0 deletions community/docs/http_files/addresses.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
@API_KEY = EASYPOST_API_KEY

# Create an Address
POST https://api.easypost.com/v2/addresses
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

{
"address": {
"street1": "417 MONTGOMERY ST",
"street2": "FLOOR 5",
"city": "SAN FRANCISCO",
"state": "CA",
"zip": "94104",
"country": "US",
"company": "EasyPost",
"phone": "415-123-4567"
}
}

###

# Create and verify an Address in one call (basic verification checks)
POST https://api.easypost.com/v2/addresses/create_and_verify
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

{
"address": {
"street1": "000 unknown street",
"city": "Not A City",
"state": "ZZ",
"zip": "00001",
"country": "US",
"email": "[email protected]",
"phone": "5555555555"
}
}

###

# Create and verify an Address in one call (basic + delivery/zip validation)
POST https://api.easypost.com/v2/addresses/create
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

{
"address": {
"street1": "000 unknown street",
"city": "Not A City",
"state": "ZZ",
"zip": "00001",
"country": "US",
"email": "[email protected]",
"phone": "5555555555"
},
"verify": true
}

###

# Create and verify an Address in one call (basic + strict delivery/zip validation)
POST https://api.easypost.com/v2/addresses/create
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

{
"address": {
"street1": "000 unknown street",
"city": "Not A City",
"state": "ZZ",
"zip": "00001",
"country": "US",
"email": "[email protected]",
"phone": "5555555555"
},
"verify_strict": true
}

###

# Verify an existing Address (basic verification checks)
GET https://api.easypost.com/v2/addresses/{{ADDRESS_ID}}/verify
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

###

# Retrieve an Address
GET https://api.easypost.com/v2/addresses/{{ADDRESS_ID}}
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

###

# List all Addresses
GET https://api.easypost.com/v2/addresses
?page_size=10
Authorization: Bearer {{API_KEY}}
Content-Type: application/json
49 changes: 49 additions & 0 deletions community/docs/http_files/api-keys.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
@API_KEY = EASYPOST_API_KEY

# Create a test API key
POST https://api.easypost.com/v2/api_keys
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

{
"mode": "test"
}

###

# Create a production API key
POST https://api.easypost.com/v2/api_keys
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

{
"mode": "production"
}

###

# Retrieve all API keys
GET https://api.easypost.com/v2/api_keys
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

###

# Enable a disabled API key
POST https://api.easypost.com/v2/api_keys/{{API_KEY_ID}}/enable
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

###

# Disable an enabled API key
POST https://api.easypost.com/v2/api_keys/{{API_KEY_ID}}/disable
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

###

# Delete an API key
DELETE https://api.easypost.com/v2/api_keys/{{API_KEY_ID}}
Authorization: Bearer {{API_KEY}}
Content-Type: application/json
89 changes: 89 additions & 0 deletions community/docs/http_files/batches.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
@API_KEY = EASYPOST_API_KEY

# Create a Batch with existing Shipments
POST https://api.easypost.com/v2/batches
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

{
"batch": {
"shipments": [
{
"id": "shp_123"
},
{
"id": "shp_456"
}
]
}
}

###

# Add Shipments to a Batch
POST https://api.easypost.com/v2/batches/{{BATCH_ID}}/add_shipments
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

{
"shipments": [
{
"id": "shp_789"
}
]
}

###

# Remove Shipments from a Batch
POST https://api.easypost.com/v2/batches/{{BATCH_ID}}/remove_shipments
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

{
"shipments": [
{
"id": "shp_789"
}
]
}

###

# Purchase a Batch
POST https://api.easypost.com/v2/batches/{{BATCH_ID}}/buy
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

###

# Generate a label for a Batch
POST https://api.easypost.com/v2/batches/{{BATCH_ID}}/label
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

{
"file_format": "PDF"
}

###

# Generate a ScanForm for a Batch
POST https://api.easypost.com/v2/batches/{{BATCH_ID}}/scan_form
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

###

# Retrieve a Batch
GET https://api.easypost.com/v2/batches/{{BATCH_ID}}
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

###

# List all Batches
GET https://api.easypost.com/v2/batches
?page_size=5
Authorization: Bearer {{API_KEY}}
Content-Type: application/json
61 changes: 61 additions & 0 deletions community/docs/http_files/billing.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
@partner_api_key = PARTNER_API_KEY
@referral_customer_api_key = REFERRAL_CUSTOMER_API_KEY
nwithan8 marked this conversation as resolved.
Show resolved Hide resolved
@API_KEY = EASYPOST_API_KEY

# Get EasyPost public key for authenticating with Stripe
GET https://api.easypost.com/v2/partners/stripe_public_key
Authorization: Bearer {{partner_api_key}}
Content-Type: application/json

###

# Add a Stripe credit card to referral customer's account
POST https://api.easypost.com/v2/credit_cards
Authorization: Bearer {{referral_customer_api_key}}
Content-Type: application/json

{
"credit_card": {
"stripe_object_id": "tok_...",
"priority": "primary"
}
}

###

# List account payment methods
GET https://api.easypost.com/v2/payment_methods
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

###

# Fund account with on-file credit card ($10.00)
POST https://api.easypost.com/v2/credit_cards/{{CREDIT_CARD_ID}}/charges
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

{
"amount": 1000
}

###

# Fund account with on-file bank account ($10.00)
POST https://api.easypost.com/v2/bank_accounts/{{BANK_ACCOUNT_ID}}/charges
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

###

# Delete an on-file credit card from account
DELETE https://api.easypost.com/v2/credit_cards/{{CREDIT_CARD_ID}}
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

###

# Delete an on-file bank account from account
DELETE https://api.easypost.com/v2/bank_accounts/{{BANK_ACCOUNT_ID}}
Authorization: Bearer {{API_KEY}}
Content-Type: application/json
18 changes: 18 additions & 0 deletions community/docs/http_files/brands.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
@API_KEY = EASYPOST_API_KEY

# Update a user's brand
PATCH https://api.easypost.com/v2/users/{{USER_ID}}/brand
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

{
"brand": {
"background_color": "#FFFFFF",
"color": "#303F9F",
"logo": "data:image/png;base64,iVBORw0K...",
"logo_href": "https://easypost.com",
"ad": "null",
"ad_href": "null",
"theme": "theme1"
}
}
63 changes: 63 additions & 0 deletions community/docs/http_files/carrier-accounts.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
@API_KEY = EASYPOST_API_KEY

# Create a Carrier Account
POST https://api.easypost.com/v2/carrier_accounts
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

{
"carrier_account": {
"type": "DhlEcsAccount",
"description": "CA Location DHL eCommerce Solutions Account",
"reference": "my-reference",
"credentials": {
"client_id": "123456",
"client_secret": "123abc",
"distribution_center": "USLAX1",
"pickup_id": "123456"
},
"test_credentials": {
"client_id": "123456",
"client_secret": "123abc",
"distribution_center": "USLAX1",
"pickup_id": "123456"
}
}
}

###

# Retrieve a Carrier Account
GET https://api.easypost.com/v2/carrier_accounts/{{CARRIER_ACCOUNT_ID}}
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

###

# List all Carrier Accounts
GET https://api.easypost.com/v2/carrier_accounts
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

###

# Update a Carrier Account
PATCH https://api.easypost.com/v2/carrier_accounts/{{CARRIER_ACCOUNT_ID}}
Authorization: Bearer {{API_KEY}}
Content-Type: application/json

{
"carrier_account": {
"description": "FL Location DHL eCommerce Solutions Account",
"credentials": {
"pickup_id": "abc123"
}
}
}

###

# Delete a Carrier Account
DELETE https://api.easypost.com/v2/carrier_accounts/{{CARRIER_ACCOUNT_ID}}
Authorization: Bearer {{API_KEY}}
Content-Type: application/json
Loading
Loading