Class: Twilio::REST::Video::V1::CompositionHookInstance

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

Overview

PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact [email protected].

Instance Method Summary collapse

Constructor Details

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

Initialize the CompositionHookInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio

  • sid (String) (defaults to: nil)

    The Composition Hook Sid that uniquely identifies the Composition Hook to fetch.



421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 421

def initialize(version, payload, sid: nil)
  super(version)

  # Marshaled Properties
  @properties = {
      'account_sid' => payload['account_sid'],
      'friendly_name' => payload['friendly_name'],
      'enabled' => payload['enabled'],
      'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
      'date_updated' => payload['date_updated'],
      'sid' => payload['sid'],
      'audio_sources' => payload['audio_sources'],
      'audio_sources_excluded' => payload['audio_sources_excluded'],
      'video_layout' => payload['video_layout'],
      'resolution' => payload['resolution'],
      'trim' => payload['trim'],
      'format' => payload['format'],
      'status_callback' => payload['status_callback'],
      'status_callback_method' => payload['status_callback_method'],
      'url' => payload['url'],
  }

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

Instance Method Details

#account_sidString

Returns Twilio Account SID.

Returns:

  • (String)

    Twilio Account SID.



461
462
463
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 461

def 
  @properties['account_sid']
end

#audio_sourcesString

Returns A list of audio sources related to this Composition Hook.

Returns:

  • (String)

    A list of audio sources related to this Composition Hook.



497
498
499
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 497

def audio_sources
  @properties['audio_sources']
end

#audio_sources_excludedString

Returns A list of audio sources excluded related to this Composition Hook.

Returns:

  • (String)

    A list of audio sources excluded related to this Composition Hook.



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

def audio_sources_excluded
  @properties['audio_sources_excluded']
end

#contextCompositionHookContext

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

Returns:



452
453
454
455
456
457
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 452

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

#date_createdTime

Returns Date when the Composition Hook Resource was created.

Returns:

  • (Time)

    Date when the Composition Hook Resource was created.



479
480
481
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 479

def date_created
  @properties['date_created']
end

#date_updatedString

Returns Date when the Composition Hook was last updated.

Returns:

  • (String)

    Date when the Composition Hook was last updated.



485
486
487
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 485

def date_updated
  @properties['date_updated']
end

#deleteBoolean

Deletes the CompositionHookInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



559
560
561
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 559

def delete
  context.delete
end

#enabledBoolean

Returns Boolean flag indicating if the Composition Hook is active.

Returns:

  • (Boolean)

    Boolean flag indicating if the Composition Hook is active.



473
474
475
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 473

def enabled
  @properties['enabled']
end

#fetchCompositionHookInstance

Fetch a CompositionHookInstance

Returns:



552
553
554
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 552

def fetch
  context.fetch
end

#formatcomposition_hook.Format

Returns The file format for the Compositions triggered by the Composition Hook.

Returns:

  • (composition_hook.Format)

    The file format for the Compositions triggered by the Composition Hook.



527
528
529
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 527

def format
  @properties['format']
end

#friendly_nameString

Returns Friendly name of the Composition Hook to be shown in the console.

Returns:

  • (String)

    Friendly name of the Composition Hook to be shown in the console.



467
468
469
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 467

def friendly_name
  @properties['friendly_name']
end

#inspectObject

Provide a detailed, user friendly representation



636
637
638
639
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 636

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

#resolutionString

Returns Pixel resolution of the composed video.

Returns:

  • (String)

    Pixel resolution of the composed video.



515
516
517
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 515

def resolution
  @properties['resolution']
end

#sidString

Returns A 34-character string that uniquely identifies this Composition Hook.

Returns:

  • (String)

    A 34-character string that uniquely identifies this Composition Hook.



491
492
493
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 491

def sid
  @properties['sid']
end

#status_callbackString

Returns A URL that Twilio sends asynchronous webhook requests to on every composition event.

Returns:

  • (String)

    A URL that Twilio sends asynchronous webhook requests to on every composition event.



533
534
535
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 533

def status_callback
  @properties['status_callback']
end

