Sha256: e1ce3e55aade4f1023486285bdd2624f6baeac906bd797b9c0f2684d2c02c32c

Contents?: true

Size: 506 Bytes

Versions: 1

Compression:

Stored size: 506 Bytes

Contents

require 'sinatra/base'
require 'momm'

module Momm
  class Web < ::Sinatra::Base
    get '/query' do
      content_type :json

      money = params[:money].to_f
      from = params[:from].to_sym
      to = params[:to].to_sym
      date = params[:date] || Date.today


      if money && from && to && date
        Momm.exchange(money, from, to, date: date).to_json
      else
        "N/A"
      end

    end

    get '/currencies' do
      content_type :json
      Momm.currencies.to_json
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
momm-0.0.1 lib/momm/web.rb