Sha256: 27899d5d4220887b3f0f46f1e88301ada7c31d0c30638888de800e2e9e0433a2

Contents?: true

Size: 709 Bytes

Versions: 3

Compression:

Stored size: 709 Bytes

Contents

require 'sinatra'
require_relative 'handler'

module Api
  class Web < Sinatra::Base


    post '/apps/connect' do
      if connect(params)[:code] == 200
        status 200
        body ['Successfully logged!']
      else
        status 400
        body ['Sorry, an error occured']
      end
    end
    after do
      response
    end

    private ################

    def format_option(params)
      option = {}
      option = {user: true, app: false} if (params[:option][:user] == 'true')
      option = {user: false, app: true} if (params[:option][:app] == 'true')
      option
    end

    def connect(params)
      Api::Handler.connect(params[:object].to_json, format_option(params))
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
recommender_api-0.0.5 lib/api/web.rb
recommender_api-0.0.4 lib/api/web.rb
recommender_api-0.0.3 lib/api/web.rb