Skip to content

Instantly share code, notes, and snippets.

@mnaichuk
Created February 4, 2019 16:47
Show Gist options
  • Save mnaichuk/f415b9335a6ce3feead428ab66bb875f to your computer and use it in GitHub Desktop.
Save mnaichuk/f415b9335a6ce3feead428ab66bb875f to your computer and use it in GitHub Desktop.
desc 'Get list of currencies',
is_array: true,
success: Entities::Currency
params do
optional :type, type: String,
values: %w[fiat coin],
desc: -> { API::V2::Entities::Currency.documentation[:type][:desc] }
end
get '/currencies' do
currencies = Currency.enabled
currencies = currencies.where(type: params[:type]).includes(:blockchain) if params[:type] == 'coin'
currencies = currencies.where(type: params[:type]) if params[:type] == 'fiat'
present :total, currencies.count
present :data, currencies.ordered, with: API::V2::Entities::Currency
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment