Module: Scorpio::Request::Configurables

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

Instance Attribute Summary collapse

Instance Attribute Details

#base_urlObject



64
65
66
67
# File 'lib/scorpio/request.rb', line 64

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



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/scorpio/request.rb', line 70

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::Util.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.



92
93
94
# File 'lib/scorpio/request.rb', line 92

def body_object
  @body_object
end

#faraday_adapterObject



119
120
121
122
# File 'lib/scorpio/request.rb', line 119

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

#faraday_builderObject



113
114
115
116
# File 'lib/scorpio/request.rb', line 113

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

#headersObject



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

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

#loggerObject



125
126
127
128
# File 'lib/scorpio/request.rb', line 125

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

#media_typeObject



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

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



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

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

#query_paramsObject



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

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

#schemeObject



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

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

#serverObject



52
53
54
55
# File 'lib/scorpio/request.rb', line 52

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

#server_variablesObject



58
59
60
61
# File 'lib/scorpio/request.rb', line 58

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

#user_agentObject



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

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