node-jamesjames
Advanced tools
Comparing version 1.0.11 to 1.1.0
@@ -30,5 +30,2 @@ /** | ||
// Cache for Client | ||
var initedClient; | ||
// Expose methods | ||
@@ -64,12 +61,7 @@ return { | ||
}, | ||
validate : { | ||
order: validateOrder | ||
} | ||
}; | ||
@@ -79,9 +71,8 @@ | ||
/* Auxiliary functions */ | ||
function debugLog(title, msg) { | ||
var msg = util.inspect(msg, {depth: null}); | ||
var message = util.inspect(msg, {depth: null}); | ||
if (settings.debugLogs) { | ||
console.log('\n Warehouse Connector DEBUG log' + '\n · ' + title + ':\n\n ', msg, '\n'); | ||
console.log('\n Warehouse Connector DEBUG log' + '\n · ' + title + ':\n\n ', message, '\n'); | ||
} | ||
@@ -91,3 +82,2 @@ } | ||
/* Request */ | ||
@@ -132,6 +122,2 @@ | ||
} | ||
@@ -141,3 +127,2 @@ | ||
/* Validation Methods */ | ||
@@ -220,3 +205,3 @@ | ||
}, | ||
"required": ['client_ref', 'ShippingContact', 'BillingContact', 'items'] | ||
"required": ['client_ref', 'BillingContact', 'ShippingContact', 'items'] | ||
}; | ||
@@ -223,0 +208,0 @@ |
{ | ||
"name": "node-jamesjames", | ||
"version": "1.0.11", | ||
"version": "1.1.0", | ||
"description": "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", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -143,6 +143,87 @@ Node-JamesJames | ||
``` | ||
####warehouse.validate.order( order ); | ||
######**Arguments** | ||
**order**: | ||
Accepts {orderObject} and is **required** | ||
Expected orderObject to be in this form: | ||
```javascript | ||
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": "david@demo.co.uk", //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": "vera@home.com", //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 | ||
} | ||
] | ||
Note: Tests will fail unless you replace with valid apikey and client ref for products | ||
}; | ||
``` | ||
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 |
/** | ||
* Created by yoni on 2/24/17. | ||
*/ | ||
var testConfig = require('./config'); | ||
var should = require('should'); | ||
var YOUR_API_KEY = testConfig.API_KEY || "3cac28674ca5c525af980b3cd92e9245"; | ||
var YOUR_CLIENT_REF_PRODUCT_1 = testConfig.PRODUCT_1 || "ABC-0001"; | ||
var YOUR_CLIENT_REF_PRODUCT_2 = testConfig.PRODUCT_2 || "ABC-0002"; | ||
var warehouse = require('../lib/warehouse').settings({ | ||
url: 'https://api.controlport.co.uk/api/1/', | ||
credentials: { | ||
api_key: '3cac28674ca5c525af980b3cd92e9245' /* use your own api key this is a dummy and will fail the test */ | ||
api_key: YOUR_API_KEY /* use your own api key this is a dummy and will fail the test */ | ||
}, | ||
@@ -21,3 +28,3 @@ allow_preorder: false, | ||
"date_placed": "2017-04-11T23:04:57+00:00", | ||
"postage_speed": 0, | ||
"postage_speed": 3, | ||
"allow_saturday": false, | ||
@@ -62,3 +69,3 @@ "signed_for": false, | ||
"items": [{ | ||
"client_ref": "ABC-0001", /* use your own client ref this is a dummy and will fail the test */ | ||
"client_ref": YOUR_CLIENT_REF_PRODUCT_1, /* use your own client ref this is a dummy and will fail the test */ | ||
"quantity": 3, | ||
@@ -68,3 +75,3 @@ "price": 10.99, | ||
}, { | ||
"client_ref": "ABC-0002", | ||
"client_ref": YOUR_CLIENT_REF_PRODUCT_2, | ||
"quantity": 1, | ||
@@ -83,2 +90,3 @@ "price": 4.5 | ||
warehouse.createOrder(sampleOrder, function (err, results) { | ||
console.log(err, results); | ||
if (err) return done(err); | ||
@@ -85,0 +93,0 @@ else { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
21820
7
262
228