Method: D2L::Valence::Request#initialize

Defined in:
lib/d2l/valence/request.rb

#initialize(user_context:, http_method:, route:, route_params: {}, query_params: {}) ⇒ Request

API routes

See D2L::Valence::UserContext.api_call for details on creating routes and route_params

Parameters:

  • the user context created after authentication

  • the HTTP Method for the call (i.e. PUT, GET, POST, DELETE)

  • the API method route (e.g. /d2l/api/lp/:version/users/whoami)

  • (defaults to: {})

    the parameters for the API method route (option)

  • (defaults to: {})

    the query parameters for the method call



19
20
21
22
23
24
25
26
27
28
# File 'lib/d2l/valence/request.rb', line 19

def initialize(user_context:, http_method:, route:, route_params: {}, query_params: {})
  @user_context = user_context
  @app_context = user_context.app_context
  @http_method = http_method.upcase
  @route = route
  @route_params = route_params
  @query_params = query_params

  raise "HTTP Method #{@http_method} is unsupported" unless %w(GET PUT POST DELETE).include? @http_method
end