Class: Twilio::REST::FrontlineApi::V1::UserInstance

Inherits:
InstanceResource show all
Defined in:
lib/twilio-ruby/rest/frontline_api/v1/user.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, sid: nil) ⇒ UserInstance

Initialize the UserInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio

  • account_sid (String)

    The SID of the Account that created this User resource.

  • sid (String) (defaults to: nil)

    The SID of the Call resource to fetch.



155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 155

def initialize(version, payload , sid: nil)
    super(version)
    
    # Marshaled Properties
    @properties = { 
        'sid' => payload['sid'],
        'identity' => payload['identity'],
        'friendly_name' => payload['friendly_name'],
        'avatar' => payload['avatar'],
        'state' => payload['state'],
        'is_available' => payload['is_available'],
        'url' => payload['url'],
    }

    # Context
    @instance_context = nil
    @params = { 'sid' => sid  || @properties['sid']  , }
end

Instance Method Details

#avatarString

Returns The avatar URL which will be shown in Frontline application.

Returns:

  • (String)

    The avatar URL which will be shown in Frontline application.



205
206
207
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 205

def avatar
    @properties['avatar']
end

#contextUserContext

Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context

Returns:



178
179
180
181
182
183
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 178

def context
    unless @instance_context
        @instance_context = UserContext.new(@version , @params['sid'])
    end
    @instance_context
end

#fetchUserInstance

Fetch the UserInstance

Returns:



230
231
232
233
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 230

def fetch

    context.fetch
end

#friendly_nameString

Returns The string that you assigned to describe the User.

Returns:

  • (String)

    The string that you assigned to describe the User.



199
200
201
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 199

def friendly_name
    @properties['friendly_name']
end

#identityString

Returns The application-defined string that uniquely identifies the resource’s User. This value is often a username or an email address, and is case-sensitive.

Returns:

  • (String)

    The application-defined string that uniquely identifies the resource’s User. This value is often a username or an email address, and is case-sensitive.



193
194
195
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 193

def identity
    @properties['identity']
end

#inspectObject

Provide a detailed, user friendly representation



266
267
268
269
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 266

def inspect
    values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
    "<Twilio.FrontlineApi.V1.UserInstance #{values}>"
end

#is_availableBoolean

Returns Whether the User is available for new conversations. Defaults to ‘false` for new users.

Returns:

  • (Boolean)

    Whether the User is available for new conversations. Defaults to ‘false` for new users.



217
218
219
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 217

def is_available
    @properties['is_available']
end

#sidString

Returns The unique string that we created to identify the User resource.

Returns:

  • (String)

    The unique string that we created to identify the User resource.



187
188
189
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 187

def sid
    @properties['sid']
end

#stateStateType

Returns:

  • (StateType)


211
212
213
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 211

def state
    @properties['state']
end

#to_sObject

Provide a user friendly representation



259
260
261
262
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 259

def to_s
    values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
    "<Twilio.FrontlineApi.V1.UserInstance #{values}>"
end

#update(friendly_name: :unset, avatar: :unset, state: :unset, is_available: :unset) ⇒ UserInstance

Update the UserInstance

Parameters:

  • friendly_name (String) (defaults to: :unset)

    The string that you assigned to describe the User.

  • avatar (String) (defaults to: :unset)

    The avatar URL which will be shown in Frontline application.

  • state (StateType) (defaults to: :unset)
  • is_available (Boolean) (defaults to: :unset)

    Whether the User is available for new conversations. Set to ‘false` to prevent User from receiving new inbound conversations if you are using [Pool Routing](www.twilio.com/docs/frontline/handle-incoming-conversations#3-pool-routing).

Returns:



242
243
244
245
246
247
248
249
250
251
252
253
254
255
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 242

def update(
    friendly_name: :unset, 
    avatar: :unset, 
    state: :unset, 
    is_available: :unset
)

    context.update(
        friendly_name: friendly_name, 
        avatar: avatar, 
        state: state, 
        is_available: is_available, 
    )
end

#urlString

Returns An absolute API resource URL for this user.

Returns:

  • (String)

    An absolute API resource URL for this user.



223
224
225
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 223

def url
    @properties['url']
end