ePages-de/epages-rest-ruby

View on GitHub
lib/epages/orders_response.rb

Summary

Maintainability
A
30 mins
Test Coverage
require 'epages/utils'
require 'epages/error'

module Epages
  class OrdersResponse
    include Epages::Utils

    KEYS = %w(results page results_per_page items).collect(&:to_sym).freeze

    attr_reader *KEYS

    def initialize(data)
      parse_attribute_as_array_of(:items, data.delete(:items), Epages::Order)
      parse_attributes(data)
    end

    alias_method :orders, :items
  end
end