Comparing version 0.2.4 to 0.2.5
@@ -124,2 +124,3 @@ var _ = require('lodash'); | ||
var customerGetMethodName; | ||
var mergeMethodName; | ||
var sendMethodName; | ||
@@ -140,2 +141,12 @@ | ||
options.lookup = options.lookup || 'externalId'; | ||
options.fieldMap = options.fieldMap || {}; | ||
_.merge(options.fieldMap, { | ||
// default field mappings | ||
particle: 'prefix', | ||
email: 'emailAddress' | ||
}); | ||
// create a new object with altered keys based on fieldMap | ||
customer = _.mapKeys(customer, function(value, key) { | ||
return options.fieldMap[key] || key; | ||
}); | ||
@@ -216,18 +227,8 @@ var customerArgs = {}; | ||
customer.id = record.id; | ||
me.request('customer_update', {customer: customer}, function(err, result) { | ||
if (err) { | ||
return callback(err); | ||
} | ||
if (!result || !result.length) { | ||
return callback(new Error('No customer returned after update')); | ||
} | ||
if (result.length > 1) { | ||
return callback(new Error('Multiple customers returned after update')); | ||
} | ||
callback(null, result[0]); | ||
}); | ||
return; | ||
mergeMethodName = 'customer_update'; | ||
} else { | ||
mergeMethodName = 'customer_insert'; | ||
} | ||
me.request('customer_insert', {customer: customer}, function(err, result) { | ||
me.request(mergeMethodName, {customer: customer}, function(err, result) { | ||
if (err) { | ||
@@ -237,6 +238,6 @@ return callback(err); | ||
if (!result || !result.length) { | ||
return callback(new Error('No customer returned after create')); | ||
return callback(new Error('No customer returned after ' + mergeMethodName)); | ||
} | ||
if (result.length > 1) { | ||
return callback(new Error('Multiple customers returned after create')); | ||
return callback(new Error('Multiple customers returned after ' + mergeMethodName)); | ||
} | ||
@@ -243,0 +244,0 @@ callback(null, result[0]); |
{ | ||
"name": "clang", | ||
"version": "0.2.4", | ||
"version": "0.2.5", | ||
"description": "Node.js api wrapper for Clang's SOAP api", | ||
@@ -5,0 +5,0 @@ "author": "Christiaan Westerbeek <chris@devotis.nl>", |
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
6811
235479