Class: Twilio::REST::Voice::V1::ConnectionPolicyContext

Inherits:
InstanceContext show all
Defined in:
lib/twilio-ruby/rest/voice/v1/connection_policy.rb,
lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb

Defined Under Namespace

Classes: ConnectionPolicyTargetContext, ConnectionPolicyTargetInstance, ConnectionPolicyTargetList, ConnectionPolicyTargetPage

Instance Method Summary collapse

Constructor Details

#initialize(version, sid) ⇒ ConnectionPolicyContext

Initialize the ConnectionPolicyContext

Parameters:

  • version (Version)

    Version that contains the resource

  • sid (String)

    The unique string that we created to identify the Connection Policy resource to update.



161
162
163
164
165
166
167
168
169
170
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy.rb', line 161

def initialize(version, sid)
    super(version)

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

    # Dependents
    @targets = nil
end

Instance Method Details

#deleteBoolean

Delete the ConnectionPolicyInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



174
175
176
177
178
179
180
181
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy.rb', line 174

def delete

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

#fetchConnectionPolicyInstance

Fetch the ConnectionPolicyInstance

Returns:



186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy.rb', line 186

def fetch

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

#inspectObject

Provide a detailed, user friendly representation



257
258
259
260
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy.rb', line 257

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

#targets(sid = :unset) ⇒ ConnectionPolicyTargetList, ConnectionPolicyTargetContext

Access the targets

Returns:

Raises:

  • (ArgumentError)


232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy.rb', line 232

def targets(sid=:unset)

    raise ArgumentError, 'sid cannot be nil' if sid.nil?

    if sid != :unset
        return ConnectionPolicyTargetContext.new(@version, @solution[:sid],sid )
    end

    unless @targets
        @targets = ConnectionPolicyTargetList.new(
            @version, connection_policy_sid: @solution[:sid], )
    end

 @targets
end

#to_sObject

Provide a user friendly representation



250
251
252
253
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy.rb', line 250

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

#update(friendly_name: :unset) ⇒ ConnectionPolicyInstance

Update the ConnectionPolicyInstance

Parameters:

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

    A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long.

Returns:



206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy.rb', line 206

def update(
    friendly_name: :unset
)

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

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