Node-JamesJames
Sixworks/Controlport Rest API Wrapper
This is a Node.js Module will allow you to hook into James & James's Fulfillment API Endpoint this is based on order api specs V 1.13
Setup
There two way for setting up the warehouse connector:
var warehouse = require('<...>/warehouse')
warehouse.settings({ ... });
var warehouse = require('<...>/warehouse').settings({ ... });
The settings object could contain these properties:
{
url: 'https://api.controlport.co.uk/api/1/',
credentials: {
api_key: 'xxxxxxxxxxxx'
},
allow_preorder : false,
update_stock : false,
test : false,
debugLogs: false // Only use it during development or testing
}
Methods
####warehouse.createOrder( order, callback );
######Arguments
order:
Accepts {orderObject} and is required
Expected orderObject to be in this form:
var order = {
"client_ref": "Order1234",
"po_number": "CustomerPONumber1",
"date_placed": "2013-12-31 23:59:59",
"postage_speed": 0,
"allow_saturday": 0,
"signed_for": 0,
"no_signature": 0,
"tracked": 0,
"postage_cost": 3.95,
"total_value": 52.3,
"currency_code": "GBP",
"tissue_wrap": 0,
"days_before_bbe": 0,
"hold": 0,
"callback_url": "http://yourwebshop.com/callback.script?hash=A1b2C3D4",
"warehouse_id": 1,
"ShippingContact": {
"name": "David Test",
"company": "Demo Ltd",
"email": "david@demo.co.uk",
"phone": "01234 567 890 ",
"address": "1 Road Street",
"address_contd": "off Avenue Lane",
"city": "Teston",
"county": "Exampleshire",
"postcode": "EG1 2EG",
"country": "United Kingdom"
},
"BillingContact": {
"name": "Vera Test",
"company": "",
"email": "vera@home.com",
"phone": "01234 567 890 ",
"address": "1 Road Street",
"address_contd": "off Avenue Lane",
"city": "Teston",
"county": "Exampleshire",
"postcode": "EG1 2EG",
"country": "United Kingdom"
},
"items": [{
"client_ref": "ABC-0001",
"quantity": 3,
"price": 10.99,
"days_before_bbe": 90
},
{
"client_ref": "ABC-0002",
"quantity": 1,
"price": 4.5
}
]
};
callback ( err, result ):
Accepts only function and is required
Arguments passed:
-
Error Object or null --> Note: Albeit the error object contains validation error info, it is not normalized therefore is not suitable to client side validation, suggested a client side validation
-
Result Object ( an object representing the raw response from the service intended)
Example Response Object:
var failResult = {
"success": 0,
"order_ref": "1234-5678",
"error": ["An order with reference 1234-5678 has already been received on this channel."],
"valid": 0,
"test": 1
};
var successResult = {
"success": 1,
"order_ref": "1234-5678",
"error": [],
"client_area_link" : "https://client.controlport.co.uk/orders/12345678",
"warehouse_tracking_link" : "http://www.ecommercefulfilment.com/track/123456789/abcdef",
"update_stock" : 0,
"last_order_placed" : "2010-12-30 23:59:59",
"stock_changes" : [{"prod1": 200}, {"prod2": 400}],
"valid": 1,
"test": 1
};
Note: Tests will fail unless you replace with valid apikey and client ref for products