Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 3 additions & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ PATH
remote: .
specs:
examples (0.1.0)
easypost (~> 6)
easypost (~> 7)

GEM
remote: https://rubygems.org/
specs:
ast (2.4.2)
easypost (6.4.1)
easypost (7.0.0)
json (2.10.2)
language_server-protocol (3.17.0.4)
lint_roller (1.1.0)
Expand Down Expand Up @@ -62,4 +62,4 @@ DEPENDENCIES
rubocop-rspec (~> 2.31)

BUNDLED WITH
2.5.11
2.6.8
2 changes: 1 addition & 1 deletion examples.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
spec.homepage = 'https://github.com/easypost/examples'
spec.license = 'MIT'

spec.add_dependency 'easypost', '~> 6'
spec.add_dependency 'easypost', '~> 7'

spec.add_development_dependency 'rubocop', '= 1.73'
spec.add_development_dependency 'rubocop-rspec', '~> 2.31' # Can't upgrade to v3 until we drop Ruby 2.7
Expand Down
16 changes: 16 additions & 0 deletions official/docs/ruby/current/billing/add-stripe-bank-account.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
require 'easypost'

client = EasyPost::Client.new(api_key: 'EASYPOST_API_KEY')

payment_method = client.referral_customer.add_bank_account_from_stripe(
'REFERRAL_USER_API_KEY',
'fca_...',
{
ip_address: '127.0.0.1',
user_agent: 'Mozilla/5.0',
accepted_at: 172_251_073,
},
'primary',
)

puts payment_method
11 changes: 11 additions & 0 deletions official/docs/ruby/current/billing/add-stripe-credit-card.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require 'easypost'

client = EasyPost::Client.new(api_key: 'EASYPOST_API_KEY')

payment_method = client.referral_customer.add_credit_card_from_stripe(
'REFERRAL_USER_API_KEY',
'seti_...',
'primary',
)

puts payment_method
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'easypost'

client = EasyPost::Client.new(api_key: 'EASYPOST_API_KEY')

response = client.beta_referral_customer.create_bank_account_client_secret

puts response
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'easypost'

client = EasyPost::Client.new(api_key: 'EASYPOST_API_KEY')

response = client.beta_referral_customer.create_credit_card_client_secret

puts response
18 changes: 9 additions & 9 deletions official/docs/ruby/current/endshipper/update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
end_shipper = client.end_shipper.update(
'es_...',
{
'name' => 'New Name',
'street1' => '388 Townsend St',
'street2' => 'Apt 20',
'city' => 'San Francisco',
'state' => 'CA',
'zip' => '94107',
'country' => 'US',
'email' => 'test@example.com',
'phone' => '5555555555',
name: 'New Name',
street1: '388 Townsend St',
street2: 'Apt 20',
city: 'San Francisco',
state: 'CA',
zip: '94107',
country: 'US',
email: 'test@example.com',
phone: '5555555555',
},
)

Expand Down
3 changes: 3 additions & 0 deletions official/docs/ruby/current/webhooks/create.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
webhook = client.webhook.create(
url: 'example.com',
webhook_secret: 'A1B2C3',
custom_headers: {
'X-Header-Name' => 'header_value',
},
)

puts webhook
9 changes: 8 additions & 1 deletion official/docs/ruby/current/webhooks/update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

client = EasyPost::Client.new(api_key: 'EASYPOST_API_KEY')

webhook = client.webhook.update('hook_...')
webhook = client.webhook.update(
'hook_...', {
webhook_secret: 'A1B2C3',
custom_headers: {
'X-Header-Name' => 'header_value',
},
},
)

puts webhook
18 changes: 9 additions & 9 deletions official/docs/ruby/v5/endshipper/update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
retrieved_endshipper = client.end_shipper.retrieve('es_...')

update_data = {
'name' => 'New Name',
'street1' => '388 Townsend St',
'street2' => 'Apt 20',
'city' => 'San Francisco',
'state' => 'CA',
'zip' => '94107',
'country' => 'US',
'email' => 'test@example.com',
'phone' => '5555555555',
name: 'New Name',
street1: '388 Townsend St',
street2: 'Apt 20',
city: 'San Francisco',
state: 'CA',
zip: '94107',
country: 'US',
email: 'test@example.com',
phone: '5555555555',
}

end_shipper = client.end_shipper.update(retrieved_endshipper.id, update_data)
Expand Down
15 changes: 15 additions & 0 deletions official/docs/ruby/v6/addresses/create-and-verify.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
require 'easypost'

client = EasyPost::Client.new(api_key: 'EASYPOST_API_KEY')

address = client.address.create_and_verify(
street1: '000 unknown street',
city: 'Not A City',
state: 'ZZ',
zip: '00001',
country: 'US',
email: 'test@example.com',
phone: '5555555555',
)

puts address
16 changes: 16 additions & 0 deletions official/docs/ruby/v6/addresses/create.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
require 'easypost'

client = EasyPost::Client.new(api_key: 'EASYPOST_API_KEY')

address = client.address.create(
street1: '417 MONTGOMERY ST',
street2: 'FLOOR 5',
city: 'SAN FRANCISCO',
state: 'CA',
zip: '94104',
country: 'US',
company: 'EasyPost',
phone: '415-123-4567',
)

puts address
9 changes: 9 additions & 0 deletions official/docs/ruby/v6/addresses/list.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require 'easypost'

client = EasyPost::Client.new(api_key: 'EASYPOST_API_KEY')

addresses = client.address.all(
page_size: 5,
)

