Module: Legion::Extensions::MicrosoftTeams::Helpers::Client

Instance Method Summary collapse

Instance Method Details

#bot_connection(token: nil, service_url: 'https://smba.trafficmanager.net/teams/', **_opts) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/legion/extensions/microsoft_teams/helpers/client.rb', line 19

def bot_connection(token: nil, service_url: 'https://smba.trafficmanager.net/teams/', **_opts)
  Faraday.new(url: service_url) do |conn|
    conn.request :json
    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



10
11
12
13
14
15
16
17
# File 'lib/legion/extensions/microsoft_teams/helpers/client.rb', line 10

def graph_connection(token: nil, api_url: 'https://graph.microsoft.com/v1.0', **_opts)
  Faraday.new(url: api_url) do |conn|
    conn.request :json
    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



32
33
34
35
36
37
# File 'lib/legion/extensions/microsoft_teams/helpers/client.rb', line 32

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



28
29
30
# File 'lib/legion/extensions/microsoft_teams/helpers/client.rb', line 28

def user_path(user_id = 'me')
  user_id == 'me' ? 'me' : "users/#{user_id}"
end