Sha256: 3cf3a2a74ec7c2f60660a745db8e0a902daff3ac4ec52b6220435e91523fd7a6
Contents?: true
Size: 1.33 KB
Versions: 5
Compression:
Stored size: 1.33 KB
Contents
module Tangany module Custody module Contracts module Wallets class List < ApplicationContract ALLOWED_ORDERS = ["created", "security", "updated", "wallet"].freeze schema do config.validate_keys = true optional(:start).filled(:integer, lt?: 10_000) optional(:limit).filled(:integer, gt?: 0, lteq?: 100) optional(:order).filled(:string, included_in?: ALLOWED_ORDERS) optional(:sort).filled(:string, included_in?: ALLOWED_SORTS) optional(:tags).filled(:array, min_size?: 1) optional(:xtags).filled(:array, min_size?: 1) end rule(:sort) do key.failure("should not be specified without `order`") if values[:sort] && values[:order].nil? end def to_safe_params!(params) safe_params = super(params) order = safe_params.delete(:order) safe_params[:sort] = order + ((safe_params[:sort] == "desc") ? "desc" : "") if order safe_params[:index] = safe_params.delete(:start) if safe_params[:start] safe_params[:tags] = safe_params[:tags].join(",") if safe_params[:tags] safe_params[:xtags] = safe_params[:xtags].join(",") if safe_params[:xtags] safe_params end end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems