Class: Twilio::REST::Media::V1::PlayerStreamerContext::PlaybackGrantInstance

Inherits:
InstanceResource
  • Object
show all
Defined in:
lib/twilio-ruby/rest/media/v1/player_streamer/playback_grant.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, sid: nil) ⇒ PlaybackGrantInstance

Initialize the PlaybackGrantInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio

  • account_sid (String)

    The SID of the Account that created this PlaybackGrant resource.

  • sid (String) (defaults to: nil)

    The SID of the Call resource to fetch.



152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/twilio-ruby/rest/media/v1/player_streamer/playback_grant.rb', line 152

def initialize(version, payload , sid: nil)
    super(version)
    
    # Marshaled Properties
    @properties = { 
        'sid' => payload['sid'],
        'url' => payload['url'],
        'account_sid' => payload['account_sid'],
        'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
        'grant' => payload['grant'],
    }

    # Context
    @instance_context = nil
    @params = { 'sid' => sid  || @properties['sid']  , }
end

Instance Method Details

#account_sidString

Returns The SID of the [Account](www.twilio.com/docs/iam/api/account) that created this resource.

Returns:



194
195
196
# File 'lib/twilio-ruby/rest/media/v1/player_streamer/playback_grant.rb', line 194

def 
    @properties['account_sid']
end

#contextPlaybackGrantContext

Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context

Returns:



173
174
175
176
177
178
# File 'lib/twilio-ruby/rest/media/v1/player_streamer/playback_grant.rb', line 173

def context
    unless @instance_context
        @instance_context = PlaybackGrantContext.new(@version , @params['sid'])
    end
    @instance_context
end

#create(ttl: :unset, access_control_allow_origin: :unset) ⇒ PlaybackGrantInstance

Create the PlaybackGrantInstance

Parameters:

  • ttl (String) (defaults to: :unset)

    The time to live of the PlaybackGrant. Default value is 15 seconds. Maximum value is 60 seconds.

  • access_control_allow_origin (String) (defaults to: :unset)

    The full origin URL where the livestream can be streamed. If this is not provided, it can be streamed from any domain.

Returns:



215
216
217
218
219
220
221
222
223
224
# File 'lib/twilio-ruby/rest/media/v1/player_streamer/playback_grant.rb', line 215

def create(
    ttl: :unset, 
    access_control_allow_origin: :unset
)

    context.create(
        ttl: ttl, 
        access_control_allow_origin: access_control_allow_origin, 
    )
end

#date_createdTime

Returns The date and time in GMT when the resource was created specified in [ISO 8601](en.wikipedia.org/wiki/ISO_8601) format.

Returns:



200
201
202
# File 'lib/twilio-ruby/rest/media/v1/player_streamer/playback_grant.rb', line 200

def date_created
    @properties['date_created']
end

#fetchPlaybackGrantInstance

Fetch the PlaybackGrantInstance

Returns:



229
230
231
232
# File 'lib/twilio-ruby/rest/media/v1/player_streamer/playback_grant.rb', line 229

def fetch

    context.fetch
end

#grantHash

Returns The grant that authorizes the player sdk to connect to the livestream.

Returns:

  • (Hash)

    The grant that authorizes the player sdk to connect to the livestream



206
207
208
# File 'lib/twilio-ruby/rest/media/v1/player_streamer/playback_grant.rb', line 206

def grant
    @properties['grant']
end

#inspectObject

Provide a detailed, user friendly representation



243
244
245
246
# File 'lib/twilio-ruby/rest/media/v1/player_streamer/playback_grant.rb', line 243

def inspect
    values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
    "<Twilio.Media.V1.PlaybackGrantInstance #{values}>"
end

#sidString

Returns The unique string generated to identify the PlayerStreamer resource that this PlaybackGrant authorizes views for.

Returns:

  • (String)

    The unique string generated to identify the PlayerStreamer resource that this PlaybackGrant authorizes views for.



182
183
184
# File 'lib/twilio-ruby/rest/media/v1/player_streamer/playback_grant.rb', line 182

def sid
    @properties['sid']
end

#to_sObject

Provide a user friendly representation



236
237
238
239
# File 'lib/twilio-ruby/rest/media/v1/player_streamer/playback_grant.rb', line 236

def to_s
    values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
    "<Twilio.Media.V1.PlaybackGrantInstance #{values}>"
end

#urlString

Returns The absolute URL of the resource.

Returns:

  • (String)

    The absolute URL of the resource.



188
189
190
# File 'lib/twilio-ruby/rest/media/v1/player_streamer/playback_grant.rb', line 188

def url
    @properties['url']
end