Comparing version 0.7.2 to 0.7.3
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.10.0 | ||
// Generated by CoffeeScript 1.12.2 | ||
var AuthorizeResponse, Response, exports, | ||
@@ -3,0 +3,0 @@ extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.10.0 | ||
// Generated by CoffeeScript 1.12.2 | ||
var AuthorizeResponse, Client, Promise, Response, VERSION, https, parser, querystring, xml2js, | ||
@@ -34,3 +34,3 @@ indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; | ||
Client = require('3scale').Client | ||
client = new Client(provider_key, [default_host]) | ||
client = new Client(provider_key, [default_host], [default_port]) | ||
*/ | ||
@@ -43,6 +43,6 @@ | ||
function Client(provider_key, default_host) { | ||
if (default_host == null) { | ||
default_host = "su1.3scale.net"; | ||
} | ||
function Client(provider_key, host, port) { | ||
var chosenHost, chosenPort; | ||
chosenHost = host || "su1.3scale.net"; | ||
chosenPort = port || 443; | ||
if (provider_key == null) { | ||
@@ -52,3 +52,4 @@ throw new Error("missing provider_key"); | ||
this.provider_key = provider_key; | ||
this.host = default_host; | ||
this.host = chosenHost; | ||
this.port = chosenPort; | ||
} | ||
@@ -63,3 +64,4 @@ | ||
app_id Required | ||
app_key Required | ||
service_id Required (from November 2016) | ||
app_key Optional | ||
referrer Optional | ||
@@ -71,3 +73,3 @@ usage Optional | ||
Example: | ||
client.authorize {app_id: '75165984', app_key: '3e05c797ef193fee452b1ddf19defa74'}, (response) -> | ||
client.authorize {service_id: '1234567890987', app_id: 'ca5c5a49'}, (response) -> | ||
if response.is_success | ||
@@ -93,3 +95,3 @@ * All Ok | ||
host: this.host, | ||
port: 443, | ||
port: this.port, | ||
path: url + query, | ||
@@ -126,3 +128,3 @@ method: 'GET', | ||
app_id Required | ||
service_id Optional (In case of mmultiple services) | ||
service_id Required (from November 2016) | ||
callback {Function} Is the callback function that receives the Response object which includes `is_success` | ||
@@ -132,3 +134,3 @@ method to determine the status of the response | ||
Example: | ||
client.oauth_authorize {app_id: '75165984', (response) -> | ||
client.oauth_authorize {service_id: '1234567890987', app_id: 'ca5c5a49'}, (response) -> | ||
if response.is_success | ||
@@ -153,3 +155,3 @@ * All Ok | ||
host: this.host, | ||
port: 443, | ||
port: this.port, | ||
path: url + query, | ||
@@ -186,3 +188,3 @@ method: 'GET', | ||
user_key Required | ||
service_id Optional (In case of mmultiple services) | ||
service_id Required (from November 2016) | ||
callback {Function} Is the callback function that receives the Response object which includes `is_success` | ||
@@ -192,3 +194,3 @@ method to determine the status of the response | ||
Example: | ||
client.authorize_with_user_key {user_key: '123456', (response) -> | ||
client.authorize_with_user_key {service_id: '1234567890987', user_key: 'ca5c5a49'}, (response) -> | ||
if response.is_success | ||
@@ -213,3 +215,3 @@ * All Ok | ||
host: this.host, | ||
port: 443, | ||
port: this.port, | ||
path: url + query, | ||
@@ -245,3 +247,4 @@ method: 'GET', | ||
app_id Required | ||
app_key, user_id, object, usage, no-body, service_id Optional | ||
service_id Required (from November 2016) | ||
app_key, user_id, object, usage, no-body | ||
callback {Function} Is the callback function that receives the Response object which includes `is_success` | ||
@@ -251,3 +254,3 @@ method to determine the status of the response | ||
Example: | ||
client.authrep {app_id: '75165984', (response) -> | ||
client.authrep {service_id: '1234567890987', app_id: 'ca5c5a49'}, (response) -> | ||
if response.is_success | ||
@@ -275,3 +278,3 @@ * All Ok | ||
host: this.host, | ||
port: 443, | ||
port: this.port, | ||
path: url + query, | ||
@@ -305,2 +308,14 @@ method: 'GET', | ||
Authorize and Report with :user_key | ||
options is a Hash object with the following fields | ||
user_key Required | ||
service_id Required (from November 2016) | ||
callback {Function} Is the callback function that receives the Response object which includes `is_success` | ||
method to determine the status of the response | ||
Example: | ||
client.authrep_with_user_key {service_id: '1234567890987', user_key: 'ca5c5a49'}, (response) -> | ||
if response.is_success | ||
* All Ok | ||
else | ||
sys.puts "#{response.error_message} with code: #{response.error_code}" | ||
*/ | ||
@@ -321,3 +336,3 @@ | ||
host: this.host, | ||
port: 443, | ||
port: this.port, | ||
path: url + query, | ||
@@ -353,3 +368,3 @@ method: 'GET', | ||
Parameters: | ||
service_id {String} Optional (required only if you have more than one service) | ||
service_id {String} Required (from November 2016) | ||
trans {Array} each array element contain information of a transaction. That information is in a Hash in the form | ||
@@ -369,3 +384,3 @@ { | ||
client.report trans, (response) -> | ||
client.report "your service id", trans, (response) -> | ||
if response.is_success | ||
@@ -399,3 +414,3 @@ * All Ok | ||
host: this.host, | ||
port: 443, | ||
port: this.port, | ||
path: url, | ||
@@ -402,0 +417,0 @@ method: 'POST', |
@@ -1,4 +0,4 @@ | ||
// Generated by CoffeeScript 1.10.0 | ||
// Generated by CoffeeScript 1.12.2 | ||
module.exports = { | ||
Client: require("./client") | ||
}; |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.10.0 | ||
// Generated by CoffeeScript 1.12.2 | ||
var Response, exports; | ||
@@ -3,0 +3,0 @@ |
{ | ||
"name": "3scale", | ||
"description": "Client for 3Scale Networks API", | ||
"version": "0.7.2", | ||
"version": "0.7.3", | ||
"homepage": "http://www.3scale.net", | ||
@@ -6,0 +6,0 @@ "repository": { |
@@ -29,2 +29,4 @@ # 3scale integration plugin for JavaScript/CoffeeScript/Node.js applications [![Build Status](https://secure.travis-ci.org/3scale/3scale_ws_api_for_nodejs.png?branch=master)](http://travis-ci.org/3scale/3scale_ws_api_for_nodejs) | ||
> NOTE: From November 2016 `service_id` is mandatory. | ||
### Authrep | ||
@@ -38,5 +40,9 @@ | ||
// Creates a Client with default host and port.This will comunicate with the 3scale platform SaaS default server. | ||
client = new Client("your provider key"); | ||
client.authrep({"app_id": "your application id", "app_key": "your application key", "usage": { "hits": 1 } }, function(response){ | ||
// When connecting to an on-premise instance of the 3scale platform, create a Client with a given host and port: | ||
//client = new Client("your provider key", "backend.example.com", 80); | ||
client.authrep({ "service_id": "your service id", "app_id": "your application id", "app_key": "your application key", "usage": { "hits": 1 } }, function(response){ | ||
console.log(response); | ||
@@ -51,5 +57,9 @@ }); | ||
// Creates a Client with default host and port. This will comunicate with the 3scale platform SaaS default server. | ||
client = new Client("your provider key"); | ||
client.authrep_with_user_key({ "user_key": "your key", "usage": { "hits": 1 } }, function(response){ | ||
// When connecting to an on-premise instance of the 3scale platform, create a Client with a given host and port: | ||
//client = new Client("your provider key", "backend.example.com", 80); | ||
client.authrep_with_user_key({ "service_id": "your service id", "user_key": "your key", "usage": { "hits": 1 } }, function(response){ | ||
console.log(response); | ||
@@ -67,8 +77,12 @@ }); | ||
// Creates a Client with default host and port. This will comunicate with the 3scale platform SaaS default server. | ||
client = new Client("your provider key"); | ||
client.authorize({ "app_id": "your application id", "app_key": "your application key" }, function(response){ | ||
// When connecting to an on-premise instance of the 3scale platform, create a Client with a given host and port: | ||
//client = new Client("your provider key", "backend.example.com", 80); | ||
client.authorize({ "service_id": "your service id", "app_id": "your application id", "app_key": "your application key" }, function(response){ | ||
if (response.is_success()) { | ||
var trans = [{ "app_id": "your application id", "usage": { "hits": 3 } }]; | ||
client.report(trans, function (response) { | ||
client.report("your service id", trans, function (response) { | ||
console.log(response); | ||
@@ -88,8 +102,12 @@ }); | ||
// Creates a Client with default host and port. This will comunicate with the 3scale platform SaaS default server. | ||
client = new Client("your provider key"); | ||
client.authorize_with_user_key({ "user_key": "your key" }, function(response){ | ||
// When connecting to an on-premise instance of the 3scale platform, create a Client with a given host and port: | ||
//client = new Client("your provider key", "backend.example.com", 80); | ||
client.authorize_with_user_key({ "service_id": "your service id", "user_key": "your key" }, function(response){ | ||
if (response.is_success()) { | ||
var trans = [{ "user_key": "your key", "usage": { "hits": 3 }}]; | ||
client.report(trans, function (response) { | ||
var trans = [{ "user_key": "your key", "usage": { "hits": 3 } }]; | ||
client.report("your service id", trans, function (response) { | ||
console.log(response); | ||
@@ -108,7 +126,7 @@ }); | ||
var trans = [ | ||
{ "app_id": "your application id", "usage": {"hits": 1}}, | ||
{ "app_id": "your application id", "usage": {"hits": 1000}} | ||
{ "app_id": "your application id", "usage": {"hits": 1} }, | ||
{ "app_id": "your application id", "usage": {"hits": 1000} } | ||
] | ||
client.report(trans, function(response){ | ||
client.report("your service id", trans, function(response){ | ||
console.log(response); | ||
@@ -125,8 +143,12 @@ }); | ||
// Creates a Client with default host and port. This will comunicate with the 3scale platform SaaS default server. | ||
client = new Client("your provider key"); | ||
client.oauth_authorize({"app_id": "your application id"}, function(response){ | ||
// When connecting to an on-premise instance of the 3scale platform, create a Client with a given host and port: | ||
//client = new Client("your provider key", "backend.example.com", 80); | ||
client.oauth_authorize({ "service_id": "your service id", "app_id": "your application id" }, function(response){ | ||
if (response.is_success()) { | ||
var trans = [{"app_id": "your application id", "usage": {"hits": 3}}]; | ||
client.report(trans, function (response) { | ||
var trans = [{ "app_id": "your application id", "usage": {"hits": 3} }]; | ||
client.report("your service id", trans, function (response) { | ||
console.log(response); | ||
@@ -133,0 +155,0 @@ }); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
60877
522
164
2