class Microsoft::Graph::Batch::Request

Attributes

body[R]
depends_on[RW]
endpoint[R]
headers[R]
id[R]
method[R]

Public Class Methods

body_formatter() click to toggle source
# File lib/microsoft/graph/batch.rb, line 44
def self.body_formatter
  @body_formatter ||= Microsoft::Graph::BodyFormatter.new
end
new(endpoint, id:, method:, headers:, params:, body:, depends_on:) click to toggle source
# File lib/microsoft/graph/batch.rb, line 51
def initialize(endpoint, id:, method:, headers:, params:, body:, depends_on:)
  @id = id
  @endpoint = "#{self.class.parser.escape(endpoint)}#{params ? "?#{params.to_query}" : ""}"
  @method = method.upcase
  @headers = headers
  @headers[:Accept] = "application/json" if body
  @headers[:"Content-Type"] = "application/json" if body
  @body = body
  @depends_on = depends_on
end
parser() click to toggle source
# File lib/microsoft/graph/batch.rb, line 40
def self.parser
  @parser ||= URI::Parser.new
end

Public Instance Methods

to_h() click to toggle source
# File lib/microsoft/graph/batch.rb, line 62
def to_h
  hash = {
    id: @id,
    url: @endpoint,
    method: @method
  }
  hash[:headers] = @headers unless @headers.empty?
  hash[:body] = self.class.body_formatter.call(@body, method: @method) if @body
  hash[:dependsOn] = [@depends_on] if @depends_on

  hash
end