Class: Twilio::REST::IpMessaging::V1::ServiceContext::UserContext

Inherits:
Twilio::REST::InstanceContext show all
Defined in:
lib/twilio-ruby/rest/ip_messaging/v1/service/user.rb,
lib/twilio-ruby/rest/ip_messaging/v1/service/user/user_channel.rb

Defined Under Namespace

Classes: UserChannelInstance, UserChannelList, UserChannelPage

Instance Method Summary collapse

Constructor Details

#initialize(version, service_sid, sid) ⇒ UserContext

Initialize the UserContext



167
168
169
170
171
172
173
174
175
176
# File 'lib/twilio-ruby/rest/ip_messaging/v1/service/user.rb', line 167

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
end

Instance Method Details

#deleteBoolean

Delete the UserInstance



180
181
182
183
184
185
# File 'lib/twilio-ruby/rest/ip_messaging/v1/service/user.rb', line 180

def delete

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

#fetchUserInstance

Fetch the UserInstance



190
191
192
193
194
195
196
197
198
199
200
201
# File 'lib/twilio-ruby/rest/ip_messaging/v1/service/user.rb', line 190

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

#inspectObject

Provide a detailed, user friendly representation



253
254
255
256
# File 'lib/twilio-ruby/rest/ip_messaging/v1/service/user.rb', line 253

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

#to_sObject

Provide a user friendly representation



246
247
248
249
# File 'lib/twilio-ruby/rest/ip_messaging/v1/service/user.rb', line 246

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

#update(role_sid: :unset, attributes: :unset, friendly_name: :unset) ⇒ UserInstance

Update the UserInstance



209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
# File 'lib/twilio-ruby/rest/ip_messaging/v1/service/user.rb', line 209

def update(
    role_sid: :unset, 
    attributes: :unset, 
    friendly_name: :unset
)

    data = Twilio::Values.of({
        'RoleSid' => role_sid,
        'Attributes' => attributes,
        'FriendlyName' => friendly_name,
    })

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

#user_channelsUserChannelList, UserChannelContext

Access the user_channels



236
237
238
239
240
241
242
# File 'lib/twilio-ruby/rest/ip_messaging/v1/service/user.rb', line 236

def user_channels
  unless @user_channels
    @user_channels = UserChannelList.new(
            @version, service_sid: @solution[:service_sid], user_sid: @solution[:sid], )
  end
  @user_channels
end