Sha256: a55e5eed3e7ffafe1166a435a1e8d2995d0bdf7f71cc399b462d37d3dd70eb6b

Contents?: true

Size: 786 Bytes

Versions: 2

Compression:

Stored size: 786 Bytes

Contents

module Pina
  module Models
    class SalesInvoiceList
      include Virtus.model

      attribute :items, Array[SalesInvoice]
      attribute :_meta
      attribute :response

      def next_page
        Pina::SalesInvoice.all(extract_next_page)
      end

      def first_page
        Pina::SalesInvoice.all
      end

      def previous_page
        Pina::SalesInvoice.all(extract_prev_page)
      end

      private

      def extract_next_page
        string = _meta['pagination']['next']
        return unless string

        index = string.index('?')
        string[index..-1]
      end

      def extract_prev_page
        string = _meta['pagination']['prev']
        return unless string

        index = string.index('?')
        string[index..-1]
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pina-0.3.1 lib/pina/models/sales_invoice_list.rb
pina-0.2.0 lib/pina/models/sales_invoice_list.rb