Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ma3route-sdk

Package Overview
Dependencies
Maintainers
2
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ma3route-sdk - npm Package Compare versions

Comparing version 0.11.1 to 0.12.0

docs/ma3route-sdk/0.11.1/fonts/OpenSans-Bold-webfont.eot

7

CHANGELOG.md

@@ -9,4 +9,11 @@ # Change Log

Added:
* Add methods `sdk.bannerAdverts.editOne()` and `sdk.listedAdverts.editOne()`
Fixed:
* Typos in code
## 0.11.1 - 2016-07-15

@@ -13,0 +20,0 @@

10

index.js

@@ -55,3 +55,3 @@ /**

/**
* A callack passed a success indicator
* A callback passed a success indicator
* @callback successCallback

@@ -109,2 +109,10 @@ * @param {Error} error - error object

/**
* Sends a PUT request, usually for editing entities.
* @typedef {Function} itemsPutOneRequest
* @param {Object} body
* @param {successCallback} callback
*/
/**
* Creates and returns a SSE Client.

@@ -111,0 +119,0 @@ * @typedef {Function} SSEClientFactory

@@ -31,5 +31,10 @@ /**

* Retrieve a single banner advert
*@type {itemsGetOneRequest}
* @type {itemsGetOneRequest}
*/
getOne: generate.newGetOne("bannerAdverts", paramsConfig.bannerAdverts.get),
/**
* Edit a single banner advert
* @type {itemsPutOneRequest}
*/
editOne: generate.newPutOne("bannerAdverts", paramsConfig.bannerAdverts.edit),
};

@@ -17,2 +17,3 @@ /**

newPostOne: newPostOne,
newPutOne: newPutOne,
newSSEClientFactory: newSSEClientFactory,

@@ -96,6 +97,15 @@ };

* @param {Endpoint} endpoint
* @param {String[]} [allowable]
* @param {Object} [options]
* @param {String[]} [options.allowable]
* @param {String} [options.method=post]
* @return {itemsPostOneRequest}
*/
function newPostOne(endpoint, allowable) {
function newPostOne(endpoint, options) {
// for backwards-compatibility <= 0.11.1
if (_.isArray(options)) options = { allowable: options };
else options = _.defaultsDeep({}, options, {
allowable: [],
method: "post",
});
return function(body, callback) {

@@ -111,3 +121,3 @@ // get and remove/detach URI options

// remove params that are not allowed
body = utils.pickParams(body, allowable);
body = utils.pickParams(body, options.allowable);
// sign the URI (automatically removes the secret param from body)

@@ -121,7 +131,20 @@ try {

var url = uri.toString();
debug("[POST] /%s (%s) [%j]", endpoint, url, body);
return utils.request().post({
var method;
var resOpts = {};
switch (options.method) {
case "put":
method = "put";
resOpts.put = true;
break;
case "post":
default:
method = "post";
resOpts.post = true;
}
debug("[%s] /%s (%s) [%j]", method.toUpperCase(), endpoint, url, body);
return utils.request()[method]({
url: url,
body: body,
}, utils.passResponse(callback, { post: true }));
}, utils.passResponse(callback, resOpts));
};

@@ -149,2 +172,18 @@ }

/**
* Return a function for editing an item
*
* @param {String} endpoint
* @param {Object} [options] Passed to {@link module:generate~newPostOne}
* @return {itemsPutOneRequest}
*/
function newPutOne(endpoint, options) {
// for backwards-compatibility <= 0.11.1
if (_.isArray(options)) options = { allowable: options };
else options = options || {};
options.method = "put";
return newPostOne(endpoint, options);
}
/**
* Return a function that returns a SSE client

@@ -151,0 +190,0 @@ *

@@ -33,2 +33,7 @@ /**

getOne: generate.newGetOne("listedAdverts", paramsConfig.listedAdverts.get),
/**
* Edit a single listed advert
* @type {itemsPutOneRequest}
*/
editOne: generate.newPutOne("listedAdverts", paramsConfig.listedAdverts.edit),
};

8

lib/params.json
{
"bannerAdverts": {
"create": ["title", "town", "context", "mediaurl", "url", "email", "size"],
"get": ["id", "limit", "lastread_id", "town_id", "context", "size"]
"get": ["id", "limit", "lastread_id", "town_id", "context", "size"],
"edit": ["id", "title", "town", "context", "mediaurl", "url", "email", "size"]
},

@@ -26,3 +27,4 @@ "contactUs": {

"create": ["title", "description", "site", "phone", "place", "category", "mediaurl", "days", "social", "ademail", "areadescription"],
"get": ["id", "limit", "lastread_id", "town_id", "type", "targettext", "withinpromixity"]
"get": ["id", "limit", "lastread_id", "town_id", "type", "targettext", "withinpromixity"],
"edit": ["id", "title", "description", "site", "phone", "place", "category", "mediaurl", "days", "social", "ademail", "areadescription"]
},

@@ -43,3 +45,3 @@ "news": {

"create": ["firstname", "middlename", "lastname", "gender", "email", "country", "alias"],
"modify": ["firstname", "middlename", "lastname", "email", "alias", "resetpassword", "editprofile"],
"edit": ["firstname", "middlename", "lastname", "email", "alias", "resetpassword", "editprofile"],
"login": ["email", "password"],

@@ -46,0 +48,0 @@ "resetPassword": ["email"]

@@ -318,2 +318,3 @@ /**

* @param {Boolean} [options.post] - callback is for a POST request
* @param {Boolean} [options.put] - callback is for a PUT request
* @return {Function} function to handle responses from `request` calls

@@ -332,6 +333,6 @@ */

var err = new response.ErrorClass(response.statusCode, message);
if (options.post) return callback(err, body, response);
if (options.post || options.put) return callback(err, body, response);
return callback(err, body.data, body.meta, response);
}
if (options.post) return callback(null, body, response);
if (options.post || options.put) return callback(null, body, response);
return callback(null, body.data, body.meta, response);

@@ -338,0 +339,0 @@ };

{
"name": "ma3route-sdk",
"version": "0.11.1",
"version": "0.12.0",
"description": "Node.js SDK for developing with the Ma3Route REST API",

@@ -5,0 +5,0 @@ "repository": {

@@ -36,3 +36,3 @@ # Ma3Route SDK

To get you started, we have added some examples that you can
inspect, in [`examples/`][examples].
inspect, in [`example/`][example].

@@ -58,3 +58,3 @@

[examples]:https://github.com/Ma3Route/node-sdk/examples/
[guide]:https://github.com/Ma3Route/node-sdk/CONTRIBUTING.md
[example]:https://github.com/Ma3Route/node-sdk/tree/master/example
[guide]:https://github.com/Ma3Route/node-sdk/blob/master/CONTRIBUTING.md

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc