rejoiner 2.17.0 → 2.17.1

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.
Files changed (2) hide show
  1. package/README.md +199 -126
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,188 +1,261 @@
1
- # Rejoiner Node.js client wrapper
1
+ # Rejoiner Node.js Client
2
2
 
3
- ## Install
4
-
5
- ````bash
6
- yarn add rejoiner
7
- ````
3
+ A Node.js client for the [Rejoiner](https://rejoiner.com) email marketing and cart abandonment platform API.
8
4
 
9
- or
5
+ ## Install
10
6
 
11
- ````bash
7
+ ```bash
12
8
  npm install rejoiner --save
13
- ````
9
+ ```
10
+
11
+ ## Configuration
14
12
 
15
- ## Use
13
+ ```js
14
+ const Rejoiner = require('rejoiner')
16
15
 
17
- ````js
18
- var Rejoiner = require('rejoiner')
16
+ const client = new Rejoiner({
17
+ siteId: 'yourSiteId',
18
+ apiKey: 'yourApiKey',
19
19
 
20
- var client = new Rejoiner({
21
- // Your Site ID
22
- siteId: 'eXaMpLe',
23
- // Your API key
24
- apiKey: 'tHiSaPiKeYiSjUsTaNeXaMpLeAnDyOuCaNtUsEiT',
20
+ // Optional
21
+ apiVersion: 2, // API version: 1 (default) or 2
22
+ webhookSecret: 'secret', // For webhook verification
25
23
  })
26
- ````
24
+ ```
25
+
26
+ ### Environment Variables
27
+
28
+ Configuration can also be set via environment variables:
29
+
30
+ - `REJOINER_SITE_ID` - Your site ID
31
+ - `REJOINER_API_KEY` - Your API key
32
+ - `REJOINER_WEBHOOK_SECRET` - Webhook secret for verification (optional)
27
33
 
28
- ## Ping
34
+ ```js
35
+ // With env vars set, you can instantiate without options
36
+ const client = new Rejoiner()
37
+ ```
29
38
 
30
- The `ping` endpoint can be used to verify your credentials are working.
39
+ ## Verify Credentials
31
40
 
32
- ````js
41
+ ```js
33
42
  client.verify.ping()
34
- .then(...)
35
- .catch(...)
36
- ````
43
+ ```
44
+
45
+ ## Webhooks
46
+
47
+ Verify incoming webhook signatures:
48
+
49
+ ```js
50
+ const signatureHeader = req.headers['x-rejoiner-signature']
51
+ const payload = req.rawBody // Raw request body as string
52
+
53
+ const isValid = client.verifyWebhook(signatureHeader, payload)
54
+ ```
55
+
56
+ Requires `webhookSecret` to be configured.
37
57
 
38
58
  ## Customer Endpoints
39
59
 
60
+ ### Get Customer
61
+
62
+ ```js
63
+ // By email (API v1 and v2)
64
+ client.customer.get('test@example.com')
65
+ client.customer.getByEmail('test@example.com')
66
+
67
+ // By phone (API v2 only)
68
+ client.customer.getByPhone('+15551234567')
69
+ client.customer.get('+15551234567', 'by_phone')
70
+ ```
71
+
72
+ ### Update Customer
73
+
74
+ ```js
75
+ client.customer.update({
76
+ email: 'test@example.com',
77
+ first_name: 'Test',
78
+ last_name: 'User',
79
+ // ... other customer fields
80
+ })
81
+ ```
82
+
40
83
  ### Convert Customer
41
84
 
42
- ````js
85
+ ```js
43
86
  client.customer.convert({
44
87
  email: 'test@example.com',
45
88
  cart_data: {
46
89
  cart_value: 20000,
47
90
  cart_item_count: 2,
48
91
  promo: 'COUPON_CODE',
49
- return_url: 'https://www.example.com/return_url',
50
- ...
92
+ return_url: 'https://www.example.com/cart',
51
93
  },
52
94
  cart_items: [
53
95
  {
54
- product_id: 'example',
96
+ product_id: 'SKU123',
55
97
  name: 'Example Product',
56
98
  price: 10000,
57
- description: 'Information about Example Product.',
58
- category: [
59
- 'Example Category 1',
60
- 'Example Category 2',
61
- ],
62
- item_qty: 1,
63
- qty_price: 10000,
99
+ item_qty: 2,
100
+ qty_price: 20000,
64
101
  product_url: 'https://www.example.com/products/example',
65
- image_url: 'https://www.example.com/products/example/images/example.jpg',
66
- ...
102
+ image_url: 'https://www.example.com/images/example.jpg',
67
103
  },
68
- {
69
- product_id: 'example2',
70
- name: 'Example Product 2',
71
- price: 10000,
72
- description: 'Information about Example Product 2.',
73
- category: [
74
- 'Example Category 2',
75
- 'Example Category 3',
76
- ],
77
- item_qty: 1,
78
- qty_price: 10000,
79
- product_url: 'https://www.example.com/products/example2',
80
- image_url: 'https://www.example.com/products/example2/images/example.jpg',
81
- ...
82
- },
83
- ...
84
104
  ],
85
105
  })
86
- .then(...)
87
- .catch(...)
88
- ````
89
106
 
90
- ### Journey Cancellation
107
+ // Force conversion even if customer already converted
108
+ client.customer.convert(data, true)
109
+ ```
110
+
111
+ ### Cancel Journey
91
112
 
92
- ````js
113
+ ```js
93
114
  client.customer.cancel('test@example.com')
94
- .then(...)
95
- .catch(...)
96
- ````
115
+ ```
97
116
 
98
- ### Customer Unsubscribe
117
+ ### Unsubscribe Customer
99
118
 
100
- ````js
119
+ ```js
101
120
  client.customer.unsubscribe('test@example.com')
102
- .then(...)
103
- .catch(...)
104
- ````
121
+ ```
105
122
 
106
- ### Record Explicit Customer Consent
123
+ ### Record Opt-In Consent
107
124
 
108
- ````js
125
+ ```js
109
126
  client.customer.optIn('test@example.com')
110
- .then(...)
111
- .catch(...)
112
- ````
127
+ ```
113
128
 
114
- ### Customer Preference Tags
129
+ ## Customer Tags (API v2 only)
115
130
 
116
- ### Get Preference Tags
131
+ Manage customer tags for segmentation and journey triggers.
117
132
 
118
- ````js
119
- client.customer.preferenceTags.get('test@example.com')
120
- .then(...)
121
- .catch(...)
122
- ````
133
+ ```js
134
+ // Get tags
135
+ client.customer.tags.get('test@example.com')
136
+
137
+ // Replace all tags
138
+ client.customer.tags.set('test@example.com', ['vip', 'newsletter'])
123
139
 
124
- ### Replace Preference Tags
140
+ // Add tags
141
+ client.customer.tags.add('test@example.com', ['new-tag'])
125
142
 
126
- ````js
127
- client.customer.preferenceTags.set('test@example.com', ['example-tag'])
128
- .then(...)
129
- .catch(...)
130
- ````
143
+ // Remove tags
144
+ client.customer.tags.remove('test@example.com', ['old-tag'])
145
+ ```
131
146
 
132
- ### Add Preference Tags
147
+ The `set`, `add`, and `remove` methods accept an optional third parameter `startJourney` (default: `true`). Set to `false` to prevent triggering journeys:
133
148
 
134
- ````js
135
- client.customer.preferenceTags.add('test@example.com', ['example-tag'])
136
- .then(...)
137
- .catch(...)
138
- ````
149
+ ```js
150
+ client.customer.tags.add('test@example.com', ['tag'], false)
151
+ ```
139
152
 
140
- ### Remove Preference Tags
153
+ ## Preference Tags
141
154
 
142
- ````js
143
- client.customer.preferenceTags.remove('test@example.com', ['example-tag'])
144
- .then(...)
145
- .catch(...)
146
- ````
155
+ Manage customer preference tags for email preferences.
147
156
 
148
- ## Email List Endpoints
157
+ ```js
158
+ // Get preference tags
159
+ client.customer.preferenceTags.get('test@example.com')
149
160
 
150
- ### Email Lists
161
+ // Replace all preference tags
162
+ client.customer.preferenceTags.set('test@example.com', ['weekly-digest'])
151
163
 
152
- ````js
164
+ // Add preference tags
165
+ client.customer.preferenceTags.add('test@example.com', ['promotions'])
166
+
167
+ // Remove preference tags
168
+ client.customer.preferenceTags.remove('test@example.com', ['promotions'])
169
+ ```
170
+
171
+ ## Email Lists
172
+
173
+ ### Get All Lists
174
+
175
+ ```js
153
176
  client.lists.get()
154
- .then(...)
155
- .catch(...)
156
- ````
177
+ ```
178
+
179
+ ### Create a List
180
+
181
+ ```js
182
+ client.lists.add('My New List')
183
+
184
+ // Or with additional options
185
+ client.lists.add({ name: 'My New List' })
186
+ ```
157
187
 
158
- ### Retrieving Listing of Contacts
188
+ ### List Contacts
159
189
 
160
- ````js
161
- client.lists.contacts('eXaMpLeLiStId').get()
162
- .then(...)
163
- .catch(...)
164
- ````
190
+ ```js
191
+ // Get contacts in a list
192
+ client.lists.contacts('listId').get()
165
193
 
166
- #### With optional page number for pagination
194
+ // With pagination
195
+ client.lists.contacts('listId').get(2) // page 2
167
196
 
168
- ````js
169
- client.lists.contacts('eXaMpLeLiStId').get(2)
170
- .then(...)
171
- .catch(...)
172
- ````
197
+ // Add contact to list
198
+ client.lists.contacts('listId').add('test@example.com')
173
199
 
174
- ### Add Customer to List
200
+ // Remove contact from list
201
+ client.lists.contacts('listId').remove('test@example.com')
202
+ ```
203
+
204
+ ## Journeys
205
+
206
+ Trigger webhook event waits in journeys.
207
+
208
+ ```js
209
+ client.journeys('journeyId').nodes('nodeId').webhook('test@example.com')
210
+
211
+ // With additional data
212
+ client.journeys('journeyId').nodes('nodeId').webhook({
213
+ email: 'test@example.com',
214
+ customer_data: { /* ... */ },
215
+ session_data: { /* ... */ },
216
+ })
217
+ ```
175
218
 
176
- ````js
177
- client.lists.contacts('eXaMpLeLiStId').add('test@example.com')
178
- .then(...)
179
- .catch(...)
180
- ````
219
+ ## Segments
181
220
 
182
- ### Remove Customer From List
221
+ ### Get Customers in Segment
183
222
 
184
- ````js
185
- client.lists.contacts('eXaMpLeLiStId').remove('test@example.com')
186
- .then(...)
187
- .catch(...)
188
- ````
223
+ ```js
224
+ client.segments.customers('segmentId').get()
225
+ ```
226
+
227
+ ## Sessions
228
+
229
+ Update session data after conversion.
230
+
231
+ ```js
232
+ client.sessions.update('sessionId', {
233
+ paymentDate: new Date(),
234
+ fulfillmentDate: new Date(),
235
+ deliveryDate: new Date(),
236
+ metadata: {
237
+ tracking_number: '1Z999AA10123456784',
238
+ },
239
+ })
240
+ ```
241
+
242
+ All date fields are optional and accept `Date` objects or date strings.
243
+
244
+ ## API Versions
245
+
246
+ Some features require API v2:
247
+
248
+ | Feature | API v1 | API v2 |
249
+ |---------|--------|--------|
250
+ | `customer.getByPhone()` | - | Yes |
251
+ | `customer.tags.*` | - | Yes |
252
+
253
+ Set the API version when creating the client:
254
+
255
+ ```js
256
+ const client = new Rejoiner({
257
+ siteId: 'yourSiteId',
258
+ apiKey: 'yourApiKey',
259
+ apiVersion: 2,
260
+ })
261
+ ```
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rejoiner",
3
3
  "description": "Rejoiner REST API client wrapper for Node.js",
4
- "version": "2.17.0",
4
+ "version": "2.17.1",
5
5
  "main": "lib/rejoiner.js",
6
6
  "author": "Sascha Bratton <sascha@brattonbratton.com>",
7
7
  "license": "MIT",