mailerlite-ruby 1.0.5 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 102aeffa28b4e834a28a6e03482f93bbbcc051bae9fc460e4211556c747471d5
4
- data.tar.gz: cdb4915ff453305c4d1c839955589c0139fc38271aa7b65c1f1581ec3cb7714b
3
+ metadata.gz: bf06c2b614a36abc1ae9f8d33f4fa738771e56e6645c7b97c8152c7f895ef3b7
4
+ data.tar.gz: 1e58adc94cfaef6c71985335d8c26ec0f89f351bde8f5218c4c2073f333dc337
5
5
  SHA512:
6
- metadata.gz: d992ce5751fb5509c94260284c943d35a4ce4ce39557e796b8930064886a9e57cf9e3956008d69f8b93650c03b7ef7809a6e3e6f175b06645dd0cecac990f895
7
- data.tar.gz: 54b4d12eafd3e6f2816dcfed36374a9d85d45562a1caf482fe67351150024fcc1631befa6050671009ef2031c451e9219d957a69e2530993db999caa231b7e1a
6
+ metadata.gz: ba180fb682d7c3fb4cc7668c66031dfcd544a21febb0b390ac5f7dd7896d588b4b80bbf2d7cca40be4d43bd9d47b611e4b17ddd3c471a54c18a9f5d3983eac3e
7
+ data.tar.gz: 4552b68bc80f9566bb05a957e06947a95898b3726918e13877b88bfcd9e1b19f91087c53ebdf6d32e094e294eb894183047bd50d5ff7b089c8f52bddd15170c1
@@ -11,13 +11,13 @@ jobs:
11
11
  - name: Set up Ruby
12
12
  uses: ruby/setup-ruby@v1
13
13
  with:
14
- ruby-version: 3.0
14
+ ruby-version: 3.1
15
15
 
16
16
  - name: Install Bundler
17
- run: gem install bundler -v 2.4.22
17
+ run: gem install bundler -v 2.5.23
18
18
 
19
19
  - name: Install dependencies
20
- run: bundle _2.4.22_ install
20
+ run: bundle _2.5.23_ install
21
21
 
22
22
  - name: Run tests
