module Dag::Client::API::ListParams

Public Instance Methods

list_params(options) click to toggle source
# File lib/dag/client/api/list_params.rb, line 4
def list_params(options)
  params = {}

  max = options[:max]

  if max.present?
    unless max.kind_of?(Integer)
      raise Dag::Client::ParameterInvalid.new("max should be integer")
    end

    if max < 1
      raise Dag::Client::ParameterInvalid.new("max should be greater than 0:#{max}")
    end

    if max > 100
      raise Dag::Client::ParameterInvalid.new("max should be less than 100 or equal to 100:#{max}")
    end

    params.merge!('max' => max)
  end

  marker = options[:marker]


  if marker.present?
    params.merge!('marker' => marker)
  end

  params
end