Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update on catalog category and product mandatory and optional fields #31

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
14 changes: 11 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
{
"name": "magento",
"author": "Tim Marshall <timothyjmarshall@gmail.com>",
"author": "Ernest Conill <ernestconill@gmail.com>",
"description": "Magento SOAP API wrapper for Node.js",
"version": "0.0.5",
"version": "0.0.7",
"main": "./src/magento",
"contributors": [
{
"name": "Ernest Conill",
"email": "[email protected]"
},
{
"name": "Stephen Keep",
"email": "[email protected]"
},
{
"name": "Tim Marshall",
"email": "[email protected]"
Expand All @@ -23,6 +31,6 @@
"api",
"xml"
],
"repository": "git://github.com/MadisonReed/magentoapi",
"repository": "git://github.com/netusco/magentoapi",
"license": "MIT"
}
12 changes: 10 additions & 2 deletions src/magento.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ var resources = {
customerGroup: './resources/customer_group.js',
directoryCountry: './resources/directory_country.js',
directoryRegion: './resources/directory_region.js',
ourlaborisjoyTools: './resources/ourlaborisjoy_tools.js',
salesOrder: './resources/sales_order.js',
salesOrderCreditMemo: './resources/sales_order_credit_memo.js',
salesOrderInvoice: './resources/sales_order_invoice.js',
Expand All @@ -48,7 +49,8 @@ var configDefaults = {
path: mandatory,
login: mandatory,
pass: mandatory,
parallelLimit: Infinity
parallelLimit: Infinity,
secure: false
};

/**
Expand Down Expand Up @@ -77,7 +79,13 @@ function Magento(config) {
}

this.config = magentoConfig;
this.client = xmlrpc.createClient(this.config);

if (this.config.secure === true) {
this.client = xmlrpc.createSecureClient(this.config);
} else {
this.client = xmlrpc.createClient(this.config);
}

this.queue = [];
this.queue.running = 0;
this.queue.parallelLimit = this.config.parallelLimit;
Expand Down
2 changes: 1 addition & 1 deletion src/resources/catalog_category.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var protos = {
Create a new category and return its ID.
*/
create: {
mandatory: 'categoryId,data',
mandatory: 'parentId,categoryData',
optional: 'storeView'
},

Expand Down
23 changes: 13 additions & 10 deletions src/resources/catalog_product.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,43 +21,46 @@ var protos = {
Allows you to create a new product and return ID of the created product.
*/
create: {
mandatory: 'type,set,sku,data'
mandatory: 'type,set,sku,productData',
optional: 'storeView'
},

/**
Allows you to set/get the current store view.
*/
currentStore: {
optional: 'view'
optional: 'storeView'
},

/**
Allows you to delete the required product.
*/
'delete': {
mandatory: 'id'
mandatory: 'product',
optional: 'identifierType'
},

/**
Allows you to get the product special price data.
*/
getSpecialPrice: {
mandatory: 'id'
mandatory: 'product',
optional: 'storeView'
},

/**
Allows you to retrieve information about the required product.
*/
info: {
mandatory: 'id',
optional: 'storeView'
mandatory: 'productId',
optional: 'storeView,attributes'
},

/**
Allows you to retrieve the list of products.
*/
list: {
optional: 'filters'
optional: 'filters,storeView'
},

/**
Expand All @@ -71,7 +74,7 @@ var protos = {
Allows you to set the product special price.
*/
setSpecialPrice: {
mandatory: 'id,specialPrice,from,to',
mandatory: 'productId,specialPrice,fromDate,toDate',
optional: 'storeView',
modifiers: {
from: dateToISO8601Time,
Expand All @@ -83,8 +86,8 @@ var protos = {
Allows you to update the required product. Note that you should specify only those parameters which you want to be updated.
*/
update: {
mandatory: 'id,data',
optional: 'storeView'
mandatory: 'product,productData',
optional: 'storeView,identifierType'
}
};

Expand Down
44 changes: 44 additions & 0 deletions src/resources/ourlaborisjoy_tools.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// external dependencies
var events = require('events');
var util = require('util');

// internal dependencies
var prototypeBase = require('../prototype_base.js');
var curry = require('../curry.js');

/**
Allows you to manage products.
*/
function OurlaborisjoyTools() {
this.prefix = 'ourlaborisjoy_tools.';
}
util.inherits(OurlaborisjoyTools, events.EventEmitter);


// prototypes we will be applying
var protos = {
/**
Allows you to link simple products with a configurable product,
set the configurable attributes and prices.
*/
configurable_create_for_reals: {
mandatory: 'productId,attributes,variants',
optional: 'identifierType'
},

/**
* Allows you to add product attributes that cannot be added through normal api calls
*/
add_msrp_attribute: {
mandatory: 'product,msrp',
optional: 'identifierType,storeView'
}
};

// creating prototypes using curry func
for (var key in protos) {
OurlaborisjoyTools.prototype[key] = curry(prototypeBase, key, protos[key]);
}
protos = undefined;

module.exports = OurlaborisjoyTools;