Skip to content

Commit

Permalink
[WIP] Update API namespace from Chime to ChimeSDKMeetings
Browse files Browse the repository at this point in the history
  • Loading branch information
simukappu committed Feb 26, 2024
1 parent 856bca2 commit 954b826
Show file tree
Hide file tree
Showing 14 changed files with 175 additions and 179 deletions.
2 changes: 1 addition & 1 deletion amazon-chime-sdk-rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Gem::Specification.new do |s|
s.required_ruby_version = '>= 2.2.2'

s.add_dependency 'railties', '>= 5.0.0'
s.add_dependency 'aws-sdk-chime', '>= 1.0.0'
s.add_dependency 'aws-sdk-chimesdkmeetings', '>= 1.0.0'

s.add_development_dependency 'rspec-rails', '>= 4.0.1'
s.add_development_dependency 'factory_bot_rails', '>= 6.1.0'
Expand Down
5 changes: 2 additions & 3 deletions lib/amazon-chime-sdk-rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ def self.config
# config.appication_name = 'chime-sdk-rails'
# config.media_region = 'us-east-1'
# config.prefix = "#{config.application_name}-#{Rails.env}-"
# config.max_meeting_results = 10
# config.max_attendee_results = 10
# config.create_meeting_with_attendee = true
# config.create_attendee_from_meeting = true
Expand All @@ -27,8 +26,8 @@ def self.configure
yield(config) if block_given?
end

# Load AWS SDK for Amazon Chime
require 'aws-sdk-chime'
# Load AWS SDK for Amazon Chime SDK meetings
require 'aws-sdk-chimesdkmeetings'

# Load ChimeSdk helpers
require 'chime_sdk/controller/common'
Expand Down
10 changes: 0 additions & 10 deletions lib/chime_sdk/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,6 @@ class Config
# @return [Boolean] Prefix to make unique key of Chime SDK meetings and attendees
attr_accessor :prefix

# @overload max_meeting_results
# Return default max_results value used in list_meetings API.
# @return [Boolean] Default max_results value used in list_meetings API
# @overload max_meeting_results=(value)
# Set default max_results value used in list_meetings API.
# @param [Boolean] max_meeting_results The new max_meeting_results
# @return [Boolean] Default max_results value used in list_meetings API
attr_accessor :max_meeting_results

# @overload max_attendee_results
# Return default max_results value used in list_attendees API.
# @return [Boolean] Default max_results value used in list_attendees API
Expand Down Expand Up @@ -80,7 +71,6 @@ def initialize
@application_name = 'chime-sdk-rails'
@media_region = 'us-east-1'
@prefix = "#{@application_name}-#{Rails.env}-"
@max_meeting_results = 10
@max_attendee_results = 10
@create_meeting_with_attendee = true
@create_attendee_from_meeting = true
Expand Down
23 changes: 4 additions & 19 deletions lib/chime_sdk/controller/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ module Common
extend ActiveSupport::Concern

included do
rescue_from Aws::Chime::Errors::ForbiddenException, with: :render_forbidden
rescue_from Aws::Chime::Errors::NotFoundException, with: :render_resource_not_found
rescue_from Aws::Chime::Errors::ValidationException, with: :render_resource_not_found
rescue_from Aws::ChimeSDKMeetings::Errors::ForbiddenException, with: :render_forbidden
rescue_from Aws::ChimeSDKMeetings::Errors::NotFoundException, with: :render_resource_not_found
rescue_from Aws::ChimeSDKMeetings::Errors::ValidationException, with: :render_resource_not_found

class ::String
# Convets to boolean.
Expand Down Expand Up @@ -39,14 +39,6 @@ def attendee_id
@attendee ? @attendee[:Attendee][:AttendeeId] : attendee_id_param
end

# List meetings by MeetingCoordinator.
# @api protected
# @return [Array<Hash>] Meeting list
def list_meetings
@meetings = ChimeSdk::MeetingCoordinator.list_meetings(prefix_filter: meeting_request_id)
@meetings = @meetings.map { |meeting| merge_application_meeting_metadata(meeting) }
end

# Create meeting by MeetingCoordinator.
# @api protected
# @return [Hash] Created meeting
Expand Down Expand Up @@ -82,7 +74,7 @@ def list_attendees
# @api protected
# @return [Hash] Created attendee
def create_attendee
@attendee = ChimeSdk::MeetingCoordinator.create_attendee(meeting_id, attendee_request_id, tags: attendee_tags)
@attendee = ChimeSdk::MeetingCoordinator.create_attendee(meeting_id, attendee_request_id)
@attendee = merge_application_attendee_metadata(@attendee)
end

Expand Down Expand Up @@ -144,13 +136,6 @@ def meeting_tags
tags + optional_meeting_tags
end

# Return tags for attendees from defined optional_attendee_tags.
# @api protected
# @return [Array<Hash>] Tags for attendees
def attendee_tags
tags + optional_attendee_tags
end

# Merge application metadata into meeting instance and return.
# @api protected
# @param [Hash] meeting Meeting JSON object as hash
Expand Down
5 changes: 3 additions & 2 deletions lib/chime_sdk/controller/meetings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ def index
if params[:create_meeting].to_s.to_boolean(false) || ChimeSdk.config.create_meeting_by_get_request && params[:create_meeting].to_s.to_boolean(true)
create
else
list_meetings
@meeting_request_id = ChimeSdk.config.prefix + meeting_request_id
@attendee_request_id = ChimeSdk.config.prefix + attendee_request_id
respond_to do |format|
format.html
format.json { render json: { meetings: @meetings } }
format.json { render json: { meeting_request_id: @meeting_request_id, attendee_request_id: @attendee_request_id } }
end
end
end
Expand Down
Loading

0 comments on commit 954b826

Please sign in to comment.