Class: Bandwidth::Subscriptions

Inherits:
BaseModel show all
Defined in:
lib/bandwidth/web_rtc_lib/web_rtc/models/subscriptions.rb

Overview

Subscriptions Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(session_id = nil, participants = nil) ⇒ Subscriptions

Returns a new instance of Subscriptions.



28
29
30
31
32
# File 'lib/bandwidth/web_rtc_lib/web_rtc/models/subscriptions.rb', line 28

def initialize(session_id = nil,
               participants = nil)
  @session_id = session_id
  @participants = participants
end

Instance Attribute Details

#participantsList of ParticipantSubscription

Subset of participants to subscribe to in the session. Optional.

Returns:



18
19
20
# File 'lib/bandwidth/web_rtc_lib/web_rtc/models/subscriptions.rb', line 18

def participants
  @participants
end

#session_idString

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)

Returns:

  • (String)


14
15
16
# File 'lib/bandwidth/web_rtc_lib/web_rtc/models/subscriptions.rb', line 14

def session_id
  @session_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/bandwidth/web_rtc_lib/web_rtc/models/subscriptions.rb', line 35

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  session_id = hash['sessionId']
  # 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

  # Create object from extracted values.
  Subscriptions.new(session_id,
                    participants)
end

.namesObject

A mapping from model property names to API property names.



21
22
23
24
25
26
# File 'lib/bandwidth/web_rtc_lib/web_rtc/models/subscriptions.rb', line 21

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['session_id'] = 'sessionId'
  @_hash['participants'] = 'participants'
  @_hash
end