puts addresses
7 changes: 7 additions & 0 deletions official/docs/ruby/v6/addresses/retrieve.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'easypost'

client = EasyPost::Client.new(api_key: 'EASYPOST_API_KEY')

address = client.address.retrieve('adr_...')

puts address
16 changes: 16 additions & 0 deletions official/docs/ruby/v6/addresses/verify-param.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
require 'easypost'

client = EasyPost::Client.new(api_key: 'EASYPOST_API_KEY')

address = client.address.create(
verify: true,
street1: '000 unknown street',
city: 'Not A City',
state: 'ZZ',
zip: '00001',
country: 'US',
email: 'test@example.com',
phone: '5555555555',
)

puts address
16 changes: 16 additions & 0 deletions official/docs/ruby/v6/addresses/verify-strict-param.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
require 'easypost'

client = EasyPost::Client.new(api_key: 'EASYPOST_API_KEY')

address = client.address.create(
verify_strict: true,
street1: '000 unknown street',
city: 'Not A City',
state: 'ZZ',
zip: '00001',
country: 'US',
email: 'test@example.com',
phone: '5555555555',
)

puts address
7 changes: 7 additions & 0 deletions official/docs/ruby/v6/addresses/verify.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'easypost'

client = EasyPost::Client.new(api_key: 'EASYPOST_API_KEY')

address = client.address.verify('adr_...')

puts address
13 changes: 13 additions & 0 deletions official/docs/ruby/v6/api-keys/retrieve.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require 'easypost'

client = EasyPost::Client.new(api_key: 'EASYPOST_API_KEY')

# Retrieve all API keys including children
api_keys = client.api_key.all

puts api_keys

# Retrieve API keys for a specific child user
child_api_keys = client.api_key.retrieve_api_keys_for_user('user_...')

puts child_api_keys
13 changes: 13 additions & 0 deletions official/docs/ruby/v6/batches/add-shipments.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require 'easypost'

client = EasyPost::Client.new(api_key: 'EASYPOST_API_KEY')

batch = client.batch.add_shipments(
'batch_...',
shipments: [
{ id: 'shp_...' },
{ id: 'shp_...' },
],
)

puts batch
20 changes: 20 additions & 0 deletions official/docs/ruby/v6/batches/buy.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require 'easypost'

client = EasyPost::Client.new(api_key: 'EASYPOST_API_KEY')

created_batch = client.batch.create(
shipments: [
{
from_address: { id: 'adr_...' },
to_address: { id: 'adr_...' },
parcel: { id: 'prcl_...' },
service: 'First',
carrier: 'USPS',
carrier_accounts: ['ca_...'],
},
],
)

batch = client.batch.buy(created_batch.id)

puts batch
12 changes: 12 additions & 0 deletions official/docs/ruby/v6/batches/create.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require 'easypost'

client = EasyPost::Client.new(api_key: 'EASYPOST_API_KEY')

batch = client.batch.create(
shipments: [
{ id: 'shp_...' },
{ id: 'shp_...' },
],
)

puts batch
10 changes: 10 additions & 0 deletions official/docs/ruby/v6/batches/label.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
require 'easypost'

client = EasyPost::Client.new(api_key: 'EASYPOST_API_KEY')

batch = client.batch.label(
'batch_...',
file_format: 'PDF',
)

puts batch
9 changes: 9 additions & 0 deletions official/docs/ruby/v6/batches/list.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require 'easypost'

client = EasyPost::Client.new(api_key: 'EASYPOST_API_KEY')

batches = client.batch.all(
page_size: 5,
)

puts batches
12 changes: 12 additions & 0 deletions official/docs/ruby/v6/batches/remove-shipments.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require 'easypost'

client = EasyPost::Client.new(api_key: 'EASYPOST_API_KEY')

batch = client.batch.remove_shipments(
'batch_...',
shipments: [
{ id: 'shp_...' },
],
)

puts batch
7 changes: 7 additions & 0 deletions official/docs/ruby/v6/batches/retrieve.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'easypost'

client = EasyPost::Client.new(api_key: 'EASYPOST_API_KEY')

batch = client.batch.retrieve('batch_...')

puts batch
7 changes: 7 additions & 0 deletions official/docs/ruby/v6/batches/scan-forms.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'easypost'

client = EasyPost::Client.new(api_key: 'EASYPOST_API_KEY')

batch = client.batch.create_scan_form('batch_...')

puts batch
13 changes: 13 additions & 0 deletions official/docs/ruby/v6/billing/create-ep-credit-card.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
require 'easypost'

client = EasyPost::Client.new(api_key: 'EASYPOST_API_KEY')

credit_card = client.referral_customer.add_credit_card(
'REFERRAL_USER_API_KEY',
'0123456789101234',
'01',
'2025',
'111',
)

puts credit_card
5 changes: 5 additions & 0 deletions official/docs/ruby/v6/billing/delete.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require 'easypost'

client = EasyPost::Client.new(api_key: 'EASYPOST_API_KEY')

client.referral_customer.delete('primary')
5 changes: 5 additions & 0 deletions official/docs/ruby/v6/billing/fund.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require 'easypost'

client = EasyPost::Client.new(api_key: 'EASYPOST_API_KEY')

client.billing.fund_wallet('2000', 'primary')
7 changes: 7 additions & 0 deletions official/docs/ruby/v6/billing/list.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'easypost'

client = EasyPost::Client.new(api_key: 'EASYPOST_API_KEY')

payment_methods = client.billing.retrieve_payment_methods

puts payment_methods
Loading
Loading