Class: Twilio::REST::FlexApi::V1::InteractionContext::InteractionChannelContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/flex_api/v1/interaction/interaction_channel.rb,
lib/twilio-ruby/rest/flex_api/v1/interaction/interaction_channel/interaction_channel_invite.rb,
lib/twilio-ruby/rest/flex_api/v1/interaction/interaction_channel/interaction_channel_participant.rb

Defined Under Namespace

Classes: InteractionChannelInviteInstance, InteractionChannelInviteList, InteractionChannelInvitePage, InteractionChannelParticipantContext, InteractionChannelParticipantInstance, InteractionChannelParticipantList, InteractionChannelParticipantPage

Instance Method Summary collapse

Constructor Details

#initialize(version, interaction_sid, sid) ⇒ InteractionChannelContext

Initialize the InteractionChannelContext

Parameters:

  • version (Version)

    Version that contains the resource

  • interaction_sid (String)

    The unique string created by Twilio to identify an Interaction resource, prefixed with KD.

  • sid (String)

    The unique string created by Twilio to identify an Interaction Channel resource, prefixed with UO.



139
140
141
142
143
144
145
146
147
148
149
# File 'lib/twilio-ruby/rest/flex_api/v1/interaction/interaction_channel.rb', line 139

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

    # Path Solution
    @solution = { interaction_sid: interaction_sid, sid: sid,  }
    @uri = "/Interactions/#{@solution[:interaction_sid]}/Channels/#{@solution[:sid]}"

    # Dependents
    @invites = nil
    @participants = nil
end

Instance Method Details

#fetchInteractionChannelInstance

Fetch the InteractionChannelInstance

Returns:



153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/twilio-ruby/rest/flex_api/v1/interaction/interaction_channel.rb', line 153

def fetch

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

#inspectObject

Provide a detailed, user friendly representation



240
241
242
243
# File 'lib/twilio-ruby/rest/flex_api/v1/interaction/interaction_channel.rb', line 240

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

#invitesInteractionChannelInviteList, InteractionChannelInviteContext

Access the invites

Returns:



204
205
206
207
208
209
210
# File 'lib/twilio-ruby/rest/flex_api/v1/interaction/interaction_channel.rb', line 204

def invites
  unless @invites
    @invites = InteractionChannelInviteList.new(
            @version, interaction_sid: @solution[:interaction_sid], channel_sid: @solution[:sid], )
  end
  @invites
end

#participants(sid = :unset) ⇒ InteractionChannelParticipantList, InteractionChannelParticipantContext

Access the participants

Returns:

Raises:

  • (ArgumentError)


215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# File 'lib/twilio-ruby/rest/flex_api/v1/interaction/interaction_channel.rb', line 215

def participants(sid=:unset)

    raise ArgumentError, 'sid cannot be nil' if sid.nil?

    if sid != :unset
        return InteractionChannelParticipantContext.new(@version, @solution[:interaction_sid], @solution[:sid],sid )
    end

    unless @participants
        @participants = InteractionChannelParticipantList.new(
            @version, interaction_sid: @solution[:interaction_sid], channel_sid: @solution[:sid], )
    end

 @participants
end

#to_sObject

Provide a user friendly representation



233
234
235
236
# File 'lib/twilio-ruby/rest/flex_api/v1/interaction/interaction_channel.rb', line 233

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

#update(status: nil, routing: :unset) ⇒ InteractionChannelInstance

Update the InteractionChannelInstance

Parameters:

  • status (UpdateChannelStatus) (defaults to: nil)
  • routing (Object) (defaults to: :unset)

    It changes the state of associated tasks. Routing status is required, When the channel status is set to ‘inactive`. Allowed Value for routing status is `closed`. Otherwise Optional, if not specified, all tasks will be set to `wrapping`.

Returns:



175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
# File 'lib/twilio-ruby/rest/flex_api/v1/interaction/interaction_channel.rb', line 175

def update(
    status: nil, 
    routing: :unset
)

    data = Twilio::Values.of({
        'Status' => status,
        'Routing' => Twilio.serialize_object(routing),
    })

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