mailerlite-ruby 1.0.3 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 24c0e7de260800159f65b77ed7de5e14bd081027063960187f72e26832eec6a4
4
- data.tar.gz: b9bacc2dbd3b1a1ae9807045307185a0d5d4e66981e4e966424f7ff08932e550
3
+ metadata.gz: ca13a21a170a5491fc4131d379f7f9618e7d75938956c04799f48daa030e6248
4
+ data.tar.gz: e490234cdda5ceeb25769b2d64cbdc4b3c132d8afcdae30f902ea276c64da628
5
5
  SHA512:
6
- metadata.gz: 6e7fbe796f01f62f16c018d0e4af071fcfe19843ffb80ac284100a93d7c9281093f0bf5b9882253ee22dbaefbd0d84e41eb12e4a775ea95398f3243dae831670
7
- data.tar.gz: 31e6cccbbfedf736691e45051462bb590478d45c84996f882d41b66c58ad515daaeba635df752ab7fc7f9d03d6bd63dd9005c684cc9050901b4ae0059d8e78f9
6
+ metadata.gz: 141af02c1a738eaadfb3e79fc7f4e83400a59b860013cbbbc0ad04efd26049e9a18007a1d93f0fdb5506e78027cd6c902065dd954ddb1c2f74a084b3f4b3e3a8
7
+ data.tar.gz: 216f1ae8efebc7a8978ea8807e455e343a0faaf6c2304befdb25324891ac249a295d8c5db9f9b9262ddf08f0cc56a5dc424be2595036afc975c38917f83c2c47
@@ -9,7 +9,7 @@ jobs:
9
9
  runs-on: ubuntu-latest
10
10
 
11
11
  steps:
12
- - uses: actions/checkout@v3
12
+ - uses: actions/checkout@v4
13
13
 
14
14
  - name: Release Gem
15
15
  if: contains(github.ref, 'refs/tags/v')
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [1.0.4] - 2023-11-20
2
+ - Update subscribers update
3
+ - Add forget subscriber method
4
+
1
5
  ## [1.0.3] - 2023-06-02
2
6
  - Documentation update
3
7
  - mailerlite.rb missing version
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
- subscribers.assign_subscriber(subscriber_id:111222, group_id:1234567)
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
- subscribers.unassign_subscriber(subscriber_id:111222, group_id:1234567)
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
- # Creates a new subscriber with the specified details.
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:, fields: nil, groups: nil, status: nil, subscribed_at: nil, ip_address: nil, opted_in_at: nil, optin_ip: nil, unsubscribed_at: nil)
71
- params = { 'email' => email }
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.post("#{API_URL}/subscribers", json: params.compact)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MailerLite
4
- VERSION = '1.0.3'
4
+ VERSION = '1.0.4'
5
5
  end
@@ -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.3
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-06-02 00:00:00.000000000 Z
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: []