mailerlite-ruby 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/publish_gem.yml +1 -1
- data/CHANGELOG.md +4 -0
- data/README.md +3 -3
- 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/spec/subscribers_rspec.rb +24 -0
- metadata +7 -5
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
data/README.md
CHANGED
@@ -243,7 +243,7 @@ require "mailerlite-ruby"
|
|
243
243
|
# Intialize the class
|
244
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
|
@@ -256,7 +256,7 @@ require "mailerlite-ruby"
|
|
256
256
|
# Intialize the class
|
257
257
|
groups = MailerLite::Groups.new
|
258
258
|
|
259
|
-
|
259
|
+
groups.unassign_subscriber(subscriber:111222, group_id:1234567)
|
260
260
|
```
|
261
261
|
|
262
262
|
## Segments
|
@@ -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/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
|
@@ -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
|
@@ -297,7 +299,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
297
299
|
version: '0'
|
298
300
|
requirements: []
|
299
301
|
rubygems_version: 3.4.10
|
300
|
-
signing_key:
|
302
|
+
signing_key:
|
301
303
|
specification_version: 4
|
302
304
|
summary: MailerLite's official Ruby SDK
|
303
305
|
test_files: []
|