Class: LiveKit::ClaimGrant
- Inherits:
-
Object
- Object
- LiveKit::ClaimGrant
- Defined in:
- lib/livekit/grants.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
-
#identity ⇒ Object
Returns the value of attribute identity.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#name ⇒ Object
Returns the value of attribute name.
-
#room_config ⇒ Object
Returns the value of attribute room_config.
-
#room_preset ⇒ Object
Returns the value of attribute room_preset.
-
#sha256 ⇒ Object
Returns the value of attribute sha256.
-
#sip ⇒ Object
Returns the value of attribute sip.
-
#video ⇒ Object
Returns the value of attribute video.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ ClaimGrant
constructor
A new instance of ClaimGrant.
- #to_hash ⇒ Object
Constructor Details
#initialize ⇒ ClaimGrant
Returns a new instance of ClaimGrant.
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/livekit/grants.rb', line 26 def initialize @identity = nil @name = nil @metadata = nil @sha256 = nil @video = nil @sip = nil @attributes = nil @room_preset = nil @room_config = nil end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
5 6 7 |
# File 'lib/livekit/grants.rb', line 5 def attributes @attributes end |
#identity ⇒ Object
Returns the value of attribute identity.
5 6 7 |
# File 'lib/livekit/grants.rb', line 5 def identity @identity end |
#metadata ⇒ Object
Returns the value of attribute metadata.
5 6 7 |
# File 'lib/livekit/grants.rb', line 5 def @metadata end |
#name ⇒ Object
Returns the value of attribute name.
5 6 7 |
# File 'lib/livekit/grants.rb', line 5 def name @name end |
#room_config ⇒ Object
Returns the value of attribute room_config.
5 6 7 |
# File 'lib/livekit/grants.rb', line 5 def room_config @room_config end |
#room_preset ⇒ Object
Returns the value of attribute room_preset.
5 6 7 |
# File 'lib/livekit/grants.rb', line 5 def room_preset @room_preset end |
#sha256 ⇒ Object
Returns the value of attribute sha256.
5 6 7 |
# File 'lib/livekit/grants.rb', line 5 def sha256 @sha256 end |
#sip ⇒ Object
Returns the value of attribute sip.
5 6 7 |
# File 'lib/livekit/grants.rb', line 5 def sip @sip end |
#video ⇒ Object
Returns the value of attribute video.
5 6 7 |
# File 'lib/livekit/grants.rb', line 5 def video @video end |
Class Method Details
.from_hash(hash) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/livekit/grants.rb', line 7 def self.from_hash(hash) return nil if hash.nil? claim_grant = ClaimGrant.new claim_grant.identity = hash["sub"] claim_grant.name = hash["name"] claim_grant. = hash["metadata"] claim_grant.attributes = hash["attributes"] claim_grant.sha256 = hash["sha256"] claim_grant.video = VideoGrant.from_hash(hash["video"]) claim_grant.sip = SIPGrant.from_hash(hash["sip"]) claim_grant.room_preset = hash["roomPreset"] if hash["roomConfig"] # re-hydrate from JSON to ensure it can parse camelCase fields correctly claim_grant.room_config = Proto::RoomConfiguration.decode_json(hash["roomConfig"].to_json) end return claim_grant end |
Instance Method Details
#to_hash ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/livekit/grants.rb', line 38 def to_hash val = { name: @name, metadata: @metadata, attributes: @attributes, sha256: @sha256, } if @video val[:video] = @video.to_hash end if @sip val[:sip] = @sip.to_hash end if @room_preset val[:roomPreset] = @room_preset end if @room_config val[:roomConfig] = JSON.parse(@room_config.to_json) end return val end |