Class: Twilio::REST::IpMessaging::V2::ServiceContext::UserContext
- Inherits:
-
Twilio::REST::InstanceContext
- Object
- Twilio::REST::InstanceContext
- Twilio::REST::IpMessaging::V2::ServiceContext::UserContext
- Defined in:
- lib/twilio-ruby/rest/ip_messaging/v2/service/user.rb,
lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_binding.rb,
lib/twilio-ruby/rest/ip_messaging/v2/service/user/user_channel.rb
Defined Under Namespace
Classes: UserBindingContext, UserBindingInstance, UserBindingList, UserBindingPage, UserChannelContext, UserChannelInstance, UserChannelList, UserChannelPage
Instance Method Summary collapse
-
#delete ⇒ Boolean
Delete the UserInstance.
-
#fetch ⇒ UserInstance
Fetch the UserInstance.
-
#initialize(version, service_sid, sid) ⇒ UserContext
constructor
Initialize the UserContext.
-
#inspect ⇒ Object
Provide a detailed, user friendly representation.
-
#to_s ⇒ Object
Provide a user friendly representation.
-
#update(role_sid: :unset, attributes: :unset, friendly_name: :unset, x_twilio_webhook_enabled: :unset) ⇒ UserInstance
Update the UserInstance.
-
#user_bindings(sid = :unset) ⇒ UserBindingList, UserBindingContext
Access the user_bindings.
-
#user_channels(channel_sid = :unset) ⇒ UserChannelList, UserChannelContext
Access the user_channels.
Constructor Details
#initialize(version, service_sid, sid) ⇒ UserContext
Initialize the UserContext
176 177 178 179 180 181 182 183 184 185 186 |
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/user.rb', line 176 def initialize(version, service_sid, sid) super(version) # Path Solution @solution = { service_sid: service_sid, sid: sid, } @uri = "/Services/#{@solution[:service_sid]}/Users/#{@solution[:sid]}" # Dependents @user_channels = nil @user_bindings = nil end |
Instance Method Details
#delete ⇒ Boolean
Delete the UserInstance
190 191 192 193 194 195 196 197 |
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/user.rb', line 190 def delete headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) @version.delete('DELETE', @uri, headers: headers) end |
#fetch ⇒ UserInstance
Fetch the UserInstance
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/user.rb', line 202 def fetch headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) payload = @version.fetch('GET', @uri, headers: headers) UserInstance.new( @version, payload, service_sid: @solution[:service_sid], sid: @solution[:sid], ) end |
#inspect ⇒ Object
Provide a detailed, user friendly representation
302 303 304 305 |
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/user.rb', line 302 def inspect context = @solution.map{|k, v| "#{k}: #{v}"}.join(',') "#<Twilio.IpMessaging.V2.UserContext #{context}>" end |
#to_s ⇒ Object
Provide a user friendly representation
295 296 297 298 |
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/user.rb', line 295 def to_s context = @solution.map{|k, v| "#{k}: #{v}"}.join(',') "#<Twilio.IpMessaging.V2.UserContext #{context}>" end |
#update(role_sid: :unset, attributes: :unset, friendly_name: :unset, x_twilio_webhook_enabled: :unset) ⇒ UserInstance
Update the UserInstance
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/user.rb', line 226 def update( role_sid: :unset, attributes: :unset, friendly_name: :unset, x_twilio_webhook_enabled: :unset ) data = Twilio::Values.of({ 'RoleSid' => role_sid, 'Attributes' => attributes, 'FriendlyName' => friendly_name, }) 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) UserInstance.new( @version, payload, service_sid: @solution[:service_sid], sid: @solution[:sid], ) end |
#user_bindings(sid = :unset) ⇒ UserBindingList, UserBindingContext
Access the user_bindings
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/user.rb', line 277 def user_bindings(sid=:unset) raise ArgumentError, 'sid cannot be nil' if sid.nil? if sid != :unset return UserBindingContext.new(@version, @solution[:service_sid], @solution[:sid],sid ) end unless @user_bindings @user_bindings = UserBindingList.new( @version, service_sid: @solution[:service_sid], user_sid: @solution[:sid], ) end @user_bindings end |
#user_channels(channel_sid = :unset) ⇒ UserChannelList, UserChannelContext
Access the user_channels
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 |
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/user.rb', line 258 def user_channels(channel_sid=:unset) raise ArgumentError, 'channel_sid cannot be nil' if channel_sid.nil? if channel_sid != :unset return UserChannelContext.new(@version, @solution[:service_sid], @solution[:sid],channel_sid ) end unless @user_channels @user_channels = UserChannelList.new( @version, service_sid: @solution[:service_sid], user_sid: @solution[:sid], ) end @user_channels end |