Class: Teams::Graph::Client
- Inherits:
-
Object
- Object
- Teams::Graph::Client
- Defined in:
- lib/teams/graph/client.rb
Overview
Thin Microsoft Graph HTTP client, following the TypeScript SDK's core Graph client (Python/.NET delegate to the official Graph SDKs, which Ruby lacks a maintained equivalent of; TypeScript's generated endpoint packages are out of scope, so the raw request surface is the API here, like TypeScript's client.http escape hatch).
Constant Summary collapse
- DEFAULT_BASE_URL_ROOT =
"https://graph.microsoft.com"
Instance Attribute Summary collapse
-
#base_url_root ⇒ Object
readonly
Returns the value of attribute base_url_root.
-
#http ⇒ Object
readonly
Returns the value of attribute http.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Instance Method Summary collapse
- #delete(path, params: nil) ⇒ Object
- #get(path, params: nil) ⇒ Object
-
#initialize(token:, base_url_root: nil, version: "v1.0", http: nil) ⇒ Client
constructor
token: a string or a callable returning one (an app-only Graph token or a user token from sign-in).
- #patch(path, json: nil, params: nil) ⇒ Object
- #post(path, json: nil, params: nil) ⇒ Object
- #put(path, json: nil, params: nil) ⇒ Object
Constructor Details
#initialize(token:, base_url_root: nil, version: "v1.0", http: nil) ⇒ Client
token: a string or a callable returning one (an app-only Graph token or a user token from sign-in). base_url_root overrides the Graph host for sovereign clouds (e.g. "https://graph.microsoft.us").
18 19 20 21 22 |
# File 'lib/teams/graph/client.rb', line 18 def initialize(token:, base_url_root: nil, version: "v1.0", http: nil) @base_url_root = (base_url_root || DEFAULT_BASE_URL_ROOT).sub(%r{/+\z}, "") @version = version @http = http || Common::HttpClient.new(token:) end |
Instance Attribute Details
#base_url_root ⇒ Object (readonly)
Returns the value of attribute base_url_root.
13 14 15 |
# File 'lib/teams/graph/client.rb', line 13 def base_url_root @base_url_root end |
#http ⇒ Object (readonly)
Returns the value of attribute http.
13 14 15 |
# File 'lib/teams/graph/client.rb', line 13 def http @http end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
13 14 15 |
# File 'lib/teams/graph/client.rb', line 13 def version @version end |
Instance Method Details
#delete(path, params: nil) ⇒ Object
40 41 42 |
# File 'lib/teams/graph/client.rb', line 40 def delete(path, params: nil) request { http.delete(url(path), params:) } end |
#get(path, params: nil) ⇒ Object
24 25 26 |
# File 'lib/teams/graph/client.rb', line 24 def get(path, params: nil) request { http.get(url(path), params:) } end |
#patch(path, json: nil, params: nil) ⇒ Object
32 33 34 |
# File 'lib/teams/graph/client.rb', line 32 def patch(path, json: nil, params: nil) request { http.patch(url(path), json: stringify(json), params:) } end |
#post(path, json: nil, params: nil) ⇒ Object
28 29 30 |
# File 'lib/teams/graph/client.rb', line 28 def post(path, json: nil, params: nil) request { http.post(url(path), json: stringify(json), params:) } end |
#put(path, json: nil, params: nil) ⇒ Object
36 37 38 |
# File 'lib/teams/graph/client.rb', line 36 def put(path, json: nil, params: nil) request { http.put(url(path), json: stringify(json), params:) } end |