Sha256: dec2f743b7e0ad9359eb5938e90d5f6e5ad3d6eba26350fb64d1abb3f37846b4

Contents?: true

Size: 1.13 KB

Versions: 1

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

module Tikkie
  module Api
    module Resources
      # Resource for Payment Requests.
      class PaymentRequests < List
        include Enumerable

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

        private

        def load_resource
          params = { pageNumber: page_number, pageSize: page_size }
          params[:fromDate] = options[:from_date].respond_to?(:utc) ? options[:from_date].utc.iso8601 : options[:from_date] if options.key?(:from_date)
          params[:toDate] = options[:to_date].respond_to?(:utc) ? options[:to_date].utc.iso8601 : options[:to_date] if options.key?(:to_date)

          request.get("paymentrequests", params)
        end

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

            if body[:paymentRequests]
              body[:paymentRequests].each do |payment_request|
                payment_requests << Tikkie::Api::Resources::PaymentRequest.new(config, body: payment_request)
              end
            end

            payment_requests
          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/resources/payment_requests.rb