Coder Social home page Coder Social logo

omniship's Introduction

Gem Version Code Climate Build Status

Omniship

Update 9/21/2015 - I have started working on the 1.0.0 release for this gem, this will include a complete test suite as well as UPS, FedEx, and USPS full integeration 1-to-1 with all basic features of these carriers. After this release, then I'll get into developing out the more advanced features of these carriers which will include full support for international shipping. If you wish to provide a suggestion for more carriers, please create an issue with the "feature" tag.

This gem is under active development, I'm only in the Alpha stage right now, so keep checking back for updates.

This library has been created to make web requests to common shipping carriers using XML. I created this to be easy to use with a nice Ruby API. This code was originally forked from the Shopify/active_shipping code, I began to strip it down cause I wan't a cleaner API along with the ability to actually create shipment labels with it. After changing enough code, I created this gem as its own project since it's different enough.

Supported Shipping Carriers

  • UPS
    • Create Shipment
    • Void Shipment
    • Get Rates
    • Validate Address
    • Validate Address with Street
  • FedEx (These listed features work, but still need more options added)
    • Create Shipment
    • Void Shipment
    • Get Rates
    • Shipment Tracking
  • USPS COMING SOON!

Simple example snippets

UPS Code Example

To run in test mode during development, pass :test => true as an option into create_shipment and accept_shipment.

  def create_shipment
  # If you have created the omniship.yml config file
  @config  = OMNISHIP_CONFIG[Rails.env]['ups']
  shipment = create_ups_shipment
end

def create_ups_shipment
  # If using the yml config
  ups = Omniship::UPS.new
  # Else just pass in the credentials
  ups = Omniship::UPS.new(:login => @user, :password => @password, :key => @key)
  send_options = {}
  send_options[:origin_account] = @config["account"] # Or just put the shipper account here
  send_options[:service]        = "03"
  response = ups.create_shipment(origin, destination, package, options = send_options)
  return ups.accept_shipment(response)
end

def origin
  address = {}
  address[:name]     = "My House"
  address[:address1] = "555 Diagonal"
  address[:city]     = "Saint George"
  address[:state]    = "UT"
  address[:zip]      = "84770"
  address[:country]  = "USA"
  return Omniship::Address.new(address)
end

def destination
  address = {}
  address[:company_name] = "Wal-Mart"
  address[:address1]     = "555 Diagonal"
  address[:city]         = "Saint George"
  address[:state]        = "UT"
  address[:zip]          = "84770"
  address[:country]      = "USA"
  return Omniship::Address.new(address)
end

def packages
  # UPS can handle a single package or multiple packages
  pkg_list = []
  weight = 1
  length = 1
  width  = 1
  height = 1
  package_type = "02"
  pkg_list << Omniship::Package.new(weight.to_i,[length.to_i,width.to_i,height.to_i],:units => :imperial, :package_type => package_type)
  return pkg_list
end

Tests

Currently this is on my TODO list. Check back for updates

Change Log

0.4.5

  • Bug fixes for UPS
  • Updated syntax for gemspec
  • Updated dependencies

0.4.1

  • Bug fixes for dependencies

Contributing

Before anyone starts contributing, I want to get a good stable version going and tests to follow, after I get that going then for the features you add, you should have both unit tests and remote tests. It's probably best to start with the remote tests, and then log those requests and responses and use them as the mocks for the unit tests.

To log requests and responses, just set the logger on your carrier class to some kind of Logger object:

Omniship::USPS.logger = Logger.new($stdout)

(This logging functionality is provided by the PostsData module in the active_utils dependency.)

After you've pushed your well-tested changes to your github fork, make a pull request and we'll take it from there!

Legal Mumbo Jumbo

Unless otherwise noted in specific files, all code in the Omniship project is under the copyright and license described in the included MIT-LICENSE file.

omniship's People

Contributors

digi-cazter avatar cakestylestaging avatar adamthedeveloper avatar forkata avatar jordan-brough avatar

Watchers

James Cloos 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.