Class: Twilio::REST::FrontlineApi::V1::UserContext

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

Instance Method Summary collapse

Constructor Details

#initialize(version, sid) ⇒ UserContext

Initialize the UserContext

Parameters:

  • version (Version)

    Version that contains the resource

  • sid (String)

    The SID of the User resource to update. This value can be either the sid or the identity of the User resource to update.



50
51
52
53
54
55
56
57
58
59
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 50

def initialize(version, sid)
    super(version)
    

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

    
end

Instance Method Details

#fetchUserInstance

Fetch the UserInstance

Returns:



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 63

def fetch

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

#fetch_with_metadataUserInstance

Fetch the UserInstanceMetadata

Returns:



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 82

def 

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('GET', @uri, headers: headers)
    user_instance = UserInstance.new(
        @version,
        response.body,
        sid: @solution[:sid],
    )
    .new(
        @version,
        user_instance,
        response.headers,
        response.status_code
    )
end

#inspectObject

Provide a detailed, user friendly representation



190
191
192
193
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 190

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

#to_sObject

Provide a user friendly representation



183
184
185
186
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 183

def to_s
    context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
    "#<Twilio.FrontlineApi.V1.UserContext #{context}>"
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:



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 111

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

    data = Twilio::Values.of({
        'FriendlyName' => friendly_name,
        'Avatar' => avatar,
        'State' => state,
        'IsAvailable' => is_available,
    })

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

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

Update the UserInstanceMetadata

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:



146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
# File 'lib/twilio-ruby/rest/frontline_api/v1/user.rb', line 146

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

    data = Twilio::Values.of({
        'FriendlyName' => friendly_name,
        'Avatar' => avatar,
        'State' => state,
        'IsAvailable' => is_available,
    })

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