npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-jamesjames

v1.1.0

Published

This is a Node.js warpper that will allow you to hook to the James & James Warehouse API Endpoints. This warpper is bases on API Version 1.13 Specs

Downloads

4

Readme

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", //Required  Type:string(32) - Must be Unique
   "po_number": "CustomerPONumber1", //Type:string(32)
   "date_placed": "2013-12-31 23:59:59", //Type:String ISO 8601 date, GMT (+0:00) Default: NOW 
   "postage_speed": 0, // Type:interger Values:[ 0, 1, 2, 3] Default: 2
   "allow_saturday": 0, // Type:bool Default:false
   "signed_for": 0, // Type:bool Default:false
   "no_signature": 0, // Type:bool Default:false
   "tracked": 0, // Type:bool Default:false
   "postage_cost": 3.95, // Type:float
   "total_value": 52.3, // Type:float Default: Sum of line items
   "currency_code": "GBP", //Type:string(3) Default: [inherits channel or account default] Valid: alpha-3 ISO 4217 currency code	
   "tissue_wrap": 0, // Type:bool Default:false
   "days_before_bbe": 0, //Type:integer Default:[account default], else 0
   "hold": 0, // Type:bool Default:false
   "callback_url": "http://yourwebshop.com/callback.script?hash=A1b2C3D4", //Type:string(200) - Must be valid url
   "warehouse_id": 1, //Type:integer Default: null

   "ShippingContact": {
       "name": "David Test", //Required  Type:string(64)
       "company": "Demo Ltd", //Type:string(64)
       "email": "[email protected]", //Required  Type:string(32) - Must be a vaild email
       "phone": "01234 567 890	", //  Type:string(32)
       "address": "1 Road Street", //Required  Type:string(32)
       "address_contd": "off Avenue Lane", //Required  Type:string(32)
       "city": "Teston", //Required  Type:string(32)
       "county": "Exampleshire", //Required  Type:string(32)
       "postcode": "EG1 2EG", //Required  Type:string(16)
       "country": "United Kingdom" //Required  Type:string(32)
   },

   "BillingContact": {
       "name": "Vera Test", //Required  Type:string(64)
       "company": "", //Type:string(64)
       "email": "[email protected]", //Required  Type:string(32) - Must be a vaild email
       "phone": "01234 567 890	", //  Type:string(32)
       "address": "1 Road Street", //Required  Type:string(32)
       "address_contd": "off Avenue Lane", //Required  Type:string(32)
       "city": "Teston", //Required  Type:string(32)
       "county": "Exampleshire", //Required  Type:string(32)
       "postcode": "EG1 2EG", //Required  Type:string(16)
       "country": "United Kingdom" //Required  Type:string(32)
   },
   "items": [{
           "client_ref": "ABC-0001", //Required  Type:string(32)
           "quantity": 3, //Required Type:integer
           "price": 10.99, //Required Type:Float
           "days_before_bbe": 90 // Type:integer Default: order[days_before_bbe]
       },
       {
           "client_ref": "ABC-0002", //Required  Type:string(32)
           "quantity": 1, //Required Type:integer
           "price": 4.5 //Required Type:Float
       }
   ]

};

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, //0 = false or 1 = true 
                "order_ref": "1234-5678",
                "error": ["An order with reference 1234-5678 has already been received on this channel."],
                "valid":  0,  //0 = false or 1 = true
                "test": 1  //0 = false or 1 = true 
            };


var successResult = {
                "success": 1, //0 = false or 1 = true 
                "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, //0 = false or 1 = true  (only if update stock in request true)
                "last_order_placed" : "2010-12-30 23:59:59", // (only if update stock in request true)
                "stock_changes" : [{"prod1": 200}, {"prod2": 400}], // (only if update stock in request true)
                "valid": 1, //0 = false or 1 = true 
                "test": 1  //0 = false or 1 = true 
            };

####warehouse.validate.order( order );

######Arguments order: Accepts {orderObject} and is required Expected orderObject to be in this form:

var order = {
   "client_ref": "Order1234", //Required  Type:string(32) - Must be Unique
   "po_number": "CustomerPONumber1", //Type:string(32)
   "date_placed": "2013-12-31 23:59:59", //Type:String ISO 8601 date, GMT (+0:00) Default: NOW 
   "postage_speed": 0, // Type:interger Values:[ 0, 1, 2, 3] Default: 2
   "allow_saturday": 0, // Type:bool Default:false
   "signed_for": 0, // Type:bool Default:false
   "no_signature": 0, // Type:bool Default:false
   "tracked": 0, // Type:bool Default:false
   "postage_cost": 3.95, // Type:float
   "total_value": 52.3, // Type:float Default: Sum of line items
   "currency_code": "GBP", //Type:string(3) Default: [inherits channel or account default] Valid: alpha-3 ISO 4217 currency code	
   "tissue_wrap": 0, // Type:bool Default:false
   "days_before_bbe": 0, //Type:integer Default:[account default], else 0
   "hold": 0, // Type:bool Default:false
   "callback_url": "http://yourwebshop.com/callback.script?hash=A1b2C3D4", //Type:string(200) - Must be valid url
   "warehouse_id": 1, //Type:integer Default: null

   "ShippingContact": {
       "name": "David Test", //Required  Type:string(64)
       "company": "Demo Ltd", //Type:string(64)
       "email": "[email protected]", //Required  Type:string(32) - Must be a vaild email
       "phone": "01234 567 890	", //  Type:string(32)
       "address": "1 Road Street", //Required  Type:string(32)
       "address_contd": "off Avenue Lane", //Required  Type:string(32)
       "city": "Teston", //Required  Type:string(32)
       "county": "Exampleshire", //Required  Type:string(32)
       "postcode": "EG1 2EG", //Required  Type:string(16)
       "country": "United Kingdom" //Required  Type:string(32)
   },

   "BillingContact": {
       "name": "Vera Test", //Required  Type:string(64)
       "company": "", //Type:string(64)
       "email": "[email protected]", //Required  Type:string(32) - Must be a vaild email
       "phone": "01234 567 890	", //  Type:string(32)
       "address": "1 Road Street", //Required  Type:string(32)
       "address_contd": "off Avenue Lane", //Required  Type:string(32)
       "city": "Teston", //Required  Type:string(32)
       "county": "Exampleshire", //Required  Type:string(32)
       "postcode": "EG1 2EG", //Required  Type:string(16)
       "country": "United Kingdom" //Required  Type:string(32)
   },
   "items": [{
           "client_ref": "ABC-0001", //Required  Type:string(32)
           "quantity": 3, //Required Type:integer
           "price": 10.99, //Required Type:Float
           "days_before_bbe": 90 // Type:integer Default: order[days_before_bbe]
       },
       {
           "client_ref": "ABC-0002", //Required  Type:string(32)
           "quantity": 1, //Required Type:integer
           "price": 4.5 //Required Type:Float
       }
   ]

};

This is strictly a pre-validation utility function to help you detect issues with your order object.

######Returns

Either the String 'SUCCESS' or an Array of issues with the object you provided.

Notes

Tests will fail unless you update config file in test folder and replace with valid apikey and client ref your products