Giter Club home page Giter Club logo

easypost-ruby's Introduction

EasyPost Ruby Client Library

EasyPost is a simple shipping API. You can sign up for an account at https://easypost.com

Installation

Install the gem:

gem install easypost

Import the EasyPost client in your application:

require 'easypost'

Example

require 'easypost'
EasyPost.api_key = 'cueqNZUb3ldeWTNX7MU3Mel8UXtaAMUi'

to_address = EasyPost::Address.create(
  :name => 'Sawyer Bateman',
  :street1 => '1A Larkspur Cres.',
  :city => 'St. Albert',
  :state => 'AB',
  :zip => 't8n2m4',
  :country => 'CA',
  :phone => '780-273-8374'
)
from_address = EasyPost::Address.create(
  :company => 'Simpler Postage Inc',
  :street1 => '388 Townsend Street',
  :street2 => 'Apt 20',
  :city => 'San Francisco',
  :state => 'CA',
  :zip => '94107',
  :phone => '415-456-7890'
)

parcel = EasyPost::Parcel.create(
  :width => 15.2,
  :length => 18,
  :height => 9.5,
  :weight => 35.1
)

customs_item = EasyPost::CustomsItem.create(
  :description => 'EasyPost T-shirts',
  :quantity => 2,
  :value => 23.56,
  :weight => 33,
  :origin_country => 'us',
  :hs_tariff_number => 123456
)
customs_info = EasyPost::CustomsInfo.create(
  :integrated_form_type => 'form_2976',
  :customs_certify => true,
  :customs_signer => 'Dr. Pepper',
  :contents_type => 'gift',
  :contents_explanation => '', # only required when contents_type => 'other'
  :eel_pfc => 'NOEEI 30.37(a)',
  :non_delivery_option => 'abandon',
  :restriction_type => 'none',
  :restriction_comments => '',
  :customs_items => [customs_item]
)

shipment = EasyPost::Shipment.create(
  :to_address => to_address,
  :from_address => from_address,
  :parcel => parcel,
  :customs_info => customs_info
)

shipment.buy(
  :rate => shipment.lowest_rate
)

puts shipment.postage_label.label_url

Configuration

EasyPost.retry_count

Defaults to 0.

The number of times to retry timeouts connecting to server (503s)

EasyPost.retry_wait_time

Defaults to 10 seconds.

The number of seconds to sleep between each attempt to reach the server after a 503.

Documentation

Up-to-date documentation at: https://easypost.com/docs

Tests

rspec spec

easypost-ruby's People

Contributors

bosh avatar deeeki avatar dkan avatar gsinkin avatar joncalhoun avatar jstreebin avatar jwilsjustin avatar kylecrum avatar laurynas avatar mbeale avatar reillyse avatar sawyer avatar victoryftw avatar xacaxulu avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.