@voucherify/sdk 1.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/CHANGELOG.md +110 -0
- package/README.md +1258 -0
- package/dist/AsyncActions.d.ts +15 -0
- package/dist/Balance.d.ts +12 -0
- package/dist/Campaigns.d.ts +45 -0
- package/dist/ClientSide.d.ts +40 -0
- package/dist/Consents.d.ts +10 -0
- package/dist/Customers.d.ts +43 -0
- package/dist/Distributions.d.ts +22 -0
- package/dist/Events.d.ts +7 -0
- package/dist/Exports.d.ts +18 -0
- package/dist/Loyalties.d.ts +82 -0
- package/dist/Orders.d.ts +22 -0
- package/dist/Products.d.ts +54 -0
- package/dist/PromotionTiers.d.ts +30 -0
- package/dist/Promotions.d.ts +16 -0
- package/dist/Redemptions.d.ts +26 -0
- package/dist/RequestController.d.ts +20 -0
- package/dist/Rewards.d.ts +39 -0
- package/dist/Segments.d.ts +22 -0
- package/dist/ValidationRules.d.ts +39 -0
- package/dist/Validations.d.ts +13 -0
- package/dist/VoucherifyClientSide.d.ts +76 -0
- package/dist/VoucherifyError.d.ts +6 -0
- package/dist/VoucherifyServerSide.d.ts +111 -0
- package/dist/Vouchers.d.ts +64 -0
- package/dist/helpers.d.ts +19 -0
- package/dist/index.d.ts +24 -0
- package/dist/types/AsyncActions.d.ts +18 -0
- package/dist/types/Balance.d.ts +14 -0
- package/dist/types/Campaigns.d.ts +117 -0
- package/dist/types/ClientSide.d.ts +135 -0
- package/dist/types/Consents.d.ts +33 -0
- package/dist/types/Customers.d.ts +113 -0
- package/dist/types/Distributions.d.ts +141 -0
- package/dist/types/Events.d.ts +17 -0
- package/dist/types/Exports.d.ts +30 -0
- package/dist/types/Loyalties.d.ts +462 -0
- package/dist/types/Orders.d.ts +61 -0
- package/dist/types/Products.d.ts +97 -0
- package/dist/types/PromotionTiers.d.ts +107 -0
- package/dist/types/Promotions.d.ts +90 -0
- package/dist/types/Redemptions.d.ts +150 -0
- package/dist/types/Rewards.d.ts +114 -0
- package/dist/types/Segments.d.ts +32 -0
- package/dist/types/ValidationRules.d.ts +74 -0
- package/dist/types/Validations.d.ts +66 -0
- package/dist/types/Vouchers.d.ts +227 -0
- package/dist/types/index.d.ts +19 -0
- package/dist/voucherifysdk.esm.js +1567 -0
- package/dist/voucherifysdk.esm.js.map +1 -0
- package/dist/voucherifysdk.umd.development.js +1578 -0
- package/dist/voucherifysdk.umd.development.js.map +1 -0
- package/dist/voucherifysdk.umd.production.min.js +2 -0
- package/dist/voucherifysdk.umd.production.min.js.map +1 -0
- package/package.json +48 -0
package/README.md
ADDED
|
@@ -0,0 +1,1258 @@
|
|
|
1
|
+
<p align="center" >
|
|
2
|
+
<img src="https://vf-asset.s3-eu-west-1.amazonaws.com/voucherify-js-sdk/logo.png" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
5
|
+
<h3 align="center">Official <a href="http://voucherify.io?utm_source=github&utm_medium=sdk&utm_campaign=acq">Voucherify</a> JS SDK</h3>
|
|
6
|
+
|
|
7
|
+
<p>
|
|
8
|
+
<a href="#"><img src="https://github.com/voucherifyio/voucherify-js-sdk/workflows/Release/badge.svg?branch=main" alt="Build Status"/></a>
|
|
9
|
+
<a href="#"><img src="https://img.shields.io/npm/v/@voucherify/sdk?label=SDK" alt="SDK NPM Version"/></a>
|
|
10
|
+
<a href="#"><img src="https://img.shields.io/npm/dm/@voucherify/sdk?label=SDK%20downloads" alt="SDK NPM Downloads"/></a>
|
|
11
|
+
</p>
|
|
12
|
+
<hr/>
|
|
13
|
+
|
|
14
|
+
<p align="center">
|
|
15
|
+
<b><a href="#documentation">Documentation</a></b>
|
|
16
|
+
|
|
|
17
|
+
<b><a href="#installation">Installation</a></b>
|
|
18
|
+
|
|
|
19
|
+
<b><a href="#snippet">Marketer-ready Voucherify snippet</a></b>
|
|
20
|
+
|
|
|
21
|
+
<b><a href="#migration">Migration</a></b>
|
|
22
|
+
|
|
|
23
|
+
<b><a href="#typescript">Typescript</a></b>
|
|
24
|
+
|
|
|
25
|
+
<b><a href="#error-handling">Error handling</a></b>
|
|
26
|
+
|
|
|
27
|
+
<b><a href="#contributing">Contributing</a></b>
|
|
28
|
+
|
|
|
29
|
+
<b><a href="#changelog">Changelog</a></b>
|
|
30
|
+
</p>
|
|
31
|
+
|
|
32
|
+
<p align="center">
|
|
33
|
+
Server side:
|
|
34
|
+
<a href="#server-side-setup">Setup</a>
|
|
35
|
+
|
|
|
36
|
+
<a href="#server-side-methods">Methods</a>
|
|
37
|
+
|
|
|
38
|
+
<a href="#vouchers">Vouchers</a>
|
|
39
|
+
|
|
|
40
|
+
<a href="#campaigns">Campaigns</a>
|
|
41
|
+
|
|
|
42
|
+
<a href="#distributions">Distributions</a>
|
|
43
|
+
|
|
|
44
|
+
<a href="#validations">Validations</a>
|
|
45
|
+
|
|
|
46
|
+
<a href="#redemptions">Redemptions</a>
|
|
47
|
+
|
|
|
48
|
+
<a href="#customers">Customers</a>
|
|
49
|
+
|
|
|
50
|
+
<a href="#consents">Consents</a>
|
|
51
|
+
|
|
|
52
|
+
<a href="#orders">Orders</a>
|
|
53
|
+
|
|
|
54
|
+
<a href="#products">Products</a>
|
|
55
|
+
|
|
|
56
|
+
<a href="#rewards">Rewards</a>
|
|
57
|
+
|
|
|
58
|
+
<a href="#loyalties">Loyalties</a>
|
|
59
|
+
|
|
|
60
|
+
<a href="#segments">Segments</a>
|
|
61
|
+
|
|
|
62
|
+
<a href="#validation-rules">Validation Rules</a>
|
|
63
|
+
|
|
|
64
|
+
<a href="#promotions">Promotions</a>
|
|
65
|
+
|
|
|
66
|
+
<a href="#events">Events</a>
|
|
67
|
+
|
|
|
68
|
+
<a href="#async-actions">Async Actions</a>
|
|
69
|
+
</p>
|
|
70
|
+
|
|
71
|
+
<p align="center">
|
|
72
|
+
Client side:
|
|
73
|
+
<a href="#client-side-setup">Setup</a>
|
|
74
|
+
|
|
|
75
|
+
<a href="#client-side-methods">Methods</a>
|
|
76
|
+
</p>
|
|
77
|
+
|
|
78
|
+
Voucherify JS SDK is a JavaScript SDK which is fully consistent with restful API Voucherify provides and has fully integrated TypeScript support. It also combines together our previously maintained [Voucherify Node.js SDK](https://github.com/voucherifyio/voucherify-nodejs-sdk) and [Voucherify.js](https://github.com/rspective/voucherify.js/).
|
|
79
|
+
|
|
80
|
+
Learn more about Voucherify by visiting [our site](http://voucherify.io?utm_source=github&utm_medium=sdk&utm_campaign=acq).
|
|
81
|
+
|
|
82
|
+
# <a name="documentation"></a>📝 Documentation
|
|
83
|
+
|
|
84
|
+
You will find detailed description and example responses at our [official documentation](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq). Most method headers point to more detailed descriptions of arguments you can use.
|
|
85
|
+
|
|
86
|
+
You can also use our detailed documentation provided by our package [here](https://voucherifyio.github.io/voucherify-js-sdk/).
|
|
87
|
+
|
|
88
|
+
📚 Want to learn more? Visit our [official site](https://voucherify.io) or our [Success Portal](https://success.voucherify.io).
|
|
89
|
+
|
|
90
|
+
👽 Having troubles? Check our [Help center](https://support.voucherify.io/).
|
|
91
|
+
|
|
92
|
+
🧪 Looking for promotion ideas? Check our [Cookbook](https://cookbook.voucherify.io/) to get an inspiration.
|
|
93
|
+
|
|
94
|
+
# <a name="installation"></a>⚙️ Installation
|
|
95
|
+
|
|
96
|
+
Local installation:
|
|
97
|
+
|
|
98
|
+
```sh
|
|
99
|
+
npm install @voucherify/sdk --save
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
CDN installation:
|
|
103
|
+
|
|
104
|
+
```html
|
|
105
|
+
<script
|
|
106
|
+
type="text/javascript"
|
|
107
|
+
src="https://unpkg.com/@voucherify/sdk/dist/voucherifysdk.umd.production.min.js"
|
|
108
|
+
crossorigin
|
|
109
|
+
></script>
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
Then, [login](http://app.voucherify.io/?utm_source=github&utm_medium=sdk&utm_campaign=acq#/login) to your Voucherify Dashboard and get your API keys from [Configuration](https://app.voucherify.io/?utm_source=github&utm_medium=sdk&utm_campaign=acq#/app/core/projects/current/general).
|
|
113
|
+
|
|
114
|
+
# <a name="server-side"></a>🤖 Server Side
|
|
115
|
+
|
|
116
|
+
## <a name="server-side-setup"></a>Setup
|
|
117
|
+
|
|
118
|
+
```javascript
|
|
119
|
+
const { VoucherifyServerSide } = require('@voucherify/sdk')
|
|
120
|
+
|
|
121
|
+
// import { VoucherifyServerSide } from '@voucherify/sdk' ES6 compatible
|
|
122
|
+
|
|
123
|
+
const client = VoucherifyServerSide({
|
|
124
|
+
applicationId: 'YOUR-APPLICATION-ID',
|
|
125
|
+
secretKey: 'YOUR-SECRET-KEY',
|
|
126
|
+
apiUrl: 'https://<region>.api.voucherify.io', // optional
|
|
127
|
+
apiVersion: 'v2018-08-01', // optional
|
|
128
|
+
channel: 'e-commerce', // optional
|
|
129
|
+
customHeaders: { "MY_CUSTOM_HEADER": "my_value" } // optional
|
|
130
|
+
})
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## <a name="server-side-methods"></a>Methods
|
|
134
|
+
|
|
135
|
+
### Vouchers
|
|
136
|
+
|
|
137
|
+
Methods are provided within `client.vouchers.*` namespace.
|
|
138
|
+
|
|
139
|
+
- [Create Voucher](#create-voucher)
|
|
140
|
+
- [Get Voucher](#get-voucher)
|
|
141
|
+
- [Update Voucher](#update-voucher)
|
|
142
|
+
- [Delete Voucher](#delete-voucher)
|
|
143
|
+
- [Add Gift Voucher Balance](#add-gift-voucher-balance)
|
|
144
|
+
- [List Vouchers](#list-vouchers)
|
|
145
|
+
- [Enable Voucher](#enable-voucher)
|
|
146
|
+
- [Disable Voucher](#disable-voucher)
|
|
147
|
+
- [Import Vouchers](#import-vouchers)
|
|
148
|
+
- [Examine Vouchers Qualification](#examine-vouchers-qualification)
|
|
149
|
+
- [Update Vouchers Metadata in bulk](#update-vouchers-metadata-in-bulk)
|
|
150
|
+
- [Update Vouchers in bulk](#update-vouchers-in-bulk)
|
|
151
|
+
- [Release Validation Session](#release-validation-session)
|
|
152
|
+
|
|
153
|
+
#### [Create Voucher](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-voucher)
|
|
154
|
+
|
|
155
|
+
```javascript
|
|
156
|
+
client.vouchers.create(voucher)
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Check [voucher object](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#the-voucher-object).
|
|
160
|
+
|
|
161
|
+
#### [Get Voucher](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#vouchers-get)
|
|
162
|
+
|
|
163
|
+
```javascript
|
|
164
|
+
client.vouchers.get(code)
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
#### [Update Voucher](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#update-voucher)
|
|
168
|
+
|
|
169
|
+
```javascript
|
|
170
|
+
client.vouchers.update(voucher)
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
#### [Delete Voucher](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#delete-voucher)
|
|
174
|
+
|
|
175
|
+
```javascript
|
|
176
|
+
client.vouchers.delete(code)
|
|
177
|
+
client.vouchers.delete(code, params)
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
#### [List Vouchers](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-vouchers)
|
|
181
|
+
|
|
182
|
+
```javascript
|
|
183
|
+
client.vouchers.list()
|
|
184
|
+
client.vouchers.list(params)
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
#### [Enable Voucher](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#enable-voucher)
|
|
188
|
+
|
|
189
|
+
```javascript
|
|
190
|
+
client.vouchers.enable(code)
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
#### [Disable Voucher](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#disable-voucher)
|
|
194
|
+
|
|
195
|
+
```javascript
|
|
196
|
+
client.vouchers.disable(code)
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
#### [Add Gift Voucher Balance](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#add-gift-voucher-balance)
|
|
200
|
+
|
|
201
|
+
```javascript
|
|
202
|
+
client.vouchers.balance.create(code, params)
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
#### [Import Vouchers](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#import-vouchers-1)
|
|
206
|
+
|
|
207
|
+
```javascript
|
|
208
|
+
client.vouchers.import(vouchers)
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
#### [Examine Vouchers Qualification](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#push-qualification-request)
|
|
212
|
+
|
|
213
|
+
```javascript
|
|
214
|
+
client.vouchers.qualifications.examine(body, params)
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
#### [Update Vouchers Metadata in bulk](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#update-vouchers-metadata-in-bulk)
|
|
218
|
+
|
|
219
|
+
```javascript
|
|
220
|
+
client.vouchers.bulkUpdateMetadata(params)
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
#### [Update Vouchers in bulk](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#update-vouchers-in-bulk)
|
|
224
|
+
|
|
225
|
+
```javascript
|
|
226
|
+
client.vouchers.bulkUpdate(vouchers)
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
#### [Release Validation Session](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#release-validation-session)
|
|
230
|
+
|
|
231
|
+
```javascript
|
|
232
|
+
client.vouchers.releaseValidationSession(code, sessionKey)
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
---
|
|
236
|
+
|
|
237
|
+
### Campaigns
|
|
238
|
+
|
|
239
|
+
Methods are provided within `client.campaigns.*` namespace.
|
|
240
|
+
|
|
241
|
+
- [Create Campaign](#create-campaign)
|
|
242
|
+
- [Update Campaign](#update-campaign)
|
|
243
|
+
- [Get Campaign](#get-campaign)
|
|
244
|
+
- [Add Voucher to Campaign](#add-voucher-to-campaign)
|
|
245
|
+
- [Import Vouchers to Campaign](#import-vouchers-to-campaign)
|
|
246
|
+
- [List Campaigns](#list-campaigns)
|
|
247
|
+
- [Examine Campaigns Qualification](#examine-campaigns-qualification)
|
|
248
|
+
|
|
249
|
+
#### [Create Campaign](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-campaign)
|
|
250
|
+
|
|
251
|
+
```javascript
|
|
252
|
+
client.campaigns.create(campaign)
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
#### [Update Campaign](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#update-campaign)
|
|
256
|
+
|
|
257
|
+
```javascript
|
|
258
|
+
client.campaigns.update(campaignId, campaign)
|
|
259
|
+
client.campaigns.update(campaignName, campaign)
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
Method will update only fields passed to `campaign` argument.
|
|
263
|
+
|
|
264
|
+
#### [Get Campaign](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#get-campaign)
|
|
265
|
+
|
|
266
|
+
```javascript
|
|
267
|
+
client.campaigns.get(name)
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
#### [Delete Campaign](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#delete-campaign)
|
|
271
|
+
|
|
272
|
+
```javascript
|
|
273
|
+
client.campaigns.delete(campaignName)
|
|
274
|
+
client.campaigns.delete(campaignName, params)
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
#### [Add Voucher to Campaign](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#add-voucher-to-campaign)
|
|
278
|
+
|
|
279
|
+
```javascript
|
|
280
|
+
client.campaigns.addVoucher(campaignName)
|
|
281
|
+
client.campaigns.addVoucher(campaignName, body)
|
|
282
|
+
client.campaigns.addVoucher(campaignName, body, params)
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
#### [Add certain Voucher to Campaign](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#add-voucher-with-certain-code-to-campaign)
|
|
286
|
+
|
|
287
|
+
```javascript
|
|
288
|
+
client.campaigns.addCertainVoucher(campaignName, code, codeParams)
|
|
289
|
+
client.campaigns.addCertainVoucher(campaignName, code)
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
#### [Import Vouchers to Campaign](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#import-vouchers)
|
|
293
|
+
|
|
294
|
+
```javascript
|
|
295
|
+
client.campaigns.importVouchers(campaignName, vouchers)
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
#### [List Campaigns](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-campaigns)
|
|
299
|
+
|
|
300
|
+
```javascript
|
|
301
|
+
client.campaigns.list()
|
|
302
|
+
client.campaigns.list(params)
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
#### [Examine Campaigns Qualification](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-qualification-request)
|
|
306
|
+
|
|
307
|
+
```javascript
|
|
308
|
+
client.campaigns.qualifications.examine(body)
|
|
309
|
+
client.campaigns.qualifications.examine(body, params)
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
### Distributions
|
|
315
|
+
|
|
316
|
+
Methods are provided within `client.distributions.*` namespace.
|
|
317
|
+
|
|
318
|
+
- [Create Export](#create-export)
|
|
319
|
+
- [Get Export](#get-export)
|
|
320
|
+
- [Delete Export](#delete-export)
|
|
321
|
+
- [List publications](#list-publications)
|
|
322
|
+
- [Create publication](#create-publication)
|
|
323
|
+
|
|
324
|
+
#### [Create Export](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-export)
|
|
325
|
+
|
|
326
|
+
```javascript
|
|
327
|
+
client.distributions.exports.create(exportObject)
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
Check [the export object](https://docs.voucherify.io/v1/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#the-export-object).
|
|
331
|
+
|
|
332
|
+
#### [Get Export](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#get-export)
|
|
333
|
+
|
|
334
|
+
```javascript
|
|
335
|
+
client.distributions.exports.get(exportId)
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
#### [Delete Export](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#delete-export)
|
|
339
|
+
|
|
340
|
+
```javascript
|
|
341
|
+
client.distributions.exports.delete(exportId)
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
#### [List publications](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-publications)
|
|
345
|
+
|
|
346
|
+
```javascript
|
|
347
|
+
client.distributions.publications.list()
|
|
348
|
+
client.distributions.publications.list(params)
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
#### [Create publication](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-publication)
|
|
352
|
+
|
|
353
|
+
```javascript
|
|
354
|
+
client.distributions.publications.create(params)
|
|
355
|
+
```
|
|
356
|
+
|
|
357
|
+
---
|
|
358
|
+
|
|
359
|
+
### Validations
|
|
360
|
+
|
|
361
|
+
Methods are provided within `client.validations.*` or `client.promotions.*` namespace.
|
|
362
|
+
|
|
363
|
+
- [Validate Voucher](#validate-voucher)
|
|
364
|
+
- [Validate Promotion Campaign](#validate-promotion-campaign)
|
|
365
|
+
|
|
366
|
+
#### [Validate Voucher](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#validate-voucher)
|
|
367
|
+
|
|
368
|
+
```javascript
|
|
369
|
+
client.validations.validateVoucher(code)
|
|
370
|
+
client.validations.validateVoucher(code, params)
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
Other possibility
|
|
374
|
+
|
|
375
|
+
```javascript
|
|
376
|
+
client.validations.validate(code)
|
|
377
|
+
client.validations.validate(code, params)
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
#### [Validate Promotion Campaign](http://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#validate-promotions-1)
|
|
381
|
+
|
|
382
|
+
```javascript
|
|
383
|
+
client.promotions.validate(params)
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
Other possibility
|
|
387
|
+
|
|
388
|
+
```javascript
|
|
389
|
+
client.validations.validate(params)
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
---
|
|
393
|
+
|
|
394
|
+
### Redemptions
|
|
395
|
+
|
|
396
|
+
Methods are provided within `client.redemptions.*` namespace.
|
|
397
|
+
|
|
398
|
+
- [Redeem Voucher](#redeem-voucher)
|
|
399
|
+
- [Get Redemption](#get-redemption)
|
|
400
|
+
- [Redeem Promotion's Tier](#redeem-promotions-tier)
|
|
401
|
+
- [Redeem Loyalty Card](#redeem-loyalty-card)
|
|
402
|
+
- [List Redemptions](#list-redemptions)
|
|
403
|
+
- [Get Voucher's Redemptions](#get-vouchers-redemptions)
|
|
404
|
+
- [Rollback Redemption](#rollback-redemption)
|
|
405
|
+
|
|
406
|
+
#### [Redeem Voucher](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#redeem-voucher)
|
|
407
|
+
|
|
408
|
+
```javascript
|
|
409
|
+
client.redemptions.redeem(code)
|
|
410
|
+
client.redemptions.redeem(code, params)
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
#### [Get Redemption](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#get-redemption)
|
|
414
|
+
|
|
415
|
+
```javascript
|
|
416
|
+
client.redemptions.get(redemptionId)
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
#### [List Redemptions](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-redemptions)
|
|
420
|
+
|
|
421
|
+
```javascript
|
|
422
|
+
client.redemptions.list()
|
|
423
|
+
client.redemptions.list(params)
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
#### [Get Voucher's Redemptions](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#vouchers-redemptions)
|
|
427
|
+
|
|
428
|
+
```javascript
|
|
429
|
+
client.redemptions.getForVoucher(code)
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
#### [Rollback Redemption](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#rollback-redemption)
|
|
433
|
+
|
|
434
|
+
```javascript
|
|
435
|
+
client.redemptions.rollback(redemptionId)
|
|
436
|
+
client.redemptions.rollback(redemptionId, params)
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
Check [redemption rollback object](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#the-redemption-rollback-object).
|
|
440
|
+
|
|
441
|
+
---
|
|
442
|
+
|
|
443
|
+
### Promotions
|
|
444
|
+
|
|
445
|
+
Methods are provided within `client.promotions.*` namespace.
|
|
446
|
+
|
|
447
|
+
- [Create Promotion Campaign](#create-promotion-campaign)
|
|
448
|
+
- [Validate Promotion Campaign](#validate-promotion-campaign)
|
|
449
|
+
- [List Promotion's Tiers](#list-promotions-tiers)
|
|
450
|
+
- [List All Promotion Tiers](#list-all-promotion-tiers)
|
|
451
|
+
- [Add Promotion Tier to Campaign](#create-promotions-tier)
|
|
452
|
+
- [Redeem Promotion](#redeem-promotion)
|
|
453
|
+
- [Update Promotion Tier](#update-promotions-tier)
|
|
454
|
+
- [Delete Promotion Tier](#delete-promotions-tier)
|
|
455
|
+
|
|
456
|
+
Read how to [Validate Promotion Campaign](#validate-promotion-campaign) in Validations section
|
|
457
|
+
|
|
458
|
+
#### [Create Promotion Campaign](http://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-promotion-campaign)
|
|
459
|
+
|
|
460
|
+
```javascript
|
|
461
|
+
client.promotions.create(promotionCampaign)
|
|
462
|
+
```
|
|
463
|
+
|
|
464
|
+
Check [promotion campaign object](http://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-promotion-campaign).
|
|
465
|
+
|
|
466
|
+
#### [List Promotion's Tiers](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#get-promotions)
|
|
467
|
+
|
|
468
|
+
```javascript
|
|
469
|
+
client.promotions.tiers.list(promotionCampaignId)
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
Check [promotion's tier object](http://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#the-promotion-object)
|
|
473
|
+
|
|
474
|
+
#### [List All Promotion Tiers](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-promotion-tiers)
|
|
475
|
+
|
|
476
|
+
```javascript
|
|
477
|
+
client.promotions.tiers.listAll()
|
|
478
|
+
client.promotions.tiers.listAll(params})
|
|
479
|
+
```
|
|
480
|
+
|
|
481
|
+
#### [Add Promotion Tier to Campaign](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#add-promotion-tier-to-campaign)
|
|
482
|
+
|
|
483
|
+
```javascript
|
|
484
|
+
client.promotions.tiers.create(promotionId, params)
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
#### [Redeem Promotion](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#redeem-promotion)
|
|
488
|
+
|
|
489
|
+
```javascript
|
|
490
|
+
client.promotions.tiers.redeem(promotionsTierId, params)
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
#### [Update Promotion Tier](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#update-promotion)
|
|
494
|
+
|
|
495
|
+
```javascript
|
|
496
|
+
client.promotions.tiers.update(promotionsTier)
|
|
497
|
+
```
|
|
498
|
+
|
|
499
|
+
#### [Delete Promotion Tier](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#delete-promotion)
|
|
500
|
+
|
|
501
|
+
```javascript
|
|
502
|
+
client.promotions.tiers.delete(promotionsTierId)
|
|
503
|
+
```
|
|
504
|
+
|
|
505
|
+
---
|
|
506
|
+
|
|
507
|
+
### Customers
|
|
508
|
+
|
|
509
|
+
Methods are provided within `client.customers.*` namespace.
|
|
510
|
+
|
|
511
|
+
- [Create Customer](#create-customer)
|
|
512
|
+
- [Get Customer](#get-customer)
|
|
513
|
+
- [Update Customer](#update-customer)
|
|
514
|
+
- [Delete Customer](#delete-customer)
|
|
515
|
+
- [List Customers](#list-customers)
|
|
516
|
+
- [Update Customer's Consents](#update-customers-consents)
|
|
517
|
+
|
|
518
|
+
#### [Create Customer](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-customer)
|
|
519
|
+
|
|
520
|
+
```javascript
|
|
521
|
+
client.customers.create(customer)
|
|
522
|
+
```
|
|
523
|
+
|
|
524
|
+
Check [customer object](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#the-customer-object).
|
|
525
|
+
|
|
526
|
+
#### [Get Customer](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#get-customer)
|
|
527
|
+
|
|
528
|
+
```javascript
|
|
529
|
+
client.customers.get(customerId)
|
|
530
|
+
```
|
|
531
|
+
|
|
532
|
+
#### [Update Customer](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#update-customer)
|
|
533
|
+
|
|
534
|
+
```javascript
|
|
535
|
+
client.customers.update(customer)
|
|
536
|
+
```
|
|
537
|
+
|
|
538
|
+
`customer` object must contain `id` or `source_id`.
|
|
539
|
+
|
|
540
|
+
#### [Delete Customer](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#delete-customer)
|
|
541
|
+
|
|
542
|
+
```javascript
|
|
543
|
+
client.customers.delete(customerId)
|
|
544
|
+
```
|
|
545
|
+
|
|
546
|
+
#### [List Customers](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-customers)
|
|
547
|
+
|
|
548
|
+
```javascript
|
|
549
|
+
client.customers.list()
|
|
550
|
+
client.customers.list(params)
|
|
551
|
+
```
|
|
552
|
+
|
|
553
|
+
Standard list customers API has limitation of available pages to be shown equal to 100. To cover cases when you would like to fetch more, you must use scroll capabilities as shown below.
|
|
554
|
+
|
|
555
|
+
#### Scroll through customers
|
|
556
|
+
|
|
557
|
+
```javascript
|
|
558
|
+
async function () {
|
|
559
|
+
for await (const customer of client.customers.scroll(params)) {
|
|
560
|
+
console.log('Customer', customer)
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
```
|
|
564
|
+
|
|
565
|
+
With optional arguments
|
|
566
|
+
|
|
567
|
+
```javascript
|
|
568
|
+
async function () {
|
|
569
|
+
for await (const customer of client.customers.scroll({
|
|
570
|
+
starting_after: "2020-01-01", // optional
|
|
571
|
+
order: "created_at" // default: "-created_at"
|
|
572
|
+
...params})
|
|
573
|
+
) {
|
|
574
|
+
console.log('Customer', customer)
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
```
|
|
578
|
+
|
|
579
|
+
`params` argument is consistent with `client.customers.list()` method.
|
|
580
|
+
|
|
581
|
+
You can optionally define scrolling cursor based on customer creation date using property `starting_after`. By default returned customers are in descending order, if you want to change it to ascending define `order` equal to `created_at`.
|
|
582
|
+
|
|
583
|
+
Keep in mind this operation may drain your API call limits fairly quickly - each api call fetches 100 customers. So if you have 100.000 customers, you will use 1000 API calls.
|
|
584
|
+
|
|
585
|
+
#### [Update Customer's Consents](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#update-customers-consents)
|
|
586
|
+
|
|
587
|
+
```javascript
|
|
588
|
+
client.customers.updateConsents(customer, consents)
|
|
589
|
+
```
|
|
590
|
+
|
|
591
|
+
---
|
|
592
|
+
|
|
593
|
+
### Consents
|
|
594
|
+
|
|
595
|
+
Methods are provided within `client.consents.*` namespace.
|
|
596
|
+
|
|
597
|
+
- [Get Consents](#get-consents)
|
|
598
|
+
|
|
599
|
+
You can [update Customer's consents](#update-customers-consents) in `client.customer.*` namespace.
|
|
600
|
+
|
|
601
|
+
#### [Get Consents](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#get-consents)
|
|
602
|
+
|
|
603
|
+
```javascript
|
|
604
|
+
client.consents.list()
|
|
605
|
+
```
|
|
606
|
+
|
|
607
|
+
---
|
|
608
|
+
|
|
609
|
+
### Orders
|
|
610
|
+
|
|
611
|
+
Methods are provided within `client.orders.*` namespace.
|
|
612
|
+
|
|
613
|
+
- [Create Order](#create-order)
|
|
614
|
+
- [Get Order](#get-order)
|
|
615
|
+
- [Update Order](#update-order)
|
|
616
|
+
- [List Orders](#list-orders)
|
|
617
|
+
|
|
618
|
+
#### [Create Order](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-order)
|
|
619
|
+
|
|
620
|
+
```javascript
|
|
621
|
+
client.orders.create(order)
|
|
622
|
+
```
|
|
623
|
+
|
|
624
|
+
Check [the order object](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#the-order-object).
|
|
625
|
+
|
|
626
|
+
#### [Get Order](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#get-order)
|
|
627
|
+
|
|
628
|
+
```javascript
|
|
629
|
+
client.orders.get(orderId)
|
|
630
|
+
```
|
|
631
|
+
|
|
632
|
+
#### [Update Order](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#update-order)
|
|
633
|
+
|
|
634
|
+
```javascript
|
|
635
|
+
client.orders.update(order)
|
|
636
|
+
```
|
|
637
|
+
|
|
638
|
+
`order` object must contain `id` or `source_id`.
|
|
639
|
+
|
|
640
|
+
#### [List Orders](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-orders)
|
|
641
|
+
|
|
642
|
+
```javascript
|
|
643
|
+
client.orders.list()
|
|
644
|
+
client.orders.list(params)
|
|
645
|
+
```
|
|
646
|
+
|
|
647
|
+
---
|
|
648
|
+
|
|
649
|
+
### Products
|
|
650
|
+
|
|
651
|
+
Methods are provided within `client.products.*` namespace.
|
|
652
|
+
|
|
653
|
+
- [Create Product](#create-product)
|
|
654
|
+
- [Get Product](#get-product)
|
|
655
|
+
- [Update Product](#update-product)
|
|
656
|
+
- [Delete Product](#delete-product)
|
|
657
|
+
- [Update Products in Bulk](#update-products-in-bulk)
|
|
658
|
+
- [List Products](#list-products)
|
|
659
|
+
- [Create SKU](#create-sku)
|
|
660
|
+
- [Get SKU](#get-sku)
|
|
661
|
+
- [Update SKU](#update-sku)
|
|
662
|
+
- [Delete SKU](#delete-sku)
|
|
663
|
+
- [List all product SKUs](#list-all-product-skus)
|
|
664
|
+
|
|
665
|
+
#### [Create Product](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-product)
|
|
666
|
+
|
|
667
|
+
```javascript
|
|
668
|
+
client.products.create(product)
|
|
669
|
+
```
|
|
670
|
+
|
|
671
|
+
Check [product object](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#the-product-object).
|
|
672
|
+
|
|
673
|
+
#### [Get Product](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#get-product)
|
|
674
|
+
|
|
675
|
+
```javascript
|
|
676
|
+
client.products.get(productId)
|
|
677
|
+
```
|
|
678
|
+
|
|
679
|
+
#### [Update Product](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#update-product)
|
|
680
|
+
|
|
681
|
+
```javascript
|
|
682
|
+
client.products.update(product)
|
|
683
|
+
```
|
|
684
|
+
|
|
685
|
+
#### [Delete Product](<(https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#delete-product)>)
|
|
686
|
+
|
|
687
|
+
```javascript
|
|
688
|
+
client.products.delete(productId)
|
|
689
|
+
client.products.delete(productId, { force: true })
|
|
690
|
+
```
|
|
691
|
+
|
|
692
|
+
#### [Update Products in Bulk](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#update-products-in-bulk)
|
|
693
|
+
|
|
694
|
+
```javascript
|
|
695
|
+
client.products.bulkUpdate(products)
|
|
696
|
+
```
|
|
697
|
+
|
|
698
|
+
#### [List Products](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-products)
|
|
699
|
+
|
|
700
|
+
```javascript
|
|
701
|
+
client.products.list()
|
|
702
|
+
client.products.list(params)
|
|
703
|
+
```
|
|
704
|
+
|
|
705
|
+
#### [Create SKU](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-skus)
|
|
706
|
+
|
|
707
|
+
```javascript
|
|
708
|
+
client.products.createSku(productId, sku)
|
|
709
|
+
```
|
|
710
|
+
|
|
711
|
+
Check [SKU object](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#the-sku-object).
|
|
712
|
+
|
|
713
|
+
#### [Get SKU](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#get-skus)
|
|
714
|
+
|
|
715
|
+
```javascript
|
|
716
|
+
client.products.getSku(productId, skuId)
|
|
717
|
+
```
|
|
718
|
+
|
|
719
|
+
#### [Update SKU](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#update-skus)
|
|
720
|
+
|
|
721
|
+
```javascript
|
|
722
|
+
client.products.updateSku(productId, sku)
|
|
723
|
+
```
|
|
724
|
+
|
|
725
|
+
#### [Delete SKU](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#delete-skus)
|
|
726
|
+
|
|
727
|
+
```javascript
|
|
728
|
+
client.products.deleteSku(productId, skuId)
|
|
729
|
+
client.products.deleteSku(productId, skuId, { force: true })
|
|
730
|
+
```
|
|
731
|
+
|
|
732
|
+
#### [List all product SKUs](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-skus)
|
|
733
|
+
|
|
734
|
+
```javascript
|
|
735
|
+
client.products.listSkus(productId)
|
|
736
|
+
```
|
|
737
|
+
|
|
738
|
+
---
|
|
739
|
+
|
|
740
|
+
### Rewards
|
|
741
|
+
|
|
742
|
+
Methods are provided within `client.rewards.*` namespace.
|
|
743
|
+
|
|
744
|
+
- [Create Reward](#create-reward)
|
|
745
|
+
- [Get Reward](#get-reward)
|
|
746
|
+
- [Update Reward](#update-reward)
|
|
747
|
+
- [Delete Reward](#delete-reward)
|
|
748
|
+
- [List Rewards](#list-rewards)
|
|
749
|
+
- [Create Reward Assignment](#create-reward-assignment)
|
|
750
|
+
- [Update Reward Assignment](#update-reward-assignment)
|
|
751
|
+
- [Delete Reward Assignment](#delete-reward-assignment)
|
|
752
|
+
- [List Reward Assignments](#list-reward-assignments)
|
|
753
|
+
|
|
754
|
+
#### [Create Reward](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-reward)
|
|
755
|
+
|
|
756
|
+
```javascript
|
|
757
|
+
client.rewards.create(reward)
|
|
758
|
+
```
|
|
759
|
+
|
|
760
|
+
Check [reward object](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#the-reward-object).
|
|
761
|
+
|
|
762
|
+
#### [Get Reward](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#get-reward)
|
|
763
|
+
|
|
764
|
+
```javascript
|
|
765
|
+
client.rewards.get(rewardId)
|
|
766
|
+
```
|
|
767
|
+
|
|
768
|
+
#### [Update Reward](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#update-reward)
|
|
769
|
+
|
|
770
|
+
```javascript
|
|
771
|
+
client.rewards.update(reward)
|
|
772
|
+
```
|
|
773
|
+
|
|
774
|
+
#### [Delete Reward](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#delete-reward)
|
|
775
|
+
|
|
776
|
+
```javascript
|
|
777
|
+
client.rewards.delete(rewardId)
|
|
778
|
+
```
|
|
779
|
+
|
|
780
|
+
#### [List Rewards](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-rewards)
|
|
781
|
+
|
|
782
|
+
```javascript
|
|
783
|
+
client.rewards.list()
|
|
784
|
+
client.rewards.list(params)
|
|
785
|
+
```
|
|
786
|
+
|
|
787
|
+
#### [Create Reward Assignment](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-reward-assignment)
|
|
788
|
+
|
|
789
|
+
```javascript
|
|
790
|
+
client.rewards.createAssignment(rewardId, assignment)
|
|
791
|
+
```
|
|
792
|
+
|
|
793
|
+
Check [reward assignment object](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#the-reward-assignment-object).
|
|
794
|
+
|
|
795
|
+
#### [Update Reward Assignment](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#update-reward-assignment)
|
|
796
|
+
|
|
797
|
+
```javascript
|
|
798
|
+
client.rewards.updateAssignment(rewardId, assignment)
|
|
799
|
+
```
|
|
800
|
+
|
|
801
|
+
#### [Delete Reward Assignment](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#delete-reward-assignment)
|
|
802
|
+
|
|
803
|
+
```javascript
|
|
804
|
+
client.rewards.deleteAssignment(rewardId, assignmentId)
|
|
805
|
+
```
|
|
806
|
+
|
|
807
|
+
#### [List Reward Assignments](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-reward-assignments)
|
|
808
|
+
|
|
809
|
+
```javascript
|
|
810
|
+
client.rewards.listAssignments(rewardId)
|
|
811
|
+
client.rewards.listAssignments(rewardId, params)
|
|
812
|
+
```
|
|
813
|
+
|
|
814
|
+
---
|
|
815
|
+
|
|
816
|
+
### Loyalties
|
|
817
|
+
|
|
818
|
+
Methods are provided within `client.loyalties.*` namespace.
|
|
819
|
+
|
|
820
|
+
- [Create Loyalty Program](#create-loyalty-program)
|
|
821
|
+
- [Get Loyalty Program](#get-loyalty-program)
|
|
822
|
+
- [Update Loyalty Program](#update-loyalty-program)
|
|
823
|
+
- [Delete Loyalty Program](#delete-loyalty-program)
|
|
824
|
+
- [List Loyalty Programs](#list-loyalty-programs)
|
|
825
|
+
- [Create Loyalty Program Reward Assignment](#create-loyalty-program-reward-assignment)
|
|
826
|
+
- [Update Loyalty Program Reward Assignment](#update-loyalty-program-reward-assignment)
|
|
827
|
+
- [Delete Loyalty Program Reward Assignment](#delete-loyalty-program-reward-assignment)
|
|
828
|
+
- [List Loyalty Program Reward Assignments](#list-loyalty-program-reward-assignments)
|
|
829
|
+
- [Create Loyalty Program Earning Rules](#create-loyalty-program-earning-rules)
|
|
830
|
+
- [Update Loyalty Program Earning Rule](#update-loyalty-program-earning-rule)
|
|
831
|
+
- [Delete Loyalty Program Earning Rule](#delete-loyalty-program-earning-rule)
|
|
832
|
+
- [List Loyalty Program Earning Rules](#list-loyalty-program-earning-rules)
|
|
833
|
+
- [Create Loyalty Program Member](#create-loyalty-program-member)
|
|
834
|
+
- [Get Loyalty Program Member](#get-loyalty-program-member)
|
|
835
|
+
- [List Loyalty Program Members](#list-loyalty-members)
|
|
836
|
+
- [Get Loyalty Program Member Activities](#get-loyalty-program-member-activities)
|
|
837
|
+
- [Add Loyalty Card Balance](#add-loyalty-card-balance)
|
|
838
|
+
- [Redeem Loyalty Card](#redeem-loyalty-card)
|
|
839
|
+
|
|
840
|
+
#### [Create Loyalty Program](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-loyalty-program)
|
|
841
|
+
|
|
842
|
+
```javascript
|
|
843
|
+
client.loyalties.create(campaign)
|
|
844
|
+
```
|
|
845
|
+
|
|
846
|
+
#### [Get Loyalty Program](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#get-loyalty-program)
|
|
847
|
+
|
|
848
|
+
```javascript
|
|
849
|
+
client.loyalties.get(campaignId)
|
|
850
|
+
```
|
|
851
|
+
|
|
852
|
+
#### [Update Loyalty Program](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#update-loyalty-program)
|
|
853
|
+
|
|
854
|
+
```javascript
|
|
855
|
+
client.loyalties.update(campaign)
|
|
856
|
+
```
|
|
857
|
+
|
|
858
|
+
#### [Delete Loyalty Program](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#delete-loyalty-program)
|
|
859
|
+
|
|
860
|
+
```javascript
|
|
861
|
+
client.loyalties.delete(campaignId)
|
|
862
|
+
```
|
|
863
|
+
|
|
864
|
+
#### [List Loyalty Programs](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-loyalty-programs)
|
|
865
|
+
|
|
866
|
+
```javascript
|
|
867
|
+
client.loyalties.list()
|
|
868
|
+
client.loyalties.list(params)
|
|
869
|
+
```
|
|
870
|
+
|
|
871
|
+
#### [Create Loyalty Program Reward Assignment](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-reward-assignment-1)
|
|
872
|
+
|
|
873
|
+
```javascript
|
|
874
|
+
client.loyalties.createRewardAssignments(campaignId, assignment)
|
|
875
|
+
```
|
|
876
|
+
|
|
877
|
+
#### [Update Loyalty Program Reward Assignment](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#update-reward-assignment-1)
|
|
878
|
+
|
|
879
|
+
```javascript
|
|
880
|
+
client.loyalties.updateRewardAssignment(campaignId, assignment)
|
|
881
|
+
```
|
|
882
|
+
|
|
883
|
+
#### [Delete Loyalty Program Reward Assignment](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#delete-reward-assignment-1)
|
|
884
|
+
|
|
885
|
+
```javascript
|
|
886
|
+
client.loyalties.deleteRewardAssignment(campaignId, assignmentId)
|
|
887
|
+
```
|
|
888
|
+
|
|
889
|
+
#### [List Loyalty Program Reward Assignments](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-reward-assignments-1)
|
|
890
|
+
|
|
891
|
+
```javascript
|
|
892
|
+
client.loyalties.listRewardAssignments(campaignId)
|
|
893
|
+
client.loyalties.listRewardAssignments(campaignId, params)
|
|
894
|
+
```
|
|
895
|
+
|
|
896
|
+
#### [Create Loyalty Program Earning Rules](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-earning-rule)
|
|
897
|
+
|
|
898
|
+
```javascript
|
|
899
|
+
client.loyalties.createEarningRule(campaignId, earningRules)
|
|
900
|
+
```
|
|
901
|
+
|
|
902
|
+
#### [Update Loyalty Program Earning Rule](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#update-earning-rule)
|
|
903
|
+
|
|
904
|
+
```javascript
|
|
905
|
+
client.loyalties.updateEarningRule(campaignId, earningRule)
|
|
906
|
+
```
|
|
907
|
+
|
|
908
|
+
#### [Delete Loyalty Program Earning Rule](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#delete-earning-rule)
|
|
909
|
+
|
|
910
|
+
```javascript
|
|
911
|
+
client.loyalties.deleteEarningRule(campaignId, earningRuleId)
|
|
912
|
+
```
|
|
913
|
+
|
|
914
|
+
#### [List Loyalty Program Earning Rules](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-earning-rules)
|
|
915
|
+
|
|
916
|
+
```javascript
|
|
917
|
+
client.loyalties.listEarningRules(campaignId)
|
|
918
|
+
client.loyalties.listEarningRules(campaignId, params)
|
|
919
|
+
```
|
|
920
|
+
|
|
921
|
+
#### [Create Loyalty Program Member](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-member)
|
|
922
|
+
|
|
923
|
+
```javascript
|
|
924
|
+
client.loyalties.createMember(campaignId, member)
|
|
925
|
+
```
|
|
926
|
+
|
|
927
|
+
#### [Get Loyalty Program Member](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#get-member)
|
|
928
|
+
|
|
929
|
+
```javascript
|
|
930
|
+
client.loyalties.getMember(campaignId, memberId)
|
|
931
|
+
```
|
|
932
|
+
|
|
933
|
+
#### [List Loyalty Program Members](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-members)
|
|
934
|
+
|
|
935
|
+
```javascript
|
|
936
|
+
client.loyalties.listMembers(campaignId)
|
|
937
|
+
client.loyalties.listMembers(campaignId, params)
|
|
938
|
+
```
|
|
939
|
+
|
|
940
|
+
#### [Get Loyalty Program Member Activities](https://docs.voucherify.io/reference#get-member-activities)
|
|
941
|
+
|
|
942
|
+
```javascript
|
|
943
|
+
client.loyalties.getMemberActivities(campaignId, memberId)
|
|
944
|
+
```
|
|
945
|
+
|
|
946
|
+
`memberId` referrers to Loyalty Card code.
|
|
947
|
+
|
|
948
|
+
#### [Add Loyalty Card Balance](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#add-loyalty-card-balance)
|
|
949
|
+
|
|
950
|
+
```javascript
|
|
951
|
+
client.loyalties.addPoints(campaignId, memberId, balance)
|
|
952
|
+
```
|
|
953
|
+
|
|
954
|
+
`memberId` referrers to Loyalty Card code.
|
|
955
|
+
|
|
956
|
+
#### [Redeem Loyalty Card]
|
|
957
|
+
|
|
958
|
+
```javascript
|
|
959
|
+
client.loyalties.redeemReward(campaignId, memberId, params)
|
|
960
|
+
```
|
|
961
|
+
|
|
962
|
+
`memberId` referrers to Loyalty Card code.
|
|
963
|
+
|
|
964
|
+
When redeeming reward with type `COIN` you need to provide additional `order` object in the `params`
|
|
965
|
+
|
|
966
|
+
---
|
|
967
|
+
|
|
968
|
+
### Segments
|
|
969
|
+
|
|
970
|
+
Methods are provided within `client.segments.*` namespace.
|
|
971
|
+
|
|
972
|
+
- [Create Segment](#create-segment)
|
|
973
|
+
- [Get Segment](#get-segment)
|
|
974
|
+
- [Delete Segment](#delete-segment)
|
|
975
|
+
|
|
976
|
+
#### [Create Segment](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-segment)
|
|
977
|
+
|
|
978
|
+
```javascript
|
|
979
|
+
client.segments.create(segment)
|
|
980
|
+
```
|
|
981
|
+
|
|
982
|
+
Check [the segment object](https://docs.voucherify.io/v1/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#the-segment-object).
|
|
983
|
+
|
|
984
|
+
#### [Get Segment](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#get-segment)
|
|
985
|
+
|
|
986
|
+
```javascript
|
|
987
|
+
client.segments.get(segmentId)
|
|
988
|
+
```
|
|
989
|
+
|
|
990
|
+
#### [Delete Segment](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#delete-segment)
|
|
991
|
+
|
|
992
|
+
```javascript
|
|
993
|
+
client.segments.delete(segmentId)
|
|
994
|
+
```
|
|
995
|
+
|
|
996
|
+
---
|
|
997
|
+
|
|
998
|
+
### Validation Rules
|
|
999
|
+
|
|
1000
|
+
Methods are provided within `client.validationRules.*` namespace.
|
|
1001
|
+
|
|
1002
|
+
- [Create Rule](#create-validation-rule)
|
|
1003
|
+
- [Get Rule](#get-validation-rule)
|
|
1004
|
+
- [Update Rule](#update-validation-rule)
|
|
1005
|
+
- [Delete Rule](#delete-validation-rule)
|
|
1006
|
+
- [Create Rule Assignment](#create-validation-rule-assignment)
|
|
1007
|
+
- [Delete Rule Assignment](#delete-validation-rule-assignment)
|
|
1008
|
+
- [List Rules](#list-validation-rules)
|
|
1009
|
+
- [List Rule Assignments](#list-validation-rule-assignments)
|
|
1010
|
+
|
|
1011
|
+
#### [Create Validation Rule](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-validation-rules)
|
|
1012
|
+
|
|
1013
|
+
```javascript
|
|
1014
|
+
client.validationRules.create(validationRule)
|
|
1015
|
+
```
|
|
1016
|
+
|
|
1017
|
+
Check [validation rule object](https://docs.voucherify.io/v1/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#the-validation-rule-object).
|
|
1018
|
+
|
|
1019
|
+
#### [Get Validation Rule](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#get-validation-rules)
|
|
1020
|
+
|
|
1021
|
+
```javascript
|
|
1022
|
+
client.validationRules.get(validationRuleId)
|
|
1023
|
+
```
|
|
1024
|
+
|
|
1025
|
+
#### [Update Validation Rule](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#update-validation-rules)
|
|
1026
|
+
|
|
1027
|
+
```javascript
|
|
1028
|
+
client.validationRules.update(validationRule)
|
|
1029
|
+
```
|
|
1030
|
+
|
|
1031
|
+
#### [Delete Validation Rule](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#delete-validation-rules)
|
|
1032
|
+
|
|
1033
|
+
```javascript
|
|
1034
|
+
client.validationRules.delete(validationRuleId)
|
|
1035
|
+
```
|
|
1036
|
+
|
|
1037
|
+
#### [Create Validation Rule Assignment](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-validation-rules-assignment)
|
|
1038
|
+
|
|
1039
|
+
```javascript
|
|
1040
|
+
client.validationRules.createAssignment(validationRuleId, assignment)
|
|
1041
|
+
```
|
|
1042
|
+
|
|
1043
|
+
#### [Delete Validation Rule Assignment](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#delete-validation-rules-assignment)
|
|
1044
|
+
|
|
1045
|
+
```javascript
|
|
1046
|
+
client.validationRules.deleteAssignment(validationRuleId, assignmentId)
|
|
1047
|
+
```
|
|
1048
|
+
|
|
1049
|
+
#### [List Validation Rules](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-validation-rules)
|
|
1050
|
+
|
|
1051
|
+
```javascript
|
|
1052
|
+
client.validationRules.list()
|
|
1053
|
+
client.validationRules.list(params)
|
|
1054
|
+
```
|
|
1055
|
+
|
|
1056
|
+
#### [List Validation Rule Assignments](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-validation-rule-assignments)
|
|
1057
|
+
|
|
1058
|
+
```javascript
|
|
1059
|
+
client.validationRules.listAssignments(validationRuleId)
|
|
1060
|
+
client.validationRules.listAssignments(validationRuleId, params)
|
|
1061
|
+
```
|
|
1062
|
+
|
|
1063
|
+
---
|
|
1064
|
+
|
|
1065
|
+
### Events
|
|
1066
|
+
|
|
1067
|
+
Methods are provided within `client.events.*` namespace.
|
|
1068
|
+
|
|
1069
|
+
- [Create Custom Event](#create-custom-event)
|
|
1070
|
+
|
|
1071
|
+
#### [Create Custom Event](http://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#the-custom-event-object)
|
|
1072
|
+
|
|
1073
|
+
```javascript
|
|
1074
|
+
client.events.create(eventName, { customer })
|
|
1075
|
+
client.events.create(eventName, { customer, metadata })
|
|
1076
|
+
client.events.create(eventName, { customer, referral, metadata })
|
|
1077
|
+
client.events.create(eventName, { customer, referral, loyalty, metadata })
|
|
1078
|
+
```
|
|
1079
|
+
|
|
1080
|
+
Check [customer object](https://docs.voucherify.io/v1/reference#the-customer-object).
|
|
1081
|
+
|
|
1082
|
+
|
|
1083
|
+
### Async Actions
|
|
1084
|
+
Methods are provided within `client.asyncActions.*` namespace.
|
|
1085
|
+
|
|
1086
|
+
- [Get Async Action](#get-async-action)
|
|
1087
|
+
- [List Async Actions](#list-async-actions)
|
|
1088
|
+
|
|
1089
|
+
#### [Get Async Action](http://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#get-async-actions-1)
|
|
1090
|
+
```javascript
|
|
1091
|
+
client.asyncActions.get(asyncActionId)
|
|
1092
|
+
```
|
|
1093
|
+
|
|
1094
|
+
#### [List Async Actions](http://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-async-actions)
|
|
1095
|
+
```javascript
|
|
1096
|
+
client.asyncActions.list()
|
|
1097
|
+
client.asyncActions.list(params)
|
|
1098
|
+
```
|
|
1099
|
+
|
|
1100
|
+
---
|
|
1101
|
+
|
|
1102
|
+
# 💅 Client Side
|
|
1103
|
+
|
|
1104
|
+
## <a name="client-side-setup"></a>Setup
|
|
1105
|
+
|
|
1106
|
+
```javascript
|
|
1107
|
+
const { VoucherifyClientSide } = require('@voucherify/sdk')
|
|
1108
|
+
|
|
1109
|
+
const client = VoucherifyClientSide({
|
|
1110
|
+
clientApplicationId: 'YOUR-APPLICATION-ID',
|
|
1111
|
+
clientSecretKey: 'YOUR-CLIENT-SECRET-KEY',
|
|
1112
|
+
apiUrl: 'https://<region>.api.voucherify.io', // optional
|
|
1113
|
+
origin: 'example.com', // read more below
|
|
1114
|
+
customHeaders: { "MY_CUSTOM_HEADER": "my_value" } // optional
|
|
1115
|
+
})
|
|
1116
|
+
```
|
|
1117
|
+
|
|
1118
|
+
The `origin` property is required in Node.js, but when using in client-side environment (in browser) this option will be ignored.
|
|
1119
|
+
|
|
1120
|
+
We are tracking users which are validating vouchers with those who consume them by a tracking_id. For that we are setting up an identity for the user.
|
|
1121
|
+
|
|
1122
|
+
```javascript
|
|
1123
|
+
client.setIdentity('gustav@purpleson.com')
|
|
1124
|
+
```
|
|
1125
|
+
|
|
1126
|
+
## <a name="client-side-methods"></a>Methods
|
|
1127
|
+
|
|
1128
|
+
Methods are provided within `client.*` namespace.
|
|
1129
|
+
|
|
1130
|
+
- [Set Identity](#set-identity)
|
|
1131
|
+
- [Validate](#validate)
|
|
1132
|
+
- [Redeem](#redeem)
|
|
1133
|
+
- [Publish](#publish)
|
|
1134
|
+
- [List vouchers](#list-vouchers)
|
|
1135
|
+
- [Create customer](#create-customer)
|
|
1136
|
+
- [List consents](#list-consents)
|
|
1137
|
+
- [Update consents](#update-consents)
|
|
1138
|
+
- [Track custom events](#track-custom-events)
|
|
1139
|
+
|
|
1140
|
+
#### Set Identity
|
|
1141
|
+
|
|
1142
|
+
```javascript
|
|
1143
|
+
client.setIdentity(trackingId)
|
|
1144
|
+
```
|
|
1145
|
+
|
|
1146
|
+
#### [Validate](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#vouchers-validate)
|
|
1147
|
+
|
|
1148
|
+
```javascript
|
|
1149
|
+
client.validate(params)
|
|
1150
|
+
```
|
|
1151
|
+
|
|
1152
|
+
#### [Redeem](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#redeem-voucher-client-side)
|
|
1153
|
+
|
|
1154
|
+
```javascript
|
|
1155
|
+
client.redeem(code, payload)
|
|
1156
|
+
```
|
|
1157
|
+
|
|
1158
|
+
#### Publish
|
|
1159
|
+
|
|
1160
|
+
```javascript
|
|
1161
|
+
client.publish(campaignName, payload)
|
|
1162
|
+
client.publish(campaignName, payload, queryParams)
|
|
1163
|
+
```
|
|
1164
|
+
|
|
1165
|
+
#### [List vouchers](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#list-vouchers)
|
|
1166
|
+
|
|
1167
|
+
```javascript
|
|
1168
|
+
client.listVouchers()
|
|
1169
|
+
client.listVouchers(params)
|
|
1170
|
+
```
|
|
1171
|
+
|
|
1172
|
+
#### [Create customer](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#create-customer)
|
|
1173
|
+
|
|
1174
|
+
```javascript
|
|
1175
|
+
client.createCustomer(customer)
|
|
1176
|
+
client.createCustomer(customer, enableDoubleOptIn)
|
|
1177
|
+
```
|
|
1178
|
+
|
|
1179
|
+
`enableDoubleOptIn` sets request header to `{X-Voucherify-Double-Opt-In: true}`, which forces user to confirm registration / subscription.
|
|
1180
|
+
|
|
1181
|
+
#### [List consents](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#get-consent-client-side)
|
|
1182
|
+
|
|
1183
|
+
```javascript
|
|
1184
|
+
client.listConsents()
|
|
1185
|
+
```
|
|
1186
|
+
|
|
1187
|
+
#### [Update consents](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#update-customers-consents-client)
|
|
1188
|
+
|
|
1189
|
+
```javascript
|
|
1190
|
+
client.updateConsents(idOrSourceId, consents)
|
|
1191
|
+
```
|
|
1192
|
+
|
|
1193
|
+
#### [Track custom events](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#track-custom-event-client-side)
|
|
1194
|
+
|
|
1195
|
+
```javascript
|
|
1196
|
+
client.track(eventName, metadata, customer)
|
|
1197
|
+
```
|
|
1198
|
+
|
|
1199
|
+
# <a name="snippet"></a>🏎 Marketer-ready Voucherify snippet
|
|
1200
|
+
|
|
1201
|
+
Go [here](./examples/sdk/with-html) for more HTML-based examples
|
|
1202
|
+
|
|
1203
|
+
```
|
|
1204
|
+
<body>
|
|
1205
|
+
<div id="voucher-validate"></div>
|
|
1206
|
+
|
|
1207
|
+
<link rel="stylesheet" type="text/css" href="https://unpkg.com/@voucherify/react-widget@0.0.5/dist/voucherify.css" />
|
|
1208
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/qs/6.5.1/qs.min.js" crossorigin></script>
|
|
1209
|
+
<script src="https://unpkg.com/react@17/umd/react.production.min.js" crossorigin></script>
|
|
1210
|
+
<script src="https://unpkg.com/react-dom@17/umd/react-dom.production.min.js" crossorigin></script>
|
|
1211
|
+
<script src="https://unpkg.com/axios/dist/axios.min.js" crossorigin></script>
|
|
1212
|
+
<script type="text/javascript" src="https://unpkg.com/@voucherify/sdk@0.0.5/dist/voucherifysdk.umd.production.min.js" crossorigin></script>
|
|
1213
|
+
<script type="text/javascript" src="https://unpkg.com/@voucherify/react-widget@0.0.5/dist/voucherifywidget.umd.production.min.js" crossorigin></script>
|
|
1214
|
+
|
|
1215
|
+
<script type="text/javascript">
|
|
1216
|
+
window.ReactDOM.render(
|
|
1217
|
+
window.React.createElement(VoucherifyWidget.VoucherifyValidate, {
|
|
1218
|
+
clientApplicationId: 'CLIENT-APPLICATION-ID',
|
|
1219
|
+
clientSecretKey: 'CLIENT-SECRET-KEY',
|
|
1220
|
+
amount: true,
|
|
1221
|
+
}),
|
|
1222
|
+
document.querySelector('#voucher-validate'),
|
|
1223
|
+
)
|
|
1224
|
+
</script>
|
|
1225
|
+
</body>
|
|
1226
|
+
```
|
|
1227
|
+
|
|
1228
|
+
# <a name="migration"></a>↔️ Migration
|
|
1229
|
+
|
|
1230
|
+
Check our [MIGRATION GUIDE](./MIGRATION.md) to learn more about switching to our newest SDK.
|
|
1231
|
+
|
|
1232
|
+
# <a name="typescript"></a>🦸 TypeScript
|
|
1233
|
+
|
|
1234
|
+
Voucherify JS SDK includes TypeScript declarations for our latest API. We recommend using TypeScript Version 4.2.
|
|
1235
|
+
|
|
1236
|
+
You can find TS example in [examples/with-nodejs-typescript](/examples/with-nodejs).
|
|
1237
|
+
|
|
1238
|
+
# <a name="error-handling"></a>😨 Error handling
|
|
1239
|
+
|
|
1240
|
+
Voucherify `error` object always has consistent structure, described in details in our [API reference](https://docs.voucherify.io/reference?utm_source=github&utm_medium=sdk&utm_campaign=acq#errors).
|
|
1241
|
+
|
|
1242
|
+
# <a name="legacy"></a>👴 Legacy Voucherify JS SDKs
|
|
1243
|
+
|
|
1244
|
+
Legacy client-side Voucherify JS SDK is available here: [voucherify.js](https://github.com/rspective/voucherify.js).
|
|
1245
|
+
|
|
1246
|
+
Legacy server-side Voucherify JS SDK is available here: [voucherify-nodejs-sdk](https://github.com/voucherifyio/voucherify-nodejs-sdk).
|
|
1247
|
+
|
|
1248
|
+
# <a name="contributing"></a>🛠️ Contributing
|
|
1249
|
+
|
|
1250
|
+
Bug reports and pull requests are welcome through [GitHub Issues](https://github.com/voucherifyio/voucherify-nodejs-sdk/issues).
|
|
1251
|
+
|
|
1252
|
+
Read more about how to Contribute to Voucherify JS SDK by visiting [CONTRIBUTING.md](/CONTRIBUTING.md)
|
|
1253
|
+
|
|
1254
|
+
# <a name="changelog"></a>🗄️ Changelog
|
|
1255
|
+
|
|
1256
|
+
Visit [CHANGELOG](./CHANGELOG.md) to learn more about new changes.
|
|
1257
|
+
|
|
1258
|
+
Voucherify React Widget CHANGELOG can be found [here](../react-widget/CHANGELOG.md)
|