Class: MicrosoftKiotaAbstractions::RequestInformation
- Inherits:
-
Object
- Object
- MicrosoftKiotaAbstractions::RequestInformation
- Defined in:
- lib/microsoft_kiota_abstractions/request_information.rb
Constant Summary collapse
- @@binary_content_type =
'application/octet-stream'- @@content_type_header =
'Content-Type'- @@raw_url_key =
'request-raw-url'
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#http_method ⇒ Object
Returns the value of attribute http_method.
-
#path_parameters ⇒ Object
Returns the value of attribute path_parameters.
-
#query_parameters ⇒ Object
Returns the value of attribute query_parameters.
-
#url_template ⇒ Object
Returns the value of attribute url_template.
Instance Method Summary collapse
- #add_headers_from_raw_object(h) ⇒ Object
- #add_request_options(request_options_to_add) ⇒ Object
- #get_request_option(key) ⇒ Object
- #get_request_options ⇒ Object
-
#initialize ⇒ RequestInformation
constructor
A new instance of RequestInformation.
- #remove_request_options(keys) ⇒ Object
- #set_content_from_parsable(request_adapter, content_type, values) ⇒ Object
- #set_query_string_parameters_from_raw_object(q) ⇒ Object
- #set_stream_content(value = $stdin, content_type) ⇒ Object
- #uri ⇒ Object
- #uri=(arg) ⇒ Object
Constructor Details
#initialize ⇒ RequestInformation
Returns a new instance of RequestInformation.
17 18 19 20 21 |
# File 'lib/microsoft_kiota_abstractions/request_information.rb', line 17 def initialize @headers = RequestHeaders.new @query_parameters = {} @path_parameters = {} end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
10 11 12 |
# File 'lib/microsoft_kiota_abstractions/request_information.rb', line 10 def content @content end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
10 11 12 |
# File 'lib/microsoft_kiota_abstractions/request_information.rb', line 10 def headers @headers end |
#http_method ⇒ Object
Returns the value of attribute http_method.
10 11 12 |
# File 'lib/microsoft_kiota_abstractions/request_information.rb', line 10 def http_method @http_method end |
#path_parameters ⇒ Object
Returns the value of attribute path_parameters.
11 12 13 |
# File 'lib/microsoft_kiota_abstractions/request_information.rb', line 11 def path_parameters @path_parameters end |
#query_parameters ⇒ Object
Returns the value of attribute query_parameters.
11 12 13 |
# File 'lib/microsoft_kiota_abstractions/request_information.rb', line 11 def query_parameters @query_parameters end |
#url_template ⇒ Object
Returns the value of attribute url_template.
11 12 13 |
# File 'lib/microsoft_kiota_abstractions/request_information.rb', line 11 def url_template @url_template end |
Instance Method Details
#add_headers_from_raw_object(h) ⇒ Object
97 98 99 |
# File 'lib/microsoft_kiota_abstractions/request_information.rb', line 97 def add_headers_from_raw_object(h) h&.get_all&.select { |x, y| @headers.add(x.to_s, y) } end |
#add_request_options(request_options_to_add) ⇒ Object
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/microsoft_kiota_abstractions/request_information.rb', line 42 def () return if .nil? @request_options ||= {} = [] unless .is_a?(Array) .each do |request_option| key = request_option.get_key @request_options[key] = request_option end end |
#get_request_option(key) ⇒ Object
59 60 61 62 63 |
# File 'lib/microsoft_kiota_abstractions/request_information.rb', line 59 def get_request_option(key) return nil if @request_options.nil? || key.nil? || key.empty? @request_options[key] end |
#get_request_options ⇒ Object
53 54 55 56 57 |
# File 'lib/microsoft_kiota_abstractions/request_information.rb', line 53 def return [] if @request_options.nil? @request_options.values end |
#remove_request_options(keys) ⇒ Object
65 66 67 68 69 70 71 72 |
# File 'lib/microsoft_kiota_abstractions/request_information.rb', line 65 def (keys) return if keys.nil? || @request_options.nil? keys = [keys] unless keys.is_a?(Array) keys.each do |key| @request_options.delete(key) end end |
#set_content_from_parsable(request_adapter, content_type, values) ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/microsoft_kiota_abstractions/request_information.rb', line 84 def set_content_from_parsable(request_adapter, content_type, values) writer = request_adapter.get_serialization_writer_factory.get_serialization_writer(content_type) @headers.try_add(@@content_type_header, content_type) if !values.nil? && values.is_a?(Array) writer.write_collection_of_object_values(nil, values) else writer.write_object_value(nil, values) end @content = writer.get_serialized_content rescue StandardError raise StandardError, 'could not serialize payload' end |
#set_query_string_parameters_from_raw_object(q) ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/microsoft_kiota_abstractions/request_information.rb', line 101 def set_query_string_parameters_from_raw_object(q) return if !q || q.is_a?(Hash) || q.is_a?(Array) q.class.instance_methods(false).select do |x| method_name = x.to_s if method_name == 'compare_by_identity' || method_name == 'get_query_parameter' || method_name.end_with?('=') || method_name.end_with?('?') || method_name.end_with?('!') next end begin key = q.get_query_parameter(method_name) rescue StandardError key = method_name end value = eval("q.#{method_name}") query_parameters[key] = value unless value.nil? end end |
#set_stream_content(value = $stdin, content_type) ⇒ Object
78 79 80 81 82 |
# File 'lib/microsoft_kiota_abstractions/request_information.rb', line 78 def set_stream_content(value = $stdin, content_type) @content = value content_type = @@binary_content_type if content_type.nil? || content_type.empty? @headers.try_add(@@content_type_header, content_type) end |
#uri ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/microsoft_kiota_abstractions/request_information.rb', line 31 def uri return @uri unless @uri.nil? if path_parameters[@@raw_url_key].nil? return URI(StdUriTemplate.(@url_template, path_parameters.merge(query_parameters))) end self.uri = path_parameters[@@raw_url_key] @uri end |
#uri=(arg) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/microsoft_kiota_abstractions/request_information.rb', line 23 def uri=(arg) raise ArgumentError, 'arg cannot be nil or empty' if arg.nil? || arg.empty? path_parameters.clear query_parameters.clear @uri = URI(arg) end |