Class: Bandwidth::Subscriptions
- Defined in:
- lib/bandwidth/web_rtc_lib/web_rtc/models/subscriptions.rb
Overview
Subscriptions Model.
Instance Attribute Summary collapse
-
#participants ⇒ List of ParticipantSubscription
Subset of participants to subscribe to in the session.
-
#session_id ⇒ String
Session the subscriptions are associated with If this is the only field, the subscriber will be subscribed to all participants in the session (including any participants that are later added to the session).
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
Instance Method Summary collapse
-
#initialize(session_id = nil, participants = nil) ⇒ Subscriptions
constructor
A new instance of Subscriptions.
-
#nullables ⇒ Object
An array for nullable fields.
-
#optionals ⇒ Object
An array for optional fields.
Methods inherited from BaseModel
Constructor Details
#initialize(session_id = nil, participants = nil) ⇒ Subscriptions
Returns a new instance of Subscriptions.
43 44 45 46 47 |
# File 'lib/bandwidth/web_rtc_lib/web_rtc/models/subscriptions.rb', line 43 def initialize(session_id = nil, participants = nil) @session_id = session_id unless session_id == SKIP @participants = participants unless participants == SKIP end |
Instance Attribute Details
#participants ⇒ List of ParticipantSubscription
Subset of participants to subscribe to in the session. Optional.
21 22 23 |
# File 'lib/bandwidth/web_rtc_lib/web_rtc/models/subscriptions.rb', line 21 def participants @participants end |
#session_id ⇒ String
Session the subscriptions are associated with If this is the only field, the subscriber will be subscribed to all participants in the session (including any participants that are later added to the session)
17 18 19 |
# File 'lib/bandwidth/web_rtc_lib/web_rtc/models/subscriptions.rb', line 17 def session_id @session_id end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/bandwidth/web_rtc_lib/web_rtc/models/subscriptions.rb', line 50 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. session_id = hash.key?('sessionId') ? hash['sessionId'] : SKIP # Parameter is an array, so we need to iterate through it participants = nil unless hash['participants'].nil? participants = [] hash['participants'].each do |structure| participants << (ParticipantSubscription.from_hash(structure) if structure) end end participants = SKIP unless hash.key?('participants') # Create object from extracted values. Subscriptions.new(session_id, participants) end |
.names ⇒ Object
A mapping from model property names to API property names.
24 25 26 27 28 29 |
# File 'lib/bandwidth/web_rtc_lib/web_rtc/models/subscriptions.rb', line 24 def self.names @_hash = {} if @_hash.nil? @_hash['session_id'] = 'sessionId' @_hash['participants'] = 'participants' @_hash end |
Instance Method Details
#nullables ⇒ Object
An array for nullable fields
39 40 41 |
# File 'lib/bandwidth/web_rtc_lib/web_rtc/models/subscriptions.rb', line 39 def nullables [] end |
#optionals ⇒ Object
An array for optional fields
32 33 34 35 36 |
# File 'lib/bandwidth/web_rtc_lib/web_rtc/models/subscriptions.rb', line 32 def optionals %w[ participants ] end |