Class: LeanMicrosoftGraph::Client
- Inherits:
-
Object
- Object
- LeanMicrosoftGraph::Client
- Defined in:
- lib/lean_microsoft_graph/client.rb
Instance Method Summary collapse
- #connection ⇒ Object private
- #credentials ⇒ Object private
-
#initialize(tenant_id:, client_id:, client_secret:, adapter: Faraday.default_adapter, stubs: nil) ⇒ Client
constructor
A new instance of Client.
- #token_retriever ⇒ Object private
- #users ⇒ Object
Constructor Details
#initialize(tenant_id:, client_id:, client_secret:, adapter: Faraday.default_adapter, stubs: nil) ⇒ Client
Returns a new instance of Client.
7 8 9 10 11 12 13 |
# File 'lib/lean_microsoft_graph/client.rb', line 7 def initialize(tenant_id:, client_id:, client_secret:, adapter: Faraday.default_adapter, stubs: nil) @tenant_id = tenant_id @client_id = client_id @client_secret = client_secret @adapter = adapter @stubs = stubs # Stubs for testing purpouses end |
Instance Method Details
#connection ⇒ Object (private)
21 22 23 24 25 26 27 28 |
# File 'lib/lean_microsoft_graph/client.rb', line 21 def connection @connection ||= Faraday.new(url: 'https://graph.microsoft.com/v1.0') do |faraday| faraday.request :authorization, 'Bearer', proc(&token_retriever) faraday.request :url_encoded faraday.request :retry, retry_statuses: [429] faraday.adapter @adapter, @stubs end end |
#credentials ⇒ Object (private)
37 38 39 |
# File 'lib/lean_microsoft_graph/client.rb', line 37 def credentials Authentication::Credentials.new(@tenant_id, @client_id, @client_secret) end |
#token_retriever ⇒ Object (private)
30 31 32 33 34 35 |
# File 'lib/lean_microsoft_graph/client.rb', line 30 def token_retriever @token_retriever ||= begin token_resource = Resources::TokenResource.new(credentials, @adapter, @stubs) Authentication::TokenRetriever.new(token_resource) end end |
#users ⇒ Object
15 16 17 |
# File 'lib/lean_microsoft_graph/client.rb', line 15 def users Resources::UsersResource.new(connection) end |