Skip to content

hrdwdmrbl/StallionExpress

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

StallionExpress Ruby Gem

ActiveResource-based Ruby client for Stallion Express API v4.

Installation

gem 'stallionexpress'

Configuration

StallionExpress.configure!(
  api_token: ENV["STALLION_EXPRESS_API_TOKEN"],
)

Usage

Orders

# Get all orders (lazy - fetches as needed)
StallionExpress::Order.all_lazy.each do |order|
  puts order.order_id
  order.items.each do |item|
    puts "  #{item.description}: #{item.quantity}"
  end
end

# Find a specific order
order = StallionExpress::Order.find("ORDER-123")

# Create an order
order = StallionExpress::Order.create!(
  store_id: "1234",
  order_id: "ORDER-001",
  name: "Jane Doe",
  address1: "30 Clearview Dr",
  city: "Rock Springs",
  province_code: "WY",
  postal_code: "82901",
  country_code: "US",
  weight: 0.6,
  items: [
    { title: "Product", quantity: 1, value: 10.5 }
  ]
)

Shipments & Tracking

# Get all shipments with tracking codes
StallionExpress::Shipment.all_lazy.each do |shipment|
  puts "Order #{shipment.order_id}: #{shipment.tracking_code}"
  puts "To: #{shipment.to_address.name}" if shipment.to_address
end

# Get full tracking details
tracking = StallionExpress::Shipment.track(order_id: "ORDER-123")
puts tracking.status
tracking.events.each do |event|
  puts "#{event.datetime}: #{event.status} at #{event.location}"
end
puts "Tracking URL: #{tracking.details.url}" if tracking.details

# Create a shipment
shipment = StallionExpress::Shipment.create!(
  to_address: {
    name: "Jane Doe",
    address1: "30 Clearview Dr",
    city: "Rock Springs",
    province_code: "WY",
    postal_code: "82901",
    country_code: "US"
  },
  weight: 0.6,
  items: [
    { description: "Product", quantity: 1, value: 10 }
  ]
)

Rates

rates = StallionExpress::Rates.quote(
  to_address: { ... },
  weight: 0.6,
  items: [ ... ]
)

rates.each do |rate|
  puts "#{rate.postage_type}: $#{rate.total_rate}"
end

License

MIT

About

Stallion Express API wrapper for Ruby using ActiveResource

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages