Shipwire API client
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
tests
.gitignore
.travis.yml
LICENSE
Makefile
README.md
Setup.hs
ballast.cabal
ballast.jpg
stack.yaml

README.md

Ballast TravisCI

Ship cross-section showing ballast Image courtesy University of Edinburgh

A Haskell wrapper for the Shipwire API

Example Usage

You should set up two ENV variables: SHIPWIRE_USER and SHIPWIRE_PASS that represent your Shipwire account's email and password.

Get all receivings with expand=all query parameter:

import Ballast.Client
import Ballast.Types (sandboxEnvConfig, (-&-), ExpandProductsParam(..), ExpandProducts(..))

main :: IO ()
main = do
  config <- sandboxEnvConfig
  result <- shipwire config $ getReceivings -&- (ExpandReceivingsParam [ExpandAll])
  print result

Create a new order:

{-# LANGUAGE OverloadedStrings #-}

import Ballast.Client
import Ballast.Types

myOrder :: CreateOrder
myOrder =
  CreateOrder
    Nothing
    (Just $ OrderNo "testorder")
    Nothing
    Nothing
    (Just $
     CreateOrderOptions
       (Just $ WarehouseId 10281)
       Nothing
       Nothing
       Nothing
       DomesticOneDay
       Nothing
       NotSameDay
       (Just DontForceDuplicate)
       (Just DontForceAddress)
       Nothing
       Nothing
       Nothing
       USD
       Nothing
       Nothing
       Nothing
       Nothing
       Nothing
       Nothing)
    Nothing
    (OrderShipTo
       (Just $ Email "test@example.com")
       (Name "Test Person")
       (Just $ Company "Best Company")
       (AddressLine "First line")
       (Just $ AddressLine "Second line 25")
       (Just $ AddressLine "")
       (City "Best city")
       (State "WA")
       (Just $ PostalCode "100100")
       (Country "US")
       (Phone "1234567891")
       NotCommercial
       (Just NotPoBox))
    Nothing
    Nothing
    (OrderItems
       [ OrderItem
           (Just $ CommercialInvoiceValue 4.5)
           (Just $ CommercialInvoiceValueCurrency "USD")
           (Quantity 5)
           (SKU "mySKU")
       ])

main :: IO ()
main = do
  config <- sandboxEnvConfig
  result <- shipwire config $ createOrder myOrder
  print result

Testing

The TravisCI tests are run using Stack. You should use Stack instead of cabal to build and test Ballast to avoid compatibility problems.

Steps to run the tests locally:

  1. Create a sandbox Shipwire account.
  2. Go to Warehouse overview and add a warehouse named Test Warehouse.
  3. Accept the accurate dimensions agreement by creating a dummy product.
  4. Install Stack.
  5. In your local Ballast directory, run stack setup && stack build.
  6. Run stack test in your local Ballast directory.

What's implemented so far

The core functionality is complete. What's left is to add request and return types for the remaining endpoints.

  • Order

    • GET /api/v3/orders

    • GET /api/v3/orders/{id} or /api/v3/orders/E{externalId}

    • POST /api/v3/orders

    • PUT /api/v3/orders/{id} or /api/v3/orders/E{externalId}

    • POST /api/v3/orders/{id}/cancel or /api/v3/orders/E{externalId}/cancel

    • GET /api/v3/orders/{id}/items or /api/v3/orders/E{externalId}/items

    • GET /api/v3/orders/{id}/holds or /api/v3/orders/E{externalId}/holds

    • GET /api/v3/orders/{id}/trackings or /api/v3/orders/E{externalId}/trackings

    • GET /api/v3/orders/{id}/splitOrders or /api/v3/orders/E{externalId}/splitOrders

    • GET /api/v3/orders/{id}/pieces or /api/v3/orders/E{externalId}/pieces

    • GET /api/v3/orders/{id}/extendedAttributes or /api/v3/orders/E{externalId}/extendedAttributes

    • GET /api/v3/orders/{id}/returns or /api/v3/orders/E{externalId}/returns

    • POST /api/v3/orders/{id}/holds/clear or /api/v3/orders/E{externalId}/holds/clear

    • POST /api/v3/orders/{id}/markProcessed or /api/v3/orders/E{externalId}/markProcessed

    • POST /api/v3/orders/{id}/markSubmitted or /api/v3/orders/E{externalId}/markSubmitted

    • POST /api/v3/orders/{id}/markComplete or /api/v3/orders/E{externalId}/markComplete

  • Purchase Order

    • GET /api/v3/purchaseOrders

    • GET /api/v3/purchaseOrders/{id} or /api/v3/purchaseOrders/E{externalId}

    • POST /api/v3/purchaseOrders

    • PUT /api/v3/purchaseOrders/{id} or /api/v3/purchaseOrders/E{externalId}

    • POST /api/v3/purchaseOrders/{id}/cancel or /api/v3/purchaseOrders/E{externalId}/cancel

    • POST /api/v3/purchaseOrders/{id}/hold or /api/v3/purchaseOrders/E{externalId}/hold

    • POST /api/v3/purchaseOrders/{id}/hold/clear or /api/v3/purchaseOrders/E{externalId}/hold/clear

    • GET /api/v3/purchaseOrders/{id}/items or /api/v3/purchaseOrders/E{externalId}/items

    • GET /api/v3/purchaseOrders/{id}/trackings or /api/v3/purchaseOrders/E{externalId}/trackings

    • POST /api/v3/purchaseOrders/{id}/approve or /api/v3/purchaseOrders/E{externalId}/approve

  • Container (API v3.1)

    • GET /api/v3.1/containers?isActive={isActive}&type={type}&warehouseIds={warehouseIds}&warehouseExternalIds={warehouseExternalIds}

    • POST /api/v3.1/containers

    • PUT /api/v3.1/containers/{id}

    • GET /api/v3.1/containers/{id}

  • Address Validation (API v3.1)

    • POST /api/v3.1/addressValidation
  • Stock

    • GET /api/v3/stock

    • POST /api/v3/stock/adjust

  • Rate

    • POST /api/v3/rate

    • POST /api/v3.1/rate

  • Receiving

    • GET /api/v3/receivings

    • POST /api/v3/receivings

    • GET /api/v3/receivings/{id}

    • PUT /api/v3/receivings/{id}

    • POST /api/v3/receivings/{id}/cancel

    • POST /api/v3/receivings/{id}/labels/cancel

    • GET /api/v3/receivings/{id}/holds

    • GET /api/v3/receivings/{id}/instructionsRecipients

    • GET /api/v3/receivings/{id}/items

    • GET /api/v3/receivings/{id}/shipments

    • GET /api/v3/receivings/{id}/trackings

    • GET /api/v3/receivings/{id}/labels

  • Return

    • GET /api/v3/returns

    • POST /api/v3/returns

    • GET /api/v3/returns/{id}

    • POST /api/v3/returns/{id}/cancel

    • GET /api/v3/returns/{id}/holds

    • GET /api/v3/returns/{id}/items

    • GET /api/v3/returns/{id}/trackings

    • GET /api/v3/returns/{id}/labels

  • Product

    • GET /api/v3/products

    • POST /api/v3/products

    • PUT /api/v3/products

    • PUT /api/v3/products/{id}

    • GET /api/v3/products/{id}

    • POST /api/v3/products/retire

  • Vendor (API v3.1)

    • GET /api/v3.1/vendors?id={id}&externalId={externalId}&name={name}&status={status}

    • POST /api/v3.1/vendors

    • PUT /api/v3.1/vendors/{id}

    • GET /api/v3.1/vendors/{id}

    • POST /api/v3.1/vendors/{id}/retire

    • GET /api/v3.1/vendors/{id}/extendedAttributes

  • Webhook

    • GET /api/v3/webhooks

    • POST /api/v3/webhooks

    • GET /api/v3/webhooks/{id}

    • PUT /api/v3/webhooks/{id}

    • DELETE /api/v3/webhooks/{id}

    • GET /api/v3/secret

    • POST /api/v3/secret

    • GET /api/v3/secret/{id}

    • DELETE /api/v3/secret/{id}