From e0ef94829b1168e39d2224069d83fa5732b3011c Mon Sep 17 00:00:00 2001 From: Daniel Puglisi Date: Tue, 23 Nov 2021 15:27:30 +0100 Subject: [PATCH 1/2] enable beta as version parameter --- lib/microsoft/graph.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/microsoft/graph.rb b/lib/microsoft/graph.rb index 0686aaf..8ce2834 100644 --- a/lib/microsoft/graph.rb +++ b/lib/microsoft/graph.rb @@ -12,7 +12,7 @@ class Graph BODY_METHODS = %w[POST PUT PATCH].freeze ALLOWED_METHODS = [*BODY_METHODS, "GET", "DELETE"].freeze - def initialize(token: nil, error_handler: method(:error_handler), version: "1.0") + def initialize(token: nil, error_handler: method(:error_handler), version: "v1.0") @token = token @parser = URI::Parser.new @body_formatter = Microsoft::Graph::BodyFormatter.new @@ -39,7 +39,7 @@ def call(endpoint, token: @token, method: "GET", headers: {}, params: nil, body: method = method.upcase raise ArgumentError, "`#{method}` is not a valid HTTP method." unless ALLOWED_METHODS.include?(method) - url = URI.join(GRAPH_HOST, @parser.escape("v#{@version}/#{endpoint.gsub(%r{^/}, "")}")) + url = URI.join(GRAPH_HOST, @parser.escape("#{@version}/#{endpoint.gsub(%r{^/}, "")}")) headers = headers.merge( Authorization: "Bearer #{token}", Accept: "application/json" From e223030fd4812b1db09dfbfc1cdad0e09495d442 Mon Sep 17 00:00:00 2001 From: Daniel Puglisi Date: Mon, 20 Mar 2023 10:53:58 +0100 Subject: [PATCH 2/2] add last_response attribute --- lib/microsoft/graph.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/microsoft/graph.rb b/lib/microsoft/graph.rb index 8ce2834..b337924 100644 --- a/lib/microsoft/graph.rb +++ b/lib/microsoft/graph.rb @@ -12,6 +12,8 @@ class Graph BODY_METHODS = %w[POST PUT PATCH].freeze ALLOWED_METHODS = [*BODY_METHODS, "GET", "DELETE"].freeze + attr_reader :last_response + def initialize(token: nil, error_handler: method(:error_handler), version: "v1.0") @token = token @parser = URI::Parser.new @@ -54,6 +56,7 @@ def call(endpoint, token: @token, method: "GET", headers: {}, params: nil, body: body: @body_formatter.call(body, method: method).to_json, parser: InstanceParser ) + @last_response = response case response.code when 200...400