├── .gitignore ├── README.md ├── package.json ├── readmes ├── catalogInventory_stock_item.md ├── catalog_category.md ├── catalog_category_attribute.md ├── catalog_product.md ├── catalog_product_attribute.md ├── catalog_product_attribute_media.md ├── catalog_product_attribute_set.md ├── catalog_product_custom_option.md ├── catalog_product_custom_option_value.md ├── catalog_product_downloadable_link.md ├── catalog_product_link.md ├── catalog_product_tag.md ├── catalog_product_tier_price.md ├── catalog_product_type.md ├── checkout_cart.md ├── checkout_cart_coupon.md ├── checkout_cart_customer.md ├── checkout_cart_payment.md ├── checkout_cart_product.md ├── checkout_cart_shipping.md ├── core.md ├── customer.md ├── customer_address.md ├── customer_group.md ├── directory_country.md ├── directory_region.md ├── sales_order.md ├── sales_order_credit_memo.md ├── sales_order_invoice.md ├── sales_order_shipment.md └── store.md └── src ├── curry.js ├── error.js ├── magento.js ├── prototype_base.js ├── resources ├── catalogInventory_stock_item.js ├── catalog_category.js ├── catalog_category_attribute.js ├── catalog_product.js ├── catalog_product_attribute.js ├── catalog_product_attribute_media.js ├── catalog_product_attribute_set.js ├── catalog_product_custom_option.js ├── catalog_product_custom_option_value.js ├── catalog_product_downloadable_link.js ├── catalog_product_link.js ├── catalog_product_tag.js ├── catalog_product_tier_price.js ├── catalog_product_type.js ├── checkout_cart.js ├── checkout_cart_coupon.js ├── checkout_cart_customer.js ├── checkout_cart_payment.js ├── checkout_cart_product.js ├── checkout_cart_shipping.js ├── core.js ├── customer.js ├── customer_address.js ├── customer_group.js ├── directory_country.js ├── directory_region.js ├── sales_order.js ├── sales_order_credit_memo.js ├── sales_order_invoice.js ├── sales_order_shipment.js └── store.js └── test └── index.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | */node_modules/ 3 | .DS_Store 4 | */.DS_Store 5 | *.txt 6 | *.log -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Magento SOAP API Wrapper 2 | 3 | This wrapper lets you talk to Magento via SOAP. 4 | 5 | ## Installation 6 | 7 | `npm install magento` 8 | 9 | ## Usage 10 | 11 | ```js 12 | var MagentoAPI = require('magento'); 13 | var magento = new MagentoAPI({ 14 | host: 'your.host', 15 | port: 80, 16 | path: '/api/xmlrpc/', 17 | login: 'your_username', 18 | pass: 'your_pass' 19 | }); 20 | 21 | magento.login(function(err, sessId) { 22 | if (err) { 23 | // deal with error 24 | return; 25 | } 26 | 27 | // use magento 28 | }); 29 | ``` 30 | 31 | If need be, you can manually change the session id. 32 | 33 | ```js 34 | magento.changeSession(newSessionId); 35 | ``` 36 | 37 | All of the API methods take an object of params as the first argument, and a callback as the second. 38 | 39 | Or, if no params are sent, just a callback as the first argument. 40 | 41 | ## Methods 42 | 43 | + [Catalog Category](./readmes/catalog_category.md) 44 | + [Catalog Category Attribute](./readmes/catalog_category_attribute.md) 45 | + [Catalog Product](./readmes/catalog_product.md) 46 | + [Catalog Product Attribute](./readmes/catalog_product_attribute.md) 47 | + [Catalog Product Attribute Media](./readmes/catalog_product_attribute_media.md) 48 | + [Catalog Product Attribute Set](./readmes/catalog_product_attribute_set.md) 49 | + [Catalog Product Custom Option](./readmes/catalog_product_custom_option.md) 50 | + [Catalog Product Custom Option Value](./readmes/catalog_product_custom_option_value.md) 51 | + [Catalog Product Downloadable Link](./readmes/catalog_product_downloadable_link.md) 52 | + [Catalog Product Link](./readmes/catalog_product_link.md) 53 | + [Catalog Product Tag](./readmes/catalog_product_tag.md) 54 | + [Catalog Product Tier Price](./readmes/catalog_product_tier_price.md) 55 | + [Catalog Product Type](./readmes/catalog_product_type.md) 56 | + [Catalog Inventory Stock Item](./readmes/catalogInventory_stock_item.md) 57 | + [Checkout Cart](./readmes/checkout_cart.md) 58 | + [Checkout Cart Coupon](./readmes/checkout_cart_coupon.md) 59 | + [Checkout Cart Customer](./readmes/checkout_cart_customer.md) 60 | + [Checkout Cart Payment](./readmes/checkout_cart_payment.md) 61 | + [Checkout Cart Product](./readmes/checkout_cart_product.md) 62 | + [Checkout Cart Shipping](./readmes/checkout_cart_shipping.md) 63 | + [Core](./readmes/core.md) 64 | + [Customer](./readmes/customer.md) 65 | + [Customer Address](./readmes/customer_address.md) 66 | + [Customer Group](./readmes/customer_group.md) 67 | + [Directory Country](./readmes/directory_country.md) 68 | + [Directory Region](./readmes/directory_region.md) 69 | + [Sales Order](./readmes/sales_order.md) 70 | + [Sales Order Credit Memo](./readmes/sales_order_credit_memo.md) 71 | + [Sales Order Invoice](./readmes/sales_order_invoice.md) 72 | + [Sales Order Shipment](./readmes/sales_order_shipment.md) 73 | + [Store](./readmes/store.md) -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "magento", 3 | "author": "Tim Marshall ", 4 | "description": "Magento SOAP API wrapper for Node.js", 5 | "version": "0.0.5", 6 | "main": "./src/magento", 7 | "contributors": [ 8 | { 9 | "name": "Tim Marshall", 10 | "email": "timothyjmarshall@gmail.com" 11 | } 12 | ], 13 | "engines": { 14 | "node": ">=0.10.20" 15 | }, 16 | "dependencies" : { 17 | "request": "2.34.0", 18 | "xmlrpc": "1.2.0" 19 | }, 20 | "keywords": [ 21 | "magento", 22 | "soap", 23 | "api", 24 | "xml" 25 | ], 26 | "repository": "git://github.com/MadisonReed/magentoapi", 27 | "license": "MIT" 28 | } 29 | -------------------------------------------------------------------------------- /readmes/catalogInventory_stock_item.md: -------------------------------------------------------------------------------- 1 | # Catalog Inventory Stock Item 2 | 3 | ## [list](http://www.magentocommerce.com/api/soap/catalogInventory/cataloginventory_stock_item.list.html) 4 | 5 | Allows you to retrieve the list of stock data by product IDs. 6 | 7 | ```js 8 | magento.catalogInventoryStockItem.list({ 9 | products: [ val, val, val ] 10 | }, callback); 11 | 12 | // or a single product 13 | 14 | magento.catalogInventoryStockItem.list({ 15 | products: val 16 | }, callback); 17 | ``` 18 | 19 | ## [update](http://www.magentocommerce.com/api/soap/catalogInventory/cataloginventory_stock_item.update.html) 20 | 21 | Allows you to update the required product stock data. 22 | 23 | `data` is a catalogInventoryStockItemUpdateEntity object. 24 | 25 | ```js 26 | magento.catalogInventoryStockItem.update({ 27 | product: val, 28 | data: val 29 | }, callback); 30 | ``` -------------------------------------------------------------------------------- /readmes/catalog_category.md: -------------------------------------------------------------------------------- 1 | # Catalog Category 2 | 3 | ## [assignedProducts](http://www.magentocommerce.com/api/soap/catalog/catalogCategory/catalog_category.assignedProducts.html) 4 | 5 | Retrieve the list of products assigned to a required category. 6 | 7 | ```js 8 | magento.catalogCategory.assignedProducts({ 9 | categoryId: val 10 | }, callback); 11 | ``` 12 | 13 | ## [assignProduct](http://www.magentocommerce.com/api/soap/catalog/catalogCategory/catalog_category.assignProduct.html) 14 | 15 | Create a new category and return its ID. 16 | 17 | ```js 18 | magento.catalogCategory.assignProduct({ 19 | categoryId: val, 20 | product: val, 21 | position: val /* optional */ 22 | }, callback); 23 | ``` 24 | 25 | ## [create](http://www.magentocommerce.com/api/soap/catalog/catalogCategory/catalog_category.create.html) 26 | 27 | Create a new category and return its ID. 28 | 29 | `data` is a catalogCategoryEntityCreate object. 30 | 31 | ```js 32 | magento.catalogCategory.create({ 33 | categoryId: val, 34 | data: val, 35 | storeView: val /* optional */ 36 | }, callback); 37 | ``` 38 | 39 | ## [currentStore](http://www.magentocommerce.com/api/soap/catalog/catalogCategory/catalog_category.currentStore.html) 40 | 41 | Allows you to set/get the current store view. 42 | 43 | ```js 44 | magento.catalogCategory.currentStore({ 45 | storeView: val 46 | }, callback); 47 | ``` 48 | 49 | ## [delete](http://www.magentocommerce.com/api/soap/catalog/catalogCategory/catalog_category.delete.html) 50 | 51 | Allows you to delete the required category. 52 | 53 | ```js 54 | magento.catalogCategory.delete({ 55 | categoryId: val 56 | }, callback); 57 | ``` 58 | 59 | ## [info](http://www.magentocommerce.com/api/soap/catalog/catalogCategory/catalog_category.info.html) 60 | 61 | Allows you to retrieve information about the required category. 62 | 63 | ```js 64 | magento.catalogCategory.info({ 65 | categoryId: val, 66 | storeView: val, /* optional */ 67 | attributes: val /* optional */ 68 | }, callback); 69 | ``` 70 | 71 | ## [level](http://www.magentocommerce.com/api/soap/catalog/catalogCategory/catalog_category.level.html) 72 | 73 | Allows you to retrieve one level of categories by a website, a store view, or a parent category. 74 | 75 | ```js 76 | magento.catalogCategory.level(callback); 77 | 78 | // or 79 | 80 | magento.catalogCategory.level({ 81 | website: val, /* optional */ 82 | storeView: val, /* optional */ 83 | parentCategory: val /* optional */ 84 | }, callback); 85 | ``` 86 | 87 | ## [move](http://www.magentocommerce.com/api/soap/catalog/catalogCategory/catalog_category.move.html) 88 | 89 | Allows you to move the required category in the category tree. 90 | 91 | ```js 92 | magento.catalogCategory.move({ 93 | categoryId: val, 94 | parentId: val, 95 | afterId: val /* optional */ 96 | }, callback); 97 | ``` 98 | 99 | ## [removeProduct](http://www.magentocommerce.com/api/soap/catalog/catalogCategory/catalog_category.removeProduct.html) 100 | 101 | Allows you to remove the product assignment from the category. 102 | 103 | ```js 104 | magento.catalogCategory.removeProduct({ 105 | categoryId: val, 106 | productId: val 107 | }, callback); 108 | ``` 109 | 110 | ## [tree](http://www.magentocommerce.com/api/soap/catalog/catalogCategory/catalog_category.tree.html) 111 | 112 | Allows you to retrieve the hierarchical tree of categories. 113 | 114 | ```js 115 | magento.catalogCategory.tree(callback); 116 | 117 | // or 118 | 119 | magento.catalogCategory.tree({ 120 | parentId: val, /* optional */ 121 | storeView: val /* optional */ 122 | }, callback); 123 | ``` 124 | 125 | ## [update](http://www.magentocommerce.com/api/soap/catalog/catalogCategory/catalog_category.update.html) 126 | 127 | Update the required category. Note that you should specify only those parameters which you want to be updated. 128 | 129 | ```js 130 | magento.catalogCategory.update({ 131 | categoryId: val, 132 | categoryData: val, 133 | storeView: val /* optional */ 134 | }, callback); 135 | ``` 136 | 137 | ## [updateProduct](http://www.magentocommerce.com/api/soap/catalog/catalogCategory/catalog_category.updateProduct.html) 138 | 139 | Allows you to update the product assigned to a category. The product position is updated. 140 | 141 | ```js 142 | magento.catalogCategory.updateProduct({ 143 | categoryId: val, 144 | productId: val, 145 | position: val /* optional */ 146 | }, callback); 147 | ``` -------------------------------------------------------------------------------- /readmes/catalog_category_attribute.md: -------------------------------------------------------------------------------- 1 | # Catalog Category Attribute 2 | 3 | ## [currentStore](http://www.magentocommerce.com/api/soap/catalog/catalogCategoryAttributes/catalog_category_attribute.currentStore.html) 4 | 5 | Allows you to set/get the current store view. 6 | 7 | ```js 8 | magento.catalogCategoryAttribute.currentStore({ 9 | storeView: val 10 | }, callback); 11 | ``` 12 | 13 | ## [list](http://www.magentocommerce.com/api/soap/catalog/catalogCategoryAttributes/catalog_category_attribute.list.html) 14 | 15 | Allows you to retrieve the list of category attributes. 16 | 17 | ```js 18 | magento.catalogCategoryAttribute.list(callback); 19 | ``` 20 | 21 | ## [options](http://www.magentocommerce.com/api/soap/catalog/catalogCategoryAttributes/catalog_category_attribute.options.html) 22 | 23 | Allows you to retrieve the attribute options. 24 | 25 | ```js 26 | magento.catalogCategoryAttribute.options({ 27 | attributeId: val, 28 | storeView: val 29 | }, callback); 30 | ``` -------------------------------------------------------------------------------- /readmes/catalog_product.md: -------------------------------------------------------------------------------- 1 | # Catalog Product 2 | 3 | ## [create](http://www.magentocommerce.com/api/soap/catalog/catalogProduct/catalog_product.create.html) 4 | 5 | Allows you to create a new product and return ID of the created product. 6 | 7 | `data` is a catalogProductCreateEntity object. 8 | 9 | ```js 10 | magento.catalogProduct.create({ 11 | type: val, 12 | set: val, 13 | sku: val, 14 | data: val 15 | }, callback); 16 | ``` 17 | 18 | ## [currentStore](http://www.magentocommerce.com/api/soap/catalog/catalogProduct/catalog_product.currentStore.html) 19 | 20 | Allows you to set/get the current store view. 21 | 22 | ```js 23 | magento.catalogProduct.currentStore(callback); 24 | 25 | // or 26 | 27 | magento.catalogProduct.currentStore({ 28 | view: val /* optional */ 29 | }, callback); 30 | ``` 31 | 32 | ## [delete](http://www.magentocommerce.com/api/soap/catalog/catalogProduct/catalog_product.delete.html) 33 | 34 | Allows you to delete the required product. 35 | 36 | ```js 37 | magento.catalogProduct.delete({ 38 | id: val 39 | }, callback); 40 | ``` 41 | 42 | ## [getSpecialPrice](http://www.magentocommerce.com/api/soap/catalog/catalogProduct/catalog_product.getSpecialPrice.html) 43 | 44 | Allows you to get the product special price data. 45 | 46 | ```js 47 | magento.catalogProduct.getSpecialPrice({ 48 | id: val 49 | }, callback); 50 | ``` 51 | 52 | ## [info](http://www.magentocommerce.com/api/soap/catalog/catalogProduct/catalog_product.info.html) 53 | 54 | Allows you to retrieve information about the required product. 55 | 56 | ```js 57 | magento.catalogProduct.info({ 58 | id: val, 59 | view: val /* optional */ 60 | }, callback); 61 | ``` 62 | 63 | ## [list](http://www.magentocommerce.com/api/soap/catalog/catalogProduct/catalog_product.list.html) 64 | 65 | Allows you to retrieve the list of products. 66 | 67 | ```js 68 | magento.catalogProduct.list(callback); 69 | ``` 70 | //or 71 | 72 | ```js 73 | magento.catalogProduct.listOfAdditionalAttributes({ 74 | filters: val /* optional */ 75 | }, callback); 76 | ``` 77 | filter examples 78 | 79 | ```js 80 | {'type': {'in': 'simple'}} 81 | ``` 82 | 83 | ```js 84 | {'created_at': {'from': '2011-07-06 01:01:01'}} 85 | ``` 86 | 87 | 88 | ## [listOfAdditionalAttributes](http://www.magentocommerce.com/api/soap/catalog/catalogProduct/catalog_product.listOfAdditionalAttributes.html) 89 | 90 | Get the list of additional attributes. 91 | 92 | Additional attributes are attributes that are not in the default set of attributes. 93 | 94 | ```js 95 | magento.catalogProduct.listOfAdditionalAttributes({ 96 | prodType: val, 97 | attributeSetId: val 98 | }, callback); 99 | ``` 100 | 101 | ## [setSpecialPrice](http://www.magentocommerce.com/api/soap/catalog/catalogProduct/catalog_product.setSpecialPrice.html) 102 | 103 | Allows you to set the product special price. 104 | 105 | `from` and `to` should be native JavaScript date objects. 106 | 107 | ```js 108 | magento.catalogProduct.setSpecialPrice({ 109 | id: val, 110 | specialPrice: val, 111 | from: val, 112 | to: val, 113 | storeView: val /* optional */ 114 | }, callback); 115 | ``` 116 | 117 | ## [update](http://www.magentocommerce.com/api/soap/catalog/catalogProduct/catalog_product.update.html) 118 | 119 | Allows you to update the required product. Note that you should specify only those parameters which you want to be updated. 120 | 121 | `data` is a catalogProductCreateEntity object. 122 | 123 | ```js 124 | magento.catalogProduct.update({ 125 | id: val, 126 | data: val, 127 | storeView: val /* optional */ 128 | }, callback); 129 | ``` -------------------------------------------------------------------------------- /readmes/catalog_product_attribute.md: -------------------------------------------------------------------------------- 1 | # Catalog Product Attribute 2 | 3 | ## [addOption](http://www.magentocommerce.com/api/soap/catalog/catalogProductAttribute/product_attribute.addOption.html) 4 | 5 | Allows you to add a new option for attributes with selectable fields. 6 | 7 | `data` is a catalogProductAttributeOptionEntityToAdd object. 8 | 9 | ```js 10 | magento.catalogProductAttribute.addOption({ 11 | attribute: val, 12 | data: val 13 | }, callback); 14 | ``` 15 | 16 | ## [create](http://www.magentocommerce.com/api/soap/catalog/catalogProductAttribute/product_attribute.create.html) 17 | 18 | Allows you to create a new product attribute. 19 | 20 | `data` is a catalogProductAttributeEntityToCreate object. 21 | 22 | ```js 23 | magento.catalogProductAttribute.create({ 24 | data: val 25 | }, callback); 26 | ``` 27 | 28 | ## [currentStore](http://www.magentocommerce.com/api/soap/catalog/catalogProductAttribute/product_attribute.currentStore.html) 29 | 30 | Allows you to set/get the current store view. 31 | 32 | ```js 33 | magento.catalogProductAttribute.currentStore(callback); 34 | 35 | // or 36 | 37 | magento.catalogProductAttribute.currentStore({ 38 | storeView: val 39 | }, callback); 40 | ``` 41 | 42 | ## [info](http://www.magentocommerce.com/api/soap/catalog/catalogProductAttribute/product_attribute.info.html) 43 | 44 | Allows you to get full information about a required attribute with the list of options. 45 | 46 | ```js 47 | magento.catalogProductAttribute.info({ 48 | attribute: val 49 | }, callback); 50 | ``` 51 | 52 | ## [list](http://www.magentocommerce.com/api/soap/catalog/catalogProductAttribute/product_attribute.list.html) 53 | 54 | Allows you to retrieve the list of product attributes. 55 | 56 | ```js 57 | magento.catalogProductAttribute.list({ 58 | setId: val 59 | }, callback); 60 | ``` 61 | 62 | ## [options](http://www.magentocommerce.com/api/soap/catalog/catalogProductAttribute/product_attribute.options.html) 63 | 64 | Allows you to retrieve the product attribute options. 65 | 66 | ```js 67 | magento.catalogProductAttribute.options({ 68 | attributeId: val, 69 | storeView: val /* optional */ 70 | }, callback); 71 | ``` 72 | 73 | ## [remove](http://www.magentocommerce.com/api/soap/catalog/catalogProductAttribute/product_attribute.remove.html) 74 | 75 | Allows you to remove the required attribute from a product. 76 | 77 | magento.catalogProductAttribute.remove({ 78 | attribute: val 79 | }, callback); 80 | 81 | ## [removeOption](http://www.magentocommerce.com/api/soap/catalog/catalogProductAttribute/product_attribute.removeOption.html) 82 | 83 | Allows you to remove the option for an attribute. 84 | 85 | ```js 86 | magento.catalogProductAttribute.removeOption({ 87 | attribute: val, 88 | optionId: val 89 | }, callback); 90 | ``` 91 | 92 | ## [types](http://www.magentocommerce.com/api/soap/catalog/catalogProductAttribute/product_attribute.types.html) 93 | 94 | Allows you to retrieve the list of possible attribute types. 95 | 96 | ```js 97 | magento.catalogProductAttribute.types(callback); 98 | ``` 99 | 100 | ## [update](http://www.magentocommerce.com/api/soap/catalog/catalogProductAttribute/product_attribute.update.html) 101 | 102 | Allows you to update the required attribute. 103 | 104 | `data` is a catalogProductAttributeEntityToUpdate object. 105 | 106 | ```js 107 | magento.catalogProductAttribute.update({ 108 | attribute: val, 109 | data: val 110 | }, callback); 111 | ``` -------------------------------------------------------------------------------- /readmes/catalog_product_attribute_media.md: -------------------------------------------------------------------------------- 1 | # Catalog Product Attribute Media 2 | 3 | ## [create](http://www.magentocommerce.com/api/soap/catalog/catalogProductAttributeMedia/catalog_product_attribute_media.create.html) 4 | 5 | Allows you to upload a new product image. 6 | 7 | `data` is a catalogProductAttributeMediaCreateEntity object. 8 | 9 | ```js 10 | magento.catalogProductAttributeMedia.create({ 11 | product: val, 12 | data: val, 13 | storeView: val /* optional */ 14 | }, callback); 15 | ``` 16 | 17 | ## [currentStore](http://www.magentocommerce.com/api/soap/catalog/catalogProductAttributeMedia/catalog_product_attribute_media.currentStore.html) 18 | 19 | Allows you to set/get the current store view. 20 | 21 | ```js 22 | magento.catalogProductAttributeMedia.currentStore(callback); 23 | 24 | // or 25 | 26 | magento.catalogProductAttributeMedia.currentStore({ 27 | storeView: val /* optional */ 28 | }, callback); 29 | ``` 30 | 31 | ## [info](http://www.magentocommerce.com/api/soap/catalog/catalogProductAttributeMedia/catalog_product_attribute_media.info.html) 32 | 33 | Allows you to retrieve information about the specified product image. 34 | 35 | ```js 36 | magento.catalogProductAttributeMedia.info({ 37 | info: val, 38 | file: val, 39 | storeView: val /* optional */ 40 | }, callback); 41 | ``` 42 | 43 | ## [list](http://www.magentocommerce.com/api/soap/catalog/catalogProductAttributeMedia/catalog_product_attribute_media.list.html) 44 | 45 | Allows you to retrieve the list of product images. 46 | 47 | ```js 48 | magento.catalogProductAttributeMedia.list({ 49 | product: val, 50 | storeView: val /* optional */ 51 | }, callback); 52 | ``` 53 | 54 | ## [remove](http://www.magentocommerce.com/api/soap/catalog/catalogProductAttributeMedia/catalog_product_attribute_media.remove.html) 55 | 56 | Allows you to remove the image from a product. 57 | 58 | ```js 59 | magento.catalogProductAttributeMedia.remove({ 60 | product: val, 61 | file: val 62 | }, callback); 63 | ``` 64 | 65 | ## [types](http://www.magentocommerce.com/api/soap/catalog/catalogProductAttributeMedia/catalog_product_attribute_media.types.html) 66 | 67 | Allows you to retrieve product image types including standard image, small_image, thumbnail, etc. 68 | 69 | Note that if the product attribute set contains attributes of the Media Image type (Catalog Input Type for Store Owner > Media Image), 70 | it will also be returned in the response. 71 | 72 | ```js 73 | magento.catalogProductAttributeMedia.types({ 74 | setId: val 75 | }, callback); 76 | ``` 77 | 78 | ## [update](http://www.magentocommerce.com/api/soap/catalog/catalogProductAttributeMedia/catalog_product_attribute_media.update.html) 79 | 80 | Allows you to update the product image. 81 | 82 | ```js 83 | magento.catalogProductAttributeMedia.update({ 84 | product: val, 85 | file: val, 86 | data: val, 87 | storeView: val 88 | }, callback); 89 | ``` -------------------------------------------------------------------------------- /readmes/catalog_product_attribute_set.md: -------------------------------------------------------------------------------- 1 | # Catalog Product Attribute Set 2 | 3 | ## [attributeAdd](http://www.magentocommerce.com/api/soap/catalog/catalogProductAttributeSet/product_attribute_set.attributeAdd.html) 4 | 5 | Allows you to add an existing attribute to an attribute set. 6 | 7 | ```js 8 | magento.catalogProductAttributeSet.attributeAdd({ 9 | attributeId: val, 10 | attributeSetId: val, 11 | attributeGroupId: val, /* optional */ 12 | sortOrder: val /* optional */ 13 | }, callback); 14 | ``` 15 | 16 | ## [attributeRemove](http://www.magentocommerce.com/api/soap/catalog/catalogProductAttributeSet/product_attribute_set.attributeRemove.html) 17 | 18 | Allows you to remove an existing attribute from an attribute set. 19 | 20 | ```js 21 | magento.catalogProductAttributeSet.attributeRemove({ 22 | attributeId: val, 23 | attributeSetId: val 24 | }, callback); 25 | ``` 26 | 27 | ## [create](http://www.magentocommerce.com/api/soap/catalog/catalogProductAttributeSet/product_attribute_set.create.html) 28 | 29 | Allows you to create a new attribute set based on another attribute set. 30 | 31 | ```js 32 | magento.catalogProductAttributeSet.create({ 33 | attributeSetName: val, 34 | skeletonSetId: val 35 | }, callback); 36 | ``` 37 | 38 | ## [groupAdd](http://www.magentocommerce.com/api/soap/catalog/catalogProductAttributeSet/product_attribute_set.groupAdd.html) 39 | 40 | Allows you to add a new group for attributes to the attribute set. 41 | 42 | ```js 43 | magento.catalogProductAttributeSet.groupAdd({ 44 | attributeSetId: val, 45 | groupName: val 46 | }, callback); 47 | ``` 48 | 49 | ## [groupRemove](http://www.magentocommerce.com/api/soap/catalog/catalogProductAttributeSet/product_attribute_set.groupRemove.html) 50 | 51 | Allows you to remove a group from an attribute set. 52 | 53 | ```js 54 | magento.catalogProductAttributeSet.groupRemove({ 55 | attributeGroupId: val 56 | }, callback); 57 | ``` 58 | 59 | ## [groupRename](http://www.magentocommerce.com/api/soap/catalog/catalogProductAttributeSet/product_attribute_set.groupRename.html) 60 | 61 | Allows you to rename a group in the attribute set. 62 | 63 | ```js 64 | magento.catalogProductAttributeSet.groupRename({ 65 | groupId: val, 66 | groupName: val 67 | }, callback); 68 | ``` 69 | 70 | ## [list](http://www.magentocommerce.com/api/soap/catalog/catalogProductAttributeSet/product_attribute_set.list.html) 71 | 72 | Allows you to retrieve the list of product attribute sets. 73 | 74 | ```js 75 | magento.catalogProductAttributeSet.list(callback); 76 | ``` 77 | 78 | ## [remove](http://www.magentocommerce.com/api/soap/catalog/catalogProductAttributeSet/product_attribute_set.remove.html) 79 | 80 | Allows you to remove an existing attribute set. 81 | 82 | ```js 83 | magento.catalogProductAttributeSet.remove({ 84 | attributeSetId: val, 85 | forceProductsRemove: val /* optional */ 86 | }, callback); 87 | ``` -------------------------------------------------------------------------------- /readmes/catalog_product_custom_option.md: -------------------------------------------------------------------------------- 1 | # Catalog Product Custom Option 2 | 3 | ## [add](http://www.magentocommerce.com/api/soap/catalog/catalogProductCustomOption/product_custom_option.add.html) 4 | 5 | Allows you to add a new custom option for a product. 6 | 7 | `data` is a catalogProductCustomOptionToAdd object. 8 | 9 | ```js 10 | magento.catalogProductCustomOption.add({ 11 | productId: val, 12 | data: val, 13 | storeView: val /* optional */ 14 | }, callback); 15 | ``` 16 | 17 | ## [info](http://www.magentocommerce.com/api/soap/catalog/catalogProductCustomOption/product_custom_option.info.html) 18 | 19 | Allows you to retrieve full information about the custom option in a product. 20 | 21 | ```js 22 | magento.catalogProductCustomOption.info({ 23 | optionId: val, 24 | storeView: val /* optional */ 25 | }, callback); 26 | ``` 27 | 28 | ## [list](http://www.magentocommerce.com/api/soap/catalog/catalogProductCustomOption/product_custom_option.list.html) 29 | 30 | Allows you to retrieve the list of custom options for a specific product. 31 | 32 | ```js 33 | magento.catalogProductCustomOption.list({ 34 | productId: val, 35 | storeView: val /* optional */ 36 | }, callback); 37 | ``` 38 | 39 | ## [remove](http://www.magentocommerce.com/api/soap/catalog/catalogProductCustomOption/product_custom_option.remove.html) 40 | 41 | Allows you to remove a custom option from the product. 42 | 43 | ```js 44 | magento.catalogProductCustomOption.remove({ 45 | optionId: val 46 | }, callback); 47 | ``` 48 | 49 | ## [types](http://www.magentocommerce.com/api/soap/catalog/catalogProductCustomOption/product_custom_option.types.html) 50 | 51 | Allows you to retrieve the list of available custom option types. 52 | 53 | ```js 54 | magento.catalogProductCustomOption.types(callback); 55 | ``` 56 | 57 | ## [update](http://www.magentocommerce.com/api/soap/catalog/catalogProductCustomOption/product_custom_option.update.html) 58 | 59 | Allows you to update the required product custom option. 60 | 61 | `data` is a catalogProductCustomOptionToUpdate object. 62 | 63 | ```js 64 | magento.catalogProductCustomOption.update({ 65 | optionId: val, 66 | data: val, 67 | storeView: val /* optional */ 68 | }, callback); 69 | ``` -------------------------------------------------------------------------------- /readmes/catalog_product_custom_option_value.md: -------------------------------------------------------------------------------- 1 | # Catalog Product Custom Option Value 2 | 3 | ## [add](http://www.magentocommerce.com/api/soap/catalog/catalogProductCustomOptionValue/product_custom_option_value.add.html) 4 | 5 | Allows you to add a new custom option value to a custom option. 6 | 7 | Note that the custom option value can be added only to the option with the Select Input Type. 8 | 9 | `data` is a catalogProductCustomOptionValueAdd object. 10 | 11 | ```js 12 | magento.catalogProductCustomOptionValue.add({ 13 | optionId: val, 14 | data: val, 15 | storeView: val /* optional */ 16 | }, callback); 17 | ``` 18 | 19 | ## [info](http://www.magentocommerce.com/api/soap/catalog/catalogProductCustomOptionValue/product_custom_option_value.info.html) 20 | 21 | Allows you to retrieve full information about the specified product custom option value. 22 | 23 | ```js 24 | magento.catalogProductCustomOptionValue.info({ 25 | valueId: val, 26 | storeView: val /* optional */ 27 | }, callback); 28 | ``` 29 | 30 | ## [list](http://www.magentocommerce.com/api/soap/catalog/catalogProductCustomOptionValue/product_custom_option_value.list.html) 31 | 32 | Allows you to retrieve the list of product custom option values. 33 | 34 | Note that the method is available only for the option Select Input Type. 35 | 36 | ```js 37 | magento.catalogProductCustomOptionValue.list({ 38 | optionId: val, 39 | storeView: val /* optional */ 40 | }, callback); 41 | ``` 42 | 43 | ## [remove](http://www.magentocommerce.com/api/soap/catalog/catalogProductCustomOptionValue/product_custom_option_value.remove.html) 44 | 45 | Allows you to remove the custom option value from a product. 46 | 47 | ```js 48 | magento.catalogProductCustomOptionValue.remove({ 49 | valueId: val 50 | }, callback); 51 | ``` 52 | 53 | ## [update](http://www.magentocommerce.com/api/soap/catalog/catalogProductCustomOptionValue/product_custom_option_value.update.html) 54 | 55 | Allows you to update the product custom option value. 56 | 57 | `data` is a catalogProductCustomOptionValueUpdateEntity object. 58 | 59 | ```js 60 | magento.catalogProductCustomOptionValue.update({ 61 | valueId: val, 62 | data: val, 63 | storeView: val /* optional */ 64 | }, callback); 65 | ``` -------------------------------------------------------------------------------- /readmes/catalog_product_downloadable_link.md: -------------------------------------------------------------------------------- 1 | # Catalog Product Downloadable Link 2 | 3 | ## [add](http://www.magentocommerce.com/api/soap/catalog/catalogProductDownloadableLink/product_downloadable_link.add.html) 4 | 5 | Allows you to add a new link to a downloadable product. 6 | 7 | `resource` is a catalogProductDownloadableLinkAddEntity object. 8 | 9 | ```js 10 | magento.catalogProductDownloadableLink.add({ 11 | productId: val, 12 | resource: val, 13 | resourceType: val 14 | storeView: val /* optional */ 15 | }, callback); 16 | ``` 17 | 18 | ## [list](http://www.magentocommerce.com/api/soap/catalog/catalogProductDownloadableLink/product_downloadable_link.list.html) 19 | 20 | Allows you to retrieve a list of links of a downloadable product. 21 | 22 | ```js 23 | magento.catalogProductDownloadableLink.list({ 24 | productId: val, 25 | storeView: val /* optional */ 26 | }, callback); 27 | ``` 28 | 29 | ## [remove](http://www.magentocommerce.com/api/soap/catalog/catalogProductDownloadableLink/product_downloadable_link.remove.html) 30 | 31 | Allows you to remove a link/sample from a downloadable product. 32 | 33 | ```js 34 | magento.catalogProductDownloadableLink.remove({ 35 | linkId: val 36 | }, callback); 37 | ``` -------------------------------------------------------------------------------- /readmes/catalog_product_link.md: -------------------------------------------------------------------------------- 1 | # Catalog Product Link 2 | 3 | ## [assign](http://www.magentocommerce.com/api/soap/catalog/catalogProductLink/catalog_product_link.assign.html) 4 | 5 | Allows you to assign a product link (related, cross-sell, up-sell, or grouped) to another product. 6 | 7 | `data` is a catalogProductLinkEntity object. 8 | 9 | ```js 10 | magento.catalogProductLink.assign({ 11 | type: val, 12 | product: val, 13 | linkedProduct: val, 14 | data: val 15 | }, callback); 16 | ``` 17 | 18 | ## [attributes](http://www.magentocommerce.com/api/soap/catalog/catalogProductLink/catalog_product_link.attributes.html) 19 | 20 | Allows you to retrieve the product link type attributes. 21 | 22 | ```js 23 | magento.catalogProductLink.attributes({ 24 | type: val 25 | }, callback); 26 | ``` 27 | 28 | ## [list](http://www.magentocommerce.com/api/soap/catalog/catalogProductLink/catalog_product_link.list.html) 29 | 30 | Allows you to retrieve the list of linked products for a specific product. 31 | 32 | ```js 33 | magento.catalogProductLink.list({ 34 | type: val, 35 | product: val 36 | }, callback); 37 | ``` 38 | 39 | ## [remove](http://www.magentocommerce.com/api/soap/catalog/catalogProductLink/catalog_product_link.remove.html) 40 | 41 | Allows you to remove the product link from a specific product. 42 | 43 | ```js 44 | magento.catalogProductLink.remove({ 45 | type: val, 46 | product: val, 47 | linkedProduct: val 48 | }, callback); 49 | ``` 50 | 51 | ## [types](http://www.magentocommerce.com/api/soap/catalog/catalogProductLink/catalog_product_link.types.html) 52 | 53 | Allows you to retrieve the list of product link types. 54 | 55 | ```js 56 | magento.catalogProductLink.types(callback); 57 | ``` 58 | 59 | ## [update](http://www.magentocommerce.com/api/soap/catalog/catalogProductLink/catalog_product_link.update.html) 60 | 61 | Allows you to update the product link. 62 | 63 | `data` is a catalogProductLinkEntity object. 64 | 65 | ```js 66 | magento.catalogProductLink.update({ 67 | type: val, 68 | product: val, 69 | linkedProduct: val, 70 | data: val 71 | }, callback); 72 | ``` -------------------------------------------------------------------------------- /readmes/catalog_product_tag.md: -------------------------------------------------------------------------------- 1 | # Catalog Product Tag 2 | 3 | ## [add](http://www.magentocommerce.com/api/soap/catalog/catalogProductTag/product_tag.add.html) 4 | 5 | Allows you to add one or more tags to a product. 6 | 7 | `data` is a catalogProductTagAddEntity object 8 | 9 | ```js 10 | magento.catalogProductTag.add({ 11 | data: val 12 | }, callback); 13 | ``` 14 | 15 | ## [info](http://www.magentocommerce.com/api/soap/catalog/catalogProductTag/product_tag.info.html) 16 | 17 | Allows you to retrieve information about the required product tag. 18 | 19 | ```js 20 | magento.catalogProductTag.info({ 21 | tagId: val, 22 | storeView: val 23 | }, callback); 24 | ``` 25 | 26 | ## [list](http://www.magentocommerce.com/api/soap/catalog/catalogProductTag/product_tag.list.html) 27 | 28 | Allows you to retrieve the list of tags for a specific product. 29 | 30 | ```js 31 | magento.catalogProductTag.list({ 32 | productId: val, 33 | storeView: val 34 | }, callback); 35 | ``` 36 | 37 | ## [remove](http://www.magentocommerce.com/api/soap/catalog/catalogProductTag/product_tag.remove.html) 38 | 39 | Allows you to remove an existing product tag. 40 | 41 | ```js 42 | magento.catalogProductTag.remove({ 43 | tagId: val 44 | }, callback); 45 | ``` 46 | 47 | ## [update](http://www.magentocommerce.com/api/soap/catalog/catalogProductTag/product_tag.update.html) 48 | 49 | Allows you to update information about an existing product tag. 50 | 51 | `data` is a catalogProductTagUpdateEntity object. 52 | 53 | ```js 54 | magento.catalogProductTag.update({ 55 | tagId: val, 56 | data: val, 57 | storeView: val /* optional */ 58 | }, callback); 59 | ``` -------------------------------------------------------------------------------- /readmes/catalog_product_tier_price.md: -------------------------------------------------------------------------------- 1 | # Catalog Product Tier Price 2 | 3 | ## [info](http://www.magentocommerce.com/api/soap/catalog/catalogProductTierPrice/catalog_product_attribute_tier_price.info.html) 4 | 5 | Allows you to retrieve information about product tier prices. 6 | 7 | ```js 8 | magento.catalogProductTierPrice.info({ 9 | product: val 10 | }, callback); 11 | ``` 12 | 13 | ## [update](http://www.magentocommerce.com/api/soap/catalog/catalogProductTierPrice/catalog_product_attribute_tier_price.update.html) 14 | 15 | Allows you to update the product tier prices. 16 | 17 | `tierPrices` is a catalogProductTierPriceEntity object. 18 | 19 | ```js 20 | magento.catalogProductTierPrice.update({ 21 | product: val, 22 | tierPrices: val 23 | }, callback); 24 | ``` -------------------------------------------------------------------------------- /readmes/catalog_product_type.md: -------------------------------------------------------------------------------- 1 | # Catalog Product Type 2 | 3 | ## [list](http://www.magentocommerce.com/api/soap/catalog/catalogProductTypes/catalog_product_type.list.html) 4 | 5 | Allows you to retrieve the list of product types. 6 | 7 | ```js 8 | magento.catalogProductType.list(callback); 9 | ``` -------------------------------------------------------------------------------- /readmes/checkout_cart.md: -------------------------------------------------------------------------------- 1 | # Checkout Cart 2 | 3 | ## [create](http://www.magentocommerce.com/api/soap/checkout/cart/cart.create.html) 4 | 5 | Allows you to create an empty shopping cart. 6 | 7 | ```js 8 | magento.checkoutCart.create(callback); 9 | 10 | // or 11 | 12 | magento.checkoutCart.create({ 13 | storeView: val 14 | }, callback); 15 | ``` 16 | 17 | ## [info](http://www.magentocommerce.com/api/soap/checkout/cart/cart.info.html) 18 | 19 | Allows you to retrieve full information about the shopping cart (quote). 20 | 21 | ```js 22 | magento.checkoutCart.info({ 23 | quoteId: val, 24 | storeView: val /* optional */ 25 | }, callback); 26 | ``` 27 | 28 | ## [license](http://www.magentocommerce.com/api/soap/checkout/cart/cart.license.html) 29 | 30 | Allows you to retrieve the website license agreement for the quote according to the website (store). 31 | 32 | ```js 33 | magento.checkoutCart.license({ 34 | quoteId: val, 35 | storeView: val /* optional */ 36 | }, callback); 37 | ``` 38 | 39 | ## [order](http://www.magentocommerce.com/api/soap/checkout/cart/cart.order.html) 40 | 41 | Allows you to create an order from a shopping cart (quote). 42 | 43 | Before placing the order, you need to add the customer, customer address, shipping and payment methods. 44 | 45 | ```js 46 | magento.checkoutCart.order({ 47 | quoteId: val, 48 | storeView: val, /* optional */ 49 | agreements: val /* optional */ 50 | }, callback); 51 | ``` 52 | 53 | ## [totals](http://www.magentocommerce.com/api/soap/checkout/cart/cart.totals.html) 54 | 55 | Allows you to retrieve total prices for a shopping cart (quote). 56 | 57 | ```js 58 | magento.checkoutCart.totals({ 59 | quoteId: val, 60 | storeView: val /* optional */ 61 | }, callback); 62 | ``` -------------------------------------------------------------------------------- /readmes/checkout_cart_coupon.md: -------------------------------------------------------------------------------- 1 | # Checkout Cart Coupon 2 | 3 | ## [add](http://www.magentocommerce.com/api/soap/checkout/cartCoupon/cart_coupon.add.html) 4 | 5 | ```js 6 | magento.checkoutCartCoupon.add({ 7 | quoteId: val, 8 | couponCode: val, 9 | storeView: val /* optional */ 10 | }, callback); 11 | ``` 12 | 13 | ## [remove](http://www.magentocommerce.com/api/soap/checkout/cartCoupon/cart_coupon.remove.html) 14 | 15 | ```js 16 | magento.checkoutCartCoupon.remove({ 17 | quoteId: val, 18 | storeView: val /* optional */ 19 | }, callback); 20 | ``` -------------------------------------------------------------------------------- /readmes/checkout_cart_customer.md: -------------------------------------------------------------------------------- 1 | # Checkout Cart Customer 2 | 3 | ## [addresses](http://www.magentocommerce.com/api/soap/checkout/cartCustomer/cart_customer.addresses.html) 4 | 5 | Allows you to set the customer addresses in the shopping cart (quote). 6 | 7 | `customerAddressData` is an array of shoppingCartCustomerAddressEntity objects. 8 | 9 | ```js 10 | magento.checkoutCartCustomer.addresses({ 11 | quoteId: val, 12 | customerAddressData: [ val, val, val ], 13 | storeView: val /* optional */ 14 | }, callback); 15 | 16 | // or a single address 17 | 18 | magento.checkoutCartCustomer.addresses({ 19 | quoteId: val, 20 | customerAddressData: val, 21 | storeView: val /* optional */ 22 | }, callback); 23 | ``` 24 | 25 | ## [set](http://www.magentocommerce.com/api/soap/checkout/cartCustomer/cart_customer.set.html) 26 | 27 | Allows you to add information about the customer to a shopping cart (quote). 28 | 29 | `customerAddressData` is an array of shoppingCartCustomerEntity objects. 30 | 31 | ```js 32 | magento.checkoutCartCustomer.set({ 33 | quoteId: val, 34 | customerData: [ val, val, val ], 35 | storeView: val /* optional */ 36 | }, callback); 37 | 38 | // or a single cell of data 39 | 40 | magento.checkoutCartCustomer.set({ 41 | quoteId: val, 42 | customerData: val, 43 | storeView: val /* optional */ 44 | }, callback); 45 | ``` -------------------------------------------------------------------------------- /readmes/checkout_cart_payment.md: -------------------------------------------------------------------------------- 1 | # Checkout Cart Payment 2 | 3 | ## [list](http://www.magentocommerce.com/api/soap/checkout/cartPayment/cart_payment.list.html) 4 | 5 | Allows you to retrieve a list of available payment methods for a shopping cart (quote). 6 | 7 | ```js 8 | magento.checkoutCartPayment.list({ 9 | quoteId: val, 10 | storeView: val /* optional */ 11 | }, callback); 12 | ``` 13 | 14 | ## [method](http://www.magentocommerce.com/api/soap/checkout/cartPayment/cart_payment.method.html) 15 | 16 | Allows you to set a payment method for a shopping cart (quote). 17 | 18 | `data` is an array of shoppingCartPaymentMethodEntity objects. 19 | 20 | ```js 21 | magento.checkoutCartPayment.method({ 22 | quoteId: val, 23 | paymentData: [ val, val, val ], 24 | storeView: val /* optional */ 25 | }, callback); 26 | 27 | // or a single cell of payment data 28 | 29 | magento.checkoutCartPayment.method({ 30 | quoteId: val, 31 | paymentData: val, 32 | storeView: val /* optional */ 33 | }, callback); 34 | ``` -------------------------------------------------------------------------------- /readmes/checkout_cart_product.md: -------------------------------------------------------------------------------- 1 | # Checkout Cart Product 2 | 3 | ## [add](http://www.magentocommerce.com/api/soap/checkout/cartProduct/cart_product.add.html) 4 | 5 | Allows you to add one or more products to the shopping cart (quote). 6 | 7 | `products` is an array of shoppingCartProductEntity objects. 8 | 9 | ```js 10 | magento.checkoutCartProduct.add({ 11 | quoteId: val, 12 | products: [ val, val, val ], 13 | storeView: val /* optional */ 14 | }, callback); 15 | 16 | // or a single product 17 | 18 | magento.checkoutCartProduct.add({ 19 | quoteId: val, 20 | products: val, 21 | storeView: val /* optional */ 22 | }, callback); 23 | ``` 24 | 25 | ## [list](http://www.magentocommerce.com/api/soap/checkout/cartProduct/cart_product.list.html) 26 | 27 | Allows you to retrieve the list of products in the shopping cart (quote). 28 | 29 | ```js 30 | magento.checkoutCartProduct.list({ 31 | quoteId: val, 32 | storeView: val /* optional */ 33 | }, callback); 34 | ``` 35 | 36 | ## [moveToCustomerQuote](http://www.magentocommerce.com/api/soap/checkout/cartProduct/cart_product.moveToCustomerQuote.html) 37 | 38 | Allows you to move products from the current quote to a customer quote. 39 | 40 | `productsData` is an array of shoppingCartProductEntity objects. 41 | 42 | ```js 43 | magento.checkoutCartProduct.moveToCustomerQuote({ 44 | quoteId: val, 45 | productsData: [ val, val, val ], 46 | storeView: val /* optional */ 47 | }, callback); 48 | 49 | // or a single product data cell 50 | 51 | magento.checkoutCartProduct.moveToCustomerQuote({ 52 | quoteId: val, 53 | productsData: val, 54 | storeView: val /* optional */ 55 | }, callback); 56 | ``` 57 | 58 | ## [remove](http://www.magentocommerce.com/api/soap/checkout/cartProduct/cart_product.remove.html) 59 | 60 | Allows you to remove one or several products from a shopping cart (quote). 61 | 62 | `productsData` is an array of shoppingCartProductEntity objects. 63 | 64 | ```js 65 | magento.checkoutCartProduct.remove({ 66 | quoteId: val, 67 | productsData: [ val, val, val ], 68 | storeView: val /* optional */ 69 | }, callback); 70 | 71 | // or a single product data cell 72 | 73 | magento.checkoutCartProduct.remove({ 74 | quoteId: val, 75 | productsData: val, 76 | storeView: val /* optional */ 77 | }, callback); 78 | ``` 79 | 80 | ## [update](http://www.magentocommerce.com/api/soap/checkout/cartProduct/cart_product.update.html) 81 | 82 | Allows you to update one or several products in the shopping cart (quote). 83 | 84 | `productsData` is an array of shoppingCartProductEntity objects. 85 | 86 | ```js 87 | magento.checkoutCartProduct.update({ 88 | quoteId: val, 89 | productsData: [ val, val, val ], 90 | storeView: val /* optional */ 91 | }, callback); 92 | 93 | // or a single product data cell 94 | 95 | magento.checkoutCartProduct.update({ 96 | quoteId: val, 97 | productsData: val, 98 | storeView: val /* optional */ 99 | }, callback); 100 | ``` -------------------------------------------------------------------------------- /readmes/checkout_cart_shipping.md: -------------------------------------------------------------------------------- 1 | # Checkout Cart Shipping 2 | 3 | ## [list](http://www.magentocommerce.com/api/soap/checkout/cartShipping/cart_shipping.list.html) 4 | 5 | Allows you to retrieve the list of available shipping methods for a shopping cart (quote). 6 | 7 | ```js 8 | magento.checkoutCartShipping.list({ 9 | quoteId: val, 10 | storeView: val /* optional */ 11 | }, callback); 12 | ``` 13 | 14 | ## [method](http://www.magentocommerce.com/api/soap/checkout/cartShipping/cart_shipping.method.html) 15 | 16 | Allows you to set a shipping method for a shopping cart (quote). 17 | 18 | ```js 19 | magento.checkoutCartShipping.method({ 20 | quoteId: val, 21 | shippingMethod: val, 22 | storeView: val /* optional */ 23 | }, callback); 24 | ``` -------------------------------------------------------------------------------- /readmes/core.md: -------------------------------------------------------------------------------- 1 | # Core 2 | 3 | ## [info](http://www.magentocommerce.com/api/soap/miscellaneous/magento.info.html) 4 | 5 | Allows you to retrieve information about Magento version and edition. 6 | 7 | ```js 8 | magento.core.info(callback); 9 | ``` -------------------------------------------------------------------------------- /readmes/customer.md: -------------------------------------------------------------------------------- 1 | # Customer 2 | 3 | ## [create](http://www.magentocommerce.com/api/soap/customer/customer.create.html) 4 | 5 | Create a new customer. 6 | 7 | `customerData` is an array of customerCustomerEntityToCreate objects. 8 | 9 | ```js 10 | magento.customer.create({ 11 | customerData: [ val, val, val ] 12 | }, callback); 13 | 14 | // or a single cell of customer data 15 | 16 | magento.customer.create({ 17 | customerData: val 18 | }, callback); 19 | ``` 20 | 21 | ## [delete](http://www.magentocommerce.com/api/soap/customer/customer.delete.html) 22 | 23 | Delete the required customer. 24 | 25 | ```js 26 | magento.customer.delete({ 27 | customerId: val 28 | }, callback); 29 | ``` 30 | 31 | ## [info](http://www.magentocommerce.com/api/soap/customer/customer.info.html) 32 | 33 | Retrieve information about the specified customer. 34 | 35 | ```js 36 | magento.customer.info({ 37 | customerId: val, 38 | attributes: [ val, val, val ] /* optional */ 39 | }, callback); 40 | 41 | // or a single attribute 42 | 43 | magento.customer.info({ 44 | customerId: val, 45 | attributes: val /* optional */ 46 | }, callback); 47 | ``` 48 | 49 | ## [list](http://www.magentocommerce.com/api/soap/customer/customer.list.html) 50 | 51 | Allows you to retrieve the list of customers. 52 | 53 | ```js 54 | magento.customer.list({ 55 | filters: [ val, val, val ] 56 | }, callback); 57 | 58 | // or a single attribute 59 | 60 | magento.customer.list({ 61 | filters: val 62 | }, callback); 63 | ``` 64 | 65 | ## [update](http://www.magentocommerce.com/api/soap/customer/customer.update.html) 66 | 67 | Update information about the required customer. 68 | 69 | Note that you need to pass only those arguments which you want to be updated. 70 | 71 | `customerData` is an array of customerCustomerEntityToCreate objects. 72 | 73 | ```js 74 | magento.customer.update({ 75 | customerId: val, 76 | customerData: [ val, val, val ] 77 | }, callback); 78 | 79 | // or a single attribute 80 | 81 | magento.customer.update({ 82 | customerId: val, 83 | customerData: val 84 | }, callback); 85 | ``` -------------------------------------------------------------------------------- /readmes/customer_address.md: -------------------------------------------------------------------------------- 1 | # Customer 2 | 3 | ## [create](http://www.magentocommerce.com/api/soap/customer/customerAddress/customer_address.create.html) 4 | 5 | Create a new address for the customer. 6 | 7 | `addressData` is an array of customerAddressEntityCreate objects. 8 | 9 | ```js 10 | magento.customerAddress.create({ 11 | customerId: val, 12 | addressData: [ val, val, val ] 13 | }, callback); 14 | 15 | // or a single cell of address data 16 | 17 | magento.customerAddress.create({ 18 | customerId: val, 19 | addressData: val 20 | }, callback); 21 | ``` 22 | 23 | ## [delete](http://www.magentocommerce.com/api/soap/customer/customerAddress/customer_address.delete.html) 24 | 25 | Delete the required customer address. 26 | 27 | ```js 28 | magento.customerAddress.delete({ 29 | addressId: val 30 | }, callback); 31 | ``` 32 | 33 | ## [info](http://www.magentocommerce.com/api/soap/customer/customerAddress/customer_address.info.html) 34 | 35 | Retrieve information about the required customer address. 36 | 37 | ```js 38 | magento.customerAddress.info({ 39 | addressId: val 40 | }, callback); 41 | ``` 42 | 43 | ## [list](http://www.magentocommerce.com/api/soap/customer/customerAddress/customer_address.list.html) 44 | 45 | Retrieve the list of customer addresses. 46 | 47 | ```js 48 | magento.customerAddress.list({ 49 | customerId: val 50 | }, callback); 51 | ``` 52 | 53 | ## [update](http://www.magentocommerce.com/api/soap/customer/customerAddress/customer_address.update.html) 54 | 55 | Update address data of the required customer. 56 | 57 | `addressData` is an array of customerAddressEntityCreate objects. 58 | 59 | ```js 60 | magento.customerAddress.update({ 61 | addressId: val, 62 | addressData: [ val, val, val ] 63 | }, callback); 64 | 65 | // or a single cell of address data 66 | 67 | magento.customerAddress.update({ 68 | addressId: val, 69 | addressData: val 70 | }, callback); 71 | ``` -------------------------------------------------------------------------------- /readmes/customer_group.md: -------------------------------------------------------------------------------- 1 | # Customer Group 2 | 3 | ## [list](http://www.magentocommerce.com/api/soap/customer/customer_group.html) 4 | 5 | Retrieve the list of customer groups. 6 | 7 | ```js 8 | magento.customerGroup.list(callback); 9 | ``` -------------------------------------------------------------------------------- /readmes/directory_country.md: -------------------------------------------------------------------------------- 1 | # Directory Country 2 | 3 | ## [list](http://www.magentocommerce.com/api/soap/directory/directory_country.list.html) 4 | 5 | Retrieve the list of countries from Magento. 6 | 7 | ```js 8 | magento.directoryCountry.list(callback); 9 | ``` -------------------------------------------------------------------------------- /readmes/directory_region.md: -------------------------------------------------------------------------------- 1 | # Directory Region 2 | 3 | ## [list](http://www.magentocommerce.com/api/soap/directory/directory_region.list.html) 4 | 5 | Retrieve the list of countries from Magento. 6 | 7 | `country` must be the country code in IOS 2 or ISO 3 (e.g. US or USA). 8 | 9 | ```js 10 | magento.directoryRegion.list({ 11 | country: val, 12 | }, callback); 13 | ``` -------------------------------------------------------------------------------- /readmes/sales_order.md: -------------------------------------------------------------------------------- 1 | # Sales Order 2 | 3 | ## [addComment](http://www.magentocommerce.com/api/soap/sales/salesOrder/sales_order.addComment.html) 4 | 5 | Allows you to add a new comment to the order. 6 | 7 | ```js 8 | magento.salesOrder.addComment({ 9 | orderIncrementId: val, 10 | status: val, 11 | comment: val, /* optional */ 12 | notify: val /* optional */ 13 | }, callback); 14 | ``` 15 | 16 | ## [cancel](http://www.magentocommerce.com/api/soap/sales/salesOrder/sales_order.cancel.html) 17 | 18 | Allows you to cancel the required order. 19 | 20 | ```js 21 | magento.salesOrder.cancel({ 22 | orderIncrementId: val 23 | }, callback); 24 | ``` 25 | 26 | ## [hold](http://www.magentocommerce.com/api/soap/sales/salesOrder/sales_order.hold.html) 27 | 28 | Allows you to place the required order on hold. 29 | 30 | ```js 31 | magento.salesOrder.hold({ 32 | orderIncrementId: val 33 | }, callback); 34 | ``` 35 | 36 | ## [info](http://www.magentocommerce.com/api/soap/sales/salesOrder/sales_order.info.html) 37 | 38 | Allows you to retrieve the required order information. 39 | 40 | ```js 41 | magento.salesOrder.info({ 42 | orderIncrementId: val 43 | }, callback); 44 | ``` 45 | 46 | ## [list](http://www.magentocommerce.com/api/soap/sales/salesOrder/sales_order.list.html) 47 | 48 | Allows you to retrieve the list of orders. Additional filters can be applied. 49 | 50 | ```js 51 | magento.salesOrder.list(callback); 52 | 53 | // or 54 | 55 | magento.salesOrder.list({ 56 | filters: { key: 'val' } 57 | }, callback); 58 | ``` 59 | 60 | ## [unhold](http://www.magentocommerce.com/api/soap/sales/salesOrder/sales_order.unhold.html) 61 | 62 | Allows you to unhold the required order. 63 | 64 | ```js 65 | magento.salesOrder.unhold({ 66 | orderIncrementId: val 67 | }, callback); 68 | ``` -------------------------------------------------------------------------------- /readmes/sales_order_credit_memo.md: -------------------------------------------------------------------------------- 1 | # Sales Order Credit Memo 2 | 3 | ## [addComment](http://www.magentocommerce.com/api/soap/sales/salesOrderCreditMemo/sales_order_creditmemo.addComment.html) 4 | 5 | Allows you to add a new comment to an existing credit memo. Email notification can be sent to the user email. 6 | 7 | ```js 8 | magento.salesOrderCreditMemo.addComment({ 9 | creditmemoIncrementId: val, 10 | comment: val, /* optional */ 11 | notifyCustomer: val, /* optional */ 12 | includeComment: val /* optional */ 13 | }, callback); 14 | ``` 15 | 16 | ## [cancel](http://www.magentocommerce.com/api/soap/sales/salesOrderCreditMemo/sales_order_creditmemo.cancel.html) 17 | 18 | Allows you to cancel an existing credit memo. 19 | 20 | ```js 21 | magento.salesOrderCreditMemo.cancel({ 22 | creditmemoIncrementId: val 23 | }, callback); 24 | ``` 25 | 26 | ## [create](http://www.magentocommerce.com/api/soap/sales/salesOrderCreditMemo/sales_order_creditmemo.create.html) 27 | 28 | Allows you to create a new credit memo for the invoiced order. 29 | 30 | Comments can be added and an email notification can be sent to the user email. 31 | 32 | ```js 33 | magento.salesOrderCreditMemo.create({ 34 | orderIncrementId: val, 35 | creditmemoData: val, /* optional */ 36 | comment: val, /* optional */ 37 | notifyCustomer: val, /* optional */ 38 | includeComment: val, /* optional */ 39 | refundToStoreCreditAmount: val /* optional */ 40 | }, callback); 41 | ``` 42 | 43 | ## [info](http://www.magentocommerce.com/api/soap/sales/salesOrderCreditMemo/sales_order_creditmemo.info.html) 44 | 45 | Allows you to retrieve full information about the specified credit memo. 46 | 47 | ```js 48 | magento.salesOrderCreditMemo.info({ 49 | creditmemoIncrementId: val 50 | }, callback); 51 | ``` 52 | 53 | ## [list](http://www.magentocommerce.com/api/soap/sales/salesOrderCreditMemo/sales_order_creditmemo.list.html) 54 | 55 | Allows you to retrieve the list of orders. Additional filters can be applied. 56 | 57 | ```js 58 | magento.salesOrderCreditMemo.list(callback); 59 | 60 | // or 61 | 62 | magento.salesOrderCreditMemo.list({ 63 | filters: [ val, val, val ] 64 | }, callback); 65 | 66 | // or a single filter 67 | 68 | magento.salesOrderCreditMemo.list({ 69 | filters: val 70 | }, callback); 71 | ``` -------------------------------------------------------------------------------- /readmes/sales_order_invoice.md: -------------------------------------------------------------------------------- 1 | # Sales Order Invoice 2 | 3 | ## [addComment](http://www.magentocommerce.com/api/soap/sales/salesOrderInvoice/sales_order_invoice.addComment.html) 4 | 5 | Allows you to add a new comment to the order invoice. 6 | 7 | ```js 8 | magento.salesOrderInvoice.addComment({ 9 | invoiceIncrementId: val, 10 | comment: val, /* optional */ 11 | email: val, /* optional */ 12 | includeComment: val /* optional */ 13 | }, callback); 14 | ``` 15 | 16 | ## [cancel](http://www.magentocommerce.com/api/soap/sales/salesOrderInvoice/sales_order_invoice.cancel.html) 17 | 18 | Allows you to cancel the required invoice. 19 | Note that not all order invoices can be canceled. 20 | Only some payment methods support canceling the order invoice (e.g., Google Checkout, PayPal Pro, PayPal Express Checkout). 21 | 22 | ```js 23 | magento.salesOrderInvoice.cancel({ 24 | invoiceIncrementId: val 25 | }, callback); 26 | ``` 27 | 28 | ## [capture](http://www.magentocommerce.com/api/soap/sales/salesOrderInvoice/sales_order_invoice.capture.html) 29 | 30 | Allows you to capture the required invoice. 31 | Note that not all order invoices can be captured. 32 | Only some payment methods support capturing the order invoice (e.g., PayPal Pro). 33 | 34 | ```js 35 | magento.salesOrderInvoice.capture({ 36 | invoiceIncrementId: val 37 | }, callback); 38 | ``` 39 | 40 | ## [create](http://www.magentocommerce.com/api/soap/sales/salesOrderInvoice/sales_order_invoice.create.html) 41 | 42 | Allows you to create a new invoice for an order. 43 | 44 | ```js 45 | magento.salesOrderInvoice.create({ 46 | orderIncrementId: val, 47 | itemsQty: val, 48 | comment: val, /* optional */ 49 | email: val, /* optional */ 50 | includeComment: val /* optional */ 51 | }, callback); 52 | ``` 53 | 54 | ## [info](http://www.magentocommerce.com/api/soap/sales/salesOrderInvoice/sales_order_invoice.info.html) 55 | 56 | Allows you to retrieve information about the required invoice. 57 | 58 | ```js 59 | magento.salesOrderInvoice.info({ 60 | invoiceIncrementId: val 61 | }, callback); 62 | ``` 63 | 64 | ## [list](http://www.magentocommerce.com/api/soap/sales/salesOrderInvoice/sales_order_invoice.list.html) 65 | 66 | Allows you to retrieve the list of order invoices. Additional filters can also be applied. 67 | 68 | ```js 69 | magento.salesOrderInvoice.list(callback); 70 | 71 | // or 72 | 73 | magento.salesOrderInvoice.list({ 74 | filters: [ val, val, val ] 75 | }, callback); 76 | 77 | // or a single filter 78 | 79 | magento.salesOrderInvoice.list({ 80 | filters: val 81 | }, callback); 82 | ``` -------------------------------------------------------------------------------- /readmes/sales_order_shipment.md: -------------------------------------------------------------------------------- 1 | # Sales Order Shipment 2 | 3 | ## [addComment](http://www.magentocommerce.com/api/soap/sales/salesOrderShipment/sales_order_shipment.addComment.html) 4 | 5 | Allows you to add a new comment to the order shipment. 6 | 7 | ```js 8 | magento.salesOrderShipment.addComment({ 9 | shipmentIncrementId: val, 10 | comment: val, /* optional */ 11 | email: val, /* optional */ 12 | includeInEmail: val /* optional */ 13 | }, callback); 14 | ``` 15 | 16 | ## [addTrack](http://www.magentocommerce.com/api/soap/sales/salesOrderShipment/sales_order_shipment.addTrack.html) 17 | 18 | Allows you to add a new tracking number to the order shipment. 19 | 20 | ```js 21 | magento.salesOrderShipment.addTrack({ 22 | shipmentIncrementId: val, 23 | carrier: val, 24 | title: val, 25 | trackNumber: val 26 | }, callback); 27 | ``` 28 | 29 | ## [create](http://www.magentocommerce.com/api/soap/sales/salesOrderShipment/sales_order_shipment.create.html) 30 | 31 | Allows you to create a new shipment for an order. 32 | 33 | ```js 34 | magento.salesOrderShipment.create({ 35 | orderIncrementId: val, 36 | itemsQty: val, /* optional */ 37 | comment: val, /* optional */ 38 | email: val, /* optional */ 39 | includeComment: val /* optional */ 40 | }, callback); 41 | ``` 42 | 43 | ## [getCarriers](http://www.magentocommerce.com/api/soap/sales/salesOrderShipment/sales_order_shipment.getCarriers.html) 44 | 45 | Allows you to retrieve the list of allowed carriers for an order. 46 | 47 | ```js 48 | magento.salesOrderShipment.getCarriers({ 49 | orderIncrementId: val 50 | }, callback); 51 | ``` 52 | 53 | ## [info](http://www.magentocommerce.com/api/soap/sales/salesOrderShipment/sales_order_shipment.info.html) 54 | 55 | Allows you to retrieve the shipment information. 56 | 57 | ```js 58 | magento.salesOrderShipment.info({ 59 | shipmentIncrementId: val 60 | }, callback); 61 | ``` 62 | 63 | ## [list](http://www.magentocommerce.com/api/soap/sales/salesOrderShipment/sales_order_shipment.list.html) 64 | 65 | Allows you to retrieve the list of order shipments. Additional filters can be applied. 66 | 67 | ```js 68 | magento.salesOrderShipment.list(callback); 69 | 70 | // or 71 | 72 | magento.salesOrderShipment.list({ 73 | filters: [ val, val, val ] 74 | }, callback); 75 | 76 | // or a single filter 77 | 78 | magento.salesOrderShipment.list({ 79 | filters: val 80 | }, callback); 81 | ``` 82 | 83 | ## [removeTrack](http://www.magentocommerce.com/api/soap/sales/salesOrderShipment/sales_order_shipment.removeTrack.html) 84 | 85 | Allows you to remove a tracking number from the order shipment. 86 | 87 | ```js 88 | magento.salesOrderShipment.removeTrack({ 89 | shipmentIncrementId: val, 90 | trackId: val 91 | }, callback); 92 | ``` -------------------------------------------------------------------------------- /readmes/store.md: -------------------------------------------------------------------------------- 1 | # Store 2 | 3 | ## [info](http://www.magentocommerce.com/api/soap/miscellaneous/store.info.html) 4 | 5 | Allows you to retrieve information about the required store view. 6 | 7 | ```js 8 | magento.store.info(callback); 9 | 10 | // or 11 | 12 | magento.store.info({ 13 | storeView: val 14 | }, callback); 15 | ``` 16 | 17 | ## [list](http://www.magentocommerce.com/api/soap/miscellaneous/store.list.html) 18 | 19 | Allows you to retrieve the list of store views. 20 | 21 | ```js 22 | magento.store.list(callback); 23 | ``` -------------------------------------------------------------------------------- /src/curry.js: -------------------------------------------------------------------------------- 1 | // globals 2 | var slice = Array.prototype.slice; 3 | 4 | // delicious curry 5 | function curry(fn) { 6 | var args = slice.call(arguments, 1); 7 | 8 | return function() { 9 | // keeping the 'this' of this function, which will be useful for prototype methods 10 | return fn.apply(this, args.concat(slice.call(arguments))); 11 | }; 12 | } 13 | 14 | module.exports = curry; 15 | -------------------------------------------------------------------------------- /src/error.js: -------------------------------------------------------------------------------- 1 | /** 2 | Custom Magento error 3 | Inspiration: http://www.devthought.com/2011/12/22/a-string-is-not-an-error/ 4 | 5 | Examples: 6 | new PMKError('Error Message'); 7 | new PMKError('Error Message', err); 8 | new PMKError('Error Message', err, { key: val }); 9 | new PMKError('Error Message', { key: val }); 10 | 11 | If creating an error instance with a string, note that the stack trace will be that of where the error was initialized 12 | If extending a native error (by passing it as second argument) then trace will be accurate, keys copied over, and original message & name will be copied to the 'original' attribute 13 | If extending a non-native error (string or object) then the result will be similar to the first case, but the 'original' attribute will be equal to the non-native error 14 | 15 | @param {String} msg The relevant error message 16 | @param {Error|String|Object} [original] The original error being extended 17 | */ 18 | function MagentoError(msg) { 19 | var key; 20 | 21 | Error.call(this); 22 | 23 | for (var i = 1, l = arguments.length; i < l; i++) { 24 | extendError(this, arguments[i]); 25 | } 26 | 27 | if (!this.original) { 28 | Error.captureStackTrace(this, arguments.callee); 29 | } 30 | 31 | this.name = 'Magento Error', 32 | this.message = typeof msg === 'string' ? msg : 'An error occurred'; 33 | } 34 | MagentoError.prototype.__proto__ = Error.prototype; 35 | 36 | MagentoError.prototype.toString = function() { 37 | return JSON.stringify(this); 38 | }; 39 | 40 | function extendError(err, additions) { 41 | for (var key in additions) { 42 | err[key] = additions[key]; 43 | } 44 | 45 | if (additions instanceof Error) { 46 | err.original = { 47 | message: additions.message, 48 | name: additions.name 49 | }; 50 | } 51 | } 52 | 53 | module.exports = MagentoError; 54 | -------------------------------------------------------------------------------- /src/magento.js: -------------------------------------------------------------------------------- 1 | // external dependencies 2 | var xmlrpc = require('xmlrpc'); 3 | var events = require('events'); 4 | var util = require('util'); 5 | 6 | // internal dependencies 7 | var MagentoError = require('./error.js'); 8 | 9 | // globals 10 | var slice = Array.prototype.slice; 11 | var resources = { 12 | catalogCategory: './resources/catalog_category.js', 13 | catalogCategoryAttribute: './resources/catalog_category_attribute.js', 14 | catalogProduct: './resources/catalog_product.js', 15 | catalogProductAttribute: './resources/catalog_product_attribute.js', 16 | catalogProductAttributeMedia: './resources/catalog_product_attribute_media.js', 17 | catalogProductAttributeSet: './resources/catalog_product_attribute_set.js', 18 | catalogProductCustomOption: './resources/catalog_product_custom_option.js', 19 | catalogProductCustomOptionValue: './resources/catalog_product_custom_option_value.js', 20 | catalogProductDownloadableLink: './resources/catalog_product_downloadable_link.js', 21 | catalogProductLink: './resources/catalog_product_link.js', 22 | catalogProductTag: './resources/catalog_product_tag.js', 23 | catalogProductTierPrice: './resources/catalog_product_tier_price.js', 24 | catalogProductType: './resources/catalog_product_type.js', 25 | catalogInventoryStockItem: './resources/catalogInventory_stock_item.js', 26 | checkoutCart: './resources/checkout_cart.js', 27 | checkoutCartCoupon: './resources/checkout_cart_coupon.js', 28 | checkoutCartCustomer: './resources/checkout_cart_customer.js', 29 | checkoutCartPayment: './resources/checkout_cart_payment.js', 30 | checkoutCartProduct: './resources/checkout_cart_product.js', 31 | checkoutCartShipping: './resources/checkout_cart_shipping.js', 32 | core: './resources/core.js', 33 | customer: './resources/customer.js', 34 | customerAddress: './resources/customer_address.js', 35 | customerGroup: './resources/customer_group.js', 36 | directoryCountry: './resources/directory_country.js', 37 | directoryRegion: './resources/directory_region.js', 38 | salesOrder: './resources/sales_order.js', 39 | salesOrderCreditMemo: './resources/sales_order_credit_memo.js', 40 | salesOrderInvoice: './resources/sales_order_invoice.js', 41 | salesOrderShipment: './resources/sales_order_shipment.js', 42 | store: './resources/store.js' 43 | }; 44 | var mandatory = {}; 45 | var configDefaults = { 46 | host: mandatory, 47 | port: 80, 48 | path: mandatory, 49 | login: mandatory, 50 | pass: mandatory, 51 | parallelLimit: Infinity 52 | }; 53 | 54 | /** 55 | Constructor method 56 | 57 | @param {Object} config Configuration for magento soap api 58 | @param {String} config.path API path, most likely '/api/xmlrpc/' 59 | @param {Number} [config.port] API port, defaults to 80 60 | @param {String} config.host Host for API 61 | @param {Number} [config.parallelLimit] How many requests to make in parallel, defaults to Infinity 62 | @param {String} config.login Login username 63 | @param {String} config.pass Login password 64 | */ 65 | function Magento(config) { 66 | var self = this; 67 | var magentoConfig = {}; 68 | var key; 69 | 70 | // validating config & setting up config object 71 | for (key in configDefaults) { 72 | if (configDefaults[key] === mandatory && !config[key]) { 73 | throw new MagentoError('Mandatory config attribute, ' + key + ', not set'); 74 | } else { 75 | magentoConfig[key] = config[key] !== undefined ? config[key] : configDefaults[key]; 76 | } 77 | } 78 | 79 | this.config = magentoConfig; 80 | this.client = xmlrpc.createClient(this.config); 81 | this.queue = []; 82 | this.queue.running = 0; 83 | this.queue.parallelLimit = this.config.parallelLimit; 84 | 85 | // initializing resources 86 | for (key in resources) { 87 | this[key] = new (require(resources[key]))(); 88 | 89 | // 'method' listener, for making a request 90 | this[key].on('method', function() { 91 | var args = slice.call(arguments); 92 | args[0] = this.prefix ? this.prefix + args[0] : args[0]; 93 | self.method.apply(self, args); 94 | }.bind(this[key])); 95 | 96 | // error listener 97 | this[key].on('error', function(err, callback) { 98 | err.resource = this.prefix; 99 | callback(err); 100 | }); 101 | } 102 | 103 | this.sessionId = null; 104 | this.prevSessionId = null; 105 | 106 | return this; 107 | } 108 | util.inherits(Magento, events.EventEmitter); 109 | 110 | Magento.prototype.method = function(method, args /* = optional arr */, callback) { 111 | var self = this; 112 | var callArr; 113 | 114 | if (arguments.length < 2 || arguments.length > 3) { 115 | throw new MagentoError('Wrong arguments passed to Magento.method'); 116 | } 117 | 118 | callArr = [ this.sessionId, method ]; 119 | 120 | if (arguments.length === 2) { 121 | callback = args, 122 | args = undefined; 123 | } else { 124 | if (!Array.isArray(args)) { 125 | args = [ args ]; 126 | } 127 | callArr.push(args); 128 | } 129 | 130 | // queueing 131 | return this.queueMethod(method, callArr, callback); 132 | }; 133 | 134 | Magento.prototype.queueMethod = function() { 135 | this.queue.push(slice.call(arguments)); 136 | return this.processQueue(); 137 | }; 138 | 139 | Magento.prototype.processQueue = function() { 140 | var current; 141 | 142 | while ( 143 | this.queue.running < this.queue.parallelLimit && 144 | (current = this.queue.shift()) && 145 | ++this.queue.running 146 | ) { 147 | this.methodApply.apply(this, current); 148 | } 149 | 150 | return this; 151 | }; 152 | 153 | Magento.prototype.methodApply = function(method, callArr, callback) { 154 | var self = this; 155 | 156 | this.client.methodCall('call', callArr, function(err) { 157 | --self.queue.running; 158 | self.processQueue(); 159 | 160 | if (err) { 161 | callback(new MagentoError(err.faultString ? err.faultString : 'An error occurred while calling ' + method, err)); 162 | return; 163 | } 164 | 165 | callback.apply(self, arguments); 166 | }); 167 | 168 | return this; 169 | }; 170 | 171 | Magento.prototype.login = function(callback) { 172 | var self = this; 173 | 174 | this.client.methodCall('login', [ this.config.login, this.config.pass ], function(err, sessId) { 175 | if (err) { 176 | callback(new MagentoError('An error occurred at login', err)); 177 | return; 178 | } 179 | 180 | self.sessionId = sessId; 181 | callback(null, sessId); 182 | }); 183 | 184 | return this; 185 | }; 186 | 187 | Magento.prototype.changeSession = function(sessId) { 188 | this.prevSessId = this.sessionId; 189 | this.sessionId = sessId; 190 | 191 | return this; 192 | }; 193 | 194 | module.exports = Magento; 195 | -------------------------------------------------------------------------------- /src/prototype_base.js: -------------------------------------------------------------------------------- 1 | // internal dependencies 2 | var MagentoError = require('./error.js'); 3 | 4 | // globals 5 | var slice = Array.prototype.slice; 6 | 7 | // base prototype function, used for all the prototypes 8 | function prototypeBase(method, options /*, [arg1, [arg2, ]], callback */) { 9 | var funcArgs = slice.call(arguments, 2); 10 | var callback = funcArgs.pop(); // assuming callback 11 | var keys, k, i, l; 12 | var args, params, paramsArr; 13 | var mandatory, optional; 14 | var err; 15 | 16 | if (funcArgs.length > 1) { 17 | this.emit('error', new MagentoError('too many arguments passed'), callback); 18 | return this; 19 | } 20 | 21 | params = funcArgs[0] || {}; 22 | keys = Object.keys(params); 23 | 24 | mandatory = options.mandatory ? options.mandatory.split(',') : false, 25 | optional = options.optional ? options.optional.split(',') : false; 26 | 27 | if (mandatory) { 28 | for (i = 0, l = mandatory.length; i < l; i++) { 29 | if (!params[ mandatory[i] ]) { 30 | err = new MagentoError('missing value for "' + mandatory[i] + '"', params); 31 | err.method = method; 32 | this.emit('error', err, callback); 33 | return this; 34 | } 35 | } 36 | } 37 | 38 | if (keys.length === 0) { 39 | this.emit('method', method, callback); 40 | } else { 41 | if (options.modifiers) { 42 | for (k in options.modifiers) { 43 | if (params[k]) { 44 | params[k] = options.modifiers[k](params[k]); 45 | } 46 | } 47 | } 48 | 49 | // params must now become an array 50 | paramsArr = [], 51 | keys = (mandatory || []).concat(optional || []), 52 | i = 0, l = keys.length; 53 | 54 | for (; i < l; i++) { 55 | if (!params[keys[i]]) { 56 | continue; 57 | } 58 | 59 | paramsArr.push(params[ keys[i] ]); 60 | } 61 | 62 | this.emit('method', method, paramsArr, callback); 63 | } 64 | } 65 | 66 | module.exports = prototypeBase; 67 | -------------------------------------------------------------------------------- /src/resources/catalogInventory_stock_item.js: -------------------------------------------------------------------------------- 1 | // external dependencies 2 | var events = require('events'); 3 | var util = require('util'); 4 | 5 | // internal dependencies 6 | var prototypeBase = require('../prototype_base.js'); 7 | var curry = require('../curry.js'); 8 | 9 | /** 10 | Allows you to retrieve and update the stock data. 11 | */ 12 | function CatalogInventoryStockItem() { 13 | this.prefix = 'cataloginventory_stock_item.'; 14 | } 15 | util.inherits(CatalogInventoryStockItem, events.EventEmitter); 16 | 17 | 18 | // prototypes we will be applying 19 | var protos = { 20 | /** 21 | Allows you to retrieve the list of stock data by product IDs. 22 | */ 23 | list: { 24 | mandatory: 'products', 25 | modifiers: { 26 | products: function(products) { 27 | // if a single product, wrap it in an array 28 | if (!Array.isArray(products)) { 29 | return [ products ]; 30 | } 31 | 32 | return products; 33 | } 34 | } 35 | }, 36 | 37 | /** 38 | Allows you to update the required product stock data. 39 | */ 40 | update: { 41 | mandatory: 'product,data' 42 | } 43 | }; 44 | 45 | // creating prototypes using curry func 46 | for (var key in protos) { 47 | CatalogInventoryStockItem.prototype[key] = curry(prototypeBase, key, protos[key]); 48 | } 49 | protos = undefined; 50 | 51 | module.exports = CatalogInventoryStockItem; 52 | -------------------------------------------------------------------------------- /src/resources/catalog_category.js: -------------------------------------------------------------------------------- 1 | // external dependencies 2 | var events = require('events'); 3 | var util = require('util'); 4 | 5 | // internal dependencies 6 | var prototypeBase = require('../prototype_base.js'); 7 | var curry = require('../curry.js'); 8 | 9 | /** 10 | Allows you to manage categories and how products are assigned to categories. 11 | */ 12 | function CatalogCategory() { 13 | this.prefix = 'catalog_category.'; 14 | } 15 | util.inherits(CatalogCategory, events.EventEmitter); 16 | 17 | 18 | // prototypes we will be applying 19 | var protos = { 20 | /** 21 | Retrieve the list of products assigned to a required category. 22 | */ 23 | assignedProducts: { 24 | mandatory: 'categoryId' 25 | }, 26 | 27 | /** 28 | Create a new category and return its ID. 29 | */ 30 | assignProduct: { 31 | mandatory: 'categoryId,product', 32 | optional: 'position' 33 | }, 34 | 35 | /** 36 | Create a new category and return its ID. 37 | */ 38 | create: { 39 | mandatory: 'categoryId,data', 40 | optional: 'storeView' 41 | }, 42 | 43 | /** 44 | Allows you to set/get the current store view. 45 | */ 46 | currentStore: { 47 | mandatory: 'storeView' 48 | }, 49 | 50 | /** 51 | Allows you to delete the required category. 52 | */ 53 | 'delete': { 54 | mandatory: 'categoryId' 55 | }, 56 | 57 | /** 58 | Allows you to retrieve information about the required category. 59 | */ 60 | info: { 61 | mandatory: 'categoryId', 62 | optional: 'storeView,attributes' 63 | }, 64 | 65 | /** 66 | Allows you to retrieve one level of categories by a website, a store view, or a parent category. 67 | */ 68 | level: { 69 | optional: 'website,storeView,parentCategory' 70 | }, 71 | 72 | /** 73 | Allows you to move the required category in the category tree. 74 | */ 75 | move: { 76 | mandatory: 'categoryId,parentId', 77 | optional: 'afterId' 78 | }, 79 | 80 | /** 81 | Allows you to remove the product assignment from the category. 82 | */ 83 | removeProduct: { 84 | mandatory: 'categoryId,productId' 85 | }, 86 | 87 | /** 88 | Allows you to retrieve the hierarchical tree of categories. 89 | */ 90 | tree: { 91 | optional: 'parentId,storeView' 92 | }, 93 | 94 | /** 95 | Update the required category. Note that you should specify only those parameters which you want to be updated. 96 | */ 97 | update: { 98 | mandatory: 'categoryId,categoryData', 99 | optional: 'storeView' 100 | }, 101 | 102 | /** 103 | Allows you to update the product assigned to a category. The product position is updated. 104 | */ 105 | updateProduct: { 106 | mandatory: 'categoryId,productId', 107 | optional: 'position' 108 | } 109 | }; 110 | 111 | // creating prototypes using curry func 112 | for (var key in protos) { 113 | CatalogCategory.prototype[key] = curry(prototypeBase, key, protos[key]); 114 | } 115 | protos = undefined; 116 | 117 | module.exports = CatalogCategory; 118 | -------------------------------------------------------------------------------- /src/resources/catalog_category_attribute.js: -------------------------------------------------------------------------------- 1 | // external dependencies 2 | var events = require('events'); 3 | var util = require('util'); 4 | 5 | // internal dependencies 6 | var prototypeBase = require('../prototype_base.js'); 7 | var curry = require('../curry.js'); 8 | 9 | /** 10 | Allows you to retrieve the list of category attributes and options 11 | */ 12 | function CatalogCategoryAttribute() { 13 | this.prefix = 'catalog_category_attribute.'; 14 | } 15 | util.inherits(CatalogCategoryAttribute, events.EventEmitter); 16 | 17 | 18 | // prototypes we will be applying 19 | var protos = { 20 | /** 21 | Allows you to set/get the current store view. 22 | */ 23 | currentStore: { 24 | mandatory: 'storeView' 25 | }, 26 | 27 | /** 28 | Allows you to retrieve the list of category attributes. 29 | */ 30 | list: true, 31 | 32 | /** 33 | Allows you to retrieve the attribute options. 34 | */ 35 | options: { 36 | mandatory: 'attributeId,storeView' 37 | } 38 | }; 39 | 40 | // creating prototypes using curry func 41 | for (var key in protos) { 42 | CatalogCategoryAttribute.prototype[key] = curry(prototypeBase, key, protos[key]); 43 | } 44 | protos = undefined; 45 | 46 | module.exports = CatalogCategoryAttribute; 47 | -------------------------------------------------------------------------------- /src/resources/catalog_product.js: -------------------------------------------------------------------------------- 1 | // external dependencies 2 | var events = require('events'); 3 | var util = require('util'); 4 | 5 | // internal dependencies 6 | var prototypeBase = require('../prototype_base.js'); 7 | var curry = require('../curry.js'); 8 | 9 | /** 10 | Allows you to manage products. 11 | */ 12 | function CatalogProduct() { 13 | this.prefix = 'catalog_product.'; 14 | } 15 | util.inherits(CatalogProduct, events.EventEmitter); 16 | 17 | 18 | // prototypes we will be applying 19 | var protos = { 20 | /** 21 | Allows you to create a new product and return ID of the created product. 22 | */ 23 | create: { 24 | mandatory: 'type,set,sku,data' 25 | }, 26 | 27 | /** 28 | Allows you to set/get the current store view. 29 | */ 30 | currentStore: { 31 | optional: 'view' 32 | }, 33 | 34 | /** 35 | Allows you to delete the required product. 36 | */ 37 | 'delete': { 38 | mandatory: 'id' 39 | }, 40 | 41 | /** 42 | Allows you to get the product special price data. 43 | */ 44 | getSpecialPrice: { 45 | mandatory: 'id' 46 | }, 47 | 48 | /** 49 | Allows you to retrieve information about the required product. 50 | */ 51 | info: { 52 | mandatory: 'id', 53 | optional: 'storeView' 54 | }, 55 | 56 | /** 57 | Allows you to retrieve the list of products. 58 | */ 59 | list: { 60 | optional: 'filters' 61 | }, 62 | 63 | /** 64 | Get the list of additional attributes. Additional attributes are attributes that are not in the default set of attributes. 65 | */ 66 | listOfAdditionalAttributes: { 67 | mandatory: 'prodType,attributeSetId' 68 | }, 69 | 70 | /** 71 | Allows you to set the product special price. 72 | */ 73 | setSpecialPrice: { 74 | mandatory: 'id,specialPrice,from,to', 75 | optional: 'storeView', 76 | modifiers: { 77 | from: dateToISO8601Time, 78 | to: dateToISO8601Time 79 | } 80 | }, 81 | 82 | /** 83 | Allows you to update the required product. Note that you should specify only those parameters which you want to be updated. 84 | */ 85 | update: { 86 | mandatory: 'id,data', 87 | optional: 'storeView' 88 | } 89 | }; 90 | 91 | // function to turn a native date object into something like '2013-07-08 23:57:28' 92 | var iso8601Match = /^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2}).*$/; 93 | function dateToISO8601Time(d) { 94 | return d.toISOString().replace(iso8601Match, '$1 $2'); 95 | } 96 | 97 | // creating prototypes using curry func 98 | for (var key in protos) { 99 | CatalogProduct.prototype[key] = curry(prototypeBase, key, protos[key]); 100 | } 101 | protos = undefined; 102 | 103 | module.exports = CatalogProduct; 104 | -------------------------------------------------------------------------------- /src/resources/catalog_product_attribute.js: -------------------------------------------------------------------------------- 1 | // external dependencies 2 | var events = require('events'); 3 | var util = require('util'); 4 | 5 | // internal dependencies 6 | var prototypeBase = require('../prototype_base.js'); 7 | var curry = require('../curry.js'); 8 | 9 | /** 10 | Allows you to retrieve category attributes and options. 11 | */ 12 | function CatalogProductAttribute() { 13 | this.prefix = 'product_attribute.'; 14 | } 15 | util.inherits(CatalogProductAttribute, events.EventEmitter); 16 | 17 | 18 | // prototypes we will be applying 19 | var protos = { 20 | /** 21 | Allows you to add a new option for attributes with selectable fields. 22 | */ 23 | addOption: { 24 | mandatory: 'attribute,data' 25 | }, 26 | 27 | /** 28 | Allows you to create a new product attribute. 29 | */ 30 | create: { 31 | mandatory: 'data' 32 | }, 33 | 34 | /** 35 | Allows you to set/get the current store view. 36 | */ 37 | currentStore: { 38 | optional: 'storeView' 39 | }, 40 | 41 | /** 42 | Allows you to get full information about a required attribute with the list of options. 43 | */ 44 | info: { 45 | mandatory: 'attribute' 46 | }, 47 | 48 | /** 49 | Allows you to retrieve the list of product attributes. 50 | */ 51 | list: { 52 | mandatory: 'setId' 53 | }, 54 | 55 | /** 56 | Allows you to retrieve the product attribute options. 57 | */ 58 | options: { 59 | mandatory: 'attributeId', 60 | optional: 'storeView' 61 | }, 62 | 63 | /** 64 | Allows you to remove the required attribute from a product. 65 | */ 66 | remove: { 67 | mandatory: 'attribute' 68 | }, 69 | 70 | /** 71 | Allows you to remove the option for an attribute. 72 | */ 73 | removeOption: { 74 | mandatory: 'attribute,optionId' 75 | }, 76 | 77 | /** 78 | Allows you to retrieve the list of possible attribute types. 79 | */ 80 | types: true, 81 | 82 | /** 83 | Allows you to update the required attribute. 84 | */ 85 | update: { 86 | mandatory: 'attribute,data' 87 | } 88 | }; 89 | 90 | // creating prototypes using curry func 91 | for (var key in protos) { 92 | CatalogProductAttribute.prototype[key] = curry(prototypeBase, key, protos[key]); 93 | } 94 | protos = undefined; 95 | 96 | module.exports = CatalogProductAttribute; 97 | -------------------------------------------------------------------------------- /src/resources/catalog_product_attribute_media.js: -------------------------------------------------------------------------------- 1 | // external dependencies 2 | var events = require('events'); 3 | var util = require('util'); 4 | 5 | // internal dependencies 6 | var prototypeBase = require('../prototype_base.js'); 7 | var curry = require('../curry.js'); 8 | 9 | /** 10 | Allows you to manage product images. 11 | */ 12 | function CatalogProductAttributeMedia() { 13 | this.prefix = 'catalog_product_attribute_media.'; 14 | } 15 | util.inherits(CatalogProductAttributeMedia, events.EventEmitter); 16 | 17 | 18 | // prototypes we will be applying 19 | var protos = { 20 | /** 21 | Allows you to upload a new product image. 22 | */ 23 | create: { 24 | mandatory: 'product,data', 25 | optional: 'storeView' 26 | }, 27 | 28 | /** 29 | Allows you to set/get the current store view. 30 | */ 31 | currentStore: { 32 | optional: 'storeView' 33 | }, 34 | 35 | /** 36 | Allows you to retrieve information about the specified product image. 37 | */ 38 | info: { 39 | mandatory: 'info,file', 40 | optional: 'storeView' 41 | }, 42 | 43 | /** 44 | Allows you to retrieve the list of product images. 45 | */ 46 | list: { 47 | mandatory: 'product', 48 | optional: 'storeView' 49 | }, 50 | 51 | /** 52 | Allows you to remove the image from a product. 53 | */ 54 | remove: { 55 | mandatory: 'product,file' 56 | }, 57 | 58 | /** 59 | Allows you to retrieve product image types including standard image, small_image, thumbnail, etc. 60 | Note that if the product attribute set contains attributes of the Media Image type (Catalog Input Type for Store Owner > Media Image), 61 | it will also be returned in the response. 62 | */ 63 | types: { 64 | mandatory: 'setId' 65 | }, 66 | 67 | /** 68 | Allows you to update the product image. 69 | */ 70 | update: { 71 | mandatory: 'product,file,data,storeView' 72 | } 73 | }; 74 | 75 | // creating prototypes using curry func 76 | for (var key in protos) { 77 | CatalogProductAttributeMedia.prototype[key] = curry(prototypeBase, key, protos[key]); 78 | } 79 | protos = undefined; 80 | 81 | module.exports = CatalogProductAttributeMedia; 82 | -------------------------------------------------------------------------------- /src/resources/catalog_product_attribute_set.js: -------------------------------------------------------------------------------- 1 | // external dependencies 2 | var events = require('events'); 3 | var util = require('util'); 4 | 5 | // internal dependencies 6 | var prototypeBase = require('../prototype_base.js'); 7 | var curry = require('../curry.js'); 8 | 9 | /** 10 | Allows you to retrieve product attribute sets. 11 | */ 12 | function CatalogProductAttributeSet() { 13 | this.prefix = 'catalog_product_attribute_set.'; 14 | } 15 | util.inherits(CatalogProductAttributeSet, events.EventEmitter); 16 | 17 | 18 | // prototypes we will be applying 19 | var protos = { 20 | /** 21 | Allows you to add an existing attribute to an attribute set. 22 | */ 23 | attributeAdd: { 24 | mandatory: 'attributeId,attributeSetId', 25 | optional: 'attributeGroupId,sortOrder' 26 | }, 27 | 28 | /** 29 | Allows you to remove an existing attribute from an attribute set. 30 | */ 31 | attributeRemove: { 32 | mandatory: 'attributeId,attributeSetId' 33 | }, 34 | 35 | /** 36 | Allows you to create a new attribute set based on another attribute set. 37 | */ 38 | create: { 39 | mandatory: 'attributeSetName,skeletonSetId' 40 | }, 41 | 42 | /** 43 | Allows you to add a new group for attributes to the attribute set. 44 | */ 45 | groupAdd: { 46 | mandatory: 'attributeSetId,groupName' 47 | }, 48 | 49 | /** 50 | Allows you to remove a group from an attribute set. 51 | */ 52 | groupRemove: { 53 | mandatory: 'attributeGroupId' 54 | }, 55 | 56 | /** 57 | Allows you to rename a group in the attribute set. 58 | */ 59 | groupRename: { 60 | mandatory: 'groupId,groupName' 61 | }, 62 | 63 | /** 64 | Allows you to retrieve the list of product attribute sets. 65 | */ 66 | list: true, 67 | 68 | /** 69 | Allows you to remove an existing attribute set. 70 | */ 71 | remove: { 72 | mandatory: 'attributeSetId', 73 | optional: 'forceProductsRemove' 74 | } 75 | }; 76 | 77 | // creating prototypes using curry func 78 | for (var key in protos) { 79 | CatalogProductAttributeSet.prototype[key] = curry(prototypeBase, key, protos[key]); 80 | } 81 | protos = undefined; 82 | 83 | module.exports = CatalogProductAttributeSet; 84 | -------------------------------------------------------------------------------- /src/resources/catalog_product_custom_option.js: -------------------------------------------------------------------------------- 1 | // external dependencies 2 | var events = require('events'); 3 | var util = require('util'); 4 | 5 | // internal dependencies 6 | var prototypeBase = require('../prototype_base.js'); 7 | var curry = require('../curry.js'); 8 | 9 | function CatalogProductCustomOption() { 10 | this.prefix = 'product_custom_option.'; 11 | } 12 | util.inherits(CatalogProductCustomOption, events.EventEmitter); 13 | 14 | 15 | // prototypes we will be applying 16 | var protos = { 17 | /** 18 | Allows you to add a new custom option for a product. 19 | */ 20 | add: { 21 | mandatory: 'productId,data', 22 | optional: 'storeView' 23 | }, 24 | 25 | /** 26 | Allows you to retrieve full information about the custom option in a product. 27 | */ 28 | info: { 29 | mandatory: 'optionId', 30 | optional: 'storeView' 31 | }, 32 | 33 | /** 34 | Allows you to retrieve the list of custom options for a specific product. 35 | */ 36 | list: { 37 | mandatory: 'productId', 38 | optional: 'storeView' 39 | }, 40 | 41 | /** 42 | Allows you to remove a custom option from the product. 43 | */ 44 | remove: { 45 | mandatory: 'optionId' 46 | }, 47 | 48 | /** 49 | Allows you to retrieve the list of available custom option types. 50 | */ 51 | types: true, 52 | 53 | /** 54 | Allows you to update the required product custom option. 55 | */ 56 | update: { 57 | mandatory: 'optionId,data', 58 | optional: 'storeView' 59 | } 60 | }; 61 | 62 | // creating prototypes using curry func 63 | for (var key in protos) { 64 | CatalogProductCustomOption.prototype[key] = curry(prototypeBase, key, protos[key]); 65 | } 66 | protos = undefined; 67 | 68 | module.exports = CatalogProductCustomOption; 69 | -------------------------------------------------------------------------------- /src/resources/catalog_product_custom_option_value.js: -------------------------------------------------------------------------------- 1 | // external dependencies 2 | var events = require('events'); 3 | var util = require('util'); 4 | 5 | // internal dependencies 6 | var prototypeBase = require('../prototype_base.js'); 7 | var curry = require('../curry.js'); 8 | 9 | function CatalogProductCustomOptionValue() { 10 | this.prefix = 'product_custom_option_value.'; 11 | } 12 | util.inherits(CatalogProductCustomOptionValue, events.EventEmitter); 13 | 14 | 15 | // prototypes we will be applying 16 | var protos = { 17 | /** 18 | Allows you to add a new custom option value to a custom option. 19 | Note that the custom option value can be added only to the option with the Select Input Type. 20 | */ 21 | add: { 22 | mandatory: 'optionId,data', 23 | optional: 'storeView' 24 | }, 25 | 26 | /** 27 | Allows you to retrieve full information about the specified product custom option value. 28 | */ 29 | info: { 30 | mandatory: 'valueId', 31 | optional: 'storeView' 32 | }, 33 | 34 | /** 35 | Allows you to retrieve the list of product custom option values. 36 | Note that the method is available only for the option Select Input Type. 37 | */ 38 | list: { 39 | mandatory: 'optionId', 40 | optional: 'storeView' 41 | }, 42 | 43 | /** 44 | Allows you to remove the custom option value from a product. 45 | */ 46 | remove: { 47 | mandatory: 'valueId' 48 | }, 49 | 50 | /** 51 | Allows you to update the product custom option value. 52 | */ 53 | update: { 54 | mandatory: 'valueId,data', 55 | optional: 'storeView' 56 | } 57 | }; 58 | 59 | // creating prototypes using curry func 60 | for (var key in protos) { 61 | CatalogProductCustomOptionValue.prototype[key] = curry(prototypeBase, key, protos[key]); 62 | } 63 | protos = undefined; 64 | 65 | module.exports = CatalogProductCustomOptionValue; 66 | -------------------------------------------------------------------------------- /src/resources/catalog_product_downloadable_link.js: -------------------------------------------------------------------------------- 1 | // external dependencies 2 | var events = require('events'); 3 | var util = require('util'); 4 | 5 | // internal dependencies 6 | var prototypeBase = require('../prototype_base.js'); 7 | var curry = require('../curry.js'); 8 | 9 | function CatalogProductDownloadableLink() { 10 | this.prefix = 'product_downloadable_link.'; 11 | } 12 | util.inherits(CatalogProductDownloadableLink, events.EventEmitter); 13 | 14 | 15 | // prototypes we will be applying 16 | var protos = { 17 | /** 18 | Allows you to add a new link to a downloadable product. 19 | */ 20 | add: { 21 | mandatory: 'productId,resource,resourceType', 22 | optional: 'storeView' 23 | }, 24 | 25 | /** 26 | Allows you to retrieve a list of links of a downloadable product. 27 | */ 28 | list: { 29 | mandatory: 'productId', 30 | optional: 'storeView' 31 | }, 32 | 33 | /** 34 | Allows you to remove a link/sample from a downloadable product. 35 | */ 36 | remove: { 37 | mandatory: 'linkId' 38 | } 39 | }; 40 | 41 | // creating prototypes using curry func 42 | for (var key in protos) { 43 | CatalogProductDownloadableLink.prototype[key] = curry(prototypeBase, key, protos[key]); 44 | } 45 | protos = undefined; 46 | 47 | module.exports = CatalogProductDownloadableLink; 48 | -------------------------------------------------------------------------------- /src/resources/catalog_product_link.js: -------------------------------------------------------------------------------- 1 | // external dependencies 2 | var events = require('events'); 3 | var util = require('util'); 4 | 5 | // internal dependencies 6 | var prototypeBase = require('../prototype_base.js'); 7 | var curry = require('../curry.js'); 8 | 9 | /** 10 | Allows you to manage links for products, including related, cross-sells, up-sells, and grouped. 11 | */ 12 | function CatalogProductLink() { 13 | this.prefix = 'catalog_product_link.'; 14 | } 15 | util.inherits(CatalogProductLink, events.EventEmitter); 16 | 17 | 18 | // prototypes we will be applying 19 | var protos = { 20 | /** 21 | Allows you to assign a product link (related, cross-sell, up-sell, or grouped) to another product. 22 | */ 23 | assign: { 24 | mandatory: 'type,product,linkedProduct,data' 25 | }, 26 | 27 | /** 28 | Allows you to retrieve the product link type attributes. 29 | */ 30 | attributes: { 31 | mandatory: 'type' 32 | }, 33 | 34 | /** 35 | Allows you to retrieve the list of linked products for a specific product. 36 | */ 37 | list: { 38 | mandatory: 'type,product' 39 | }, 40 | 41 | /** 42 | Allows you to remove the product link from a specific product. 43 | */ 44 | remove: { 45 | mandatory: 'type,product,linkedProduct' 46 | }, 47 | 48 | /** 49 | Allows you to retrieve the list of product link types. 50 | */ 51 | types: true, 52 | 53 | /** 54 | Allows you to update the product link. 55 | */ 56 | update: { 57 | mandatory: 'type,product,linkedProduct,data' 58 | } 59 | }; 60 | 61 | // creating prototypes using curry func 62 | for (var key in protos) { 63 | CatalogProductLink.prototype[key] = curry(prototypeBase, key, protos[key]); 64 | } 65 | protos = undefined; 66 | 67 | module.exports = CatalogProductLink; 68 | -------------------------------------------------------------------------------- /src/resources/catalog_product_tag.js: -------------------------------------------------------------------------------- 1 | // external dependencies 2 | var events = require('events'); 3 | var util = require('util'); 4 | 5 | // internal dependencies 6 | var prototypeBase = require('../prototype_base.js'); 7 | var curry = require('../curry.js'); 8 | 9 | function CatalogProductTag() { 10 | this.prefix = 'catalog_product_tag.'; 11 | } 12 | util.inherits(CatalogProductTag, events.EventEmitter); 13 | 14 | 15 | // prototypes we will be applying 16 | var protos = { 17 | /** 18 | Allows you to add one or more tags to a product. 19 | */ 20 | add: { 21 | mandatory: 'data' 22 | }, 23 | 24 | /** 25 | Allows you to retrieve information about the required product tag. 26 | */ 27 | info: { 28 | mandatory: 'tagId,storeView' 29 | }, 30 | 31 | /** 32 | Allows you to retrieve the list of tags for a specific product. 33 | */ 34 | list: { 35 | mandatory: 'productId,storeView' 36 | }, 37 | 38 | /** 39 | Allows you to remove an existing product tag. 40 | */ 41 | remove: { 42 | mandatory: 'tagId' 43 | }, 44 | 45 | /** 46 | Allows you to update information about an existing product tag. 47 | */ 48 | update: { 49 | mandatory: 'tagId,data', 50 | optional: 'storeView' 51 | } 52 | }; 53 | 54 | // creating prototypes using curry func 55 | for (var key in protos) { 56 | CatalogProductTag.prototype[key] = curry(prototypeBase, key, protos[key]); 57 | } 58 | protos = undefined; 59 | 60 | module.exports = CatalogProductTag; 61 | -------------------------------------------------------------------------------- /src/resources/catalog_product_tier_price.js: -------------------------------------------------------------------------------- 1 | // external dependencies 2 | var events = require('events'); 3 | var util = require('util'); 4 | 5 | // internal dependencies 6 | var prototypeBase = require('../prototype_base.js'); 7 | var curry = require('../curry.js'); 8 | 9 | /** 10 | Allows you to retrieve and update product tier prices. 11 | */ 12 | function CatalogProductTierPrice() { 13 | this.prefix = 'catalog_product_attribute_tier_price.'; 14 | } 15 | util.inherits(CatalogProductTierPrice, events.EventEmitter); 16 | 17 | 18 | // prototypes we will be applying 19 | var protos = { 20 | /** 21 | Allows you to retrieve information about product tier prices. 22 | */ 23 | info: { 24 | mandatory: 'product' 25 | }, 26 | 27 | /** 28 | Allows you to update the product tier prices. 29 | */ 30 | update: { 31 | mandatory: 'product,tierPrices' 32 | } 33 | }; 34 | 35 | // creating prototypes using curry func 36 | for (var key in protos) { 37 | CatalogProductTierPrice.prototype[key] = curry(prototypeBase, key, protos[key]); 38 | } 39 | protos = undefined; 40 | 41 | module.exports = CatalogProductTierPrice; 42 | -------------------------------------------------------------------------------- /src/resources/catalog_product_type.js: -------------------------------------------------------------------------------- 1 | // external dependencies 2 | var events = require('events'); 3 | var util = require('util'); 4 | 5 | // internal dependencies 6 | var prototypeBase = require('../prototype_base.js'); 7 | var curry = require('../curry.js'); 8 | 9 | /** 10 | Allows you to retrieve product types. 11 | */ 12 | function CatalogProductType() { 13 | this.prefix = 'catalog_product_type.'; 14 | } 15 | util.inherits(CatalogProductType, events.EventEmitter); 16 | 17 | 18 | // prototypes we will be applying 19 | var protos = { 20 | /** 21 | Allows you to retrieve the list of product types. 22 | */ 23 | list: true 24 | }; 25 | 26 | // creating prototypes using curry func 27 | for (var key in protos) { 28 | CatalogProductType.prototype[key] = curry(prototypeBase, key, protos[key]); 29 | } 30 | protos = undefined; 31 | 32 | module.exports = CatalogProductType; 33 | -------------------------------------------------------------------------------- /src/resources/checkout_cart.js: -------------------------------------------------------------------------------- 1 | // external dependencies 2 | var events = require('events'); 3 | var util = require('util'); 4 | 5 | // internal dependencies 6 | var prototypeBase = require('../prototype_base.js'); 7 | var curry = require('../curry.js'); 8 | 9 | /** 10 | Allows you to manage shopping carts. 11 | */ 12 | function CheckoutCart() { 13 | this.prefix = 'cart.'; 14 | } 15 | util.inherits(CheckoutCart, events.EventEmitter); 16 | 17 | 18 | // prototypes we will be applying 19 | var protos = { 20 | /** 21 | Allows you to create an empty shopping cart. 22 | */ 23 | create: { 24 | optional: 'storeView' 25 | }, 26 | 27 | /** 28 | Allows you to retrieve full information about the shopping cart (quote). 29 | */ 30 | info: { 31 | mandatory: 'quoteId', 32 | optional: 'storeView' 33 | }, 34 | 35 | /** 36 | Allows you to retrieve the website license agreement for the quote according to the website (store). 37 | */ 38 | license: { 39 | mandatory: 'quoteId', 40 | optional: 'storeView' 41 | }, 42 | 43 | /** 44 | Allows you to create an order from a shopping cart (quote). 45 | Before placing the order, you need to add the customer, customer address, shipping and payment methods. 46 | */ 47 | order: { 48 | mandatory: 'quoteId', 49 | optional: 'storeView,agreements' 50 | }, 51 | 52 | /** 53 | Allows you to retrieve total prices for a shopping cart (quote). 54 | */ 55 | totals: { 56 | mandatory: 'quoteId', 57 | optional: 'storeView' 58 | } 59 | }; 60 | 61 | // creating prototypes using curry func 62 | for (var key in protos) { 63 | CheckoutCart.prototype[key] = curry(prototypeBase, key, protos[key]); 64 | } 65 | protos = undefined; 66 | 67 | module.exports = CheckoutCart; 68 | -------------------------------------------------------------------------------- /src/resources/checkout_cart_coupon.js: -------------------------------------------------------------------------------- 1 | // external dependencies 2 | var events = require('events'); 3 | var util = require('util'); 4 | 5 | // internal dependencies 6 | var prototypeBase = require('../prototype_base.js'); 7 | var curry = require('../curry.js'); 8 | 9 | /** 10 | Allows you to add and remove coupon codes for a shopping cart. 11 | */ 12 | function CheckoutCartCoupon() { 13 | this.prefix = 'cart_coupon.'; 14 | } 15 | util.inherits(CheckoutCartCoupon, events.EventEmitter); 16 | 17 | 18 | // prototypes we will be applying 19 | var protos = { 20 | /** 21 | Allows you to add a coupon code for a shopping cart (quote). The shopping cart must not be empty. 22 | */ 23 | add: { 24 | mandatory: 'quoteId,couponCode', 25 | optional: 'storeView' 26 | }, 27 | 28 | /** 29 | Allows you to remove a coupon code from a shopping cart (quote). 30 | */ 31 | remove: { 32 | mandatory: 'quoteId', 33 | optional: 'storeView' 34 | } 35 | }; 36 | 37 | // creating prototypes using curry func 38 | for (var key in protos) { 39 | CheckoutCartCoupon.prototype[key] = curry(prototypeBase, key, protos[key]); 40 | } 41 | protos = undefined; 42 | 43 | module.exports = CheckoutCartCoupon; 44 | -------------------------------------------------------------------------------- /src/resources/checkout_cart_customer.js: -------------------------------------------------------------------------------- 1 | // external dependencies 2 | var events = require('events'); 3 | var util = require('util'); 4 | 5 | // internal dependencies 6 | var prototypeBase = require('../prototype_base.js'); 7 | var curry = require('../curry.js'); 8 | 9 | /** 10 | Allows you to add customer information and addresses into a shopping cart. 11 | */ 12 | function CheckoutCartCustomer() { 13 | this.prefix = 'cart_customer.'; 14 | } 15 | util.inherits(CheckoutCartCustomer, events.EventEmitter); 16 | 17 | 18 | // prototypes we will be applying 19 | var protos = { 20 | /** 21 | Allows you to set the customer addresses in the shopping cart (quote). 22 | */ 23 | addresses: { 24 | mandatory: 'quoteId,customerAddressData', 25 | optional: 'store', 26 | modifiers: { 27 | customerAddressData: ensureArray 28 | } 29 | }, 30 | 31 | /** 32 | Allows you to add information about the customer to a shopping cart (quote). 33 | */ 34 | set: { 35 | mandatory: 'quoteId,customerData', 36 | optional: 'storeView', 37 | modifiers: { 38 | // customerData: ensureArray 39 | } 40 | } 41 | }; 42 | 43 | function ensureArray(val) { 44 | if (!Array.isArray(val)) { 45 | return [ val ]; 46 | } 47 | 48 | return val; 49 | } 50 | 51 | // creating prototypes using curry func 52 | for (var key in protos) { 53 | CheckoutCartCustomer.prototype[key] = curry(prototypeBase, key, protos[key]); 54 | } 55 | protos = undefined; 56 | 57 | module.exports = CheckoutCartCustomer; 58 | -------------------------------------------------------------------------------- /src/resources/checkout_cart_payment.js: -------------------------------------------------------------------------------- 1 | // external dependencies 2 | var events = require('events'); 3 | var util = require('util'); 4 | 5 | // internal dependencies 6 | var prototypeBase = require('../prototype_base.js'); 7 | var curry = require('../curry.js'); 8 | 9 | /** 10 | Allows you to retrieve and set payment methods for a shopping cart. 11 | */ 12 | function CheckoutCartPayment() { 13 | this.prefix = 'cart_payment.'; 14 | } 15 | util.inherits(CheckoutCartPayment, events.EventEmitter); 16 | 17 | 18 | // prototypes we will be applying 19 | var protos = { 20 | /** 21 | Allows you to retrieve a list of available payment methods for a shopping cart (quote). 22 | */ 23 | list: { 24 | mandatory: 'quoteId', 25 | optional: 'storeView' 26 | }, 27 | 28 | /** 29 | Allows you to set a payment method for a shopping cart (quote). 30 | */ 31 | method: { 32 | mandatory: 'quoteId,paymentData', 33 | optional: 'store', 34 | modifiers: { 35 | // to do: verify all array'ized 36 | /* paymentData: function(data) { 37 | // if data is not an array, wrap it in an array 38 | if (!Array.isArray(data)) { 39 | return [ data ]; 40 | } 41 | 42 | return data; 43 | } */ 44 | } 45 | } 46 | }; 47 | 48 | // creating prototypes using curry func 49 | for (var key in protos) { 50 | CheckoutCartPayment.prototype[key] = curry(prototypeBase, key, protos[key]); 51 | } 52 | protos = undefined; 53 | 54 | module.exports = CheckoutCartPayment; 55 | -------------------------------------------------------------------------------- /src/resources/checkout_cart_product.js: -------------------------------------------------------------------------------- 1 | // external dependencies 2 | var events = require('events'); 3 | var util = require('util'); 4 | 5 | // internal dependencies 6 | var prototypeBase = require('../prototype_base.js'); 7 | var curry = require('../curry.js'); 8 | 9 | /** 10 | Allows you to manage products in a shopping cart. 11 | */ 12 | function CheckoutCartProduct() { 13 | this.prefix = 'cart_product.'; 14 | } 15 | util.inherits(CheckoutCartProduct, events.EventEmitter); 16 | 17 | 18 | // prototypes we will be applying 19 | var protos = { 20 | /** 21 | Allows you to add one or more products to the shopping cart (quote). 22 | */ 23 | add: { 24 | mandatory: 'quoteId,products', 25 | optional: 'storeView', 26 | modifiers: { 27 | products: ensureArray 28 | } 29 | }, 30 | 31 | /** 32 | Allows you to retrieve the list of products in the shopping cart (quote). 33 | */ 34 | list: { 35 | mandatory: 'quoteId', 36 | optional: 'storeView' 37 | }, 38 | 39 | /** 40 | Allows you to move products from the current quote to a customer quote. 41 | */ 42 | moveToCustomerQuote: { 43 | mandatory: 'quoteId,productsData', 44 | optional: 'storeView', 45 | modifiers: { 46 | productsData: ensureArray 47 | } 48 | }, 49 | 50 | /** 51 | Allows you to remove one or several products from a shopping cart (quote). 52 | */ 53 | remove: { 54 | mandatory: 'quoteId,productsData', 55 | optional: 'storeView', 56 | modifiers: { 57 | productsData: ensureArray 58 | } 59 | }, 60 | 61 | /** 62 | Allows you to update one or several products in the shopping cart (quote). 63 | */ 64 | update: { 65 | mandatory: 'quoteId,productsData', 66 | optional: 'storeView', 67 | modifiers: { 68 | productsData: ensureArray 69 | } 70 | } 71 | }; 72 | 73 | function ensureArray(val) { 74 | if (!Array.isArray(val)) { 75 | return [ val ]; 76 | } 77 | 78 | return val; 79 | } 80 | 81 | // creating prototypes using curry func 82 | for (var key in protos) { 83 | CheckoutCartProduct.prototype[key] = curry(prototypeBase, key, protos[key]); 84 | } 85 | protos = undefined; 86 | 87 | module.exports = CheckoutCartProduct; 88 | -------------------------------------------------------------------------------- /src/resources/checkout_cart_shipping.js: -------------------------------------------------------------------------------- 1 | // external dependencies 2 | var events = require('events'); 3 | var util = require('util'); 4 | 5 | // internal dependencies 6 | var prototypeBase = require('../prototype_base.js'); 7 | var curry = require('../curry.js'); 8 | 9 | /** 10 | Allows you to manage products in a shopping cart. 11 | */ 12 | function CheckoutCartShipping() { 13 | this.prefix = 'cart_shipping.'; 14 | } 15 | util.inherits(CheckoutCartShipping, events.EventEmitter); 16 | 17 | 18 | // prototypes we will be applying 19 | var protos = { 20 | /** 21 | Allows you to retrieve the list of available shipping methods for a shopping cart (quote). 22 | */ 23 | list: { 24 | mandatory: 'quoteId', 25 | optional: 'storeView' 26 | }, 27 | 28 | /** 29 | Allows you to set a shipping method for a shopping cart (quote). 30 | */ 31 | method: { 32 | mandatory: 'quoteId,shippingMethod', 33 | optional: 'storeView' 34 | } 35 | }; 36 | 37 | // creating prototypes using curry func 38 | for (var key in protos) { 39 | CheckoutCartShipping.prototype[key] = curry(prototypeBase, key, protos[key]); 40 | } 41 | protos = undefined; 42 | 43 | module.exports = CheckoutCartShipping; 44 | -------------------------------------------------------------------------------- /src/resources/core.js: -------------------------------------------------------------------------------- 1 | // external dependencies 2 | var events = require('events'); 3 | var util = require('util'); 4 | 5 | // internal dependencies 6 | var prototypeBase = require('../prototype_base.js'); 7 | var curry = require('../curry.js'); 8 | 9 | /** 10 | Allows you to get information about the current Magento installation. 11 | */ 12 | function Core() { 13 | this.prefix = 'core_magento.'; 14 | } 15 | util.inherits(Core, events.EventEmitter); 16 | 17 | 18 | // prototypes we will be applying 19 | var protos = { 20 | /** 21 | Allows you to retrieve information about Magento version and edition. 22 | */ 23 | info: true 24 | }; 25 | 26 | // creating prototypes using curry func 27 | for (var key in protos) { 28 | Core.prototype[key] = curry(prototypeBase, key, protos[key]); 29 | } 30 | protos = undefined; 31 | 32 | module.exports = Core; 33 | -------------------------------------------------------------------------------- /src/resources/customer.js: -------------------------------------------------------------------------------- 1 | // external dependencies 2 | var events = require('events'); 3 | var util = require('util'); 4 | 5 | // internal dependencies 6 | var prototypeBase = require('../prototype_base.js'); 7 | var curry = require('../curry.js'); 8 | 9 | /** 10 | Allows you to create, retrieve, update, and delete data about customers. 11 | */ 12 | function Customer() { 13 | this.prefix = 'customer.'; 14 | } 15 | util.inherits(Customer, events.EventEmitter); 16 | 17 | 18 | // prototypes we will be applying 19 | var protos = { 20 | /** 21 | Create a new customer. 22 | */ 23 | create: { 24 | mandatory: 'customerData', 25 | modifiers: { 26 | // to do: figure out why this was causing an issue 27 | // customerData: ensureArray 28 | } 29 | }, 30 | 31 | /** 32 | Delete the required customer. 33 | */ 34 | 'delete': { 35 | mandatory: 'customerId' 36 | }, 37 | 38 | /** 39 | Retrieve information about the specified customer. 40 | */ 41 | info: { 42 | mandatory: 'customerId', 43 | optional: 'attributes', 44 | modifiers: { 45 | attributes: ensureArray 46 | } 47 | }, 48 | 49 | /** 50 | Allows you to retrieve the list of customers. 51 | */ 52 | list: { 53 | optional: 'filters', 54 | modifiers: { 55 | // filters: ensureArray 56 | } 57 | }, 58 | 59 | /** 60 | Update information about the required customer. 61 | Note that you need to pass only those arguments which you want to be updated. 62 | */ 63 | update: { 64 | mandatory: 'customerId,customerData', 65 | modifiers: { 66 | //customerData: ensureArray 67 | } 68 | } 69 | }; 70 | 71 | function ensureArray(val) { 72 | if (!Array.isArray(val)) { 73 | return [ val ]; 74 | } 75 | 76 | return val; 77 | } 78 | 79 | // creating prototypes using curry func 80 | for (var key in protos) { 81 | Customer.prototype[key] = curry(prototypeBase, key, protos[key]); 82 | } 83 | protos = undefined; 84 | 85 | module.exports = Customer; 86 | -------------------------------------------------------------------------------- /src/resources/customer_address.js: -------------------------------------------------------------------------------- 1 | // external dependencies 2 | var events = require('events'); 3 | var util = require('util'); 4 | 5 | // internal dependencies 6 | var prototypeBase = require('../prototype_base.js'); 7 | var curry = require('../curry.js'); 8 | 9 | /** 10 | Allows you to create, retrieve, update, and delete address data for a required customer. 11 | */ 12 | function CustomerAddress() { 13 | this.prefix = 'customer_address.'; 14 | } 15 | util.inherits(CustomerAddress, events.EventEmitter); 16 | 17 | 18 | // prototypes we will be applying 19 | var protos = { 20 | /** 21 | Create a new address for the customer. 22 | */ 23 | create: { 24 | mandatory: 'customerId,addressData', 25 | modifiers: { 26 | // to do: verify all ensureArray usecases 27 | // addressData: ensureArray 28 | } 29 | }, 30 | 31 | /** 32 | Delete the required customer address. 33 | */ 34 | 'delete': { 35 | mandatory: 'addressId' 36 | }, 37 | 38 | /** 39 | Retrieve information about the required customer address. 40 | */ 41 | info: { 42 | mandatory: 'addressId' 43 | }, 44 | 45 | /** 46 | Retrieve the list of customer addresses. 47 | */ 48 | list: { 49 | mandatory: 'customerId' 50 | }, 51 | 52 | /** 53 | Update address data of the required customer 54 | */ 55 | update: { 56 | mandatory: 'addressId,addressData', 57 | modifiers: { 58 | addressData: ensureArray 59 | } 60 | } 61 | }; 62 | 63 | function ensureArray(val) { 64 | if (!Array.isArray(val)) { 65 | return [ val ]; 66 | } 67 | 68 | return val; 69 | } 70 | 71 | // creating prototypes using curry func 72 | for (var key in protos) { 73 | CustomerAddress.prototype[key] = curry(prototypeBase, key, protos[key]); 74 | } 75 | protos = undefined; 76 | 77 | module.exports = CustomerAddress; 78 | -------------------------------------------------------------------------------- /src/resources/customer_group.js: -------------------------------------------------------------------------------- 1 | // external dependencies 2 | var events = require('events'); 3 | var util = require('util'); 4 | 5 | // internal dependencies 6 | var prototypeBase = require('../prototype_base.js'); 7 | var curry = require('../curry.js'); 8 | 9 | function CustomerGroup() { 10 | this.prefix = 'customer_group.'; 11 | } 12 | util.inherits(CustomerGroup, events.EventEmitter); 13 | 14 | 15 | // prototypes we will be applying 16 | var protos = { 17 | /** 18 | Retrieve the list of customer groups. 19 | */ 20 | list: true 21 | }; 22 | 23 | // creating prototypes using curry func 24 | for (var key in protos) { 25 | CustomerGroup.prototype[key] = curry(prototypeBase, key, protos[key]); 26 | } 27 | protos = undefined; 28 | 29 | module.exports = CustomerGroup; 30 | -------------------------------------------------------------------------------- /src/resources/directory_country.js: -------------------------------------------------------------------------------- 1 | // external dependencies 2 | var events = require('events'); 3 | var util = require('util'); 4 | 5 | // internal dependencies 6 | var prototypeBase = require('../prototype_base.js'); 7 | var curry = require('../curry.js'); 8 | 9 | function DirectoryCountry() { 10 | this.prefix = 'directory_country.'; 11 | } 12 | util.inherits(DirectoryCountry, events.EventEmitter); 13 | 14 | 15 | // prototypes we will be applying 16 | var protos = { 17 | /** 18 | Retrieve the list of countries from Magento. 19 | */ 20 | list: true 21 | }; 22 | 23 | // creating prototypes using curry func 24 | for (var key in protos) { 25 | DirectoryCountry.prototype[key] = curry(prototypeBase, key, protos[key]); 26 | } 27 | protos = undefined; 28 | 29 | module.exports = DirectoryCountry; 30 | -------------------------------------------------------------------------------- /src/resources/directory_region.js: -------------------------------------------------------------------------------- 1 | // external dependencies 2 | var events = require('events'); 3 | var util = require('util'); 4 | 5 | // internal dependencies 6 | var prototypeBase = require('../prototype_base.js'); 7 | var curry = require('../curry.js'); 8 | 9 | function DirectoryRegion() { 10 | this.prefix = 'directory_region.'; 11 | } 12 | util.inherits(DirectoryRegion, events.EventEmitter); 13 | 14 | 15 | // prototypes we will be applying 16 | var protos = { 17 | /** 18 | Retrieve the list of countries from Magento. 19 | */ 20 | list: { 21 | mandatory: 'country' 22 | } 23 | }; 24 | 25 | // creating prototypes using curry func 26 | for (var key in protos) { 27 | DirectoryRegion.prototype[key] = curry(prototypeBase, key, protos[key]); 28 | } 29 | protos = undefined; 30 | 31 | module.exports = DirectoryRegion; 32 | -------------------------------------------------------------------------------- /src/resources/sales_order.js: -------------------------------------------------------------------------------- 1 | // external dependencies 2 | var events = require('events'); 3 | var util = require('util'); 4 | 5 | // internal dependencies 6 | var prototypeBase = require('../prototype_base.js'); 7 | var curry = require('../curry.js'); 8 | 9 | /** 10 | Allows you to manage orders. 11 | */ 12 | function SalesOrder() { 13 | this.prefix = 'sales_order.'; 14 | } 15 | util.inherits(SalesOrder, events.EventEmitter); 16 | 17 | 18 | // prototypes we will be applying 19 | var protos = { 20 | /** 21 | Allows you to add a new comment to the order. 22 | */ 23 | addComment: { 24 | mandatory: 'orderIncrementId,status', 25 | optional: 'comment,notify' 26 | }, 27 | 28 | /** 29 | Allows you to cancel the required order. 30 | */ 31 | cancel: { 32 | mandatory: 'orderIncrementId' 33 | }, 34 | 35 | /** 36 | Allows you to place the required order on hold. 37 | */ 38 | hold: { 39 | mandatory: 'orderIncrementId' 40 | }, 41 | 42 | /** 43 | Allows you to retrieve the required order information. 44 | */ 45 | info: { 46 | mandatory: 'orderIncrementId' 47 | }, 48 | 49 | /** 50 | Allows you to retrieve the list of orders. Additional filters can be applied. 51 | */ 52 | list: { 53 | optional: 'filters' 54 | }, 55 | 56 | /** 57 | Allows you to unhold the required order. 58 | */ 59 | unhold: { 60 | mandatory: 'orderIncrementId' 61 | } 62 | }; 63 | 64 | // creating prototypes using curry func 65 | for (var key in protos) { 66 | SalesOrder.prototype[key] = curry(prototypeBase, key, protos[key]); 67 | } 68 | protos = undefined; 69 | 70 | module.exports = SalesOrder; 71 | -------------------------------------------------------------------------------- /src/resources/sales_order_credit_memo.js: -------------------------------------------------------------------------------- 1 | // external dependencies 2 | var events = require('events'); 3 | var util = require('util'); 4 | 5 | // internal dependencies 6 | var prototypeBase = require('../prototype_base.js'); 7 | var curry = require('../curry.js'); 8 | 9 | /** 10 | Allows you to operate with credit memos for orders. 11 | */ 12 | function SalesOrderCreditMemo() { 13 | this.prefix = 'order_creditmemo.'; 14 | } 15 | util.inherits(SalesOrderCreditMemo, events.EventEmitter); 16 | 17 | 18 | // prototypes we will be applying 19 | var protos = { 20 | /** 21 | Allows you to add a new comment to an existing credit memo. Email notification can be sent to the user email. 22 | */ 23 | addComment: { 24 | mandatory: 'creditmemoIncrementId', 25 | optional: 'comment,notifyCustomer,includeComment' 26 | }, 27 | 28 | /** 29 | Allows you to cancel an existing credit memo. 30 | */ 31 | cancel: { 32 | mandatory: 'creditmemoIncrementId' 33 | }, 34 | 35 | /** 36 | Allows you to create a new credit memo for the invoiced order. 37 | Comments can be added and an email notification can be sent to the user email. 38 | */ 39 | create: { 40 | mandatory: 'orderIncrementId', 41 | optional: 'creditmemoData,comment,notifyCustomer,includeComment,refundToStoreCreditAmount' 42 | }, 43 | 44 | /** 45 | Allows you to retrieve full information about the specified credit memo. 46 | */ 47 | info: { 48 | mandatory: 'creditmemoIncrementId' 49 | }, 50 | 51 | /** 52 | Allows you to retrieve the list of orders. Additional filters can be applied. 53 | */ 54 | list: { 55 | optional: 'filters', 56 | modifiers: { 57 | filters: function(filters) { 58 | // if filters is not an array, wrap it in an array 59 | if (!Array.isArray(filters)) { 60 | return [ filters ]; 61 | } 62 | 63 | return filters; 64 | } 65 | } 66 | } 67 | }; 68 | 69 | // creating prototypes using curry func 70 | for (var key in protos) { 71 | SalesOrderCreditMemo.prototype[key] = curry(prototypeBase, key, protos[key]); 72 | } 73 | protos = undefined; 74 | 75 | module.exports = SalesOrderCreditMemo; 76 | -------------------------------------------------------------------------------- /src/resources/sales_order_invoice.js: -------------------------------------------------------------------------------- 1 | // external dependencies 2 | var events = require('events'); 3 | var util = require('util'); 4 | 5 | // internal dependencies 6 | var prototypeBase = require('../prototype_base.js'); 7 | var curry = require('../curry.js'); 8 | 9 | /** 10 | Allows you to manage invoices. 11 | */ 12 | function SalesOrderInvoice() { 13 | this.prefix = 'order_invoice.'; 14 | } 15 | util.inherits(SalesOrderInvoice, events.EventEmitter); 16 | 17 | 18 | // prototypes we will be applying 19 | var protos = { 20 | /** 21 | Allows you to add a new comment to the order invoice. 22 | */ 23 | addComment: { 24 | mandatory: 'invoiceIncrementId', 25 | optional: 'comment,email,includeComment' 26 | }, 27 | 28 | /** 29 | Allows you to cancel the required invoice. 30 | Note that not all order invoices can be canceled. 31 | Only some payment methods support canceling the order invoice (e.g., Google Checkout, PayPal Pro, PayPal Express Checkout). 32 | */ 33 | cancel: { 34 | mandatory: 'invoiceIncrementId' 35 | }, 36 | 37 | /** 38 | Allows you to capture the required invoice. 39 | Note that not all order invoices can be captured. 40 | Only some payment methods support capturing the order invoice (e.g., PayPal Pro). 41 | */ 42 | capture: { 43 | mandatory: 'invoiceIncrementId' 44 | }, 45 | 46 | /** 47 | Allows you to create a new invoice for an order. 48 | */ 49 | create: { 50 | mandatory: 'orderIncrementId,itemsQty', 51 | optional: 'comment,email,includeComment' 52 | }, 53 | 54 | /** 55 | Allows you to retrieve information about the required invoice. 56 | */ 57 | info: { 58 | mandatory: 'invoiceIncrementId' 59 | }, 60 | 61 | /** 62 | Allows you to retrieve the list of order invoices. Additional filters can also be applied. 63 | */ 64 | list: { 65 | optional: 'filters', 66 | modifiers: { 67 | filters: function(filters) { 68 | // if filters is not an array, wrap it in an array 69 | if (!Array.isArray(filters)) { 70 | return [ filters ]; 71 | } 72 | 73 | return filters; 74 | } 75 | } 76 | } 77 | }; 78 | 79 | // creating prototypes using curry func 80 | for (var key in protos) { 81 | SalesOrderInvoice.prototype[key] = curry(prototypeBase, key, protos[key]); 82 | } 83 | protos = undefined; 84 | 85 | module.exports = SalesOrderInvoice; 86 | -------------------------------------------------------------------------------- /src/resources/sales_order_shipment.js: -------------------------------------------------------------------------------- 1 | // external dependencies 2 | var events = require('events'); 3 | var util = require('util'); 4 | 5 | // internal dependencies 6 | var prototypeBase = require('../prototype_base.js'); 7 | var curry = require('../curry.js'); 8 | 9 | /** 10 | Allows you to manage shipments and tracking numbers. 11 | */ 12 | function SalesOrderShipment() { 13 | this.prefix = 'sales_order_shipment.'; 14 | } 15 | util.inherits(SalesOrderShipment, events.EventEmitter); 16 | 17 | 18 | // prototypes we will be applying 19 | var protos = { 20 | /** 21 | Allows you to add a new comment to the order shipment. 22 | */ 23 | addComment: { 24 | mandatory: 'shipmentIncrementId', 25 | optional: 'comment,email,includeInEmail' 26 | }, 27 | 28 | /** 29 | Allows you to add a new tracking number to the order shipment. 30 | */ 31 | addTrack: { 32 | mandatory: 'shipmentIncrementId,carrier,title,trackNumber' 33 | }, 34 | 35 | /** 36 | Allows you to create a new shipment for an order. 37 | */ 38 | create: { 39 | mandatory: 'orderIncrementId', 40 | optional: 'itemsQty,comment,email,includeComment' 41 | }, 42 | 43 | /** 44 | Allows you to retrieve the list of allowed carriers for an order. 45 | */ 46 | getCarriers: { 47 | mandatory: 'orderIncrementId' 48 | }, 49 | 50 | /** 51 | Allows you to retrieve the shipment information. 52 | */ 53 | info: { 54 | mandatory: 'shipmentIncrementId' 55 | }, 56 | 57 | /** 58 | Allows you to retrieve the list of order shipments. Additional filters can be applied. 59 | */ 60 | list: { 61 | mandatory: 'filters', 62 | modifiers: { 63 | filters: function(filters) { 64 | // if filters is not an array, wrap it in an array 65 | if (!Array.isArray(filters)) { 66 | return [ filters ]; 67 | } 68 | 69 | return filters; 70 | } 71 | } 72 | }, 73 | 74 | /** 75 | Allows you to remove a tracking number from the order shipment. 76 | */ 77 | removeTrack: { 78 | mandatory: 'shipmentIncrementId,trackId' 79 | } 80 | }; 81 | 82 | // creating prototypes using curry func 83 | for (var key in protos) { 84 | SalesOrderShipment.prototype[key] = curry(prototypeBase, key, protos[key]); 85 | } 86 | protos = undefined; 87 | 88 | module.exports = SalesOrderShipment; 89 | -------------------------------------------------------------------------------- /src/resources/store.js: -------------------------------------------------------------------------------- 1 | // external dependencies 2 | var events = require('events'); 3 | var util = require('util'); 4 | 5 | // internal dependencies 6 | var prototypeBase = require('../prototype_base.js'); 7 | var curry = require('../curry.js'); 8 | 9 | function Store() { 10 | this.prefix = 'store.'; 11 | } 12 | util.inherits(Store, events.EventEmitter); 13 | 14 | 15 | // prototypes we will be applying 16 | var protos = { 17 | /** 18 | Allows you to retrieve information about the required store view. 19 | */ 20 | info: { 21 | mandatory: 'storeView' 22 | }, 23 | 24 | /** 25 | Allows you to retrieve the list of store views. 26 | */ 27 | list: true 28 | }; 29 | 30 | // creating prototypes using curry func 31 | for (var key in protos) { 32 | Store.prototype[key] = curry(prototypeBase, key, protos[key]); 33 | } 34 | protos = undefined; 35 | 36 | module.exports = Store; 37 | -------------------------------------------------------------------------------- /src/test/index.js: -------------------------------------------------------------------------------- 1 | var Magento = require('../magento'); 2 | 3 | if (!process.env.MAGENTO_HOST) throw new Error('Host not present in environment variable MAGENTO_HOST'); 4 | if (!process.env.MAGENTO_USER) throw new Error('Username not present in environment variable MAGENTO_USER'); 5 | if (!process.env.MAGENTO_PASS) throw new Error('Password not present in environment variable MAGENTO_PASS'); 6 | 7 | var magento = new Magento({ 8 | host: process.env.MAGENTO_HOST, 9 | port: 80, 10 | path: '/api/xmlrpc/', 11 | login: process.env.MAGENTO_USER, 12 | pass: process.env.MAGENTO_PASS 13 | }); 14 | 15 | 16 | console.log('Testing login'); 17 | magento.login(function(err, sessionId) { 18 | if (err) throw err; 19 | 20 | console.log(sessionId); 21 | 22 | console.log('Changing session id and trying'); 23 | magento.login(function(err, newSessionId) { 24 | if (err) throw err; 25 | 26 | magento.changeSession(sessionId); 27 | console.log('Changed session from %s to %s', newSessionId , sessionId); 28 | 29 | magento.directoryCountry.list(function(err, countries) { 30 | if (err) throw err; 31 | console.log('Found %d countries', countries.length); 32 | }); 33 | }); 34 | }); 35 | --------------------------------------------------------------------------------