Created
November 23, 2013 23:45
-
-
Save ahmadvaroqua/7621491 to your computer and use it in GitHub Desktop.
Create a batch with Easypost.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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