module ChimeSdk::Controller::Common
Common
implementation for controllers.
Protected Instance Methods
Return attendee id from @attendee object or attendee id param. @api protected @return [String] Attendee id
# File lib/chime_sdk/controller/common.rb, line 38 def attendee_id @attendee ? @attendee[:Attendee][:AttendeeId] : attendee_id_param end
Create attendee by MeetingCoordinator
. @api protected @return [Hash] Created attendee
# File lib/chime_sdk/controller/common.rb, line 84 def create_attendee @attendee = ChimeSdk::MeetingCoordinator.create_attendee(meeting_id, attendee_request_id, tags: attendee_tags) @attendee = merge_application_attendee_metadata(@attendee) end
Create attendee from meeting by MeetingCoordinator
. @api protected @return [Hash] Created attendee
# File lib/chime_sdk/controller/common.rb, line 116 def create_attendee_from_meeting create_attendee @meeting = @meeting.merge(@attendee) @meeting = merge_application_attendee_metadata(@meeting) @meeting = merge_application_attendee_metadata(@meeting) @attendee = merge_application_attendee_metadata(@attendee) end
Create meeting by MeetingCoordinator
. @api protected @return [Hash] Created meeting
# File lib/chime_sdk/controller/common.rb, line 53 def create_meeting @meeting = ChimeSdk::MeetingCoordinator.create_meeting(meeting_request_id, tags: meeting_tags) @meeting = merge_application_meeting_metadata(@meeting) end
Create meeting with attendee by MeetingCoordinator
. @api protected @return [Hash] Created meeting
# File lib/chime_sdk/controller/common.rb, line 107 def create_meeting_with_attendee create_meeting create_attendee_from_meeting @meeting end
Delete attendee by MeetingCoordinator
. @api protected @return [void]
# File lib/chime_sdk/controller/common.rb, line 100 def delete_attendee ChimeSdk::MeetingCoordinator.delete_attendee(meeting_id, attendee_id) end
Delete meeting by MeetingCoordinator
. @api protected @return [void]
# File lib/chime_sdk/controller/common.rb, line 69 def delete_meeting ChimeSdk::MeetingCoordinator.delete_meeting(meeting_id) end
Returns error response as Hash @api protected @return [Hash] Error message
# File lib/chime_sdk/controller/common.rb, line 175 def error_response(error_info = {}) { gem: "chime-sdk-rails", error: error_info } end
Get attendee by MeetingCoordinator
. @api protected @return [Hash] Attendee
# File lib/chime_sdk/controller/common.rb, line 92 def get_attendee @attendee = ChimeSdk::MeetingCoordinator.get_attendee(meeting_id, attendee_id) @attendee = merge_application_attendee_metadata(@attendee) end
Get meeting by MeetingCoordinator
. @api protected @return [Hash] Meeting
# File lib/chime_sdk/controller/common.rb, line 61 def get_meeting @meeting = ChimeSdk::MeetingCoordinator.get_meeting(meeting_id) @meeting = merge_application_meeting_metadata(@meeting) end
List attendees by MeetingCoordinator
. @api protected @return [Array<Hash>] Attendee list
# File lib/chime_sdk/controller/common.rb, line 76 def list_attendees @attendees = ChimeSdk::MeetingCoordinator.list_attendees(meeting_id) @attendees = @attendees.map { |attendee| merge_application_attendee_metadata(attendee) } end
List meetings by MeetingCoordinator
. @api protected @return [Array<Hash>] Meeting list
# File lib/chime_sdk/controller/common.rb, line 45 def list_meetings @meetings = ChimeSdk::MeetingCoordinator.list_meetings(prefix_filter: meeting_request_id) @meetings = @meetings.map { |meeting| merge_application_meeting_metadata(meeting) } end
Return meeting id from @meeting object or meeting id param. @api protected @return [String] Meeting id
# File lib/chime_sdk/controller/common.rb, line 31 def meeting_id @meeting ? @meeting[:Meeting][:MeetingId] : meeting_id_param end
Merge application metadata into attendee instance and return. @api protected @param [Hash] attendee Attendee JSON object as hash @return [Hash] Merged attendee
# File lib/chime_sdk/controller/common.rb, line 167 def merge_application_attendee_metadata(attendee) attendee[:Attendee][:ApplicationMetadata] = application_attendee_metadata(attendee) attendee end
Merge application metadata into meeting instance and return. @api protected @param [Hash] meeting Meeting JSON object as hash @return [Hash] Merged meeting
# File lib/chime_sdk/controller/common.rb, line 158 def merge_application_meeting_metadata(meeting) meeting[:Meeting][:ApplicationMetadata] = application_meeting_metadata(meeting) meeting end
Render Forbidden error with 403 status @api protected @return [void]
# File lib/chime_sdk/controller/common.rb, line 182 def render_forbidden(error = nil) message_type = error.respond_to?(:message) ? error.message : error respond_to do |format| format.html { redirect_to meeting_resources_path, notice: "Forbidden: #{message_type}" } format.json { render status: 403, json: error_response(code: 403, message: "Forbidden", type: message_type) } end end
Render Resource Not Found error with 404 status @api protected @return [void]
# File lib/chime_sdk/controller/common.rb, line 193 def render_resource_not_found(error = nil) message_type = error.respond_to?(:message) ? error.message : error respond_to do |format| format.html { redirect_to meeting_resources_path, notice: "Resource not found: #{message_type}" } format.json { render status: 404, json: error_response(code: 404, message: "Resource not found", type: message_type) } end end