Module: Scorpio::Request::Configurables

Included in:
Scorpio::Request
Defined in:
lib/scorpio/request.rb

Instance Attribute Summary collapse

Instance Attribute Details

#base_urlObject



46
47
48
49
# File 'lib/scorpio/request.rb', line 46

def base_url
  return @base_url if instance_variable_defined?(:@base_url)
  operation.base_url(scheme: scheme, server: server, server_variables: server_variables)
end

#bodyObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/scorpio/request.rb', line 52

def body
  return @body if instance_variable_defined?(:@body)
  if instance_variable_defined?(:@body_object)
    if content_type && content_type.json?
      JSON.pretty_generate(JSI::Typelike.as_json(body_object))
    elsif content_type && content_type.form_urlencoded?
      URI.encode_www_form(body_object)

    # NOTE: the supported media types above should correspond to Request::SUPPORTED_REQUEST_MEDIA_TYPES

    else
      if body_object.respond_to?(:to_str)
        body_object
      else
        raise(NotImplementedError, "Scorpio does not know how to generate the request body with content_type = #{content_type.respond_to?(:to_str) ? content_type : content_type.inspect} for operation: #{operation.human_id}. Scorpio supports media types: #{SUPPORTED_REQUEST_MEDIA_TYPES.join(', ')}. body_object was: #{body_object.pretty_inspect.chomp}")
      end
    end
  else
    nil
  end
end

#body_objectObject

Returns the value of attribute body_object.



74
75
76
# File 'lib/scorpio/request.rb', line 74

def body_object
  @body_object
end

#faraday_adapterObject



101
102
103
104
# File 'lib/scorpio/request.rb', line 101

def faraday_adapter
  return @faraday_adapter if instance_variable_defined?(:@faraday_adapter)
  operation.faraday_adapter
end

#faraday_builderObject



95
96
97
98
# File 'lib/scorpio/request.rb', line 95

def faraday_builder
  return @faraday_builder if instance_variable_defined?(:@faraday_builder)
  operation.faraday_builder
end

#headersObject



77
78
79
80
# File 'lib/scorpio/request.rb', line 77

def headers
  return @headers if instance_variable_defined?(:@headers)
  operation.request_headers
end

#loggerObject



107
108
109
110
# File 'lib/scorpio/request.rb', line 107

def logger
  return @logger if instance_variable_defined?(:@logger)
  operation.logger
end

#media_typeObject



83
84
85
86
# File 'lib/scorpio/request.rb', line 83

def media_type
  return @media_type if instance_variable_defined?(:@media_type)
  content_type_header ? content_type_header.media_type : operation.request_media_type
end

#path_paramsObject



16
17
18
19
# File 'lib/scorpio/request.rb', line 16

def path_params
  return @path_params if instance_variable_defined?(:@path_params)
  {}.freeze
end

#query_paramsObject



22
23
24
25
# File 'lib/scorpio/request.rb', line 22

def query_params
  return @query_params if instance_variable_defined?(:@query_params)
  nil
end

#schemeObject



28
29
30
31
# File 'lib/scorpio/request.rb', line 28

def scheme
  return @scheme if instance_variable_defined?(:@scheme)
  operation.scheme
end

#serverObject



34
35
36
37
# File 'lib/scorpio/request.rb', line 34

def server
  return @server if instance_variable_defined?(:@server)
  operation.server
end

#server_variablesObject



40
41
42
43
# File 'lib/scorpio/request.rb', line 40

def server_variables
  return @server_variables if instance_variable_defined?(:@server_variables)
  operation.server_variables
end

#user_agentObject



89
90
91
92
# File 'lib/scorpio/request.rb', line 89

def user_agent
  return @user_agent if instance_variable_defined?(:@user_agent)
  operation.user_agent
end