Class: Twilio::REST::Video::V1::CompositionHookContext

Inherits:
InstanceContext show all
Defined in:
lib/twilio-ruby/rest/video/v1/composition_hook.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, sid) ⇒ CompositionHookContext

Initialize the CompositionHookContext

Parameters:

  • version (Version)

    Version that contains the resource

  • sid (String)

    The SID of the CompositionHook resource to update.



301
302
303
304
305
306
307
308
309
310
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 301

def initialize(version, sid)
    super(version)
    

    # Path Solution
    @solution = { sid: sid,  }
    @uri = "/CompositionHooks/#{@solution[:sid]}"

    
end

Instance Method Details

#deleteBoolean

Delete the CompositionHookInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



314
315
316
317
318
319
320
321
322
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 314

def delete

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    

    @version.delete('DELETE', @uri, headers: headers)
end

#delete_with_metadataBoolean

Delete the CompositionHookInstanceMetadata

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 327

def 

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
      response = @version.('DELETE', @uri, headers: headers)
      compositionHook_instance = CompositionHookInstance.new(
          @version,
          response.body,
          account_sid: @solution[:account_sid],
          sid: @solution[:sid],
      )
      .new(@version, compositionHook_instance, response.headers, response.status_code)
end

#fetchCompositionHookInstance

Fetch the CompositionHookInstance

Returns:



346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 346

def fetch

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.fetch('GET', @uri, headers: headers)
    CompositionHookInstance.new(
        @version,
        payload,
        sid: @solution[:sid],
    )
end

#fetch_with_metadataCompositionHookInstance

Fetch the CompositionHookInstanceMetadata

Returns:



365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 365

def 

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('GET', @uri, headers: headers)
    composition_hook_instance = CompositionHookInstance.new(
        @version,
        response.body,
        sid: @solution[:sid],
    )
    .new(
        @version,
        composition_hook_instance,
        response.headers,
        response.status_code
    )
end

#inspectObject

Provide a detailed, user friendly representation



509
510
511
512
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 509

def inspect
    context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
    "#<Twilio.Video.V1.CompositionHookContext #{context}>"
end

#to_sObject

Provide a user friendly representation



502
503
504
505
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 502

def to_s
    context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
    "#<Twilio.Video.V1.CompositionHookContext #{context}>"
end

#update(friendly_name: nil, enabled: :unset, video_layout: :unset, audio_sources: :unset, audio_sources_excluded: :unset, trim: :unset, format: :unset, resolution: :unset, status_callback: :unset, status_callback_method: :unset) ⇒ CompositionHookInstance

Update the CompositionHookInstance

