tremendous 2.0.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -8
- package/lib/index.js +8 -12
- package/package.json +12 -22
- package/Makefile +0 -24
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ $ npm install tremendous
|
|
|
11
11
|
|
|
12
12
|
## Getting started
|
|
13
13
|
|
|
14
|
-
All API requests require an access token. A sandbox access token is assigned upon signup through the [Tremendous
|
|
14
|
+
All API requests require an access token. A sandbox access token is assigned upon signup through the [Tremendous Sandbox Environment][2]. Once you are ready to move to production, you will be assigned a production access token.
|
|
15
15
|
|
|
16
16
|
### Authentication
|
|
17
17
|
|
|
@@ -19,10 +19,10 @@ All API requests require an access token. A sandbox access token is assigned up
|
|
|
19
19
|
var Tremendous = require('tremendous');
|
|
20
20
|
|
|
21
21
|
// Sandbox environment
|
|
22
|
-
var client = new Tremendous("[SANDBOX_ACCESS_TOKEN]", "https://testflight.tremendous.com/api/v2");
|
|
22
|
+
var client = new Tremendous("[SANDBOX_ACCESS_TOKEN]", "https://testflight.tremendous.com/api/v2/");
|
|
23
23
|
|
|
24
24
|
// Production environment
|
|
25
|
-
var client = new Tremendous("[PRODUCTION_ACCESS_TOKEN]", "https://
|
|
25
|
+
var client = new Tremendous("[PRODUCTION_ACCESS_TOKEN]", "https://api.tremendous.com/api/v2/");
|
|
26
26
|
```
|
|
27
27
|
|
|
28
28
|
|
|
@@ -36,14 +36,14 @@ See [API documentation][3] for all Order attributes.
|
|
|
36
36
|
|
|
37
37
|
const order_data = {
|
|
38
38
|
payment: {
|
|
39
|
-
funding_source_id: "
|
|
39
|
+
funding_source_id: "[FUNDING_SOURCE_ID]",
|
|
40
40
|
},
|
|
41
41
|
reward: {
|
|
42
42
|
value: {
|
|
43
43
|
denomination: 25,
|
|
44
44
|
currency_code: "USD"
|
|
45
45
|
},
|
|
46
|
-
campaign_id: "
|
|
46
|
+
campaign_id: "[CAMPAIGN_ID]",
|
|
47
47
|
delivery: {
|
|
48
48
|
method: "EMAIL",
|
|
49
49
|
},
|
|
@@ -61,7 +61,7 @@ client.createOrder(order_data, function(err, results) {
|
|
|
61
61
|
|
|
62
62
|
|
|
63
63
|
// Return a reward by ID
|
|
64
|
-
client.getReward("
|
|
64
|
+
client.getReward("[REWARD_ID]", function(err, result) {
|
|
65
65
|
console.log(JSON.stringify(result, null, 2));
|
|
66
66
|
});
|
|
67
67
|
```
|
|
@@ -79,11 +79,11 @@ client.getFundingSources({}, function(err, results) {
|
|
|
79
79
|
### Products
|
|
80
80
|
|
|
81
81
|
```javascript
|
|
82
|
-
client.getProducts(function(err, results) {
|
|
82
|
+
client.getProducts({}, function(err, results) {
|
|
83
83
|
console.log(JSON.stringify(results, null, 2));
|
|
84
84
|
});
|
|
85
85
|
```
|
|
86
86
|
|
|
87
87
|
[1]: https://tremendous.com/docs
|
|
88
|
-
[2]: https://tremendous.com/rewards
|
|
88
|
+
[2]: https://testflight.tremendous.com/rewards
|
|
89
89
|
[3]: https://tremendous.com/docs
|
package/lib/index.js
CHANGED
|
@@ -4,12 +4,14 @@ var _ = require('lodash');
|
|
|
4
4
|
var request = require('request');
|
|
5
5
|
var jwt = require('jsonwebtoken');
|
|
6
6
|
|
|
7
|
-
var Tremendous = module.exports = function(accessToken,
|
|
7
|
+
var Tremendous = module.exports = function(accessToken, uri) {
|
|
8
8
|
if (_.isNil(accessToken)) {
|
|
9
9
|
throw new Error('Tremendous "Access Token" required');
|
|
10
|
+
} else if (_.isNil(uri)) {
|
|
11
|
+
throw new Error('Tremendous "URI" required');
|
|
10
12
|
} else {
|
|
11
13
|
this.accessToken = accessToken;
|
|
12
|
-
this.
|
|
14
|
+
this.uri = uri;
|
|
13
15
|
}
|
|
14
16
|
};
|
|
15
17
|
|
|
@@ -18,9 +20,7 @@ Tremendous.prototype.createOrganization = _.partial(client, 'organizations', "PO
|
|
|
18
20
|
Tremendous.prototype.getOrganizations = _.partial(client, 'organizations', "GET", {});
|
|
19
21
|
|
|
20
22
|
// products
|
|
21
|
-
Tremendous.prototype.getProducts =
|
|
22
|
-
client.call(this, 'products', "GET", {}, callback);
|
|
23
|
-
};
|
|
23
|
+
Tremendous.prototype.getProducts = _.partial(client, 'products', "GET");
|
|
24
24
|
|
|
25
25
|
// Orders
|
|
26
26
|
Tremendous.prototype.createOrder = _.partial(client, 'orders', "POST");
|
|
@@ -43,19 +43,15 @@ Tremendous.prototype.tokenizeEmbed = function(payload) {
|
|
|
43
43
|
};
|
|
44
44
|
|
|
45
45
|
function client(path, method, options, callback) {
|
|
46
|
-
var opts = _.merge({}, {
|
|
47
|
-
access_token: this.accessToken,
|
|
48
|
-
}, options);
|
|
49
|
-
|
|
50
46
|
var data = _.merge({}, {
|
|
51
47
|
url: this.uri + path,
|
|
52
48
|
method: method,
|
|
53
49
|
headers: {
|
|
54
|
-
"User-agent": "Tremendous Node v2.
|
|
55
|
-
|
|
50
|
+
"User-agent": "Tremendous Node v2.2.0",
|
|
51
|
+
"authorization": "Bearer " + this.accessToken
|
|
56
52
|
},
|
|
57
53
|
json: true
|
|
58
|
-
}, method == "GET" ? {qs:
|
|
54
|
+
}, method == "GET" ? {qs: options} : {json: options});
|
|
59
55
|
|
|
60
56
|
return request(data, handleResponse(callback));
|
|
61
57
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tremendous",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0",
|
|
4
4
|
"description": "A node.js client for the Tremendous API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tremendous",
|
|
@@ -8,42 +8,32 @@
|
|
|
8
8
|
],
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
|
-
"url": "git://github.com/
|
|
11
|
+
"url": "git://github.com/tremendous-rewards/tremendous-node.git"
|
|
12
12
|
},
|
|
13
13
|
"bugs": {
|
|
14
|
-
"url": "http://github.com/
|
|
14
|
+
"url": "http://github.com/tremendous-rewards/tremendous-node/issues"
|
|
15
15
|
},
|
|
16
16
|
"licenses": [
|
|
17
17
|
{
|
|
18
18
|
"type": "MIT",
|
|
19
|
-
"url": "https://github.com/
|
|
19
|
+
"url": "https://github.com/tremendous-rewards/tremendous-node/blob/master/LICENSE"
|
|
20
20
|
}
|
|
21
21
|
],
|
|
22
22
|
"main": "index.js",
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"jsonwebtoken": "
|
|
24
|
+
"jsonwebtoken": "9.0.x",
|
|
25
25
|
"lodash": "4.17.x",
|
|
26
|
-
"request": "2.
|
|
26
|
+
"request": "2.88.x"
|
|
27
27
|
},
|
|
28
|
-
"
|
|
29
|
-
"istanbul": "0.4.x",
|
|
30
|
-
"jscs": "2.7.x",
|
|
31
|
-
"jshint": "2.8.x",
|
|
32
|
-
"mocha": "2.3.x",
|
|
33
|
-
"proxyquire": "1.7.x",
|
|
34
|
-
"xyz": "0.5.x"
|
|
35
|
-
},
|
|
36
|
-
"homepage": "https://github.com/Giftrocket/tremendous-node#readme",
|
|
28
|
+
"homepage": "https://github.com/tremendous-rewards/tremendous-node#readme",
|
|
37
29
|
"scripts": {},
|
|
38
|
-
"
|
|
39
|
-
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=12.0.0",
|
|
32
|
+
"npm": ">=7.0.0"
|
|
33
|
+
},
|
|
40
34
|
"maintainers": [
|
|
41
35
|
" <developers@tremendous.com>"
|
|
42
36
|
],
|
|
43
|
-
"
|
|
44
|
-
"example": "examples",
|
|
45
|
-
"test": "test"
|
|
46
|
-
},
|
|
47
|
-
"author": "Tremendous Developers <developers@tremendous.com> (https://www.tremendous.com/rewards)",
|
|
37
|
+
"author": "Tremendous Developers <developers@tremendous.com> (https://www.tremendous.com)",
|
|
48
38
|
"license": "MIT"
|
|
49
39
|
}
|
package/Makefile
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
REPORTER = spec
|
|
2
|
-
|
|
3
|
-
all: jshint test
|
|
4
|
-
|
|
5
|
-
test:
|
|
6
|
-
@NODE_ENV=test ./node_modules/.bin/mocha --recursive --reporter $(REPORTER) --timeout 3000
|
|
7
|
-
|
|
8
|
-
jshint:
|
|
9
|
-
jshint lib examples test index.js
|
|
10
|
-
|
|
11
|
-
tests: test
|
|
12
|
-
|
|
13
|
-
tap:
|
|
14
|
-
@NODE_ENV=test ./node_modules/.bin/mocha -R tap > results.tap
|
|
15
|
-
|
|
16
|
-
unit:
|
|
17
|
-
@NODE_ENV=test ./node_modules/.bin/mocha --recursive -R xunit > results.xml --timeout 3000
|
|
18
|
-
|
|
19
|
-
skel:
|
|
20
|
-
mkdir examples lib test
|
|
21
|
-
touch index.js
|
|
22
|
-
npm install mocha chai --save-dev
|
|
23
|
-
|
|
24
|
-
.PHONY: test tap unit jshint skel
|