Class: Teams::Api::MeetingClient
- Inherits:
-
Object
- Object
- Teams::Api::MeetingClient
- Defined in:
- lib/teams/api/meeting_client.rb
Instance Attribute Summary collapse
-
#http ⇒ Object
readonly
Returns the value of attribute http.
-
#service_url ⇒ Object
readonly
Returns the value of attribute service_url.
Instance Method Summary collapse
- #get_by_id(meeting_id, service_url: nil) ⇒ Object
-
#get_participant(meeting_id, participant_id, tenant_id, service_url: nil) ⇒ Object
participant_id is the user's AAD object id; tenant_id is required by the service.
-
#initialize(service_url:, http:, logger: nil) ⇒ MeetingClient
constructor
A new instance of MeetingClient.
-
#send_notification(meeting_id, params, service_url: nil) ⇒ Object
Sends a targeted in-meeting notification.
Constructor Details
#initialize(service_url:, http:, logger: nil) ⇒ MeetingClient
Returns a new instance of MeetingClient.
10 11 12 13 14 |
# File 'lib/teams/api/meeting_client.rb', line 10 def initialize(service_url:, http:, logger: nil) @service_url = service_url.sub(%r{/+\z}, "") @http = http @logger = logger end |
Instance Attribute Details
#http ⇒ Object (readonly)
Returns the value of attribute http.
8 9 10 |
# File 'lib/teams/api/meeting_client.rb', line 8 def http @http end |
#service_url ⇒ Object (readonly)
Returns the value of attribute service_url.
8 9 10 |
# File 'lib/teams/api/meeting_client.rb', line 8 def service_url @service_url end |
Instance Method Details
#get_by_id(meeting_id, service_url: nil) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/teams/api/meeting_client.rb', line 16 def get_by_id(meeting_id, service_url: nil) path = "/v1/meetings/#{escape(meeting_id)}" url = absolute(path, service_url:) @logger&.debug("Teams API GET #{url}") MeetingInfo.new(http.get(url)) end |
#get_participant(meeting_id, participant_id, tenant_id, service_url: nil) ⇒ Object
participant_id is the user's AAD object id; tenant_id is required by the service.
25 26 27 28 29 30 |
# File 'lib/teams/api/meeting_client.rb', line 25 def get_participant(meeting_id, participant_id, tenant_id, service_url: nil) path = "/v1/meetings/#{escape(meeting_id)}/participants/#{escape(participant_id)}" url = absolute(path, service_url:) @logger&.debug("Teams API GET #{url}") MeetingParticipant.new(http.get(url, params: { "tenantId" => tenant_id })) end |
#send_notification(meeting_id, params, service_url: nil) ⇒ Object
Sends a targeted in-meeting notification. Returns nil when every recipient succeeded (202); returns a MeetingNotificationResponse with per-recipient failures on partial success (207).
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/teams/api/meeting_client.rb', line 35 def send_notification(meeting_id, params, service_url: nil) body = Common::Hashes.deep_stringify_keys(params.respond_to?(:to_h) ? params.to_h : params) body["type"] ||= "targetedMeetingNotification" path = "/v1/meetings/#{escape(meeting_id)}/notification" url = absolute(path, service_url:) @logger&.debug("Teams API POST #{url}") response = http.post(url, json: body) response ? MeetingNotificationResponse.new(response) : nil end |