Sha256: d0cf728686496110e6f46b35cd156dba18dcda6c802525fc093a874842bc1fe2

Contents?: true

Size: 752 Bytes

Versions: 6

Compression:

Stored size: 752 Bytes

Contents

# frozen_string_literal: true

# The base class for all services in the library.
class EasyPost::Services::Service
  def initialize(client)
    @client = client
  end

  protected

  # Get next page of an object collection
  def get_next_page_helper(collection, current_page_items, endpoint, cls, page_size = nil)
    has_more = collection.has_more || false
    unless !has_more || current_page_items.nil? || current_page_items.empty?
      params = {}
      params[:before_id] = current_page_items.last.id
      unless page_size.nil?
        params[:page_size] = page_size
      end

      @client.make_request(:get, endpoint, cls, params)
    end

    # issue with getting the next page
    raise EasyPost::Errors::EndOfPaginationError.new
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
easypost-5.3.0 lib/easypost/services/base.rb
easypost-5.2.0 lib/easypost/services/base.rb
easypost-5.1.1 lib/easypost/services/base.rb
easypost-5.1.0 lib/easypost/services/base.rb
easypost-5.0.1 lib/easypost/services/base.rb
easypost-5.0.0 lib/easypost/services/base.rb