mailerlite-ruby 1.0.2 → 1.0.4
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.
- checksums.yaml +4 -4
- data/.github/workflows/publish_gem.yml +1 -1
- data/CHANGELOG.md +16 -1
- data/README.md +89 -89
- data/fixtures/subscribers/forget.yml +62 -0
- data/fixtures/subscribers/update.yml +61 -0
- data/lib/mailerlite/subscribers/subscribers.rb +14 -4
- data/lib/mailerlite/version.rb +1 -1
- data/lib/mailerlite.rb +1 -0
- data/mailerlite-ruby.gemspec +1 -1
- data/spec/subscribers_rspec.rb +24 -0
- metadata +10 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca13a21a170a5491fc4131d379f7f9618e7d75938956c04799f48daa030e6248
|
4
|
+
data.tar.gz: e490234cdda5ceeb25769b2d64cbdc4b3c132d8afcdae30f902ea276c64da628
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 141af02c1a738eaadfb3e79fc7f4e83400a59b860013cbbbc0ad04efd26049e9a18007a1d93f0fdb5506e78027cd6c902065dd954ddb1c2f74a084b3f4b3e3a8
|
7
|
+
data.tar.gz: 216f1ae8efebc7a8978ea8807e455e343a0faaf6c2304befdb25324891ac249a295d8c5db9f9b9262ddf08f0cc56a5dc424be2595036afc975c38917f83c2c47
|
data/CHANGELOG.md
CHANGED
@@ -1 +1,16 @@
|
|
1
|
-
## [
|
1
|
+
## [1.0.4] - 2023-11-20
|
2
|
+
- Update subscribers update
|
3
|
+
- Add forget subscriber method
|
4
|
+
|
5
|
+
## [1.0.3] - 2023-06-02
|
6
|
+
- Documentation update
|
7
|
+
- mailerlite.rb missing version
|
8
|
+
|
9
|
+
## [1.0.2] - 2023-03-22
|
10
|
+
- Gemfile.lock removed
|
11
|
+
|
12
|
+
## [1.0.1] - 2023-03-22
|
13
|
+
- Version update
|
14
|
+
|
15
|
+
## [1.0.0] - 2023-03-06
|
16
|
+
- Initial release
|
data/README.md
CHANGED
@@ -103,9 +103,9 @@ This SDK requires that you either have `.env` file with `MAILERLITE_API_TOKEN` e
|
|
103
103
|
require "mailerlite-ruby"
|
104
104
|
|
105
105
|
# Intialize the class
|
106
|
-
subscribers =
|
106
|
+
subscribers = MailerLite::Subscribers.new
|
107
107
|
|
108
|
-
|
108
|
+
subscribers.fetch(filter: { status: 'active' })
|
109
109
|
```
|
110
110
|
|
111
111
|
### Create a subscriber
|
@@ -116,9 +116,9 @@ response = subscribers.list(filter: { status: 'active' })
|
|
116
116
|
require "mailerlite-ruby"
|
117
117
|
|
118
118
|
# Intialize the class
|
119
|
-
subscribers =
|
119
|
+
subscribers = MailerLite::Subscribers.new
|
120
120
|
|
121
|
-
|
121
|
+
subscribers.create(email:'some@email.com', fields: {'name': 'John', 'last_name': 'Doe'}, ip_address:'1.2.3.4', optin_ip:'1.2.3.4')
|
122
122
|
```
|
123
123
|
|
124
124
|
### Update a subscriber
|
@@ -129,9 +129,9 @@ response = subscribers.create(email:'some@email.com', fields: {'name': 'John', '
|
|
129
129
|
require "mailerlite-ruby"
|
130
130
|
|
131
131
|
# Intialize the class
|
132
|
-
subscribers =
|
132
|
+
subscribers = MailerLite::Subscribers.new
|
133
133
|
|
134
|
-
|
134
|
+
subscribers.update(email:'some@email.com', fields: {'name': 'John', 'last_name': 'Doe'}, ip_address:'1.2.3.4', optin_ip:'1.2.3.4')
|
135
135
|
```
|
136
136
|
|
137
137
|
### Get a subscriber
|
@@ -142,9 +142,9 @@ response = subscribers.update(email:'some@email.com', fields: {'name': 'John', '
|
|
142
142
|
require "mailerlite-ruby"
|
143
143
|
|
144
144
|
# Intialize the class
|
145
|
-
subscribers =
|
145
|
+
subscribers = MailerLite::Subscribers.new
|
146
146
|
|
147
|
-
|
147
|
+
subscribers.get('some@email.com')
|
148
148
|
```
|
149
149
|
|
150
150
|
### Delete a subscriber
|
@@ -155,11 +155,11 @@ response = subscribers.get('some@email.com')
|
|
155
155
|
require "mailerlite-ruby"
|
156
156
|
|
157
157
|
# Intialize the class
|
158
|
-
subscribers =
|
158
|
+
subscribers = MailerLite::Subscribers.new
|
159
159
|
|
160
160
|
subscriber_id = 1234567890
|
161
161
|
|
162
|
-
|
162
|
+
subscribers.delete(subscriber_id)
|
163
163
|
```
|
164
164
|
|
165
165
|
## Groups
|
@@ -174,9 +174,9 @@ response = subscribers.delete(subscriber_id)
|
|
174
174
|
require "mailerlite-ruby"
|
175
175
|
|
176
176
|
# Intialize the class
|
177
|
-
groups =
|
177
|
+
groups = MailerLite::Groups.new
|
178
178
|
|
179
|
-
|
179
|
+
groups.list(limit:10, page:1, filter:{'name': 'My'}, sort:'name')
|
180
180
|
```
|
181
181
|
|
182
182
|
### Create a group
|
@@ -187,9 +187,9 @@ response = groups.list(limit:10, page:1, filter:{'name': 'My'}, sort:'name')
|
|
187
187
|
require "mailerlite-ruby"
|
188
188
|
|
189
189
|
# Intialize the class
|
190
|
-
groups =
|
190
|
+
groups = MailerLite::Groups.new
|
191
191
|
|
192
|
-
|
192
|
+
groups.create(name:'Group Name')
|
193
193
|
```
|
194
194
|
|
195
195
|
### Update a group
|
@@ -200,9 +200,9 @@ response = groups.create(name:'Group Name')
|
|
200
200
|
require "mailerlite-ruby"
|
201
201
|
|
202
202
|
# Intialize the class
|
203
|
-
groups =
|
203
|
+
groups = MailerLite::Groups.new
|
204
204
|
|
205
|
-
|
205
|
+
groups.update(group_id:1234567, name:'My New Group')
|
206
206
|
```
|
207
207
|
|
208
208
|
### Delete a group
|
@@ -213,11 +213,11 @@ response = groups.update(group_id:1234567, name:'My New Group')
|
|
213
213
|
require "mailerlite-ruby"
|
214
214
|
|
215
215
|
# Intialize the class
|
216
|
-
groups =
|
216
|
+
groups = MailerLite::Groups.new
|
217
217
|
|
218
218
|
group_id = 1234567
|
219
219
|
|
220
|
-
|
220
|
+
groups.delete(group_id)
|
221
221
|
```
|
222
222
|
|
223
223
|
### Get subscribers belonging to a group
|
@@ -228,9 +228,9 @@ response = groups.delete(group_id)
|
|
228
228
|
require "mailerlite-ruby"
|
229
229
|
|
230
230
|
# Intialize the class
|
231
|
-
groups =
|
231
|
+
groups = MailerLite::Groups.new
|
232
232
|
|
233
|
-
|
233
|
+
groups.get_subscribers(group_id:1234567, page:1, limit:10, filter:{'status': 'active'})
|
234
234
|
```
|
235
235
|
|
236
236
|
### Assign subscriber to a group
|
@@ -241,9 +241,9 @@ response = groups.get_subscribers(group_id:1234567, page:1, limit:10, filter:{'s
|
|
241
241
|
require "mailerlite-ruby"
|
242
242
|
|
243
243
|
# Intialize the class
|
244
|
-
groups =
|
244
|
+
groups = MailerLite::Groups.new
|
245
245
|
|
246
|
-
|
246
|
+
groups.assign_subscriber(subscriber:111222, group_id:1234567)
|
247
247
|
```
|
248
248
|
|
249
249
|
### Unassign subscriber from a group
|
@@ -254,9 +254,9 @@ response = subscribers.assign_subscriber(subscriber_id:111222, group_id:1234567)
|
|
254
254
|
require "mailerlite-ruby"
|
255
255
|
|
256
256
|
# Intialize the class
|
257
|
-
groups =
|
257
|
+
groups = MailerLite::Groups.new
|
258
258
|
|
259
|
-
|
259
|
+
groups.unassign_subscriber(subscriber:111222, group_id:1234567)
|
260
260
|
```
|
261
261
|
|
262
262
|
## Segments
|
@@ -271,9 +271,9 @@ response = subscribers.unassign_subscriber(subscriber_id:111222, group_id:123456
|
|
271
271
|
require "mailerlite-ruby"
|
272
272
|
|
273
273
|
# Intialize the class
|
274
|
-
segments =
|
274
|
+
segments = MailerLite::Segments.new
|
275
275
|
|
276
|
-
|
276
|
+
segments.list(limit:10, page:1)
|
277
277
|
```
|
278
278
|
|
279
279
|
### Update a segment
|
@@ -284,9 +284,9 @@ response = segments.list(limit:10, page:1)
|
|
284
284
|
require "mailerlite-ruby"
|
285
285
|
|
286
286
|
# Intialize the class
|
287
|
-
segments =
|
287
|
+
segments = MailerLite::Segments.new
|
288
288
|
|
289
|
-
|
289
|
+
segments.update(segment_id: 123456, name:'My New Segment Name')
|
290
290
|
```
|
291
291
|
|
292
292
|
### Delete a segment
|
@@ -297,10 +297,10 @@ response = segments.update(segment_id: 123456, name:'My New Segment Name')
|
|
297
297
|
require "mailerlite-ruby"
|
298
298
|
|
299
299
|
# Intialize the class
|
300
|
-
segments =
|
300
|
+
segments = MailerLite::Segments.new
|
301
301
|
segment_id = 123456
|
302
302
|
|
303
|
-
|
303
|
+
segments.delete(segment_id)
|
304
304
|
```
|
305
305
|
|
306
306
|
### Get subscribers belonging to a segment
|
@@ -311,9 +311,9 @@ response = segments.delete(segment_id)
|
|
311
311
|
require "mailerlite-ruby"
|
312
312
|
|
313
313
|
# Intialize the class
|
314
|
-
segments =
|
314
|
+
segments = MailerLite::Segments.new
|
315
315
|
|
316
|
-
|
316
|
+
segments.get_subscribers(segment_id:123456, limit:10, filter:{'status': 'active'})
|
317
317
|
```
|
318
318
|
|
319
319
|
## Fields
|
@@ -328,9 +328,9 @@ response = segments.get_subscribers(segment_id:123456, limit:10, filter:{'status
|
|
328
328
|
require "mailerlite-ruby"
|
329
329
|
|
330
330
|
# Intialize the class
|
331
|
-
fields =
|
331
|
+
fields = MailerLite::Fields.new
|
332
332
|
|
333
|
-
|
333
|
+
fields.get(limit:10, page:1, sort:'name', filter:{'keyword': 'abc', 'type': 'text'})
|
334
334
|
```
|
335
335
|
|
336
336
|
### Create a field
|
@@ -341,9 +341,9 @@ response = fields.list(limit:10, page:1, sort:'name', filter:{'keyword': 'abc',
|
|
341
341
|
require "mailerlite-ruby"
|
342
342
|
|
343
343
|
# Intialize the class
|
344
|
-
fields =
|
344
|
+
fields = MailerLite::Fields.new
|
345
345
|
|
346
|
-
|
346
|
+
fields.create(name:'My Field', type:'text')
|
347
347
|
```
|
348
348
|
|
349
349
|
### Update a field
|
@@ -354,9 +354,9 @@ response = fields.create(name:'My Field', type:'text')
|
|
354
354
|
require "mailerlite-ruby"
|
355
355
|
|
356
356
|
# Intialize the class
|
357
|
-
fields =
|
357
|
+
fields = MailerLite::Fields.new
|
358
358
|
|
359
|
-
|
359
|
+
fields.update(field_id:123345, name:'My New Field')
|
360
360
|
```
|
361
361
|
|
362
362
|
### Delete a field
|
@@ -367,11 +367,11 @@ response = fields.update(field_id:123345, name:'My New Field')
|
|
367
367
|
require "mailerlite-ruby"
|
368
368
|
|
369
369
|
# Intialize the class
|
370
|
-
fields =
|
370
|
+
fields = MailerLite::Fields.new
|
371
371
|
|
372
372
|
field_id = 123456
|
373
373
|
|
374
|
-
|
374
|
+
fields.delete(field_id)
|
375
375
|
```
|
376
376
|
|
377
377
|
## Automations
|
@@ -386,9 +386,9 @@ response = fields.delete(field_id)
|
|
386
386
|
require "mailerlite-ruby"
|
387
387
|
|
388
388
|
# Intialize the class
|
389
|
-
automations =
|
389
|
+
automations = MailerLite::Automations.new
|
390
390
|
|
391
|
-
|
391
|
+
automations.get(limit:10, page:1, filter:{'status': true, 'name': 'some name', 'group': 123456})
|
392
392
|
```
|
393
393
|
|
394
394
|
### Get an automation
|
@@ -399,11 +399,11 @@ response = automations.list(limit:10, page:1, filter:{'status': true, 'name': 's
|
|
399
399
|
require "mailerlite-ruby"
|
400
400
|
|
401
401
|
# Intialize the class
|
402
|
-
automations =
|
402
|
+
automations = MailerLite::Automations.new
|
403
403
|
|
404
404
|
automation_id = 123456
|
405
405
|
|
406
|
-
|
406
|
+
automations.fetch(automation_id)
|
407
407
|
```
|
408
408
|
|
409
409
|
### Get subscribers activity for an automation
|
@@ -414,9 +414,9 @@ response = automations.get(automation_id)
|
|
414
414
|
require "mailerlite-ruby"
|
415
415
|
|
416
416
|
# Intialize the class
|
417
|
-
automations =
|
417
|
+
automations = MailerLite::Automations.new
|
418
418
|
|
419
|
-
|
419
|
+
automations.get_subscriber_activity(automation_id:123456, page:1, limit:10, filter:{'status': 'active', 'date_from': '2022-12-20', 'date_to': '2022-12-31'})
|
420
420
|
```
|
421
421
|
|
422
422
|
## Campaigns
|
@@ -431,9 +431,9 @@ response = automations.activity(automation_id:123456, page:1, limit:10, filter:{
|
|
431
431
|
require "mailerlite-ruby"
|
432
432
|
|
433
433
|
# Intialize the class
|
434
|
-
campaigns =
|
434
|
+
campaigns = MailerLite::Campaigns.new
|
435
435
|
|
436
|
-
|
436
|
+
campaigns.get(limit:10, page:1, filter:{'status': 'ready', 'type': 'regular'})
|
437
437
|
```
|
438
438
|
|
439
439
|
### Get a campaign
|
@@ -444,9 +444,9 @@ response = campaigns.list(limit:10, page:1, filter:{'status': 'ready', 'type': '
|
|
444
444
|
require "mailerlite-ruby"
|
445
445
|
|
446
446
|
# Intialize the class
|
447
|
-
campaigns =
|
447
|
+
campaigns = MailerLite::Campaigns.new
|
448
448
|
|
449
|
-
|
449
|
+
campaigns.fetch(campaign_id:123456)
|
450
450
|
```
|
451
451
|
|
452
452
|
### Create a campaign
|
@@ -457,9 +457,9 @@ response = campaigns.get(campaign_id:123456)
|
|
457
457
|
require "mailerlite-ruby"
|
458
458
|
|
459
459
|
# Intialize the class
|
460
|
-
campaigns =
|
460
|
+
campaigns = MailerLite::Campaigns.new
|
461
461
|
|
462
|
-
|
462
|
+
campaigns.create(
|
463
463
|
name: "Test Campaign",
|
464
464
|
language_id: 1,
|
465
465
|
type: "regular",
|
@@ -480,9 +480,9 @@ response = campaigns.create(
|
|
480
480
|
require "mailerlite-ruby"
|
481
481
|
|
482
482
|
# Intialize the class
|
483
|
-
campaigns =
|
483
|
+
campaigns = MailerLite::Campaigns.new
|
484
484
|
|
485
|
-
|
485
|
+
campaigns.update(
|
486
486
|
campaign_id: 1233455,
|
487
487
|
name: "New Campaign Name",
|
488
488
|
language_id: 2,
|
@@ -503,9 +503,9 @@ response = campaigns.update(
|
|
503
503
|
require "mailerlite-ruby"
|
504
504
|
|
505
505
|
# Intialize the class
|
506
|
-
campaigns =
|
506
|
+
campaigns = MailerLite::Campaigns.new
|
507
507
|
|
508
|
-
|
508
|
+
campaigns.schedule(
|
509
509
|
campaign_id: 123456,
|
510
510
|
delivery: "scheduled",
|
511
511
|
schedule: {
|
@@ -524,11 +524,11 @@ response = campaigns.schedule(
|
|
524
524
|
require "mailerlite-ruby"
|
525
525
|
|
526
526
|
# Intialize the class
|
527
|
-
campaigns =
|
527
|
+
campaigns = MailerLite::Campaigns.new
|
528
528
|
|
529
529
|
campaign_id = 123456
|
530
530
|
|
531
|
-
|
531
|
+
campaigns.cancel(campaign_id)
|
532
532
|
```
|
533
533
|
|
534
534
|
### Delete a campaign
|
@@ -539,11 +539,11 @@ response = campaigns.cancel(campaign_id)
|
|
539
539
|
require "mailerlite-ruby"
|
540
540
|
|
541
541
|
# Intialize the class
|
542
|
-
campaigns =
|
542
|
+
campaigns = MailerLite::Campaigns.new
|
543
543
|
|
544
544
|
campaign_id = 123456
|
545
545
|
|
546
|
-
|
546
|
+
campaigns.delete(campaign_id)
|
547
547
|
```
|
548
548
|
|
549
549
|
### Get subscribers activity for a campaign
|
@@ -554,11 +554,11 @@ response = campaigns.delete(campaign_id)
|
|
554
554
|
require "mailerlite-ruby"
|
555
555
|
|
556
556
|
# Intialize the class
|
557
|
-
campaigns =
|
557
|
+
campaigns = MailerLite::Campaigns.new
|
558
558
|
|
559
559
|
campaign_id = 123456
|
560
560
|
|
561
|
-
|
561
|
+
campaigns.activity(campaign_id)
|
562
562
|
```
|
563
563
|
|
564
564
|
## Forms
|
@@ -573,9 +573,9 @@ response = campaigns.activity(campaign_id)
|
|
573
573
|
require "mailerlite-ruby"
|
574
574
|
|
575
575
|
# Intialize the class
|
576
|
-
forms =
|
576
|
+
forms = MailerLite::Forms.new
|
577
577
|
|
578
|
-
|
578
|
+
forms.list(limit:10, page:1, sort:'name', filter:{'name': 'form name'})
|
579
579
|
```
|
580
580
|
|
581
581
|
### Get a form
|
@@ -586,11 +586,11 @@ response = forms.list(limit:10, page:1, sort:'name', filter:{'name': 'form name'
|
|
586
586
|
require "mailerlite-ruby"
|
587
587
|
|
588
588
|
# Intialize the class
|
589
|
-
forms =
|
589
|
+
forms = MailerLite::Forms.new
|
590
590
|
|
591
591
|
form_id = 123456
|
592
592
|
|
593
|
-
|
593
|
+
forms.fetch(form_id)
|
594
594
|
```
|
595
595
|
|
596
596
|
### Update a form
|
@@ -601,9 +601,9 @@ response = forms.get(form_id)
|
|
601
601
|
require "mailerlite-ruby"
|
602
602
|
|
603
603
|
# Intialize the class
|
604
|
-
forms =
|
604
|
+
forms = MailerLite::Forms.new
|
605
605
|
|
606
|
-
|
606
|
+
forms.update(form_id:123456, name: 'My form Name')
|
607
607
|
```
|
608
608
|
|
609
609
|
### Delete a form
|
@@ -614,11 +614,11 @@ response = forms.update(form_id:123456, name: 'My form Name')
|
|
614
614
|
require "mailerlite-ruby"
|
615
615
|
|
616
616
|
# Intialize the class
|
617
|
-
forms =
|
617
|
+
forms = MailerLite::Forms.new
|
618
618
|
|
619
619
|
form_id = 123456
|
620
620
|
|
621
|
-
|
621
|
+
forms.delete(form_id)
|
622
622
|
```
|
623
623
|
|
624
624
|
### Get subscribers who signed up to a specific form
|
@@ -629,9 +629,9 @@ response = forms.delete(form_id)
|
|
629
629
|
require "mailerlite-ruby"
|
630
630
|
|
631
631
|
# Intialize the class
|
632
|
-
forms =
|
632
|
+
forms = MailerLite::Forms.new
|
633
633
|
|
634
|
-
|
634
|
+
forms.fetch_subscribers(form_id:123345, page:1, limit:10, filter:{'status': 'active'})
|
635
635
|
```
|
636
636
|
|
637
637
|
## Batching
|
@@ -646,9 +646,9 @@ response = forms.get_subscribers(form_id:123345, page:1, limit:10, filter:{'stat
|
|
646
646
|
require "mailerlite-ruby"
|
647
647
|
|
648
648
|
# Intialize the class
|
649
|
-
batch =
|
649
|
+
batch = MailerLite::Batch.new
|
650
650
|
|
651
|
-
|
651
|
+
batch.request(
|
652
652
|
requests: [
|
653
653
|
{ method: 'GET', path: 'api/subscribers/list' },
|
654
654
|
{ method: 'GET', path: 'api/campaigns/list' }
|
@@ -668,9 +668,9 @@ response = batch.request(
|
|
668
668
|
require "mailerlite-ruby"
|
669
669
|
|
670
670
|
# Intialize the class
|
671
|
-
subscribers =
|
671
|
+
subscribers = MailerLite::Subscribers.new
|
672
672
|
|
673
|
-
|
673
|
+
webhooks.list()
|
674
674
|
```
|
675
675
|
|
676
676
|
### Get a webhook
|
@@ -681,11 +681,11 @@ response = webhooks.list()
|
|
681
681
|
require "mailerlite-ruby"
|
682
682
|
|
683
683
|
# Intialize the class
|
684
|
-
subscribers =
|
684
|
+
subscribers = MailerLite::Subscribers.new
|
685
685
|
|
686
686
|
webhook_id = 123456
|
687
687
|
|
688
|
-
|
688
|
+
webhooks.get(webhook_id)
|
689
689
|
```
|
690
690
|
|
691
691
|
### Create a webhook
|
@@ -696,9 +696,9 @@ response = webhooks.get(webhook_id)
|
|
696
696
|
require "mailerlite-ruby"
|
697
697
|
|
698
698
|
# Intialize the class
|
699
|
-
webhooks =
|
699
|
+
webhooks = MailerLite::Webhooks.new
|
700
700
|
|
701
|
-
|
701
|
+
webhooks.create(
|
702
702
|
events:[
|
703
703
|
'subscriber.created',
|
704
704
|
'subscriber.updated',
|
@@ -717,9 +717,9 @@ response = webhooks.create(
|
|
717
717
|
require "mailerlite-ruby"
|
718
718
|
|
719
719
|
# Intialize the class
|
720
|
-
webhooks =
|
720
|
+
webhooks = MailerLite::Webhooks.new
|
721
721
|
|
722
|
-
|
722
|
+
webhooks.update(
|
723
723
|
webhook_id: 123456,
|
724
724
|
events:[
|
725
725
|
'subscriber.created',
|
@@ -740,11 +740,11 @@ response = webhooks.update(
|
|
740
740
|
require "mailerlite-ruby"
|
741
741
|
|
742
742
|
# Intialize the class
|
743
|
-
webhooks =
|
743
|
+
webhooks = MailerLite::Webhooks.new
|
744
744
|
|
745
745
|
webhook_id = 123456
|
746
746
|
|
747
|
-
|
747
|
+
webhooks.delete(webhook_id)
|
748
748
|
```
|
749
749
|
|
750
750
|
## Timezones
|
@@ -759,9 +759,9 @@ response = webhooks.delete(webhook_id)
|
|
759
759
|
require "mailerlite-ruby"
|
760
760
|
|
761
761
|
# Intialize the class
|
762
|
-
timezones =
|
762
|
+
timezones = MailerLite::Timezones.new
|
763
763
|
|
764
|
-
|
764
|
+
timezones.list()
|
765
765
|
```
|
766
766
|
|
767
767
|
## Campaign languages
|
@@ -776,9 +776,9 @@ response = timezones.list()
|
|
776
776
|
require "mailerlite-ruby"
|
777
777
|
|
778
778
|
# Intialize the class
|
779
|
-
campaigns =
|
779
|
+
campaigns = MailerLite::Campaigns.new
|
780
780
|
|
781
|
-
|
781
|
+
campaigns.languages()
|
782
782
|
```
|
783
783
|
|
784
784
|
# Testing
|
@@ -798,4 +798,4 @@ bundle i
|
|
798
798
|
bundle exec yardoc 'lib/**/*.rb'
|
799
799
|
```
|
800
800
|
|
801
|
-
This will generate html docs in the doc directory which can be opened up in any browser. Navigate to index.html and open it up.
|
801
|
+
This will generate html docs in the doc directory which can be opened up in any browser. Navigate to index.html and open it up.
|
@@ -0,0 +1,62 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://connect.mailerlite.com/api/subscribers/98121614828242796/forget
|
6
|
+
body:
|
7
|
+
encoding: ASCII-8BIT
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Authorization:
|
11
|
+
- "<AUTH>"
|
12
|
+
User-Agent:
|
13
|
+
- MailerLite-client-ruby/1.0.3
|
14
|
+
Accept:
|
15
|
+
- application/json
|
16
|
+
Content-Type:
|
17
|
+
- application/json
|
18
|
+
Connection:
|
19
|
+
- close
|
20
|
+
Host:
|
21
|
+
- connect.mailerlite.com
|
22
|
+
response:
|
23
|
+
status:
|
24
|
+
code: 200
|
25
|
+
message: OK
|
26
|
+
headers:
|
27
|
+
Date:
|
28
|
+
- Fri, 01 Sep 2023 13:48:18 GMT
|
29
|
+
Content-Type:
|
30
|
+
- application/json
|
31
|
+
Transfer-Encoding:
|
32
|
+
- chunked
|
33
|
+
Connection:
|
34
|
+
- close
|
35
|
+
Cache-Control:
|
36
|
+
- no-cache, private
|
37
|
+
X-Locale:
|
38
|
+
- en
|
39
|
+
X-Ratelimit-Limit:
|
40
|
+
- '120'
|
41
|
+
X-Ratelimit-Remaining:
|
42
|
+
- '117'
|
43
|
+
Access-Control-Allow-Origin:
|
44
|
+
- "*"
|
45
|
+
Strict-Transport-Security:
|
46
|
+
- max-age=15724800; includeSubDomains
|
47
|
+
Via:
|
48
|
+
- Ingress
|
49
|
+
Cf-Cache-Status:
|
50
|
+
- DYNAMIC
|
51
|
+
Server:
|
52
|
+
- cloudflare
|
53
|
+
Cf-Ray:
|
54
|
+
- 7ffdf84ede2b1096-HKG
|
55
|
+
body:
|
56
|
+
encoding: UTF-8
|
57
|
+
string: '{"data":{"id":"98121614828242796","email":"test@mail.com","status":"active","source":"api","sent":0,"opens_count":0,"clicks_count":0,"open_rate":0,"click_rate":0,"ip_address":null,"subscribed_at":"2023-09-01
|
58
|
+
13:47:44","unsubscribed_at":null,"created_at":"2023-09-01 13:47:43","updated_at":"2023-09-01
|
59
|
+
13:48:17","deleted_at":"2023-09-01 13:48:17","forget_at":"2023-10-01 13:48:17","fields":{"name":null,"last_name":null,"company":null,"country":null,"city":null,"phone":null,"state":null,"z_i_p":null,"github_handle":null},"groups":[],"location":null,"opted_in_at":null,"optin_ip":null},"message":"Subscriber
|
60
|
+
data will be completely deleted and forgotten within 30 days."}'
|
61
|
+
recorded_at: Fri, 01 Sep 2023 13:48:18 GMT
|
62
|
+
recorded_with: VCR 6.2.0
|
@@ -0,0 +1,61 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: put
|
5
|
+
uri: https://connect.mailerlite.com/api/subscribers/98112484192290662
|
6
|
+
body:
|
7
|
+
encoding: ASCII-8BIT
|
8
|
+
string: '{"email":"updated@email.com"}'
|
9
|
+
headers:
|
10
|
+
Authorization:
|
11
|
+
- "<AUTH>"
|
12
|
+
User-Agent:
|
13
|
+
- MailerLite-client-ruby/1.0.3
|
14
|
+
Accept:
|
15
|
+
- application/json
|
16
|
+
Content-Type:
|
17
|
+
- application/json
|
18
|
+
Connection:
|
19
|
+
- close
|
20
|
+
Host:
|
21
|
+
- connect.mailerlite.com
|
22
|
+
response:
|
23
|
+
status:
|
24
|
+
code: 200
|
25
|
+
message: OK
|
26
|
+
headers:
|
27
|
+
Date:
|
28
|
+
- Fri, 01 Sep 2023 11:24:29 GMT
|
29
|
+
Content-Type:
|
30
|
+
- application/json
|
31
|
+
Transfer-Encoding:
|
32
|
+
- chunked
|
33
|
+
Connection:
|
34
|
+
- close
|
35
|
+
Cache-Control:
|
36
|
+
- no-cache, private
|
37
|
+
X-Locale:
|
38
|
+
- en
|
39
|
+
X-Ratelimit-Limit:
|
40
|
+
- '120'
|
41
|
+
X-Ratelimit-Remaining:
|
42
|
+
- '119'
|
43
|
+
Access-Control-Allow-Origin:
|
44
|
+
- "*"
|
45
|
+
Strict-Transport-Security:
|
46
|
+
- max-age=15724800; includeSubDomains
|
47
|
+
Via:
|
48
|
+
- Ingress
|
49
|
+
Cf-Cache-Status:
|
50
|
+
- DYNAMIC
|
51
|
+
Server:
|
52
|
+
- cloudflare
|
53
|
+
Cf-Ray:
|
54
|
+
- 7ffd25a40bf22118-HKG
|
55
|
+
body:
|
56
|
+
encoding: UTF-8
|
57
|
+
string: '{"data":{"id":"98112484192290662","email":"updated@email.com","status":"active","source":"api","sent":0,"opens_count":0,"clicks_count":0,"open_rate":0,"click_rate":0,"ip_address":null,"subscribed_at":"2023-09-01
|
58
|
+
11:22:36","unsubscribed_at":null,"created_at":"2023-09-01 11:22:36","updated_at":"2023-09-01
|
59
|
+
11:24:29","fields":{"name":null,"last_name":null,"company":null,"country":null,"city":null,"phone":null,"state":null,"z_i_p":null,"github_handle":null},"groups":[],"location":null,"opted_in_at":null,"optin_ip":null}}'
|
60
|
+
recorded_at: Fri, 01 Sep 2023 11:24:29 GMT
|
61
|
+
recorded_with: VCR 6.2.0
|
@@ -55,8 +55,9 @@ module MailerLite
|
|
55
55
|
client.http.post("#{API_URL}/subscribers", json: params.compact)
|
56
56
|
end
|
57
57
|
|
58
|
-
#
|
58
|
+
# Updates an existing subscriber with the specified details.
|
59
59
|
#
|
60
|
+
# @param subscriber_id [String] the ID of the subscriber to update
|
60
61
|
# @param email [String] the email address of the new subscriber
|
61
62
|
# @param fields [Hash] a hash of custom fields and their values for the subscriber
|
62
63
|
# @param groups [Array] an array of group IDs to add the subscriber to
|
@@ -67,9 +68,10 @@ module MailerLite
|
|
67
68
|
# @param optin_ip [String] the IP address of the subscriber when they confirmed their subscription
|
68
69
|
# @param unsubscribed_at [DateTime] the date and time when the subscriber was unsubscribed
|
69
70
|
# @return [HTTP::Response] the response from the API
|
70
|
-
def update(email
|
71
|
-
params = {
|
71
|
+
def update(subscriber_id, email: nil, fields: nil, groups: nil, status: nil, subscribed_at: nil, ip_address: nil, opted_in_at: nil, optin_ip: nil, unsubscribed_at: nil)
|
72
|
+
params = {}
|
72
73
|
|
74
|
+
params['email'] = email if email
|
73
75
|
params['fields'] = fields if fields
|
74
76
|
params['groups'] = groups if groups
|
75
77
|
params['status'] = status if status
|
@@ -79,7 +81,7 @@ module MailerLite
|
|
79
81
|
params['optin_ip'] = optin_ip if optin_ip
|
80
82
|
params['unsubscribed_at'] = unsubscribed_at if unsubscribed_at
|
81
83
|
|
82
|
-
client.http.
|
84
|
+
client.http.put("#{API_URL}/subscribers/#{subscriber_id}", json: params.compact)
|
83
85
|
end
|
84
86
|
|
85
87
|
# Returns the details of the specified subscribers
|
@@ -112,5 +114,13 @@ module MailerLite
|
|
112
114
|
def delete(subscriber_id)
|
113
115
|
client.http.delete("#{API_URL}/subscribers/#{subscriber_id}")
|
114
116
|
end
|
117
|
+
|
118
|
+
# Forgets the specified subscriber.
|
119
|
+
#
|
120
|
+
# @param subscriber_id [String] the ID of the subscriber to forget
|
121
|
+
# @return [HTTP::Response] the response from the API
|
122
|
+
def forget(subscriber_id)
|
123
|
+
client.http.post("#{API_URL}/subscribers/#{subscriber_id}/forget")
|
124
|
+
end
|
115
125
|
end
|
116
126
|
end
|
data/lib/mailerlite/version.rb
CHANGED
data/lib/mailerlite.rb
CHANGED
data/mailerlite-ruby.gemspec
CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
|
|
27
27
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
28
28
|
spec.require_paths = ['lib']
|
29
29
|
|
30
|
-
spec.add_development_dependency 'bundler', '~> 2.4.
|
30
|
+
spec.add_development_dependency 'bundler', '~> 2.4.1'
|
31
31
|
spec.add_development_dependency 'rake', '~> 13.0'
|
32
32
|
spec.add_development_dependency 'rubocop', '~> 1.7'
|
33
33
|
spec.add_dependency 'dotenv', '~> 2.7'
|
data/spec/subscribers_rspec.rb
CHANGED
@@ -72,6 +72,18 @@ RSpec.describe MailerLite::Subscribers do
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
+
describe '#update' do
|
76
|
+
# Use VCR to record and replay the HTTP request
|
77
|
+
it 'updates a subscriber' do
|
78
|
+
VCR.use_cassette('subscribers/update') do
|
79
|
+
response = subscribers.update(98_112_484_192_290_662, email: 'updated@email.com')
|
80
|
+
body = JSON.parse(response.body)
|
81
|
+
expect(response.status).to eq 200
|
82
|
+
expect(body['data']['email']).to eq 'updated@email.com'
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
75
87
|
describe '#delete' do
|
76
88
|
# Use VCR to record and replay the HTTP request
|
77
89
|
it 'deletes a subscriber' do
|
@@ -81,4 +93,16 @@ RSpec.describe MailerLite::Subscribers do
|
|
81
93
|
end
|
82
94
|
end
|
83
95
|
end
|
96
|
+
|
97
|
+
describe '#forget' do
|
98
|
+
# Use VCR to record and replay the HTTP request
|
99
|
+
it 'forgets a subscriber' do
|
100
|
+
VCR.use_cassette('subscribers/forget') do
|
101
|
+
response = subscribers.forget(98_121_614_828_242_796)
|
102
|
+
body = JSON.parse(response.body)
|
103
|
+
expect(response.status).to eq 200
|
104
|
+
expect(body['message']).to eq 'Subscriber data will be completely deleted and forgotten within 30 days.'
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
84
108
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mailerlite-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nikola Milojević
|
8
8
|
- Ahsan Gondal
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-
|
12
|
+
date: 2023-11-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -17,14 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: 2.4.
|
20
|
+
version: 2.4.1
|
21
21
|
type: :development
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: 2.4.
|
27
|
+
version: 2.4.1
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: rake
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -238,7 +238,9 @@ files:
|
|
238
238
|
- fixtures/subscribers/delete.yml
|
239
239
|
- fixtures/subscribers/fetch.yml
|
240
240
|
- fixtures/subscribers/fetch_count.yml
|
241
|
+
- fixtures/subscribers/forget.yml
|
241
242
|
- fixtures/subscribers/get.yml
|
243
|
+
- fixtures/subscribers/update.yml
|
242
244
|
- fixtures/timezones/list.yml
|
243
245
|
- fixtures/webhooks/create.yml
|
244
246
|
- fixtures/webhooks/delete.yml
|
@@ -281,7 +283,7 @@ metadata:
|
|
281
283
|
source_code_uri: https://github.com/mailerlite/mailerlite-ruby
|
282
284
|
changelog_uri: https://github.com/mailerlite/mailerlite-ruby/blob/main/CHANGELOG.md
|
283
285
|
rubygems_mfa_required: 'true'
|
284
|
-
post_install_message:
|
286
|
+
post_install_message:
|
285
287
|
rdoc_options: []
|
286
288
|
require_paths:
|
287
289
|
- lib
|
@@ -296,8 +298,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
296
298
|
- !ruby/object:Gem::Version
|
297
299
|
version: '0'
|
298
300
|
requirements: []
|
299
|
-
rubygems_version: 3.4.
|
300
|
-
signing_key:
|
301
|
+
rubygems_version: 3.4.10
|
302
|
+
signing_key:
|
301
303
|
specification_version: 4
|
302
304
|
summary: MailerLite's official Ruby SDK
|
303
305
|
test_files: []
|