mailerlite-ruby 1.0.3 → 1.0.5

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: 102aeffa28b4e834a28a6e03482f93bbbcc051bae9fc460e4211556c747471d5
4
+ data.tar.gz: cdb4915ff453305c4d1c839955589c0139fc38271aa7b65c1f1581ec3cb7714b
5
5
  SHA512:
6
- metadata.gz: 6e7fbe796f01f62f16c018d0e4af071fcfe19843ffb80ac284100a93d7c9281093f0bf5b9882253ee22dbaefbd0d84e41eb12e4a775ea95398f3243dae831670
7
- data.tar.gz: 31e6cccbbfedf736691e45051462bb590478d45c84996f882d41b66c58ad515daaeba635df752ab7fc7f9d03d6bd63dd9005c684cc9050901b4ae0059d8e78f9
6
+ metadata.gz: d992ce5751fb5509c94260284c943d35a4ce4ce39557e796b8930064886a9e57cf9e3956008d69f8b93650c03b7ef7809a6e3e6f175b06645dd0cecac990f895
7
+ data.tar.gz: 54b4d12eafd3e6f2816dcfed36374a9d85d45562a1caf482fe67351150024fcc1631befa6050671009ef2031c451e9219d957a69e2530993db999caa231b7e1a
@@ -6,12 +6,18 @@ jobs:
6
6
  build:
7
7
  runs-on: ubuntu-latest
8
8
  steps:
9
- - uses: actions/checkout@v3
9
+ - uses: actions/checkout@v4
10
+
10
11
  - name: Set up Ruby
11
12
  uses: ruby/setup-ruby@v1
12
13
  with:
13
14
  ruby-version: 3.0
14
- - name: Install bundle deps
15
- run: bundle i
15
+
16
+ - name: Install Bundler
17
+ run: gem install bundler -v 2.4.22
18
+
19
+ - name: Install dependencies
20
+ run: bundle _2.4.22_ install
21
+
16
22
  - name: Run tests