#status_callback_methodString

Returns HTTP method Twilio should use when requesting the above URL.

Returns:

  • (String)

    HTTP method Twilio should use when requesting the above URL.



539
540
541
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 539

def status_callback_method
  @properties['status_callback_method']
end

#to_sObject

Provide a user friendly representation



629
630
631
632
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 629

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

#trimBoolean

Returns Boolean flag for clipping intervals that have no media.

Returns:

  • (Boolean)

    Boolean flag for clipping intervals that have no media.



521
522
523
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 521

def trim
  @properties['trim']
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)

    Friendly name of the Composition Hook to be shown in the console, must be unique per account and up to 100 characters.

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

    Boolean flag indicating if the Composition Hook is active. Possible values are ‘true` or `false`. When `true`, the Composition Hook will be triggered for every completed Group Room on this account. When `false`, the Composition Hook never triggers.

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

    A JSON object defining the video layout of the Composition Hook in terms of regions. See the section [Specifying Video Layouts](www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) for further information.

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

    An array of audio sources to merge. All the specified sources must belong to the same Group Room. It can include zero or more Track names. These can be specified using wildcards (e.g. ‘student*`). The use of `[*]` has semantics “all if any” meaning zero or more (i.e. all) depending on whether the Group Room had audio tracks.

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

    An array of audio sources to exclude from the Composition Hook. Any new Composition triggered by the Composition Hook shall include all audio sources specified in ‘AudioSources` except for the ones specified in `AudioSourcesExcluded`. This parameter may include zero or more Track names. These can be specified using wildcards (e.g. `student*`).

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

    When activated, clips all the intervals where there is no active media in the Compositions triggered by the Composition Hook. This results in shorter compositions in cases when the Room was created but no Participant joined for some time, or if all the Participants left the room and joined at a later stage, as those gaps will be removed. You can find further information in the [Specifying Video Layouts](www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) section. Defaults to ‘true`.

  • format (composition_hook.Format) (defaults to: :unset)

    Container format of the Composition media files created by the Composition Hook. Can be any of the following: ‘mp4`, `webm`. The use of `mp4` or `webm` makes mandatory the specification of `AudioSources` and/or one `VideoLayout` element containing a valid `video_sources` list, otherwise an error is fired. Defaults to `webm`.

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

    A string representing the number of pixels for rows (width) and columns (height) of the generated composed video. This string must have the format ‘widthxheight`. This parameter must comply with the following constraints: `width >= 16 && width <= 1280`, `height >= 16 && height <= 1280`, `width * height <= 921,600`. Typical values are: HD = `1280x720`, PAL

    ‘1024x576`, VGA = `640x480`, CIF = `320x240`. Note that the `Resolution`

    implicitly imposes an aspect ratio to the resulting composition. When the original video tracks get constrained by this aspect ratio they are scaled-down to fit. You can find detailed information in the [Specifying Video Layouts](www.twilio.com/docs/video/api/compositions-resource#specifying-video-layouts) section. Defaults to ‘640x480`.

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

    A URL that Twilio sends asynchronous webhook requests to on every composition event. If not provided, status callback events will not be dispatched.

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

    HTTP method Twilio should use when requesting the above URL. Defaults to ‘POST`.

Returns:



612
613
614
615
616
617
618
619
620
621
622
623
624
625
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 612

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)
  context.update(
      friendly_name: friendly_name,
      enabled: enabled,
      video_layout: video_layout,
      audio_sources: audio_sources,
      audio_sources_excluded: audio_sources_excluded,
      trim: trim,
      format: format,
      resolution: resolution,
      status_callback: status_callback,
      status_callback_method: status_callback_method,
  )
end

#urlString

Returns The absolute URL for this resource.

Returns:

  • (String)

    The absolute URL for this resource.



545
546
547
# File 'lib/twilio-ruby/rest/video/v1/composition_hook.rb', line 545

def url
  @properties['url']
end

#video_layoutHash

Returns The JSON video layout description.

Returns:

  • (Hash)

    The JSON video layout description.



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

def video_layout
  @properties['video_layout']
end