Module: Legion::Extensions::MicrosoftTeams::Helpers::Client
- Includes:
- Helpers::Lex
- Included in:
- Actor::ChannelPoller, Actor::DirectChatPoller, Actor::MeetingIngest, Actor::ObservedChatPoller, Actor::PresencePoller, Client, Runners::Activities, Runners::AiInsights, Runners::ApiIngest, Runners::AppInstallations, Runners::Auth, Runners::Bot, Runners::CallEvents, Runners::ChannelMessages, Runners::Channels, Runners::Chats, Runners::Files, Runners::Loop, Runners::MeetingArtifacts, Runners::Meetings, Runners::Messages, Runners::Ownership, Runners::People, Runners::Presence, Runners::ProfileIngest, Runners::Subscriptions, Runners::Teams, Runners::Transcripts
- Defined in:
- lib/legion/extensions/microsoft_teams/helpers/client.rb
Instance Method Summary collapse
- #bot_connection(token: nil, service_url: 'https://smba.trafficmanager.net/teams/', **_opts) ⇒ Object
- #graph_connection(token: nil, api_url: 'https://graph.microsoft.com/v1.0', **_opts) ⇒ Object
- #oauth_connection(tenant_id: 'common', **_opts) ⇒ Object
- #user_path(user_id = 'me') ⇒ Object
Instance Method Details
#bot_connection(token: nil, service_url: 'https://smba.trafficmanager.net/teams/', **_opts) ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/legion/extensions/microsoft_teams/helpers/client.rb', line 27 def bot_connection(token: nil, service_url: 'https://smba.trafficmanager.net/teams/', **_opts) ::Faraday.new(url: service_url) do |conn| conn.request :json conn.use Legion::Extensions::MicrosoftTeams::Faraday::ThrottleCircuit, ** conn.use Legion::Extensions::MicrosoftTeams::Faraday::RetryAfter, ** conn.response :json, content_type: /\bjson$/ conn.headers['Authorization'] = "Bearer #{token}" if token conn.headers['Content-Type'] = 'application/json' end end |
#graph_connection(token: nil, api_url: 'https://graph.microsoft.com/v1.0', **_opts) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/legion/extensions/microsoft_teams/helpers/client.rb', line 15 def graph_connection(token: nil, api_url: 'https://graph.microsoft.com/v1.0', **_opts) token ||= entra_delegated_token ::Faraday.new(url: api_url) do |conn| conn.request :json conn.use Legion::Extensions::MicrosoftTeams::Faraday::ThrottleCircuit, ** conn.use Legion::Extensions::MicrosoftTeams::Faraday::RetryAfter, ** conn.response :json, content_type: /\bjson$/ conn.headers['Authorization'] = "Bearer #{token}" if token conn.headers['Content-Type'] = 'application/json' end end |
#oauth_connection(tenant_id: 'common', **_opts) ⇒ Object
42 43 44 45 46 47 |
# File 'lib/legion/extensions/microsoft_teams/helpers/client.rb', line 42 def oauth_connection(tenant_id: 'common', **_opts) ::Faraday.new(url: "https://login.microsoftonline.com/#{tenant_id}") do |conn| conn.request :url_encoded conn.response :json, content_type: /\bjson$/ end end |
#user_path(user_id = 'me') ⇒ Object
38 39 40 |
# File 'lib/legion/extensions/microsoft_teams/helpers/client.rb', line 38 def user_path(user_id = 'me') user_id == 'me' ? 'me' : "users/#{user_id}" end |