17
23
  run: export MAILERLITE_API_TOKEN=dummy_token && bundle exec rspec spec/*rspec.rb
@@ -9,7 +9,18 @@ jobs:
9
9
  runs-on: ubuntu-latest
10
10
 
11
11
  steps:
12
- - uses: actions/checkout@v3
12
+ - uses: actions/checkout@v4
13
+
14
+ - name: Set up Ruby
15
+ uses: actions/setup-ruby@v1
16
+ with:
17
+ ruby-version: 3.0
18
+
19
+ - name: Install Bundler
20
+ run: gem install bundler -v 2.4.22
21
+
22
+ - name: Install dependencies
23
+ run: bundle _2.4.22_ install
13
24
 
14
25
  - name: Release Gem
15
26
  if: contains(github.ref, 'refs/tags/v')
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [1.0.5] - 2024-03-12
2
+ - Update constant name
3
+
4
+ ## [1.0.4] - 2023-11-20
5
+ - Update subscribers update
6
+ - Add forget subscriber method
7
+
1
8
  ## [1.0.3] - 2023-06-02
2
9
  - Documentation update
3
10
  - 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
@@ -25,7 +25,7 @@ module MailerLite
25
25
  params['filter[group]'] = filter[:group] if filter.key?(:group)
26
26
  params['limit'] = limit if limit
27
27
  params['page'] = page if page
28
- uri = URI("#{API_URL}/automations")
28
+ uri = URI("#{MAILERLITE_API_URL}/automations")
29
29
  uri.query = URI.encode_www_form(params.compact)
30
30
  client.http.get(uri)
31
31
  end
@@ -35,7 +35,7 @@ module MailerLite
35
35
  # @param automation_id [String] the ID of the Automation to fetch
36
36
  # @return [HTTP::Response] the response from the API
37
37
  def fetch(automation_id)
38
- client.http.get("#{API_URL}/automations/#{automation_id}")
38
+ client.http.get("#{MAILERLITE_API_URL}/automations/#{automation_id}")
39
39
  end
40
40
 
41
41
  # get_subscriber_activity the subscriber activity for specified Automation
@@ -54,7 +54,7 @@ module MailerLite
54
54
  params['filter[keyword]'] = filter[:keyword] if filter.key?(:keyword)
55
55
  params['page'] = page if page
56
56
  params['limit'] = limit if limit
57
- uri = URI("#{API_URL}/automations/#{automation_id}/activity")
57
+ uri = URI("#{MAILERLITE_API_URL}/automations/#{automation_id}/activity")
58
58
  uri.query = URI.encode_www_form(params.compact)
59
59
  client.http.get(uri)
60
60
  end
@@ -18,7 +18,7 @@ module MailerLite
18
18
  # @return [HTTP::Response] the response from the API
19
19
  def request(requests:)
20
20
  params = { requests: requests }
21
- client.http.post("#{API_URL}/batch", body: params.to_json)
21
+ client.http.post("#{MAILERLITE_API_URL}/batch", body: params.to_json)
22
22
  end
23
23
  end
24
24
  end
@@ -24,7 +24,7 @@ module MailerLite
24
24
  params['filter[type]'] = filter[:type] if filter.key?(:type)
25
25
  params['limit'] = limit if limit
26
26
  params['page'] = page if page
27
- uri = URI("#{API_URL}/campaigns")
27
+ uri = URI("#{MAILERLITE_API_URL}/campaigns")
28
28
  uri.query = URI.encode_www_form(params.compact)
29
29
  client.http.get(uri)
30
30
  end
@@ -78,7 +78,7 @@ module MailerLite
78
78
  }
79
79
  end
80
80
 
81
- client.http.post("#{API_URL}/campaigns", body: params.compact.to_json)
81
+ client.http.post("#{MAILERLITE_API_URL}/campaigns", body: params.compact.to_json)
82
82
  end
83
83
 
84
84
  # Update a new campaign with the specified details.
@@ -132,7 +132,7 @@ module MailerLite
132
132
 
133
133
  end
134
134
 
135
- client.http.put("#{API_URL}/campaigns/#{campaign_id}", body: params.compact.to_json)
135
+ client.http.put("#{MAILERLITE_API_URL}/campaigns/#{campaign_id}", body: params.compact.to_json)
136
136
  end
137
137
 
138
138
  # Schedules the specified campaign.
@@ -160,7 +160,7 @@ module MailerLite
160
160
  params['resend']['minutes'] = resend[:minutes] if resend&.key?(:minutes)
161
161
  params['resend']['timezone_id'] = resend[:timezone_id] if resend&.key?(:timezone_id)
162
162
 
163
- client.http.post("#{API_URL}/campaigns/#{campaign_id}/schedule", body: params.compact.to_json)
163
+ client.http.post("#{MAILERLITE_API_URL}/campaigns/#{campaign_id}/schedule", body: params.compact.to_json)
164
164
  end
165
165
 
166
166
  # Returns the details of the specified Campaigns
@@ -168,7 +168,7 @@ module MailerLite
168
168
  # @param campaign_id [String] the ID of the campaign to fetch
169
169
  # @return [HTTP::Response] the response from the API
170
170
  def fetch(campaign_id)
171
- client.http.get("#{API_URL}/campaigns/#{campaign_id}")
171
+ client.http.get("#{MAILERLITE_API_URL}/campaigns/#{campaign_id}")
172
172
  end
173
173
 
174
174
  # Cancels the specified campaign.
@@ -176,7 +176,7 @@ module MailerLite
176
176
  # @param campaign_id [String] the ID of the campaign to delete
177
177
  # @return [HTTP::Response] the response from the API
178
178
  def cancel(campaign_id)
179
- client.http.post("#{API_URL}/campaigns/#{campaign_id}/cancel")
179
+ client.http.post("#{MAILERLITE_API_URL}/campaigns/#{campaign_id}/cancel")
180
180
  end
181
181
 
182
182
  # Deletes the specified campaign.
@@ -184,7 +184,7 @@ module MailerLite
184
184
  # @param campaign_id [String] the ID of the campaign to delete
185
185
  # @return [HTTP::Response] the response from the API
186
186
  def delete(campaign_id)
187
- client.http.delete("#{API_URL}/campaigns/#{campaign_id}")
187
+ client.http.delete("#{MAILERLITE_API_URL}/campaigns/#{campaign_id}")
188
188
  end
189
189
 
190
190
  # activity the subscriber activity for specified campaign
@@ -203,14 +203,14 @@ module MailerLite
203
203
  params['page'] = page if page
204
204
  params['limit'] = limit if limit
205
205
  params['sort'] = sort if sort
206
- client.http.post("#{API_URL}/campaigns/#{campaign_id}/reports/subscriber-activity", body: params.compact.to_json)
206
+ client.http.post("#{MAILERLITE_API_URL}/campaigns/#{campaign_id}/reports/subscriber-activity", body: params.compact.to_json)
207
207
  end
208
208
 
209
209
  # Get a list of all campaign languages available
210
210
  #
211
211
  # @return [HTTP::Response] the response from the API
212
212
  def languages
213
- client.http.get("#{API_URL}/campaigns/languages")
213
+ client.http.get("#{MAILERLITE_API_URL}/campaigns/languages")
214
214
  end
215
215
  end
216
216
  end
@@ -3,7 +3,7 @@
3
3
  require 'http'
4
4
  require 'dotenv/load'
5
5
 
6
- API_URL = 'https://connect.mailerlite.com/api'
6
+ MAILERLITE_API_URL = 'https://connect.mailerlite.com/api'
7
7
 
8
8
  Dotenv.require_keys('MAILERLITE_API_TOKEN')
9
9
 
@@ -25,7 +25,7 @@ module MailerLite
25
25
  params['sort'] = sort if sort
26
26
  params['limit'] = limit if limit
27
27
  params['page'] = page if page
28
- uri = URI("#{API_URL}/fields")
28
+ uri = URI("#{MAILERLITE_API_URL}/fields")
29
29
  uri.query = URI.encode_www_form(params.compact)
30
30
  client.http.get(uri)
31
31
  end
@@ -37,7 +37,7 @@ module MailerLite
37
37
  # @return [HTTP::Response] the response from the API
38
38
  def create(type:, name:)
39
39
  params = { 'name' => name, 'type' => type }
40
- client.http.post("#{API_URL}/fields", json: params.compact)
40
+ client.http.post("#{MAILERLITE_API_URL}/fields", json: params.compact)
41
41
  end
42
42
 
43
43
  # Update the specified Field
@@ -47,7 +47,7 @@ module MailerLite
47
47
  # @return [HTTP::Response] the response from the API
48
48
  def update(field_id:, name:)
49
49
  params = { 'name' => name }
50
- client.http.put("#{API_URL}/fields/#{field_id}", json: params.compact)
50
+ client.http.put("#{MAILERLITE_API_URL}/fields/#{field_id}", json: params.compact)
51
51
  end
52
52
 
53
53
  # Deletes the specified Field.
@@ -55,7 +55,7 @@ module MailerLite
55
55
  # @param field_id [String] the ID of the Field to delete
56
56
  # @return [HTTP::Response] the response from the API
57
57
  def delete(field_id)
58
- client.http.delete("#{API_URL}/fields/#{field_id}")
58
+ client.http.delete("#{MAILERLITE_API_URL}/fields/#{field_id}")
59
59
  end
60
60
  end
61
61
  end
@@ -24,7 +24,7 @@ module MailerLite
24
24
  params['limit'] = limit if limit
25
25
  params['sort'] = sort if sort
26
26
  params['page'] = page if page
27
- uri = URI("#{API_URL}/forms/#{type}")
27
+ uri = URI("#{MAILERLITE_API_URL}/forms/#{type}")
28
28
  uri.query = URI.encode_www_form(params.compact)
29
29
  client.http.get(uri)
30
30
  end
@@ -34,7 +34,7 @@ module MailerLite
34
34
  # @param form_id [String] the ID of the forms to fetch
35
35
  # @return [HTTP::Response] the response from the API
36
36
  def fetch(form_id)
37
- client.http.get("#{API_URL}/forms/#{form_id}")
37
+ client.http.get("#{MAILERLITE_API_URL}/forms/#{form_id}")
38
38
  end
39
39
 
40
40
  # Returns the subscribers who signed up to a specific form
@@ -42,7 +42,7 @@ module MailerLite
42
42
  # @param form_id [String] the ID of the forms to fetch
43
43
  # @return [HTTP::Response] the response from the API
44
44
  def fetch_subscribers(form_id)
45
- client.http.get("#{API_URL}/forms/#{form_id}/subscribers")
45
+ client.http.get("#{MAILERLITE_API_URL}/forms/#{form_id}/subscribers")
46
46
  end
47
47
 
48
48
  # Update the specified Forms
@@ -52,14 +52,14 @@ module MailerLite
52
52
  # @return [HTTP::Response] the response from the API
53
53
  def update(form_id:, name:)
54
54
  params = { 'name' => name }
55
- client.http.put("#{API_URL}/forms/#{form_id}", json: params.compact)
55
+ client.http.put("#{MAILERLITE_API_URL}/forms/#{form_id}", json: params.compact)
56
56
  end
57
57
 
58
58
  # Returns the total number of Forms in the MailerLite account.
59
59
  #
60
60
  # @return [HTTP::Response] the response from the API
61
61
  def fetch_count
62
- client.http.get("#{API_URL}/forms/?limit=0")
62
+ client.http.get("#{MAILERLITE_API_URL}/forms/?limit=0")
63
63
  end
64
64
 
65
65
  # Deletes the specified forms.
@@ -67,7 +67,7 @@ module MailerLite
67
67
  # @param form_id [String] the ID of the forms to delete
68
68
  # @return [HTTP::Response] the response from the API
69
69
  def delete(form_id)
70
- client.http.delete("#{API_URL}/forms/#{form_id}")
70
+ client.http.delete("#{MAILERLITE_API_URL}/forms/#{form_id}")
71
71
  end
72
72
  end
73
73
  end
@@ -24,7 +24,7 @@ module MailerLite
24
24
  params['limit'] = limit if limit
25
25
  params['sort'] = sort if sort
26
26
  params['page'] = page if page
27
- uri = URI("#{API_URL}/groups")
27
+ uri = URI("#{MAILERLITE_API_URL}/groups")
28
28
  uri.query = URI.encode_www_form(params.compact)
29
29
  client.http.get(uri)
30
30
  end
@@ -35,7 +35,7 @@ module MailerLite
35
35
  # @return [HTTP::Response] the response from the API
36
36
  def create(name:)
37
37
  params = { 'name' => name }
38
- client.http.post("#{API_URL}/groups", json: params.compact)
38
+ client.http.post("#{MAILERLITE_API_URL}/groups", json: params.compact)
39
39
  end
40
40
 
41
41
  # Update the specified Group
@@ -45,7 +45,7 @@ module MailerLite
45
45
  # @return [HTTP::Response] the response from the API
46
46
  def update(group_id:, name:)
47
47
  params = { 'name' => name }
48
- client.http.put("#{API_URL}/groups/#{group_id}", json: params.compact)
48
+ client.http.put("#{MAILERLITE_API_URL}/groups/#{group_id}", json: params.compact)
49
49
  end
50
50
 
51
51
  # Get Subscribers assigned to the specified group.
@@ -60,7 +60,7 @@ module MailerLite
60
60
  params['limit'] = limit if limit
61
61
  params['sort'] = sort if sort
62
62
  params['page'] = page if page
63
- client.http.get("#{API_URL}/groups/#{group_id}/subscribers", json: params.compact)
63
+ client.http.get("#{MAILERLITE_API_URL}/groups/#{group_id}/subscribers", json: params.compact)
64
64
  end
65
65
 
66
66
  # Assign Subscriber to the specified group.
@@ -68,7 +68,7 @@ module MailerLite
68
68
  # @param subscriber [Integer] The id of existing subscriber belonging to the account
69
69
  # @return [HTTP::Response] the response from the API
70
70
  def assign_subscriber(group_id:, subscriber:)
71
- client.http.post("#{API_URL}/subscribers/#{subscriber}/groups/#{group_id}")
71
+ client.http.post("#{MAILERLITE_API_URL}/subscribers/#{subscriber}/groups/#{group_id}")
72
72
  end
73
73
 
74
74
  # Unassign Subscriber to the specified group.
@@ -76,7 +76,7 @@ module MailerLite
76
76
  # @param subscriber [Integer] The id of existing subscriber belonging to the account
77
77
  # @return [HTTP::Response] the response from the API
78
78
  def unassign_subscriber(group_id:, subscriber:)
79
- client.http.delete("#{API_URL}/subscribers/#{subscriber}/groups/#{group_id}")
79
+ client.http.delete("#{MAILERLITE_API_URL}/subscribers/#{subscriber}/groups/#{group_id}")
80
80
  end
81
81
 
82
82
  # Deletes the specified Groups.
@@ -84,7 +84,7 @@ module MailerLite
84
84
  # @param group_id [String] the ID of the Groups to delete
85
85
  # @return [HTTP::Response] the response from the API
86
86
  def delete(group_id)
87
- client.http.delete("#{API_URL}/groups/#{group_id}")
87
+ client.http.delete("#{MAILERLITE_API_URL}/groups/#{group_id}")
88
88
  end
89
89
  end
90
90
  end
@@ -22,7 +22,7 @@ module MailerLite
22
22
  params['limit'] = limit if limit
23
23
  params['page'] = page if page
24
24
 
25
- client.http.get("#{API_URL}/segments", json: params.compact)
25
+ client.http.get("#{MAILERLITE_API_URL}/segments", json: params.compact)
26
26
  end
27
27
 
28
28
  # Update the specified Segment
@@ -32,7 +32,7 @@ module MailerLite
32
32
  # @return [HTTP::Response] the response from the API
33
33
  def update(segment_id:, name:)
34
34
  params = { 'name' => name }
35
- client.http.put("#{API_URL}/segments/#{segment_id}", json: params.compact)
35
+ client.http.put("#{MAILERLITE_API_URL}/segments/#{segment_id}", json: params.compact)
36
36
  end
37
37
 
38
38
  # Get Subscribers assigned to the specified Segment.
@@ -46,7 +46,7 @@ module MailerLite
46
46
  params['filter[status]'] = filter[:status] if filter.key?(:status)
47
47
  params['limit'] = limit if limit
48
48
  params['after'] = after if after
49
- uri = URI("#{API_URL}/segments/#{segment_id}/subscribers")
49
+ uri = URI("#{MAILERLITE_API_URL}/segments/#{segment_id}/subscribers")
50
50
  uri.query = URI.encode_www_form(params.compact)
51
51
  client.http.get(uri)
52
52
  end
@@ -56,7 +56,7 @@ module MailerLite
56
56
  # @param segment_id [String] the ID of the Segments to delete
57
57
  # @return [HTTP::Response] the response from the API
58
58
  def delete(segment_id)
59
- client.http.delete("#{API_URL}/segments/#{segment_id}")
59
+ client.http.delete("#{MAILERLITE_API_URL}/segments/#{segment_id}")
60
60
  end
61
61
  end
62
62
  end
@@ -23,7 +23,7 @@ module MailerLite
23
23
 
24
24
  params['limit'] = limit if limit
25
25
  params['page'] = page if page
26
- uri = URI("#{API_URL}/subscribers")
26
+ uri = URI("#{MAILERLITE_API_URL}/subscribers")
27
27
  uri.query = URI.encode_www_form(params.compact)
28
28
  client.http.get(uri)
29
29
  end
@@ -52,11 +52,12 @@ module MailerLite
52
52
  params['optin_ip'] = optin_ip if optin_ip
53
53
  params['unsubscribed_at'] = unsubscribed_at if unsubscribed_at
54
54
 
55
- client.http.post("#{API_URL}/subscribers", json: params.compact)
55
+ client.http.post("#{MAILERLITE_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("#{MAILERLITE_API_URL}/subscribers/#{subscriber_id}", json: params.compact)
83
85
  end
84
86
 
85
87
  # Returns the details of the specified subscribers
@@ -87,7 +89,7 @@ module MailerLite
87
89
  # @param subscriber_id [String] the ID of the subscriber to get
88
90
  # @return [HTTP::Response] the response from the API
89
91
  def get(subscriber_id)
90
- client.http.get("#{API_URL}/subscribers/#{subscriber_id}")
92
+ client.http.get("#{MAILERLITE_API_URL}/subscribers/#{subscriber_id}")
91
93
  end
92
94
 
93
95
  # Returns the details of the specified subscribers
@@ -95,14 +97,14 @@ module MailerLite
95
97
  # @param import_id [String] the ID of the import to fetch report
96
98
  # @return [HTTP::Response] the response from the API
97
99
  def get_single_import(import_id)
98
- client.http.get("#{API_URL}/subscribers/import/#{import_id}")
100
+ client.http.get("#{MAILERLITE_API_URL}/subscribers/import/#{import_id}")
99
101
  end
100
102
 
101
103
  # Returns the total number of subscribers in the MailerLite account.
102
104
  #
103
105
  # @return [HTTP::Response] the response from the API
104
106
  def fetch_count
105
- client.http.get("#{API_URL}/subscribers/?limit=0")
107
+ client.http.get("#{MAILERLITE_API_URL}/subscribers/?limit=0")
106
108
  end
107
109
 
108
110
  # Deletes the specified subscriber.
@@ -110,7 +112,15 @@ module MailerLite
110
112
  # @param subscriber_id [String] the ID of the subscriber to delete
111
113
  # @return [HTTP::Response] the response from the API
112
114
  def delete(subscriber_id)
113
- client.http.delete("#{API_URL}/subscribers/#{subscriber_id}")
115
+ client.http.delete("#{MAILERLITE_API_URL}/subscribers/#{subscriber_id}")
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("#{MAILERLITE_API_URL}/subscribers/#{subscriber_id}/forget")
114
124
  end
115
125
  end
116
126
  end
@@ -16,7 +16,7 @@ module MailerLite
16
16
  #
17
17
  # @return [HTTP::Response] the response from the API
18
18
  def list
19
- client.http.get("#{API_URL}/timezones")
19
+ client.http.get("#{MAILERLITE_API_URL}/timezones")
20
20
  end
21
21
  end
22
22
  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.5'
5
5
  end
@@ -16,7 +16,7 @@ module MailerLite
16
16
  #
17
17
  # @return [HTTP::Response] the response from the API
18
18
  def list
19
- client.http.get("#{API_URL}/webhooks")
19
+ client.http.get("#{MAILERLITE_API_URL}/webhooks")
20
20
  end
21
21
 
22
22
  # Returns the details of the specified webhooks
@@ -24,7 +24,7 @@ module MailerLite
24
24
  # @param webhook_id [String] the ID of the webhooks to fetch
25
25
  # @return [HTTP::Response] the response from the API
26
26
  def get(webhook_id)
27
- client.http.get("#{API_URL}/webhooks/#{webhook_id}")
27
+ client.http.get("#{MAILERLITE_API_URL}/webhooks/#{webhook_id}")
28
28
  end
29
29
 
30
30
  # Create a Webhook
@@ -36,7 +36,7 @@ module MailerLite
36
36
  def create(events:, url:, name: nil)
37
37
  params = { 'events' => events, 'url' => url }
38
38
  params['name'] = name if name
39
- client.http.post("#{API_URL}/webhooks", json: params.compact)
39
+ client.http.post("#{MAILERLITE_API_URL}/webhooks", json: params.compact)
40
40
  end
41
41
 
42
42
  # Update the specified Webhook
@@ -53,7 +53,7 @@ module MailerLite
53
53
  params['name'] = name if name
54
54
  params['url'] = url if url
55
55
  params['enabled'] = enabled if enabled
56
- client.http.put("#{API_URL}/webhooks/#{webhook_id}", json: params.compact)
56
+ client.http.put("#{MAILERLITE_API_URL}/webhooks/#{webhook_id}", json: params.compact)
57
57
  end
58
58
 
59
59
  # Deletes the specified Webhook.
@@ -61,7 +61,7 @@ module MailerLite
61
61
  # @param webhook_id [String] the ID of the Webhook to delete
62
62
  # @return [HTTP::Response] the response from the API
63
63
  def delete(webhook_id)
64
- client.http.delete("#{API_URL}/webhooks/#{webhook_id}")
64
+ client.http.delete("#{MAILERLITE_API_URL}/webhooks/#{webhook_id}")
65
65
  end
66
66
  end
67
67
  end
@@ -33,7 +33,7 @@ Gem::Specification.new do |spec|
33
33
  spec.add_dependency 'dotenv', '~> 2.7'
34
34
  spec.add_dependency 'http', '~> 5.0'
35
35
  spec.add_dependency 'json', '~> 2.5'
36
- spec.add_dependency 'uri', '~> 0.12.0'
36
+ spec.add_dependency 'uri', '~> 0.13.0'
37
37
  spec.add_development_dependency 'rspec'
38
38
  spec.add_development_dependency 'simplecov'
39
39
  spec.add_development_dependency 'vcr'
@@ -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.5
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: 2024-03-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -101,14 +101,14 @@ dependencies:
101
101
  requirements:
102
102
  - - "~>"
103
103
  - !ruby/object:Gem::Version
104
- version: 0.12.0
104
+ version: 0.13.0
105
105
  type: :runtime
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
108
108
  requirements:
109
109
  - - "~>"
110
110
  - !ruby/object:Gem::Version
111
- version: 0.12.0
111
+ version: 0.13.0
112
112
  - !ruby/object:Gem::Dependency
113
113
  name: rspec
114
114
  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.10
300
- signing_key:
301
+ rubygems_version: 3.5.3
302
+ signing_key:
301
303
  specification_version: 4
302
304
  summary: MailerLite's official Ruby SDK
303
305
  test_files: []