Class: Twilio::REST::Notify::V1::ServiceContext::UserContext::SegmentMembershipContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/notify/v1/service/user/segment_memberships.rb

Overview

PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.

Instance Method Summary collapse

Constructor Details

#initialize(version, service_sid, identity, segment) ⇒ SegmentMembershipContext

Initialize the SegmentMembershipContext

Parameters:

  • version (Version)

    Version that contains the resource

  • service_sid (String)

    The service_sid

  • identity (String)

    The identity

  • segment (String)

    The segment



105
106
107
108
109
110
111
# File 'lib/twilio-ruby/rest/notify/v1/service/user/segment_memberships.rb', line 105

def initialize(version, service_sid, identity, segment)
  super(version)

  # Path Solution
  @solution = {service_sid: service_sid, identity: identity, segment: segment}
  @uri = "/Services/#{@solution[:service_sid]}/Users/#{@solution[:identity]}/SegmentMemberships/#{@solution[:segment]}"
end

Instance Method Details

#deleteBoolean

Deletes the SegmentMembershipInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



116
117
118
# File 'lib/twilio-ruby/rest/notify/v1/service/user/segment_memberships.rb', line 116

def delete
  @version.delete('delete', @uri)
end

#fetchSegmentMembershipInstance

Fetch a SegmentMembershipInstance

Returns:



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/twilio-ruby/rest/notify/v1/service/user/segment_memberships.rb', line 123

def fetch
  params = Twilio::Values.of({})

  payload = @version.fetch(
      'GET',
      @uri,
      params,
  )

  SegmentMembershipInstance.new(
      @version,
      payload,
      service_sid: @solution[:service_sid],
      identity: @solution[:identity],
      segment: @solution[:segment],
  )
end

#to_sObject

Provide a user friendly representation



143
144
145
146
# File 'lib/twilio-ruby/rest/notify/v1/service/user/segment_memberships.rb', line 143

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