Sha256: 4f2daedda584cad9c247988a91b6806fd8c60d52249e2723301baa7f4c964bd9

Contents?: true

Size: 1.26 KB

Versions: 13

Compression:

Stored size: 1.26 KB

Contents

require_relative 'request_specs'
require_relative 'applications'
require_relative 'recordings'
module AgileProxy
  module Api
    #
    # = The API Root
    #
    # This is the root of the entire API for use with REST.  It will not be accessed directly
    #
    class Root < Grape::API
      version 'v1', vendor: 'agile-proxy'
      format :json
      helpers do
        # Provides easy access to the current user.
        # As we are currently only single user, then we just return the first user
        def current_user
          ::AgileProxy::User.first
        end
        # Secured methods must call this first
        def authenticate!
          # Do nothing yet
        end
        # Provides easy access to the current application whether
        # specified in the URL or not (defaults to the first if not)
        def current_application
          fail 'Application ID is missing' unless params.key?(:application_id)
          applications = current_user.applications
          applications.where(id: params[:application_id]).first
        end
      end
      namespace 'users/:user_id' do
        mount Api::Applications
        namespace '/applications/:application_id' do
          mount Api::Recordings
          mount Api::RequestSpecs
        end
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
agile-proxy-0.1.18 lib/agile_proxy/api/root.rb
agile-proxy-0.1.13 lib/agile_proxy/api/root.rb
agile-proxy-0.1.12 lib/agile_proxy/api/root.rb
agile-proxy-0.1.11 lib/agile_proxy/api/root.rb
agile-proxy-0.1.10 lib/agile_proxy/api/root.rb
agile-proxy-0.1.9 lib/agile_proxy/api/root.rb
agile-proxy-0.1.8 lib/agile_proxy/api/root.rb
agile-proxy-0.1.7 lib/agile_proxy/api/root.rb
agile-proxy-0.1.6 lib/agile_proxy/api/root.rb
agile-proxy-0.1.5 lib/agile_proxy/api/root.rb
agile-proxy-0.1.4 lib/agile_proxy/api/root.rb
agile-proxy-0.1.2 lib/agile_proxy/api/root.rb
agile-proxy-0.1.0 lib/agile_proxy/api/root.rb