23
23
  run: export MAILERLITE_API_TOKEN=dummy_token && bundle exec rspec spec/*rspec.rb
@@ -12,15 +12,15 @@ jobs:
12
12
  - uses: actions/checkout@v4
13
13
 
14
14
  - name: Set up Ruby
15
- uses: actions/setup-ruby@v1
15
+ uses: ruby/setup-ruby@v1
16
16
  with:
17
- ruby-version: 3.0
17
+ ruby-version: 3.1
18
18
 
19
19
  - name: Install Bundler
20
- run: gem install bundler -v 2.4.22
20
+ run: gem install bundler -v 2.5.23
21
21
 
22
22
  - name: Install dependencies
23
- run: bundle _2.4.22_ install
23
+ run: bundle _2.5.23_ install
24
24
 
25
25
  - name: Release Gem
26
26
  if: contains(github.ref, 'refs/tags/v')
data/.rubocop.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.5
2
+ TargetRubyVersion: 3.1
3
3
  SuggestExtensions: false
4
4
  NewCops: enable
5
5
 
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [2.0.0] - 2024-12-11
2
+ - *BREAKING CHANGE* - Please check the README file, dotenv is now optional
3
+ - *BREAKING CHANGE* - Updated the minimal required Ruby version from 2.5 to 3.1
4
+
5
+ ## [1.0.6] - 2024-12-06
6
+ - Page parameter to cursor pagination fix
7
+
1
8
  ## [1.0.5] - 2024-03-12
2
9
  - Update constant name
3
10
 
data/README.md CHANGED
@@ -89,7 +89,15 @@ You will have to initalize it in your Ruby file with `require "mailerlite-ruby"`
89
89
 
90
90
  # Usage
91
91
 
92
- This SDK requires that you either have `.env` file with `MAILERLITE_API_TOKEN` env variable or that your variable is enabled system wide (useful for Docker/Kubernetes). The example of how `MAILERLITE_API_TOKEN` should look like is in `.env.example`.
92
+ This SDK requires that you have the `MAILERLITE_API_TOKEN` environment variable set. You can set this variable in a `.env` file or enable it system-wide (useful for Docker/Kubernetes). The example of how `MAILERLITE_API_TOKEN` should look like is in `.env.example`.
93
+
94
+ If you want to use `dotenv` to manage your environment variables, you can configure the `mailerlite` gem to load `dotenv`:
95
+
96
+ ```ruby
97
+ MailerLite.configure do |config|
98
+ config.use_dotenv = true
99
+ end
100
+ ```
93
101
 
94
102
  ## Subscribers
95
103
 
@@ -105,7 +113,7 @@ require "mailerlite-ruby"
105
113
  # Intialize the class
106
114
  subscribers = MailerLite::Subscribers.new
107
115
 
108
- subscribers.fetch(filter: { status: 'active' })
116
+ subscribers.fetch(filter: { status: 'active' }, cursor: 'cursor')
109
117
  ```
110
118
 
111
119
  ### Create a subscriber
@@ -131,7 +139,7 @@ require "mailerlite-ruby"
131
139
  # Intialize the class
132
140
  subscribers = MailerLite::Subscribers.new
133
141
 
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')
142
+ subscribers.update('some@email.com', fields: {'name': 'John', 'last_name': 'Doe'}, ip_address:'1.2.3.4', optin_ip:'1.2.3.4')
135
143
  ```
136
144
 
137
145
  ### Get a subscriber
@@ -176,7 +184,7 @@ require "mailerlite-ruby"
176
184
  # Intialize the class
177
185
  groups = MailerLite::Groups.new
178
186
 
179
- groups.list(limit:10, page:1, filter:{'name': 'My'}, sort:'name')
187
+ groups.get(limit:10, page:1, filter:{'name': 'My'}, sort:'name')
180
188
  ```
181
189
 
182
190
  ### Create a group
@@ -227,10 +235,10 @@ groups.delete(group_id)
227
235
  ```ruby
228
236
  require "mailerlite-ruby"
229
237
 
230
- # Intialize the class
238
+ # Initialize the class
231
239
  groups = MailerLite::Groups.new
232
240
 
233
- groups.get_subscribers(group_id:1234567, page:1, limit:10, filter:{'status': 'active'})
241
+ groups.get_subscribers(group_id: 1234567, cursor: 'cursor', limit: 10, filter: { 'status': 'active' })
234
242
  ```
235
243
 
236
244
  ### Assign subscriber to a group
@@ -483,7 +491,7 @@ require "mailerlite-ruby"
483
491
  campaigns = MailerLite::Campaigns.new
484
492
 
485
493
  campaigns.update(
486
- campaign_id: 1233455,
494
+ campaign_id: 1233455,
487
495
  name: "New Campaign Name",
488
496
  language_id: 2,
489
497
  emails: [{
@@ -703,7 +711,7 @@ webhooks.create(
703
711
  'subscriber.created',
704
712
  'subscriber.updated',
705
713
  'subscriber.unsubscribed'
706
- ],
714
+ ],
707
715
  url:'https://my-url.com',
708
716
  name: 'Webhook name'
709
717
  )
@@ -720,12 +728,12 @@ require "mailerlite-ruby"
720
728
  webhooks = MailerLite::Webhooks.new
721
729
 
722
730
  webhooks.update(
723
- webhook_id: 123456,
731
+ webhook_id: 123456,
724
732
  events:[
725
733
  'subscriber.created',
726
734
  'subscriber.updated',
727
735
  'subscriber.unsubscribed'
728
- ],
736
+ ],
729
737
  url:'https://my-url.com',
730
738
  name: 'Webhook name',
731
739
  enabled: false
@@ -784,7 +792,7 @@ campaigns.languages()
784
792
  # Testing
785
793
 
786
794
  ```bash
787
- bundle i
795
+ bundle i
788
796
  bundle exec rspec spec/*rspec.rb
789
797
  ```
790
798
 
@@ -794,7 +802,7 @@ The fixtures for the test have been recorded using vcr and are available in the
794
802
  # Generate Docs
795
803
 
796
804
  ```bash
797
- bundle i
805
+ bundle i
798
806
  bundle exec yardoc 'lib/**/*.rb'
