Class: Svelte::GenericOperation

Inherits:
Object
  • Object
show all
Defined in:
lib/svelte/generic_operation.rb

Overview

Class that handles the actual execution of dynamically generated operations Each created operation will eventually call this class in order to make the final HTTP request to the REST endpoint

Class Method Summary collapse

Class Method Details

.call(verb:, path:, configuration:, parameters:, options:, headers: nil) ⇒ Object

Make an HTTP request to a REST resource

Parameters:

  • verb (String)

    http verb to use, i.e. 'get'

  • path (Path)

    Path object containing information about the operation to be called

  • configuration (Configuration)

    Swagger API configuration

  • parameters (Hash)

    payload of the request, i.e. { petId: 1}

  • options (Hash)

    request options, i.e. { timeout: 10 }

  • headers (Hash) (defaults to: nil)

    headers to be included in the request



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/svelte/generic_operation.rb', line 17

def call(verb:, path:, configuration:, parameters:, options:, headers: nil)
  url = url_for(configuration: configuration,
                path: path,
                parameters: parameters)
  request_parameters = clean_parameters(path: path,
                                        parameters: parameters)
  request_headers = build_request_headers(configuration: configuration,
                                          options: options,
                                          headers: headers)
  RestClient.call(verb: verb,
                  url: url,
                  params: request_parameters,
                  headers: request_headers,
                  options: options)
end