Sha256: cf84bd7d3ee76ea5f24637eed25dac097b9f6ec73aeb17054c796a07537a5365

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

module Tikkie
  module Api
    module V1
      module Responses
        # Response when requesting payment requests (list).
        class PaymentRequests < Base
          include Enumerable
          include Tikkie::Api::V1::Responses::Pagination

          def initialize(response, options = {})
            super(response)

            @offset = options[:offset]
            @limit = options[:limit]
            @total_elements = data[:totalElements]
            @elements = payment_requests.count
          end

          def each(&block)
            payment_requests.each(&block)
          end

          private

          def payment_requests
            @payment_requests ||= begin
              payment_requests = []

              if data[:paymentRequests]
                data[:paymentRequests].each do |payment_request|
                  payment_requests << Tikkie::Api::V1::Responses::PaymentRequest.new(payment_request)
                end
              end

              payment_requests
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tikkie-api-2.0.0 lib/tikkie/api/v1/responses/payment_requests.rb