Class: Twilio::REST::Conversations::V1::ConversationContext::ParticipantContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, conversation_sid, sid) ⇒ ParticipantContext

Initialize the ParticipantContext



181
182
183
184
185
186
187
188
189
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb', line 181

def initialize(version, conversation_sid, sid)
    super(version)

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

    
end

Instance Method Details

#delete(x_twilio_webhook_enabled: :unset) ⇒ Boolean

Delete the ParticipantInstance



194
195
196
197
198
199
200
201
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb', line 194

def delete(
    x_twilio_webhook_enabled: :unset
)

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, })
    
    @version.delete('DELETE', @uri, headers: headers)
end

#fetchParticipantInstance

Fetch the ParticipantInstance



206
207
208
209
210
211
212
213
214
215
216
217
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb', line 206

def fetch

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

#inspectObject

Provide a detailed, user friendly representation



278
279
280
281
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb', line 278

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

#to_sObject

Provide a user friendly representation



271
272
273
274
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb', line 271

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

#update(date_created: :unset, date_updated: :unset, attributes: :unset, role_sid: :unset, messaging_binding_proxy_address: :unset, messaging_binding_projected_address: :unset, identity: :unset, last_read_message_index: :unset, last_read_timestamp: :unset, x_twilio_webhook_enabled: :unset) ⇒ ParticipantInstance

Update the ParticipantInstance



232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
# File 'lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb', line 232

def update(
    date_created: :unset, 
    date_updated: :unset, 
    attributes: :unset, 
    role_sid: :unset, 
    messaging_binding_proxy_address: :unset, 
    messaging_binding_projected_address: :unset, 
    identity: :unset, 
    last_read_message_index: :unset, 
    last_read_timestamp: :unset, 
    x_twilio_webhook_enabled: :unset
)

    data = Twilio::Values.of({
        'DateCreated' => Twilio.serialize_iso8601_datetime(date_created),
        'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated),
        'Attributes' => attributes,
        'RoleSid' => role_sid,
        'MessagingBinding.ProxyAddress' => messaging_binding_proxy_address,
        'MessagingBinding.ProjectedAddress' => messaging_binding_projected_address,
        'Identity' => identity,
        'LastReadMessageIndex' => last_read_message_index,
        'LastReadTimestamp' => last_read_timestamp,
    })

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