Ruby wrapper for Seko Logistics' SupplyStream iHub REST API v1
SupplyStream REST API Documentation
- Inbound Product Master Upload and method
- Inbound Companies Upload and method
- Inbound Advanced Shipment Notification
- Inbound Sales Order / Cancel Orders
- Retrieve GRN’s
- Retrieve Stock Quantity
- Retrieve Tracking Details
- Retrieve Sales Order Status
- Retrieve Stock Adjustments
- Retrieve Stock Movements
Add this line to your application's Gemfile:
gem 'seko'
And then execute:
$ bundle
Or install it yourself as:
$ gem install seko
config/initializers/seko.rb
Seko.configure(
token: 'SekoAPIToKeN'
supplier_code: 'DEFSUPTCLTD001',
supplier_description: 'Default Supplier TEST COMPANY LTD',
supplier_uom: 1,
warehouses: {
us: 'US123',
uk: 'UK123'
}
)
In order to communicate with Seko(SupplyStream) you need to instantiate an instance of the Seko::Client
class using the token configured in the configuration step above.
client = Seko::Client.new(Seko.config[:token])
In order to use the live endpoint and corresponding live account with Seko you should pass it in as an argument to the client since the default is test mode.
client = Seko::Client.new(Seko.config[:token], { test_mode: false })
client = Seko::Client.new(Seko.config[:token])
response = client.submit_product(upc: "123456", description: 'A test product')
This will post product information to Supply Stream. However, your account representative will need to apply stock levels.
line_items = [ { upc: "123456", quantity: 10 } ]
warehouse = Seko.config[:warehouses][:us]
client = Seko::Client.new(Seko.config[:token])
response = client.send_return_request(line_item_array, warehouse)
Once a return return request is submited, also know as an Advanced Shipment Notice(ASN), the warehouse will either send a push notification with a Goods Received Notice(GRN) or you can check the GRN status below by using the GUID generated by this request.
company_hash = {
code: 'IND001',
description: 'Indigina'
}
client = Seko::Client.new(Seko.config[:token])
response = client.submit_company(company_hash)
Useful for submitting companies to place wholesale orders.
client = Seko::Client.new(Seko.config[:token])
response = client.get_inventory
Getting inventory will return inventory for all Warehouses configured. Pass in the warehouse identifier to filter the results by warehouse.
client = Seko::Client.new(Seko.config[:token])
response = client.check_grn('5b2dcd8e-52c3-4e27-a712-eaacda2dd8fe')
Check the status of a Return Request(ASN) submitted.
client = Seko::Client.new(Seko.config[:token])
response = client.order_status('5b2dcd8e-52c3-4e27-a712-eaacda2dd8fe')
Check the status of an order.
client = Seko::Client.new(Seko.config[:token])
response = client.order_tracking('5b2dcd8e-52c3-4e27-a712-eaacda2dd8fe')
Get the tracking information for a given order.
Seko::Order::CANCEL_CODES
# => {
# "001" => "Customer Request",
# "002" => "Order Delayed",
# "003" => "Duplicate",
# "004" => "Item not available",
# "005" => "Cannot ship to address",
# "006" => "Other"
# }
client = Seko::Client.new(Seko.config[:token])
response = client.cancel_order('5b2dcd8e-52c3-4e27-a712-eaacda2dd8fe', '001')
Cancels a placed order, only works if the order isn't already shipped.
client = Seko::Client.new(Seko.config[:token])
warehouse = Seko.config[:warehouses][:us]
from = 3.days.ago
to = Time.now
response = client.stock_movements(from, to, warehouse)
client = Seko::Client.new(Seko.config[:token])
warehouse = Seko.config[:warehouses][:us]
from = 3.days.ago
to = Time.now
response = client.stock_adjustments(from, to, warehouse)
client = Seko::Client.new(Seko.config[:token])
warehouse = Seko.config[:warehouses][:us] # warehouse is optional
from = 3.days.ago
to = Time.now
response = client.dispatch_statuses(from, to, warehouse)
# get collection of GUIDs dispatched
guid_array = Seko::Dispatch.parse(response)
# returns something like this
# => ["2b5e52cc-fb6f-4ea4-b8cf-cf64e3a2b8db", "93e92ca2-725a-46f8-90dd-43a16105f78d"]
order = {
shipping_address: {
first_name: "John",
last_name: "Smith",
address1: "123 Here Now",
address2: "2nd Floor",
city: "New York",
state: "New York",
country: "US",
zipcode: "10012",
phone: "123-123-1234"
},
email: "[email protected]",
number: "R123123123",
warehouse: "DC123",
date: "2013-12-12",
shipping_carrier: "DLP",
shipping_method: "22",
line_items: [
{
quantity: "1",
sku: "123332211"
}
]
}
client = Seko::Client.new(Seko.config[:token])
response = client.send_order_request(order)
### NOTE you may want to store the GUID from the response
### you need the guid for status updates, tracking, and canceling orders
response.guid
if response.success?
# DO SOMETHING
else
# QUEUE REQUEST, STORE AND RAISE ERRORS
end
- Fork it ( https://github.com/[my-github-username]/seko/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request