Parameters:

  • friendly_name (String) (defaults to: nil)

    A descriptive string that you create to describe the resource. It can be up to 100 characters long and it must be unique within the account.

  • enabled (Boolean) (defaults to: :unset)

    Whether the composition hook is active. When true, the composition hook will be triggered for every completed Group Room in the account. When false, the composition hook never triggers.

  • video_layout (Object) (defaults to: :unset)

    A JSON object that describes the video layout of the composition hook in terms of regions. See [Specifying Video Layouts](www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) for more info.

  • audio_sources (Array[String]) (defaults to: :unset)

    An array of track names from the same group room to merge into the compositions created by the composition hook. Can include zero or more track names. A composition triggered by the composition hook includes all audio sources specified in audio_sources except those specified in audio_sources_excluded. The track names in this parameter can include an asterisk as a wild card character, which matches zero or more characters in a track name. For example, student* includes tracks named student as well as studentTeam.

  • audio_sources_excluded (Array[String]) (defaults to: :unset)

    An array of track names to exclude. A composition triggered by the composition hook includes all audio sources specified in audio_sources except for those specified in audio_sources_excluded. The track names in this parameter can include an asterisk as a wild card character, which matches zero or more characters in a track name. For example, student* excludes student as well as studentTeam. This parameter can also be empty.

  • trim (Boolean) (defaults to: :unset)

    Whether to clip the intervals where there is no active media in the compositions triggered by the composition hook. The default is true. Compositions with trim enabled are shorter when the Room is created and no Participant joins for a while as well as if all the Participants leave the room and join later, because those gaps will be removed. See [Specifying Video Layouts](www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) for more info.

  • format (Format) (defaults to: :unset)
  • resolution (String) (defaults to: :unset)

    A string that describes the columns (width) and rows (height) of the generated composed video in pixels. Defaults to 640x480. The string’s format is ‘widthxheight` where: * 16 <= `width` <= 1280 * 16 <= `height` <= 1280 * `width` * `height` <= 921,600 Typical values are: * HD = 1280x720 * PAL = 1024x576 * VGA = 640x480 * CIF = 320x240 Note that the resolution imposes an aspect ratio to the resulting composition. When the original video tracks are constrained by the aspect ratio, they are scaled to fit. See [Specifying Video Layouts](www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) for more info.

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

    The URL we should call using the status_callback_method to send status information to your application on every composition event. If not provided, status callback events will not be dispatched.

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

    The HTTP method we should use to call status_callback. Can be: POST or GET and the default is POST.

Returns:



400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 400

def update(
    friendly_name: nil, 
    enabled: :unset, 
    video_layout: :unset, 
    audio_sources: :unset, 
    audio_sources_excluded: :unset, 
    trim: :unset, 
    format: :unset, 
    resolution: :unset, 
    status_callback: :unset, 
    status_callback_method: :unset
)

    data = Twilio::Values.of({
        'FriendlyName' => friendly_name,
        'Enabled' => enabled,
        'VideoLayout' => Twilio.serialize_object(video_layout),
        'AudioSources' => Twilio.serialize_list(audio_sources) { |e| e },
        'AudioSourcesExcluded' => Twilio.serialize_list(audio_sources_excluded) { |e| e },
        'Trim' => trim,
        'Format' => format,
        'Resolution' => resolution,
        'StatusCallback' => status_callback,
        'StatusCallbackMethod' => status_callback_method,
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.update('POST', @uri, data: data, headers: headers)
    CompositionHookInstance.new(
        @version,
        payload,
        sid: @solution[:sid],
    )
end

#update_with_metadata(friendly_name: nil, enabled: :unset, video_layout: :unset, audio_sources: :unset, audio_sources_excluded: :unset, trim: :unset, format: :unset, resolution: :unset, status_callback: :unset, status_callback_method: :unset) ⇒ CompositionHookInstance

Update the CompositionHookInstanceMetadata

Parameters:

  • friendly_name (String) (defaults to: nil)

    A descriptive string that you create to describe the resource. It can be up to 100 characters long and it must be unique within the account.

  • enabled (Boolean) (defaults to: :unset)

    Whether the composition hook is active. When true, the composition hook will be triggered for every completed Group Room in the account. When false, the composition hook never triggers.

  • video_layout (Object) (defaults to: :unset)

    A JSON object that describes the video layout of the composition hook in terms of regions. See [Specifying Video Layouts](www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) for more info.

  • audio_sources (Array[String]) (defaults to: :unset)

    An array of track names from the same group room to merge into the compositions created by the composition hook. Can include zero or more track names. A composition triggered by the composition hook includes all audio sources specified in audio_sources except those specified in audio_sources_excluded. The track names in this parameter can include an asterisk as a wild card character, which matches zero or more characters in a track name. For example, student* includes tracks named student as well as studentTeam.

  • audio_sources_excluded (Array[String]) (defaults to: :unset)

    An array of track names to exclude. A composition triggered by the composition hook includes all audio sources specified in audio_sources except for those specified in audio_sources_excluded. The track names in this parameter can include an asterisk as a wild card character, which matches zero or more characters in a track name. For example, student* excludes student as well as studentTeam. This parameter can also be empty.

  • trim (Boolean) (defaults to: :unset)

    Whether to clip the intervals where there is no active media in the compositions triggered by the composition hook. The default is true. Compositions with trim enabled are shorter when the Room is created and no Participant joins for a while as well as if all the Participants leave the room and join later, because those gaps will be removed. See [Specifying Video Layouts](www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) for more info.

  • format (Format) (defaults to: :unset)
  • resolution (String) (defaults to: :unset)

    A string that describes the columns (width) and rows (height) of the generated composed video in pixels. Defaults to 640x480. The string’s format is ‘widthxheight` where: * 16 <= `width` <= 1280 * 16 <= `height` <= 1280 * `width` * `height` <= 921,600 Typical values are: * HD = 1280x720 * PAL = 1024x576 * VGA = 640x480 * CIF = 320x240 Note that the resolution imposes an aspect ratio to the resulting composition. When the original video tracks are constrained by the aspect ratio, they are scaled to fit. See [Specifying Video Layouts](www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) for more info.

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

    The URL we should call using the status_callback_method to send status information to your application on every composition event. If not provided, status callback events will not be dispatched.

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

    The HTTP method we should use to call status_callback. Can be: POST or GET and the default is POST.

Returns:



453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 453

def (
  friendly_name: nil, 
  enabled: :unset, 
  video_layout: :unset, 
  audio_sources: :unset, 
  audio_sources_excluded: :unset, 
  trim: :unset, 
  format: :unset, 
  resolution: :unset, 
  status_callback: :unset, 
  status_callback_method: :unset
)

    data = Twilio::Values.of({
        'FriendlyName' => friendly_name,
        'Enabled' => enabled,
        'VideoLayout' => Twilio.serialize_object(video_layout),
        'AudioSources' => Twilio.serialize_list(audio_sources) { |e| e },
        'AudioSourcesExcluded' => Twilio.serialize_list(audio_sources_excluded) { |e| e },
        'Trim' => trim,
        'Format' => format,
        'Resolution' => resolution,
        'StatusCallback' => status_callback,
        'StatusCallbackMethod' => status_callback_method,
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('POST', @uri, data: data, headers: headers)
    composition_hook_instance = CompositionHookInstance.new(
        @version,
        response.body,
        sid: @solution[:sid],
    )
    .new(
        @version,
        composition_hook_instance,
        response.headers,
        response.status_code
    )
end