Class: Twilio::REST::Chat::V2::ServiceContext::ChannelContext
- Inherits:
-
InstanceContext
- Object
- InstanceContext
- Twilio::REST::Chat::V2::ServiceContext::ChannelContext
- Defined in:
- lib/twilio-ruby/rest/chat/v2/service/channel.rb,
lib/twilio-ruby/rest/chat/v2/service/channel/invite.rb,
lib/twilio-ruby/rest/chat/v2/service/channel/member.rb,
lib/twilio-ruby/rest/chat/v2/service/channel/message.rb
Defined Under Namespace
Classes: InviteContext, InviteInstance, InviteList, InvitePage, MemberContext, MemberInstance, MemberList, MemberPage, MessageContext, MessageInstance, MessageList, MessagePage
Instance Method Summary collapse
-
#delete ⇒ Boolean
Deletes the ChannelInstance.
-
#fetch ⇒ ChannelInstance
Fetch a ChannelInstance.
-
#initialize(version, service_sid, sid) ⇒ ChannelContext
constructor
Initialize the ChannelContext.
-
#invites(sid = :unset) ⇒ InviteList, InviteContext
Access the invites.
-
#members(sid = :unset) ⇒ MemberList, MemberContext
Access the members.
-
#messages(sid = :unset) ⇒ MessageList, MessageContext
Access the messages.
-
#to_s ⇒ Object
Provide a user friendly representation.
-
#update(friendly_name: :unset, unique_name: :unset, attributes: :unset, date_created: :unset, date_updated: :unset, created_by: :unset) ⇒ ChannelInstance
Update the ChannelInstance.
Constructor Details
#initialize(version, service_sid, sid) ⇒ ChannelContext
Initialize the ChannelContext
186 187 188 189 190 191 192 193 194 195 196 197 |
# File 'lib/twilio-ruby/rest/chat/v2/service/channel.rb', line 186 def initialize(version, service_sid, sid) super(version) # Path Solution @solution = {service_sid: service_sid, sid: sid, } @uri = "/Services/#{@solution[:service_sid]}/Channels/#{@solution[:sid]}" # Dependents @members = nil @messages = nil @invites = nil end |
Instance Method Details
#delete ⇒ Boolean
Deletes the ChannelInstance
217 218 219 |
# File 'lib/twilio-ruby/rest/chat/v2/service/channel.rb', line 217 def delete @version.delete('delete', @uri) end |
#fetch ⇒ ChannelInstance
Fetch a ChannelInstance
202 203 204 205 206 207 208 209 210 211 212 |
# File 'lib/twilio-ruby/rest/chat/v2/service/channel.rb', line 202 def fetch params = Twilio::Values.of({}) payload = @version.fetch( 'GET', @uri, params, ) ChannelInstance.new(@version, payload, service_sid: @solution[:service_sid], sid: @solution[:sid], ) end |
#invites(sid = :unset) ⇒ InviteList, InviteContext
Access the invites
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 |
# File 'lib/twilio-ruby/rest/chat/v2/service/channel.rb', line 297 def invites(sid=:unset) raise ArgumentError, 'sid cannot be nil' if sid.nil? if sid != :unset return InviteContext.new(@version, @solution[:service_sid], @solution[:sid], sid, ) end unless @invites @invites = InviteList.new( @version, service_sid: @solution[:service_sid], channel_sid: @solution[:sid], ) end @invites end |
#members(sid = :unset) ⇒ MemberList, MemberContext
Access the members
253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 |
# File 'lib/twilio-ruby/rest/chat/v2/service/channel.rb', line 253 def members(sid=:unset) raise ArgumentError, 'sid cannot be nil' if sid.nil? if sid != :unset return MemberContext.new(@version, @solution[:service_sid], @solution[:sid], sid, ) end unless @members @members = MemberList.new( @version, service_sid: @solution[:service_sid], channel_sid: @solution[:sid], ) end @members end |
#messages(sid = :unset) ⇒ MessageList, MessageContext
Access the messages
275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
# File 'lib/twilio-ruby/rest/chat/v2/service/channel.rb', line 275 def (sid=:unset) raise ArgumentError, 'sid cannot be nil' if sid.nil? if sid != :unset return MessageContext.new(@version, @solution[:service_sid], @solution[:sid], sid, ) end unless @messages @messages = MessageList.new( @version, service_sid: @solution[:service_sid], channel_sid: @solution[:sid], ) end @messages end |
#to_s ⇒ Object
Provide a user friendly representation
317 318 319 320 |
# File 'lib/twilio-ruby/rest/chat/v2/service/channel.rb', line 317 def to_s context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') "#<Twilio.Chat.V2.ChannelContext #{context}>" end |
#update(friendly_name: :unset, unique_name: :unset, attributes: :unset, date_created: :unset, date_updated: :unset, created_by: :unset) ⇒ ChannelInstance
Update the ChannelInstance
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 |
# File 'lib/twilio-ruby/rest/chat/v2/service/channel.rb', line 230 def update(friendly_name: :unset, unique_name: :unset, attributes: :unset, date_created: :unset, date_updated: :unset, created_by: :unset) data = Twilio::Values.of({ 'FriendlyName' => friendly_name, 'UniqueName' => unique_name, 'Attributes' => attributes, 'DateCreated' => Twilio.serialize_iso8601_datetime(date_created), 'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated), 'CreatedBy' => created_by, }) payload = @version.update( 'POST', @uri, data: data, ) ChannelInstance.new(@version, payload, service_sid: @solution[:service_sid], sid: @solution[:sid], ) end |