Class: Twilio::REST::Conversations::V1::ServiceContext

Inherits:
InstanceContext show all
Defined in:
lib/twilio-ruby/rest/conversations/v1/service.rb,
lib/twilio-ruby/rest/conversations/v1/service/role.rb,
lib/twilio-ruby/rest/conversations/v1/service/user.rb,
lib/twilio-ruby/rest/conversations/v1/service/binding.rb,
lib/twilio-ruby/rest/conversations/v1/service/conversation.rb,
lib/twilio-ruby/rest/conversations/v1/service/configuration.rb,
lib/twilio-ruby/rest/conversations/v1/service/conversation/message.rb,
lib/twilio-ruby/rest/conversations/v1/service/conversation/webhook.rb,
lib/twilio-ruby/rest/conversations/v1/service/configuration/webhook.rb,
lib/twilio-ruby/rest/conversations/v1/service/user/user_conversation.rb,
lib/twilio-ruby/rest/conversations/v1/service/conversation/participant.rb,
lib/twilio-ruby/rest/conversations/v1/service/participant_conversation.rb,
lib/twilio-ruby/rest/conversations/v1/service/configuration/notification.rb,
lib/twilio-ruby/rest/conversations/v1/service/conversation/message/delivery_receipt.rb

Defined Under Namespace

Classes: BindingContext, BindingInstance, BindingList, BindingPage, ConfigurationContext, ConfigurationInstance, ConfigurationList, ConfigurationPage, ConversationContext, ConversationInstance, ConversationList, ConversationPage, ParticipantConversationInstance, ParticipantConversationList, ParticipantConversationPage, RoleContext, RoleInstance, RoleList, RolePage, UserContext, UserInstance, UserList, UserPage

Instance Method Summary collapse

Constructor Details

#initialize(version, sid) ⇒ ServiceContext

Initialize the ServiceContext

Parameters:

  • version (Version)

    Version that contains the resource

  • sid (String)

    A 34 character string that uniquely identifies this resource.


162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
# File 'lib/twilio-ruby/rest/conversations/v1/service.rb', line 162

def initialize(version, sid)
  super(version)

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

  # Dependents
  @conversations = nil
  @bindings = nil
  @users = nil
  @roles = nil
  @configuration = nil
  @participant_conversations = nil
end

Instance Method Details

#bindings(sid = :unset) ⇒ BindingList, BindingContext

Access the bindings

Returns:

Raises:

  • (ArgumentError)

216
217
218
219
220
221
222
223
224
225
226
227
228
# File 'lib/twilio-ruby/rest/conversations/v1/service.rb', line 216

def bindings(sid=:unset)
  raise ArgumentError, 'sid cannot be nil' if sid.nil?

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

  unless @bindings
    @bindings = BindingList.new(@version, chat_service_sid: @solution[:sid], )
  end

  @bindings
end

#configurationConfigurationList, ConfigurationContext

Access the configuration


270
271
272
# File 'lib/twilio-ruby/rest/conversations/v1/service.rb', line 270

def configuration
  ConfigurationContext.new(@version, @solution[:sid], )
end

#conversations(sid = :unset) ⇒ ConversationList, ConversationContext

Access the conversations

Returns:

Raises:

  • (ArgumentError)

198
199
200
201
202
203
204
205
206
207
208
209
210
# File 'lib/twilio-ruby/rest/conversations/v1/service.rb', line 198

def conversations(sid=:unset)
  raise ArgumentError, 'sid cannot be nil' if sid.nil?

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

  unless @conversations
    @conversations = ConversationList.new(@version, chat_service_sid: @solution[:sid], )
  end

  @conversations
end

#deleteBoolean

Delete the ServiceInstance

Returns:

  • (Boolean)

    true if delete succeeds, false otherwise


181
182
183
# File 'lib/twilio-ruby/rest/conversations/v1/service.rb', line 181

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

#fetchServiceInstance

Fetch the ServiceInstance

Returns:


188
189
190
191
192
# File 'lib/twilio-ruby/rest/conversations/v1/service.rb', line 188

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

  ServiceInstance.new(@version, payload, sid: @solution[:sid], )
end

#inspectObject

Provide a detailed, user friendly representation


298
299
300
301
# File 'lib/twilio-ruby/rest/conversations/v1/service.rb', line 298

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

#participant_conversationsParticipantConversationList, ParticipantConversationContext

Access the participant_conversations

Returns:


278
279
280
281
282
283
284
285
286
287
# File 'lib/twilio-ruby/rest/conversations/v1/service.rb', line 278

def participant_conversations
  unless @participant_conversations
    @participant_conversations = ParticipantConversationList.new(
        @version,
        chat_service_sid: @solution[:sid],
    )
  end

  @participant_conversations
end

#roles(sid = :unset) ⇒ RoleList, RoleContext

Access the roles

Returns:

Raises:

  • (ArgumentError)

252
253
254
255
256
257
258
259
260
261
262
263
264
# File 'lib/twilio-ruby/rest/conversations/v1/service.rb', line 252

def roles(sid=:unset)
  raise ArgumentError, 'sid cannot be nil' if sid.nil?

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

  unless @roles
    @roles = RoleList.new(@version, chat_service_sid: @solution[:sid], )
  end

  @roles
end

#to_sObject

Provide a user friendly representation


291
292
293
294
# File 'lib/twilio-ruby/rest/conversations/v1/service.rb', line 291

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

#users(sid = :unset) ⇒ UserList, UserContext

Access the users

Returns:

Raises:

  • (ArgumentError)

234
235
236
237
238
239
240
241
242
243
244
245
246
# File 'lib/twilio-ruby/rest/conversations/v1/service.rb', line 234

def users(sid=:unset)
  raise ArgumentError, 'sid cannot be nil' if sid.nil?

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

  unless @users
    @users = UserList.new(@version, chat_service_sid: @solution[:sid], )
  end

  @users
end