Project

torque_api

0.0
The project is in a healthy, maintained state
A Ruby wrapper for the Torque Warehouse Management System API, supporting Pre Advice creation and Return RMA polling.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

~> 3.0
~> 3.0

Runtime

 Project Readme

TorqueAPI

Ruby client for the Torque WMS (Warehouse Management System) API.

Installation

Add to your Gemfile:

gem "torque_api", git: "https://github.com/PostCo/torque_api", branch: "main"

Usage

Initialize a client

client = TorqueAPI::Client.new(
  api_key: "your_api_key",
  client_defaults: {
    "CLIENT_ID" => "AM",
    "CLIENT_GROUP" => "AMVIS",
    "SITE_ID" => "WO6",
    "CONFIG_ID" => "P1",
    "OWNER_ID" => "TORQUE",
    "PALLET_CONFIG" => "MD"
  },
  sandbox: true  # Use test environment
)

Create a Pre Advice

payload = [
  {
    "Record_Type" => "PAH",
    "Pre_Advice_Id" => "12345",
    "Status" => "Released",
    "PreAdviceLines" => [
      {
        "Record_Type" => "PAL",
        "Pre_Advice_Id" => "12345",
        "Sku_Id" => "SKU-001",
        "Qty_Due" => 1,
        "Line_Id" => 1
      }
    ]
  }
]

response = client.pre_advice.create(payload)

Poll Return RMA items

items = client.return_rma.list
# Returns an array of TorqueAPI::Objects::ReturnRma

items.each do |item|
  puts item.orderid          # snake_case accessors
  puts item.sku_id
  puts item.sampling_type
  puts item.raw              # Access original (frozen) response data
end

Error handling

begin
  client.pre_advice.create(payload)
rescue TorqueAPI::AuthenticationError => e
  # 401/403 responses
  puts e.message
  puts e.status_code
  puts e.response  # Full Faraday response
rescue TorqueAPI::ValidationError => e
  # 400 responses
rescue TorqueAPI::NotFoundError => e
  # 404 responses
rescue TorqueAPI::ServerError => e
  # 500-599 responses
rescue TorqueAPI::APIError => e
  # All other error responses
end

Sandbox mode

Toggle between test and live Torque environments:

# Test: https://wms-api.torque.eu/torqueapitest/api/v1
client = TorqueAPI::Client.new(api_key: key, sandbox: true)

# Live: https://wms-api.torque.eu/torqueapi/api/v1
client = TorqueAPI::Client.new(api_key: key, sandbox: false)

Development

bundle install
bundle exec rspec        # Run tests
bundle exec standardrb   # Run linter

License

MIT License. See LICENSE.txt.