Sha256: 6ebeebd18f43b5655e89b318210d937a0d604fa4d69acb3efd886f1587a1f925

Contents?: true

Size: 722 Bytes

Versions: 7

Compression:

Stored size: 722 Bytes

Contents

# frozen_string_literal: true
module FinApps
  module REST
    class OrderReports < FinApps::REST::Resources # :nodoc:
      using ObjectExtensions
      using StringExtensions

      def show(id, format)
        raise MissingArgumentsError.new 'Missing argument: id.' if id.blank?
        raise MissingArgumentsError.new 'Missing argument: format' if format.blank?
        raise InvalidArgumentsError.new 'Invalid argument: format' unless accepted_format?(format)

        path = "orders/#{ERB::Util.url_encode(id)}/report.#{ERB::Util.url_encode(format)}"
        super nil, path
      end

      private

      def accepted_format?(format)
        [:json, :html, :pdf].include? format.to_sym
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
finapps-2.1.4 lib/finapps/rest/order_reports.rb
finapps-2.1.3 lib/finapps/rest/order_reports.rb
finapps-2.1.2 lib/finapps/rest/order_reports.rb
finapps-2.1.1 lib/finapps/rest/order_reports.rb
finapps-2.0.30 lib/finapps/rest/order_reports.rb
finapps-2.0.29 lib/finapps/rest/order_reports.rb
finapps-2.0.28 lib/finapps/rest/order_reports.rb