Skip to content

Instantly share code, notes, and snippets.

@ahmadvaroqua
Created November 23, 2013 23:45
Show Gist options
  • Save ahmadvaroqua/7621491 to your computer and use it in GitHub Desktop.
Save ahmadvaroqua/7621491 to your computer and use it in GitHub Desktop.
Create a batch with Easypost.
require 'easypost'
EasyPost.api_key = 'YOUR API KEY HERE'
from_address = EasyPost::Address.create(
:name => 'EasyPost',
:street1 => '5128 Geary Blvd',
:city => 'San Francisco',
:state => 'CA',
:zip => '94118',
:country => 'US',
:phone => '650.722.0552'
)
to_address = EasyPost::Address.create({
:name => 'Dr. Steve Brule',
:street1 => '179 N Harbor Dr',
:city => 'Redondo Beach',
:state => 'CA',
:zip => '90277',
:country => 'US',
:email => '[email protected]'
}
)
parcel = EasyPost::Parcel.create(
:weight => 32,
:height => 1,
:width => 13,
:length => 18
)
#batch = EasyPost::Batch.create({:shipment => [
batch = EasyPost::Batch.create_and_buy({:shipment => [
{
:from_address => from_address,
:to_address => to_address,
:parcel => parcel,
:service => 'Ground',
:carrier => 'UPS',
:reference => 'order_12345'
},
{
:from_address => from_address,
:to_address => to_address,
:parcel => parcel,
:service => 'Ground',
:carrier => 'UPS',
:reference => 'order_12346'
}]
})
puts batch.id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment