Class: Teams::FunctionContext
- Inherits:
-
Object
- Object
- Teams::FunctionContext
- Defined in:
- lib/teams/function_context.rb
Overview
Context for a remote function call from a tab (POST /api/functions/name): the validated Entra identity, the Teams client context headers, and the request payload.
Instance Attribute Summary collapse
-
#app ⇒ Object
readonly
Returns the value of attribute app.
-
#app_id ⇒ Object
readonly
Returns the value of attribute app_id.
-
#app_session_id ⇒ Object
readonly
Returns the value of attribute app_session_id.
-
#auth_token ⇒ Object
readonly
Returns the value of attribute auth_token.
-
#channel_id ⇒ Object
readonly
Returns the value of attribute channel_id.
-
#chat_id ⇒ Object
readonly
Returns the value of attribute chat_id.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#function_name ⇒ Object
readonly
Returns the value of attribute function_name.
-
#meeting_id ⇒ Object
readonly
Returns the value of attribute meeting_id.
-
#message_id ⇒ Object
readonly
Returns the value of attribute message_id.
-
#page_id ⇒ Object
readonly
Returns the value of attribute page_id.
-
#sub_page_id ⇒ Object
readonly
Returns the value of attribute sub_page_id.
-
#team_id ⇒ Object
readonly
Returns the value of attribute team_id.
-
#tenant_id ⇒ Object
readonly
Returns the value of attribute tenant_id.
-
#user_id ⇒ Object
readonly
Returns the value of attribute user_id.
-
#user_name ⇒ Object
readonly
Returns the value of attribute user_name.
Instance Method Summary collapse
- #api ⇒ Object
-
#conversation_id ⇒ Object
Resolves the conversation this call relates to, like the TypeScript and Python function contexts: chat/channel id when the user is a member of it; in personal scope, creates (or re-fetches) the 1:1 conversation.
-
#initialize(app:, function_name:, data:, app_session_id:, page_id:, auth_token:, tenant_id:, user_id:, user_name:, app_id: nil, channel_id: nil, chat_id: nil, meeting_id: nil, message_id: nil, sub_page_id: nil, team_id: nil) ⇒ FunctionContext
constructor
A new instance of FunctionContext.
- #log ⇒ Object
-
#post(activity_or_text) ⇒ Object
Posts into the resolved conversation (proactive send with the bot's identity).
Constructor Details
#initialize(app:, function_name:, data:, app_session_id:, page_id:, auth_token:, tenant_id:, user_id:, user_name:, app_id: nil, channel_id: nil, chat_id: nil, meeting_id: nil, message_id: nil, sub_page_id: nil, team_id: nil) ⇒ FunctionContext
Returns a new instance of FunctionContext.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/teams/function_context.rb', line 12 def initialize(app:, function_name:, data:, app_session_id:, page_id:, auth_token:, tenant_id:, user_id:, user_name:, app_id: nil, channel_id: nil, chat_id: nil, meeting_id: nil, message_id: nil, sub_page_id: nil, team_id: nil) @app = app @function_name = function_name @data = data @app_session_id = app_session_id @page_id = page_id @auth_token = auth_token @tenant_id = tenant_id @user_id = user_id @user_name = user_name @app_id = app_id @channel_id = channel_id @chat_id = chat_id @meeting_id = meeting_id @message_id = @sub_page_id = sub_page_id @team_id = team_id @resolved = false end |
Instance Attribute Details
#app ⇒ Object (readonly)
Returns the value of attribute app.
8 9 10 |
# File 'lib/teams/function_context.rb', line 8 def app @app end |
#app_id ⇒ Object (readonly)
Returns the value of attribute app_id.
8 9 10 |
# File 'lib/teams/function_context.rb', line 8 def app_id @app_id end |
#app_session_id ⇒ Object (readonly)
Returns the value of attribute app_session_id.
8 9 10 |
# File 'lib/teams/function_context.rb', line 8 def app_session_id @app_session_id end |
#auth_token ⇒ Object (readonly)
Returns the value of attribute auth_token.
8 9 10 |
# File 'lib/teams/function_context.rb', line 8 def auth_token @auth_token end |
#channel_id ⇒ Object (readonly)
Returns the value of attribute channel_id.
8 9 10 |
# File 'lib/teams/function_context.rb', line 8 def channel_id @channel_id end |
#chat_id ⇒ Object (readonly)
Returns the value of attribute chat_id.
8 9 10 |
# File 'lib/teams/function_context.rb', line 8 def chat_id @chat_id end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
8 9 10 |
# File 'lib/teams/function_context.rb', line 8 def data @data end |
#function_name ⇒ Object (readonly)
Returns the value of attribute function_name.
8 9 10 |
# File 'lib/teams/function_context.rb', line 8 def function_name @function_name end |
#meeting_id ⇒ Object (readonly)
Returns the value of attribute meeting_id.
8 9 10 |
# File 'lib/teams/function_context.rb', line 8 def meeting_id @meeting_id end |
#message_id ⇒ Object (readonly)
Returns the value of attribute message_id.
8 9 10 |
# File 'lib/teams/function_context.rb', line 8 def @message_id end |
#page_id ⇒ Object (readonly)
Returns the value of attribute page_id.
8 9 10 |
# File 'lib/teams/function_context.rb', line 8 def page_id @page_id end |
#sub_page_id ⇒ Object (readonly)
Returns the value of attribute sub_page_id.
8 9 10 |
# File 'lib/teams/function_context.rb', line 8 def sub_page_id @sub_page_id end |
#team_id ⇒ Object (readonly)
Returns the value of attribute team_id.
8 9 10 |
# File 'lib/teams/function_context.rb', line 8 def team_id @team_id end |
#tenant_id ⇒ Object (readonly)
Returns the value of attribute tenant_id.
8 9 10 |
# File 'lib/teams/function_context.rb', line 8 def tenant_id @tenant_id end |
#user_id ⇒ Object (readonly)
Returns the value of attribute user_id.
8 9 10 |
# File 'lib/teams/function_context.rb', line 8 def user_id @user_id end |
#user_name ⇒ Object (readonly)
Returns the value of attribute user_name.
8 9 10 |
# File 'lib/teams/function_context.rb', line 8 def user_name @user_name end |
Instance Method Details
#api ⇒ Object
34 35 36 |
# File 'lib/teams/function_context.rb', line 34 def api app.api end |
#conversation_id ⇒ Object
Resolves the conversation this call relates to, like the TypeScript and Python function contexts: chat/channel id when the user is a member of it; in personal scope, creates (or re-fetches) the 1:1 conversation. Returns nil when no conversation can be resolved.
46 47 48 49 50 51 |
# File 'lib/teams/function_context.rb', line 46 def conversation_id return @conversation_id if @resolved @resolved = true @conversation_id = resolve_conversation_id end |
#log ⇒ Object
38 39 40 |
# File 'lib/teams/function_context.rb', line 38 def log app.logger end |
#post(activity_or_text) ⇒ Object
Posts into the resolved conversation (proactive send with the bot's identity).
55 56 57 58 59 60 |
# File 'lib/teams/function_context.rb', line 55 def post(activity_or_text) id = conversation_id raise Error, "Unable to resolve a conversation for this function call" unless id app.post(id, activity_or_text) end |