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.



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

#participantsList of ParticipantSubscription

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

Returns:



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

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)


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

.namesObject

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

#nullablesObject

An array for nullable fields



39
40
41
# File 'lib/bandwidth/web_rtc_lib/web_rtc/models/subscriptions.rb', line 39

def nullables
  []
end

#optionalsObject

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