Class: Twilio::REST::FlexApi::V2::FlexUserContext

Inherits:
InstanceContext show all
Defined in:
lib/twilio-ruby/rest/flex_api/v2/flex_user.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, instance_sid, flex_user_sid) ⇒ FlexUserContext

Initialize the FlexUserContext

Parameters:

  • Version that contains the resource

  • The unique ID created by Twilio to identify a Flex instance.

  • The unique id for the flex user.



51
52
53
54
55
56
57
58
59
60
# File 'lib/twilio-ruby/rest/flex_api/v2/flex_user.rb', line 51

def initialize(version, instance_sid, flex_user_sid)
    super(version)
    

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

    
end

Instance Method Details

#fetchFlexUserInstance

Fetch the FlexUserInstance

Returns:

  • Fetched FlexUserInstance



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/twilio-ruby/rest/flex_api/v2/flex_user.rb', line 64

def fetch

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

#fetch_with_metadataFlexUserInstance

Fetch the FlexUserInstanceMetadata

Returns:

  • Fetched FlexUserInstance



84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/twilio-ruby/rest/flex_api/v2/flex_user.rb', line 84

def 

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

#inspectObject

Provide a detailed, user friendly representation



189
190
191
192
# File 'lib/twilio-ruby/rest/flex_api/v2/flex_user.rb', line 189

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

#to_sObject

Provide a user friendly representation



182
183
184
185
# File 'lib/twilio-ruby/rest/flex_api/v2/flex_user.rb', line 182

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

#update(email: :unset, user_sid: :unset, locale: :unset) ⇒ FlexUserInstance

Update the FlexUserInstance

Parameters:

  • (defaults to: :unset)

    Email of the User.

  • (defaults to: :unset)

    The unique SID identifier of the Twilio Unified User.

  • (defaults to: :unset)

    The locale preference of the user.

Returns:

  • Updated FlexUserInstance



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
138
# File 'lib/twilio-ruby/rest/flex_api/v2/flex_user.rb', line 113

def update(
    email: :unset, 
    user_sid: :unset, 
    locale: :unset
)

    data = Twilio::Values.of({
        'Email' => email,
        'UserSid' => user_sid,
        'Locale' => locale,
    })

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

#update_with_metadata(email: :unset, user_sid: :unset, locale: :unset) ⇒ FlexUserInstance

Update the FlexUserInstanceMetadata

Parameters:

  • (defaults to: :unset)

    Email of the User.

  • (defaults to: :unset)

    The unique SID identifier of the Twilio Unified User.

  • (defaults to: :unset)

    The locale preference of the user.

Returns:

  • Updated FlexUserInstance



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
# File 'lib/twilio-ruby/rest/flex_api/v2/flex_user.rb', line 146

def (
  email: :unset, 
  user_sid: :unset, 
  locale: :unset
)

    data = Twilio::Values.of({
        'Email' => email,
        'UserSid' => user_sid,
        'Locale' => locale,
    })

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