Module: Legion::Extensions::MicrosoftTeams::Runners::Subscriptions
- Extended by:
- Definitions
- Includes:
- Helpers::Lex, Helpers::Client
- Included in:
- Client
- Defined in:
- lib/legion/extensions/microsoft_teams/runners/subscriptions.rb
Class Method Summary
collapse
Instance Method Summary
collapse
-
#create_subscription(resource:, change_type:, notification_url:, expiration:, client_state: nil, include_resource_data: false) ⇒ Object
-
#delete_subscription(subscription_id:) ⇒ Object
-
#get_subscription(subscription_id:) ⇒ Object
-
#list_subscriptions ⇒ Object
-
#renew_subscription(subscription_id:, expiration:) ⇒ Object
-
#subscribe_to_channel_messages(team_id:, channel_id:, notification_url:, expiration:, client_state: nil) ⇒ Object
-
#subscribe_to_chat_messages(chat_id:, notification_url:, expiration:, client_state: nil) ⇒ Object
#bot_connection, #graph_connection, #oauth_connection, #user_path
Class Method Details
.trigger_words ⇒ Object
13
14
15
|
# File 'lib/legion/extensions/microsoft_teams/runners/subscriptions.rb', line 13
def self.trigger_words
%w[subscription subscriptions webhook webhooks subscribe watch]
end
|
Instance Method Details
#create_subscription(resource:, change_type:, notification_url:, expiration:, client_state: nil, include_resource_data: false) ⇒ Object
62
63
64
65
66
67
68
69
70
71
72
73
74
|
# File 'lib/legion/extensions/microsoft_teams/runners/subscriptions.rb', line 62
def create_subscription(resource:, change_type:, notification_url:, expiration:,
client_state: nil, include_resource_data: false, **)
payload = {
changeType: change_type,
notificationUrl: notification_url,
resource: resource,
expirationDateTime: expiration,
includeResourceData: include_resource_data
}
payload[:clientState] = client_state if client_state
response = graph_connection(**).post('subscriptions', payload)
{ result: response.body }
end
|
#delete_subscription(subscription_id:) ⇒ Object
104
105
106
107
|
# File 'lib/legion/extensions/microsoft_teams/runners/subscriptions.rb', line 104
def delete_subscription(subscription_id:, **)
response = graph_connection(**).delete("subscriptions/#{subscription_id}")
{ result: response.body }
end
|
#get_subscription(subscription_id:) ⇒ Object
40
41
42
43
|
# File 'lib/legion/extensions/microsoft_teams/runners/subscriptions.rb', line 40
def get_subscription(subscription_id:, **)
response = graph_connection(**).get("subscriptions/#{subscription_id}")
{ result: response.body }
end
|
#list_subscriptions ⇒ Object
25
26
27
28
|
# File 'lib/legion/extensions/microsoft_teams/runners/subscriptions.rb', line 25
def list_subscriptions(**)
response = graph_connection(**).get('subscriptions')
{ result: response.body }
end
|
#renew_subscription(subscription_id:, expiration:) ⇒ Object
88
89
90
91
92
|
# File 'lib/legion/extensions/microsoft_teams/runners/subscriptions.rb', line 88
def renew_subscription(subscription_id:, expiration:, **)
payload = { expirationDateTime: expiration }
response = graph_connection(**).patch("subscriptions/#{subscription_id}", payload)
{ result: response.body }
end
|
#subscribe_to_channel_messages(team_id:, channel_id:, notification_url:, expiration:, client_state: nil) ⇒ Object
145
146
147
148
149
150
151
152
153
154
155
|
# File 'lib/legion/extensions/microsoft_teams/runners/subscriptions.rb', line 145
def subscribe_to_channel_messages(team_id:, channel_id:, notification_url:, expiration:,
client_state: nil, **)
create_subscription(
resource: "/teams/#{team_id}/channels/#{channel_id}/messages",
change_type: 'created,updated',
notification_url: notification_url,
expiration: expiration,
client_state: client_state,
**
)
end
|
#subscribe_to_chat_messages(chat_id:, notification_url:, expiration:, client_state: nil) ⇒ Object
121
122
123
124
125
126
127
128
129
130
|
# File 'lib/legion/extensions/microsoft_teams/runners/subscriptions.rb', line 121
def subscribe_to_chat_messages(chat_id:, notification_url:, expiration:, client_state: nil, **)
create_subscription(
resource: "/chats/#{chat_id}/messages",
change_type: 'created,updated',
notification_url: notification_url,
expiration: expiration,
client_state: client_state,
**
)
end
|