Class: Twilio::REST::Webhooks::V1::RuleInstance

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

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, rule_id: nil) ⇒ RuleInstance

Initialize the RuleInstance

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 Rule resource.

  • sid (String) —

    The SID of the Call resource to fetch.



661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
# File 'lib/twilio-ruby/rest/webhooks/v1/rule.rb', line 661

def initialize(version, payload , rule_id: nil)
    
    apiV1Version = ApiV1Version.new version.domain, version
    super(apiV1Version)
    
    # Marshaled Properties
    @properties = { 
        'operation' => payload['operation'],
        'rule' => payload['rule'],
        'id' => payload['id'],
        'friendly_name' => payload['friendly_name'],
        'description' => payload['description'],
        'match_type' => payload['match_type'],
        'settings' => payload['settings'],
        'created_at' => Twilio.deserialize_iso8601_datetime(payload['created_at']),
        'updated_at' => Twilio.deserialize_iso8601_datetime(payload['updated_at']),
        'prefix' => payload['prefix'],
        'value' => payload['value'],
    }

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

Instance Method Details

#context ⇒ RuleContext

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

Returns:



690
691
692
693
694
695
# File 'lib/twilio-ruby/rest/webhooks/v1/rule.rb', line 690

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

#created_at ⇒ Time

Returns:

  • (Time)


741
742
743
# File 'lib/twilio-ruby/rest/webhooks/v1/rule.rb', line 741

def created_at
    @properties['created_at']
end

#delete(idempotency_key: :unset) ⇒ Boolean

Delete the RuleInstance

Parameters:

  • idempotency_key (String) (defaults to: :unset) —

    Idempotency key for mutation operations. Must be a UUIDv7 (other UUID versions are rejected with a 400).

Returns:

  • (Boolean) —

    True if delete succeeds, false otherwise



767
768
769
770
771
772
773
774
# File 'lib/twilio-ruby/rest/webhooks/v1/rule.rb', line 767

def delete(
  idempotency_key: :unset
)

    context.delete(
        idempotency_key: idempotency_key, 
    )
end

#description ⇒ String

Returns Optional description of the Rule's purpose and usage.

Returns:

  • (String) —

    Optional description of the Rule's purpose and usage



723
724
725
# File 'lib/twilio-ruby/rest/webhooks/v1/rule.rb', line 723

def description
    @properties['description']
end

#fetch ⇒ RuleInstance

Fetch the RuleInstance

Returns:



779
780
781
782
# File 'lib/twilio-ruby/rest/webhooks/v1/rule.rb', line 779

def fetch

    context.fetch
end

#friendly_name ⇒ String

Returns Human-readable name for identification.

Returns:

  • (String) —

    Human-readable name for identification



717
718
719
# File 'lib/twilio-ruby/rest/webhooks/v1/rule.rb', line 717

def friendly_name
    @properties['friendly_name']
end

#id ⇒ String

Returns Unique Rule identifier (TypeID/TTID format).

Returns:

  • (String) —

    Unique Rule identifier (TypeID/TTID format)



711
712
713
# File 'lib/twilio-ruby/rest/webhooks/v1/rule.rb', line 711

def id
    @properties['id']
end

#inspect ⇒ Object

Provide a detailed, user friendly representation



809
810
811
812
# File 'lib/twilio-ruby/rest/webhooks/v1/rule.rb', line 809

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

#match_type ⇒ String

Returns:

  • (String)


729
730
731
# File 'lib/twilio-ruby/rest/webhooks/v1/rule.rb', line 729

def match_type
    @properties['match_type']
end

#operation ⇒ Operation

Returns Operation tracking object — poll statusUrl for completion.

Returns:

  • (Operation) —

    Operation tracking object — poll statusUrl for completion



699
700
701
# File 'lib/twilio-ruby/rest/webhooks/v1/rule.rb', line 699

def operation
    @properties['operation']
end

#patch(idempotency_key: :unset, patch_rule: nil) ⇒ RuleInstance

Patch the RuleInstance

Parameters:

  • idempotency_key (String) (defaults to: :unset) —

    Idempotency key for mutation operations. Must be a UUIDv7 (other UUID versions are rejected with a 400).

  • patch_rule (PatchRule) (defaults to: nil)

Returns:



789
790
791
792
793
794
795
796
797
798
# File 'lib/twilio-ruby/rest/webhooks/v1/rule.rb', line 789

def patch(
  idempotency_key: :unset,
  patch_rule: nil
)

    context.patch(
        idempotency_key: idempotency_key, 
        patch_rule: patch_rule, 
    )
end

#prefix ⇒ String

Returns URL prefix to match. Must be unique - only one rule per prefix allowed. Example: 'https://api.example.com/webhooks/'.

Returns:

  • (String) —

    URL prefix to match. Must be unique - only one rule per prefix allowed. Example: 'https://api.example.com/webhooks/'



753
754
755
# File 'lib/twilio-ruby/rest/webhooks/v1/rule.rb', line 753

def prefix
    @properties['prefix']
end

#rule ⇒ Rule

Returns State of the Rule resource at the time the operation was accepted (omitted for DELETE).

Returns:

  • (Rule) —

    State of the Rule resource at the time the operation was accepted (omitted for DELETE)



705
706
707
# File 'lib/twilio-ruby/rest/webhooks/v1/rule.rb', line 705

def rule
    @properties['rule']
end

#settings ⇒ Array<SettingReference>

Returns Settings to apply with traffic distribution (percentages must sum to 100).

Returns:

  • (Array<SettingReference>) —

    Settings to apply with traffic distribution (percentages must sum to 100)



735
736
737
# File 'lib/twilio-ruby/rest/webhooks/v1/rule.rb', line 735

def settings
    @properties['settings']
end

#to_s ⇒ Object

Provide a user friendly representation



802
803
804
805
# File 'lib/twilio-ruby/rest/webhooks/v1/rule.rb', line 802

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

#updated_at ⇒ Time

Returns:

  • (Time)


747
748
749
# File 'lib/twilio-ruby/rest/webhooks/v1/rule.rb', line 747

def updated_at
    @properties['updated_at']
end

#value ⇒ String

Returns Exact URL to match. Must be unique - only one rule per value allowed. Example: 'https://api.example.com/webhooks/voice/incoming'.

Returns:

  • (String) —

    Exact URL to match. Must be unique - only one rule per value allowed. Example: 'https://api.example.com/webhooks/voice/incoming'



759
760
761
# File 'lib/twilio-ruby/rest/webhooks/v1/rule.rb', line 759

def value
    @properties['value']
end