diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b883cd..f29f375 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## [1.0.6] - 2024-12-06 +- Page parameter to cursor pagination fix + ## [1.0.5] - 2024-03-12 - Update constant name diff --git a/README.md b/README.md index bb15203..c8c3da9 100644 --- a/README.md +++ b/README.md @@ -105,7 +105,7 @@ require "mailerlite-ruby" # Intialize the class subscribers = MailerLite::Subscribers.new -subscribers.fetch(filter: { status: 'active' }) +subscribers.fetch(filter: { status: 'active' }, cursor: 'cursor') ``` ### Create a subscriber @@ -131,7 +131,7 @@ require "mailerlite-ruby" # Intialize the class subscribers = MailerLite::Subscribers.new -subscribers.update(email:'some@email.com', fields: {'name': 'John', 'last_name': 'Doe'}, ip_address:'1.2.3.4', optin_ip:'1.2.3.4') +subscribers.update('some@email.com', fields: {'name': 'John', 'last_name': 'Doe'}, ip_address:'1.2.3.4', optin_ip:'1.2.3.4') ``` ### Get a subscriber @@ -227,10 +227,10 @@ groups.delete(group_id) ```ruby require "mailerlite-ruby" -# Intialize the class +# Initialize the class groups = MailerLite::Groups.new -groups.get_subscribers(group_id:1234567, page:1, limit:10, filter:{'status': 'active'}) +groups.get_subscribers(group_id: 1234567, cursor: 'cursor', limit: 10, filter: { 'status': 'active' }) ``` ### Assign subscriber to a group diff --git a/lib/mailerlite/groups/groups.rb b/lib/mailerlite/groups/groups.rb index bc86d07..65ba3d0 100644 --- a/lib/mailerlite/groups/groups.rb +++ b/lib/mailerlite/groups/groups.rb @@ -54,12 +54,12 @@ def update(group_id:, name:) # @param limit [Integer] the maximum number of subscribers to return # @param page [Integer] the page number of the results to return # @return [HTTP::Response] the response from the API - def get_subscribers(group_id:, filter: {}, limit: nil, page: nil, sort: nil) + def get_subscribers(group_id:, filter: {}, limit: nil, cursor: nil, sort: nil) params = {} params['filter[status]'] = filter[:status] if filter.key?(:status) params['limit'] = limit if limit params['sort'] = sort if sort - params['page'] = page if page + params['cursor'] = cursor if cursor client.http.get("#{MAILERLITE_API_URL}/groups/#{group_id}/subscribers", json: params.compact) end diff --git a/lib/mailerlite/subscribers/subscribers.rb b/lib/mailerlite/subscribers/subscribers.rb index 239b187..535e747 100644 --- a/lib/mailerlite/subscribers/subscribers.rb +++ b/lib/mailerlite/subscribers/subscribers.rb @@ -18,11 +18,11 @@ def initialize(client: MailerLite::Client.new) # @param limit [Integer] the maximum number of subscribers to return # @param page [Integer] the page number of the results to return # @return [HTTP::Response] the response from the API - def fetch(filter:, limit: nil, page: nil) + def fetch(filter:, limit: nil, cursor: nil) params = { 'filter[status]' => filter[:status] } params['limit'] = limit if limit - params['page'] = page if page + params['cursor'] = cursor if cursor uri = URI("#{MAILERLITE_API_URL}/subscribers") uri.query = URI.encode_www_form(params.compact) client.http.get(uri) diff --git a/lib/mailerlite/version.rb b/lib/mailerlite/version.rb index 462b77c..9bf81de 100644 --- a/lib/mailerlite/version.rb +++ b/lib/mailerlite/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module MailerLite - VERSION = '1.0.5' + VERSION = '1.0.6' end