Class: Twilio::REST::IpMessaging::V2::ServiceContext::ChannelInstance

Inherits:
Twilio::REST::InstanceResource show all
Defined in:
lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, service_sid: nil, sid: nil) ⇒ ChannelInstance

Initialize the ChannelInstance

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

  • sid (String) (defaults to: nil) —

    The SID of the Call resource to fetch.



708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb', line 708

def initialize(version, payload , service_sid: nil, sid: nil)
    super(version)
    
    
    # Marshaled Properties
    @properties = { 
        'sid' => payload['sid'],
        'account_sid' => payload['account_sid'],
        'service_sid' => payload['service_sid'],
        'friendly_name' => payload['friendly_name'],
        'unique_name' => payload['unique_name'],
        'attributes' => payload['attributes'],
        'type' => payload['type'],
        'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
        'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
        'created_by' => payload['created_by'],
        'members_count' => payload['members_count'] == nil ? payload['members_count'] : payload['members_count'].to_i,
        'messages_count' => payload['messages_count'] == nil ? payload['messages_count'] : payload['messages_count'].to_i,
        'url' => payload['url'],
        'links' => payload['links'],
    }

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

Instance Method Details

#account_sid ⇒ String

Returns:

  • (String)


754
755
756
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb', line 754

def 
    @properties['account_sid']
end

#attributes ⇒ String

Returns:

  • (String)


778
779
780
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb', line 778

def attributes
    @properties['attributes']
end

#context ⇒ ChannelContext

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

Returns:



739
740
741
742
743
744
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb', line 739

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

#created_by ⇒ String

Returns:

  • (String)


802
803
804
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb', line 802

def created_by
    @properties['created_by']
end

#date_created ⇒ Time

Returns:

  • (Time)


790
791
792
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb', line 790

def date_created
    @properties['date_created']
end

#date_updated ⇒ Time

Returns:

  • (Time)


796
797
798
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb', line 796

def date_updated
    @properties['date_updated']
end

#delete(x_twilio_webhook_enabled: :unset) ⇒ Boolean

Delete the ChannelInstance

Parameters:

  • x_twilio_webhook_enabled (ChannelEnumWebhookEnabledType) (defaults to: :unset) —

    The X-Twilio-Webhook-Enabled HTTP request header

Returns:

  • (Boolean) —

    True if delete succeeds, false otherwise



834
835
836
837
838
839
840
841
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb', line 834

def delete(
  x_twilio_webhook_enabled: :unset
)

    context.delete(
        x_twilio_webhook_enabled: x_twilio_webhook_enabled, 
    )
end

#fetch ⇒ ChannelInstance

Fetch the ChannelInstance

Returns:



846
847
848
849
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb', line 846

def fetch

    context.fetch
end

#friendly_name ⇒ String

Returns:

  • (String)


766
767
768
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb', line 766

def friendly_name
    @properties['friendly_name']
end

#inspect ⇒ Object

Provide a detailed, user friendly representation



919
920
921
922
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb', line 919

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

#invites ⇒ invites

Access the invites

Returns:



906
907
908
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb', line 906

def invites
    context.invites
end

Returns:

  • (Hash)


826
827
828
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb', line 826

def links
    @properties['links']
end

#members ⇒ members

Access the members

Returns:



892
893
894
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb', line 892

def members
    context.members
end

#members_count ⇒ String

Returns:

  • (String)


808
809
810
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb', line 808

def members_count
    @properties['members_count']
end

#messages ⇒ messages

Access the messages

Returns:



899
900
901
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb', line 899

def messages
    context.messages
end

#messages_count ⇒ String

Returns:

  • (String)


814
815
816
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb', line 814

def messages_count
    @properties['messages_count']
end

#service_sid ⇒ String

Returns:

  • (String)


760
761
762
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb', line 760

def service_sid
    @properties['service_sid']
end

#sid ⇒ String

Returns:

  • (String)


748
749
750
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb', line 748

def sid
    @properties['sid']
end

#to_s ⇒ Object

Provide a user friendly representation



912
913
914
915
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb', line 912

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

#type ⇒ ChannelType

Returns:

  • (ChannelType)


784
785
786
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb', line 784

def type
    @properties['type']
end

#unique_name ⇒ String

Returns:

  • (String)


772
773
774
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb', line 772

def unique_name
    @properties['unique_name']
end

#update(friendly_name: :unset, unique_name: :unset, attributes: :unset, date_created: :unset, date_updated: :unset, created_by: :unset, x_twilio_webhook_enabled: :unset) ⇒ ChannelInstance

Update the ChannelInstance

Parameters:

  • friendly_name (String) (defaults to: :unset)
  • unique_name (String) (defaults to: :unset)
  • attributes (String) (defaults to: :unset)
  • date_created (Time) (defaults to: :unset)
  • date_updated (Time) (defaults to: :unset)
  • created_by (String) (defaults to: :unset)
  • x_twilio_webhook_enabled (ChannelEnumWebhookEnabledType) (defaults to: :unset) —

    The X-Twilio-Webhook-Enabled HTTP request header

Returns:



861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb', line 861

def update(
  friendly_name: :unset, 
  unique_name: :unset, 
  attributes: :unset, 
  date_created: :unset, 
  date_updated: :unset, 
  created_by: :unset, 
  x_twilio_webhook_enabled: :unset
)

    context.update(
        friendly_name: friendly_name, 
        unique_name: unique_name, 
        attributes: attributes, 
        date_created: date_created, 
        date_updated: date_updated, 
        created_by: created_by, 
        x_twilio_webhook_enabled: x_twilio_webhook_enabled, 
    )
end

#url ⇒ String

Returns:

  • (String)


820
821
822
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb', line 820

def url
    @properties['url']
end

#webhooks ⇒ webhooks

Access the webhooks

Returns:



885
886
887
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb', line 885

def webhooks
    context.webhooks
end