magento-api-rest
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -0,0 +0,0 @@ const MagentoAPI = require('../index'); |
@@ -0,0 +0,0 @@ { |
@@ -0,0 +0,0 @@ const MagentoAPI = require('../index'); |
@@ -0,0 +0,0 @@ { |
@@ -0,0 +0,0 @@ { |
13
index.js
@@ -139,11 +139,10 @@ const crypto = require('crypto'); | ||
MagentoAPI.prototype._searches = function (params) { | ||
let keys = Object.keys(params); | ||
let antiTrigger = ["filter_groups", "filterGroups", "sort_orders", "sortOrders", "page_size", "pageSize"] | ||
let parserTrigger = keys.filter(val => antiTrigger.includes(val)); | ||
if (params || params != null) { | ||
if (!params || params === null) { | ||
return 'searchCriteria=all'; | ||
} else { | ||
let paramObjKeys = Object.keys(params); | ||
let antiTrigger = ["filter_groups", "filterGroups", "sort_orders", "sortOrders", "page_size", "pageSize", "current_page", "currentPage"]; | ||
let parserTrigger = paramObjKeys.filter(val => antiTrigger.includes(val)); | ||
let param_str = parserTrigger.length > 0 ? params_url : params_convert; | ||
return param_str(params); | ||
} else { | ||
return 'searchCriteria=all'; | ||
} | ||
@@ -150,0 +149,0 @@ } |
@@ -5,3 +5,3 @@ const urlify = require('./param_url'); | ||
let myOperators = ["$or", "$from", "$to", "$after", "$before"]; | ||
let ignoreKeys = ["$sort", "$page"] | ||
let ignoreKeys = ["$sort", "$page", "$perPage"]; | ||
let filters = {} | ||
@@ -25,4 +25,6 @@ let partialFilters = []; | ||
filters.sortOrders = sortFilters; | ||
} else if (key == "$perPage") { | ||
filters.pageSize = obj[key]; | ||
} else if (key == "$page") { | ||
filters.pageSize = obj[key]; | ||
filters.currentPage = obj[key]; | ||
} else { | ||
@@ -29,0 +31,0 @@ if (myOperators.includes(key) && !ignoreKeys.includes(key)) { |
@@ -0,0 +0,0 @@ const filterify = (obj) => { |
{ | ||
"name": "magento-api-rest", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "A NodeJS wrapper to work with Magento 2 REST APIs.", | ||
@@ -15,5 +15,10 @@ "main": "index.js", | ||
"Magento", | ||
"Magento2", | ||
"eCommerce", | ||
"REST", | ||
"API" | ||
"API", | ||
"JS", | ||
"NodeJS", | ||
"Javascript", | ||
"JSON" | ||
], | ||
@@ -27,3 +32,3 @@ "author": "Aaditya Chakravarty", | ||
"dependencies": { | ||
"axios": "^0.19.0", | ||
"axios": "^0.19.2", | ||
"oauth-1.0a": "^2.2.6" | ||
@@ -30,0 +35,0 @@ }, |
@@ -22,3 +22,3 @@ # Magento API REST | ||
* The above documentation is for Magento 2.3, latest at the time of making this package. Should be compatible with Magento 2.0 and above. | ||
* The above documentation is for Magento 2.3, latest at the time of making this package. Should be compatible with Magento 2.2 as well. | ||
@@ -30,6 +30,6 @@ ## Setup | ||
```js | ||
var MagentoAPI = require('magento-api-rest'); | ||
const MagentoAPI = require('magento-api-rest'); | ||
var client = new MagentoAPI({ | ||
'url': 'http://www.test.com/index.php/rest', | ||
const client = new MagentoAPI({ | ||
'url': 'http://www.test.com', | ||
'consumerKey': '<OAuth 1.0a consumer key>', | ||
@@ -53,2 +53,4 @@ 'consumerSecret': '<OAuth 1.0a consumer secret>', | ||
If you want to use the [asynchronous Endpoints](https://devdocs.magento.com/guides/v2.3/rest/asynchronous-web-endpoints.html) set `version` to `async/V1`. | ||
## Methods | ||
@@ -66,2 +68,5 @@ | ||
* Note: In case no params are specified or required, you can leave params as empty. | ||
That will result in "?searchCriteria=all" in the URL. | ||
### POST | ||
@@ -107,3 +112,3 @@ | ||
```js | ||
var params = { | ||
let params = { | ||
"filter_groups": [ | ||
@@ -133,3 +138,4 @@ { | ||
], | ||
"pageSize": 200 | ||
"pageSize": 200, | ||
"currentPage": 1 | ||
} | ||
@@ -139,14 +145,15 @@ ``` | ||
```js | ||
var params = { | ||
"$or": [ | ||
{ "created_at": "2019-08-03 11:22:47" }, | ||
{ "created_at": "2020-08-03 11:22:47" } | ||
let params = { | ||
$or: [ | ||
{ $from: "2019-08-03 11:22:47" }, | ||
{ $to: "2020-08-03 11:22:47" } | ||
], | ||
"$sort": { | ||
$sort: { | ||
"created_at": "desc" | ||
}, | ||
"$page": 200 | ||
$perPage: 200, | ||
$page: 1 | ||
} | ||
``` | ||
* Note: You cannot use both the param writing styles together or it will cause Error 500 on your store. | ||
* Note: You cannot use both the param writing styles together. | ||
@@ -158,3 +165,3 @@ #### Parser Operators | ||
| $or | Execute OR queries. | | ||
| $from | Starting point of order search via ISO date. | | ||
| $from | Starting point of order search via ISO date. Requires $to. | | ||
| $to | Starting point of order search via ISO date. | | ||
@@ -164,3 +171,4 @@ | $after | Search after a specific ISO date. | | ||
| $sort | Sort the orders, see docs for more. | | ||
| $page | Specifies the per page orders. | | ||
| $perPage | Specifies the per page orders. | | ||
| $page | Specifies the current page. | | ||
@@ -197,2 +205,4 @@ * By default { key: value } translates to an "eq" operation where key = value. | ||
- 2020-01-26 - v1.1.1 - Fixed blank params issue, added current page support in parser. | ||
- 2019-09-03 - v1.1.0 - Naming Issue with package due to previous error. | ||
- 2019-09-03 - v1.0.0 - Added support for remaning REST functions, removed QUERY function, added parser support. | ||
@@ -208,2 +218,3 @@ - 2019-08-22 - v1.0.0-6 - Fixed Post APIs body and partially added separate rest functions. | ||
* Add test cases. | ||
* Fix any errors which may pop up. | ||
* Add test cases. |
@@ -0,0 +0,0 @@ var Magento = require('../index.js'); |
@@ -0,0 +0,0 @@ exports.or_search = { |
Sorry, the diff of this file is not supported yet
25961
495
210
Updatedaxios@^0.19.2