tremendous 2.2.0 → 3.0.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 +79 -55
- package/dist/api.d.ts +5920 -0
- package/dist/api.js +3888 -0
- package/dist/base.d.ts +66 -0
- package/dist/base.js +65 -0
- package/dist/common.d.ts +65 -0
- package/dist/common.js +161 -0
- package/dist/configuration.d.ts +91 -0
- package/dist/configuration.js +47 -0
- package/dist/environments.d.ts +5 -0
- package/dist/environments.js +7 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +32 -0
- package/package.json +16 -9
- package/index.js +0 -3
- package/lib/index.js +0 -72
package/README.md
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
==============
|
|
1
|
+
A node.js client library for the [Tremendous API][docs].
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
> [!NOTE]
|
|
4
|
+
> This branch includes the v3 version of the Tremendous Node.JS client, a new version based
|
|
5
|
+
> on our [API schema][ref] docs. If you are using the v2 versions, please check our
|
|
6
|
+
> [`UPGRADING`](UPGRADING.md) guide
|
|
5
7
|
|
|
6
8
|
## Installation
|
|
7
9
|
|
|
@@ -11,79 +13,101 @@ $ npm install tremendous
|
|
|
11
13
|
|
|
12
14
|
## Getting started
|
|
13
15
|
|
|
14
|
-
All API requests require an access token. A sandbox access token is assigned upon signup through the [Tremendous Sandbox Environment][
|
|
16
|
+
All API requests require an access token. A sandbox access token is assigned upon signup through the [Tremendous Sandbox Environment][docs]. Once you are ready to move to production, you will be assigned a production access token.
|
|
15
17
|
|
|
16
18
|
### Authentication
|
|
19
|
+
## Getting started
|
|
17
20
|
|
|
18
|
-
|
|
19
|
-
|
|
21
|
+
All endpoints require a `Configuration` object with a `basePath` and an `accessToken` for either your
|
|
22
|
+
Production or Sandbox account:
|
|
20
23
|
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
```typescript
|
|
25
|
+
import { Configuration, Environments } from "tremendous";
|
|
23
26
|
|
|
24
|
-
//
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
// when you are testing your code with the sandbox environment:
|
|
28
|
+
const configuration = new Configuration({
|
|
29
|
+
basePath: Environments.testflight,
|
|
30
|
+
accessToken: "YOUR-TESTFLIGHT-TOKEN",
|
|
31
|
+
});
|
|
27
32
|
|
|
33
|
+
// when you are ready to use the API:
|
|
34
|
+
const configuration = new Configuration({
|
|
35
|
+
basePath: Environments.production,
|
|
36
|
+
accessToken: "YOUR-PRODUCTION-TOKEN",
|
|
37
|
+
});
|
|
38
|
+
```
|
|
28
39
|
|
|
29
|
-
|
|
40
|
+
## Examples
|
|
30
41
|
|
|
31
|
-
|
|
42
|
+
Submitting an order:
|
|
32
43
|
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
// as an array of objects.
|
|
44
|
+
```typescript
|
|
45
|
+
import { OrdersApi, CreateOrderRequest } from "tremendous";
|
|
36
46
|
|
|
37
|
-
const
|
|
47
|
+
const orders = new OrdersApi(configuration);
|
|
48
|
+
const params: CreateOrderRequest = {
|
|
38
49
|
payment: {
|
|
39
|
-
funding_source_id: "[
|
|
50
|
+
funding_source_id: "[FUNDING SOURCE ID HERE]",
|
|
40
51
|
},
|
|
41
|
-
reward:
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
reward:
|
|
53
|
+
{
|
|
54
|
+
delivery: {
|
|
55
|
+
method: "EMAIL"
|
|
56
|
+
},
|
|
57
|
+
recipient: {
|
|
58
|
+
name: "Recipient Name",
|
|
59
|
+
email: "recipient@domain"
|
|
60
|
+
},
|
|
61
|
+
value: {
|
|
62
|
+
denomination: 5.0,
|
|
63
|
+
currency_code: "USD",
|
|
64
|
+
},
|
|
65
|
+
campaign_id: "[CAMPAIGN_ID]",
|
|
53
66
|
}
|
|
54
|
-
|
|
55
|
-
}
|
|
67
|
+
};
|
|
56
68
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
});
|
|
69
|
+
const { data } = await orders.createOrder(params);
|
|
70
|
+
console.log(`Order created! ID: ${data.order.id}`);
|
|
71
|
+
```
|
|
61
72
|
|
|
73
|
+
Retrieving an Order and a Reward
|
|
62
74
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
75
|
+
```typescript
|
|
76
|
+
import { OrdersApi, RewardsApi } from "tremendous";
|
|
77
|
+
|
|
78
|
+
const orders = new OrdersApi(configuration);
|
|
79
|
+
const rewards = new RewardsApi(configuration);
|
|
80
|
+
|
|
81
|
+
const { order } = (await orders.getOrder("[ORDER_ID]")).data;
|
|
82
|
+
const { reward } = (await rewards.getReward("[REWARD_ID]")).data;
|
|
83
|
+
|
|
84
|
+
console.log(`The order status is ${order.status}`);
|
|
85
|
+
console.log(`The reward was delivered to ${reward.recipient.email}`);
|
|
67
86
|
```
|
|
68
87
|
|
|
69
|
-
|
|
70
|
-
Production funding sources must be added through the web dashboard. A sandbox funding source is provided during development.
|
|
88
|
+
Listing products:
|
|
71
89
|
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
90
|
+
```typescript
|
|
91
|
+
import { ProductsApi } from "tremendous";
|
|
92
|
+
|
|
93
|
+
const client = new ProductsApi(configuration);
|
|
94
|
+
|
|
95
|
+
const { data } = await client.listProducts();
|
|
96
|
+
|
|
97
|
+
data.products.forEach(product => { /* */ });
|
|
77
98
|
```
|
|
78
99
|
|
|
79
|
-
|
|
100
|
+
Listing funding sources:
|
|
80
101
|
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
102
|
+
```typescript
|
|
103
|
+
import { FundingSourcesAPI } from "tremendous";
|
|
104
|
+
|
|
105
|
+
const client = new FundingSourcesAPI(configuration);
|
|
106
|
+
|
|
107
|
+
const { data } = await client.listFundingSources();
|
|
108
|
+
|
|
109
|
+
data.fundingSources.forEach(product => { /* */ });
|
|
85
110
|
```
|
|
86
111
|
|
|
87
|
-
[
|
|
88
|
-
[
|
|
89
|
-
[3]: https://tremendous.com/docs
|
|
112
|
+
[ref]: https://developers.tremendous.com/reference
|
|
113
|
+
[docs]: https://tremendous.com/docs
|