This is a Ruby wrapper for ShipStation's OData API.
- Support spacename, You can use it with rails model Order and SS::Order.
SS
is default namespace. - Support api host
- Collection Create
- Collection Update
- Collection Delete( set attr Active = false )
- Collection Destroy( call
delete_object
)
- Collection First
- Collection Last
- Collection Count
- Collection return Rash instance
- Collection Create return a instance, not Array.
- Collection Where by array
- Collection Where by String. eg.
client.orders.where("CreateDate ge datetime'2014-06-17'")
You can write a filter string, read more here, here, and here - Test with shipstation api 1.3
Rename the gem to shipstation-rb.
Removed gem dependency versions.
gem 'shipstation-rb', '~> 0.0.5'
gem 'awesome_print', :require => 'ap'
The ShipStation API uses basic HTTP authentication. Inside config/initializers, create a new configuration file and use the following template to pass in your ShipStation credentials:
ShipStation.username = ENV['SHIPSTATION_USERNAME']
ShipStation.password = ENV['SHIPSTATION_PASSWORD']
ShipStation.api_host = ENV['SHIPSTATION_API_HOST']
OR
require "shipstation"
client = ShipStation::Client.new(APICONFIG[:ship_station_api], APICONFIG[:ship_station_account], APICONFIG[:ship_station_password])
ShipStation.api_host = "https://data.shipstation.com/1.3"
ShipStation.password = "shipstation_password"
ShipStation.password = "shipstation_password"
client = ShipStation::Client.new
client = ShipStation::Client.new("https://data.shipstation.com/1.3", "username", "password")
order = client.order.find(12345)
orders = client.order.all
open_texas_orders = client.order.where("active" => "true", "ship_state" => "TX")
all_warehouses = client.warehouse.all
customer_12345 = client.customer.find(12345)
texas_fedex_shipments = client.shipment.where("shipping_service_id" => 0001, "state" => "TX")
etc.
client = ShipStation::Client.new
order = client.order.find(12345)
order.order_id ## 12345
order.ship_city ## Boise
order.order_total ## $343.32
client = ShipStation::Client.new
client.order.create(OrderNumber: "T0001", OrderStatusID: 2)
client = ShipStation::Client.new
client.order.Update(1234, OrderNumber: "T0002", OrderStatusID: 2)
client = ShipStation::Client.new
client.orders.delete(1234) #=> order.active = false
client = ShipStation::Client.new
client.orders.destory(1234) # svc.delete_object(klass)
client = ShipStation::Client.new
client.stores.all
client = ShipStation::Client.new
client.stores.first
client = ShipStation::Client.new
client.stores.last
client = ShipStation::Client.new
client.order.create(
StoreID: APICONFIG[:ship_station_store_id],
OrderNumber: real_order.number,
ImportKey: "OrderID#{real_order.id}",
OrderDate: real_order.order_date,
PayDate: real_order.order_date,
OrderStatusID: 2,
RequestedShippingService: provider_name,
OrderTotal: real_order.total,
AmountPaid: real_order.payment_total,
ShippingAmount: real_order.adjustments.select{|aa| aa["label"] == "Shipping" }[0].try(:amount),
TaxAmount: real_order.adjustments.select{|aa| aa["label"] == "sales_tax"}[0].try(:amount),
NotesFromBuyer: "Please make sure it gets here by Monday!",
InternalNotes: "Expedite this order.",
BuyerName: real_order.user.login,
BuyerEmail: real_order.user.email,
ShipName: "#{real_order.ship_address.firstname} #{real_order.ship_address.lastname}",
ShipCompany: "",
ShipStreet1: real_order.ship_address.address1,
ShipCity: real_order.ship_address.city,
ShipState: real_order.ship_address.state.name,
ShipPostalCode: real_order.ship_address.zipcode,
ShipCountryCode: real_order.ship_address.country.iso,
ShipPhone: real_order.ship_address.phone,
AddressVerified: 0,
MarketplaceID: 0,
InsuranceProvider: 0,
Confirmation: 0)
This gem has been tested on Ruby 1.9.3 on version 1.1 of ShipStation's API.(by author)
This gem has been tested on Ruby ruby-2.0.0-p247 on version 1.2 and 1.3 of ShipStation's API.(By Rique Li)
I am Rique Li, I fork this from shipstation-ruby and make some changes, when all test done, I will make a PR.
If You like this gem, write me. ^_^