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.
14 15 16 17 18 |
# File 'lib/microsoft_kiota_abstractions/request_information.rb', line 14 def initialize() @headers = RequestHeaders.new @query_parameters = Hash.new @path_parameters = Hash.new end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
8 9 10 |
# File 'lib/microsoft_kiota_abstractions/request_information.rb', line 8 def content @content end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
8 9 10 |
# File 'lib/microsoft_kiota_abstractions/request_information.rb', line 8 def headers @headers end |
#http_method ⇒ Object
Returns the value of attribute http_method.
8 9 10 |
# File 'lib/microsoft_kiota_abstractions/request_information.rb', line 8 def http_method @http_method end |
#path_parameters ⇒ Object
Returns the value of attribute path_parameters.
9 10 11 |
# File 'lib/microsoft_kiota_abstractions/request_information.rb', line 9 def path_parameters @path_parameters end |
#query_parameters ⇒ Object
Returns the value of attribute query_parameters.
9 10 11 |
# File 'lib/microsoft_kiota_abstractions/request_information.rb', line 9 def query_parameters @query_parameters end |
#url_template ⇒ Object
Returns the value of attribute url_template.
9 10 11 |
# File 'lib/microsoft_kiota_abstractions/request_information.rb', line 9 def url_template @url_template end |
Instance Method Details
#add_headers_from_raw_object(h) ⇒ Object
109 110 111 |
# File 'lib/microsoft_kiota_abstractions/request_information.rb', line 109 def add_headers_from_raw_object(h) h.get_all.select{|x,y| @headers.add(x.to_s, y)} unless !h end |
#add_request_options(request_options_to_add) ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/microsoft_kiota_abstractions/request_information.rb', line 42 def () unless .nil? then @request_options ||= Hash.new unless .kind_of?(Array) then = [] end .each do |request_option| key = request_option.get_key @request_options[key] = request_option end end end |
#get_request_option(key) ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/microsoft_kiota_abstractions/request_information.rb', line 63 def get_request_option(key) if @request_options.nil? || key.nil? || key.empty? then return nil else return @request_options[key] end end |
#get_request_options ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/microsoft_kiota_abstractions/request_information.rb', line 55 def () if @request_options.nil? then return [] else return @request_options.values end end |
#remove_request_options(keys) ⇒ Object
71 72 73 74 75 76 77 78 79 80 |
# File 'lib/microsoft_kiota_abstractions/request_information.rb', line 71 def (keys) unless keys.nil? || @request_options.nil? then unless keys.kind_of?(Array) then keys = [keys] end keys.each do |key| @request_options.delete(key) end end end |
#set_content_from_parsable(request_adapter, content_type, values) ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/microsoft_kiota_abstractions/request_information.rb', line 94 def set_content_from_parsable(request_adapter, content_type, values) begin writer = request_adapter.get_serialization_writer_factory().get_serialization_writer(content_type) @headers.try_add(@@content_type_header, content_type) if values != nil && values.kind_of?(Array) writer.write_collection_of_object_values(nil, values) else writer.write_object_value(nil, values); end @content = writer.get_serialized_content(); rescue => exception raise Exception.new "could not serialize payload" end end |
#set_query_string_parameters_from_raw_object(q) ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/microsoft_kiota_abstractions/request_information.rb', line 113 def set_query_string_parameters_from_raw_object(q) if !q || q.is_a?(Hash) || q.is_a?(Array) return end q.class.instance_methods(false).select{|x| method_name = x.to_s unless method_name == "compare_by_identity" || method_name == "get_query_parameter" || method_name.end_with?("=") || method_name.end_with?("?") || method_name.end_with?("!") then begin key = q.get_query_parameter(method_name) rescue => exception key = method_name end value = eval("q.#{method_name}") self.query_parameters[key] = value unless value.nil? end } end |
#set_stream_content(value = $stdin, content_type) ⇒ Object
86 87 88 89 90 91 92 |
# File 'lib/microsoft_kiota_abstractions/request_information.rb', line 86 def set_stream_content(value = $stdin, content_type) @content = value if content_type.nil? || content_type.empty? content_type = @@binary_content_type end @headers.try_add(@@content_type_header, content_type) end |
#uri ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/microsoft_kiota_abstractions/request_information.rb', line 29 def uri if @uri != nil return @uri else if self.path_parameters[@@raw_url_key] != nil self.uri = self.path_parameters[@@raw_url_key] return @uri else return URI(StdUriTemplate.(@url_template, self.path_parameters.merge(self.query_parameters))) end end end |
#uri=(arg) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/microsoft_kiota_abstractions/request_information.rb', line 20 def uri=(arg) if arg.nil? || arg.empty? raise ArgumentError, 'arg cannot be nil or empty' end self.path_parameters.clear() self.query_parameters.clear() @uri = URI(arg) end |