799
807
  ```
800
808
 
@@ -1,20 +1,30 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'http'
4
- require 'dotenv/load'
5
4
 
6
5
  MAILERLITE_API_URL = 'https://connect.mailerlite.com/api'
7
6
 
8
- Dotenv.require_keys('MAILERLITE_API_TOKEN')
9
-
10
7
  # mailerlite-ruby is a gem that integrates all endpoints from MailerLite API
11
8
  module MailerLite
12
9
  attr_reader :api_token
13
10
 
11
+ class << self
12
+ attr_accessor :use_dotenv
13
+
14
+ def configure
15
+ yield self
16
+ end
17
+ end
18
+
14
19
  # Inits the client.
15
20
  class Client
16
- def initialize(api_token = ENV.fetch('MAILERLITE_API_TOKEN', nil))
17
- @api_token = api_token
21
+ def initialize
22
+ if MailerLite.use_dotenv
23
+ require 'dotenv'
24
+ Dotenv.load
25
+ Dotenv.require_keys('MAILERLITE_API_TOKEN')
26
+ end
27
+ @api_token = ENV.fetch('MAILERLITE_API_TOKEN', nil)
18
28
  end
19
29
 
20
30
  def headers
@@ -54,12 +54,12 @@ module MailerLite
54
54
  # @param limit [Integer] the maximum number of subscribers to return
55
55
  # @param page [Integer] the page number of the results to return
56
56
  # @return [HTTP::Response] the response from the API
57
- def get_subscribers(group_id:, filter: {}, limit: nil, page: nil, sort: nil)
57
+ def get_subscribers(group_id:, filter: {}, limit: nil, cursor: nil, sort: nil)
58
58
  params = {}
59
59
  params['filter[status]'] = filter[:status] if filter.key?(:status)
60
60
  params['limit'] = limit if limit
61
61
  params['sort'] = sort if sort
62
- params['page'] = page if page
62
+ params['cursor'] = cursor if cursor
63
63
  client.http.get("#{MAILERLITE_API_URL}/groups/#{group_id}/subscribers", json: params.compact)
64
64
  end
65
65
 
@@ -18,11 +18,11 @@ module MailerLite
18
18
  # @param limit [Integer] the maximum number of subscribers to return
19
19
  # @param page [Integer] the page number of the results to return
20
20
  # @return [HTTP::Response] the response from the API
21
- def fetch(filter:, limit: nil, page: nil)
21
+ def fetch(filter:, limit: nil, cursor: nil)
22
22
  params = { 'filter[status]' => filter[:status] }
23
23
 
24
24
  params['limit'] = limit if limit
25
- params['page'] = page if page
25
+ params['cursor'] = cursor if cursor
26
26
  uri = URI("#{MAILERLITE_API_URL}/subscribers")
27
27
  uri.query = URI.encode_www_form(params.compact)
28
28
  client.http.get(uri)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MailerLite
4
- VERSION = '1.0.5'
4
+ VERSION = '2.0.0'
5
5
  end
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
14
14
  spec.description = "MailerLite's official Ruby SDK. Interacts with all endpoints at MailerLite API."
15
15
  spec.homepage = 'https://www.MailerLite.com'
16
16
  spec.license = 'MIT'
17
- spec.required_ruby_version = '>= 2.5.0'
17
+ spec.required_ruby_version = '>= 3.1'
18
18
 
19
19
  spec.metadata['allowed_push_host'] = 'https://rubygems.org'
20
20
 
@@ -27,13 +27,13 @@ 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.1'
31
- spec.add_development_dependency 'rake', '~> 13.0'
32
- spec.add_development_dependency 'rubocop', '~> 1.7'
33
- spec.add_dependency 'dotenv', '~> 2.7'
34
- spec.add_dependency 'http', '~> 5.0'
35
- spec.add_dependency 'json', '~> 2.5'
36
- spec.add_dependency 'uri', '~> 0.13.0'
30
+ spec.add_development_dependency 'bundler', '~> 2.5'
31
+ spec.add_development_dependency 'rake', '~> 13.2'
32
+ spec.add_development_dependency 'rubocop', '~> 1.69'
33
+ spec.add_dependency 'dotenv', '~> 3.1'
34
+ spec.add_dependency 'http', '~> 5.2'
35
+ spec.add_dependency 'json', '~> 2.9'
36
+ spec.add_dependency 'uri', '~> 1.0'
37
37
  spec.add_development_dependency 'rspec'
38
38
  spec.add_development_dependency 'simplecov'
39
39
  spec.add_development_dependency 'vcr'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mailerlite-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nikola Milojević
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2024-03-12 00:00:00.000000000 Z
12
+ date: 2024-12-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -17,98 +17,98 @@ dependencies:
17
17
  requirements:
18
18
  - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: 2.4.1
20
+ version: '2.5'
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.1
27
+ version: '2.5'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rake
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - "~>"
33
33
  - !ruby/object:Gem::Version
34
- version: '13.0'
34
+ version: '13.2'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
- version: '13.0'
41
+ version: '13.2'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: rubocop
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - "~>"
47
47
  - !ruby/object:Gem::Version
48
- version: '1.7'
48
+ version: '1.69'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: '1.7'
55
+ version: '1.69'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: dotenv
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
60
  - - "~>"
61
61
  - !ruby/object:Gem::Version
62
- version: '2.7'
62
+ version: '3.1'
63
63
  type: :runtime
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
67
  - - "~>"
68
68
  - !ruby/object:Gem::Version
69
- version: '2.7'
69
+ version: '3.1'
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: http
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - "~>"
75
75
  - !ruby/object:Gem::Version
76
- version: '5.0'
76
+ version: '5.2'
77
77
  type: :runtime
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
81
  - - "~>"
82
82
  - !ruby/object:Gem::Version
83
- version: '5.0'
83
+ version: '5.2'
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: json
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
88
  - - "~>"
89
89
  - !ruby/object:Gem::Version
90
- version: '2.5'
90
+ version: '2.9'
91
91
  type: :runtime
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
95
  - - "~>"
96
96
  - !ruby/object:Gem::Version
97
- version: '2.5'
97
+ version: '2.9'
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: uri
100
100
  requirement: !ruby/object:Gem::Requirement
101
101
  requirements:
102
102
  - - "~>"
103
103
  - !ruby/object:Gem::Version
104
- version: 0.13.0
104
+ version: '1.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.13.0
111
+ version: '1.0'
112
112
  - !ruby/object:Gem::Dependency
113
113
  name: rspec
114
114
  requirement: !ruby/object:Gem::Requirement
@@ -291,14 +291,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
291
291
  requirements:
292
292
  - - ">="
293
293
  - !ruby/object:Gem::Version
294
- version: 2.5.0
294
+ version: '3.1'
295
295
  required_rubygems_version: !ruby/object:Gem::Requirement
296
296
  requirements:
297
297
  - - ">="
298
298
  - !ruby/object:Gem::Version
299
299
  version: '0'
300
300
  requirements: []
301
- rubygems_version: 3.5.3
301
+ rubygems_version: 3.5.22
302
302
  signing_key:
303
303
  specification_version: 4
304
304
  summary: MailerLite's official Ruby SDK