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

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

Instance Method Summary collapse

Constructor Details

#initialize(version, connection_policy_sid, sid) ⇒ ConnectionPolicyTargetContext

Initialize the ConnectionPolicyTargetContext

Parameters:

  • version (Version)

    Version that contains the resource

  • connection_policy_sid (String)

    The SID of the Connection Policy that owns the Target.

  • sid (String)

    The unique string that we created to identify the Target resource to fetch.



199
200
201
202
203
204
205
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb', line 199

def initialize(version, connection_policy_sid, sid)
  super(version)

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

Instance Method Details

#deleteBoolean

Deletes the ConnectionPolicyTargetInstance

Returns:

  • (Boolean)

    true if delete succeeds, false otherwise



268
269
270
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb', line 268

def delete
  @version.delete('delete', @uri)
end

#fetchConnectionPolicyTargetInstance

Fetch a ConnectionPolicyTargetInstance

Returns:



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

def fetch
  params = Twilio::Values.of({})

  payload = @version.fetch(
      'GET',
      @uri,
      params,
  )

  ConnectionPolicyTargetInstance.new(
      @version,
      payload,
      connection_policy_sid: @solution[:connection_policy_sid],
      sid: @solution[:sid],
  )
end

#inspectObject

Provide a detailed, user friendly representation



281
282
283
284
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb', line 281

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

#to_sObject

Provide a user friendly representation



274
275
276
277
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb', line 274

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

#update(friendly_name: :unset, target: :unset, priority: :unset, weight: :unset, enabled: :unset) ⇒ ConnectionPolicyTargetInstance

Update the ConnectionPolicyTargetInstance

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.

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

    The SIP address you want Twilio to route your calls to. This must be a sip: schema. sips is NOT supported.

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

    The relative importance of the target. Can be an integer from 0 to 65535, inclusive. The lowest number represents the most important target.

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

    The value that determines the relative share of the load the Target should receive compared to other Targets with the same priority. Can be an integer from 1 to 65535, inclusive. Targets with higher values receive more load than those with lower ones with the same priority.

  • enabled (Boolean) (defaults to: :unset)

    Whether the Target is enabled.

Returns:



242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb', line 242

def update(friendly_name: :unset, target: :unset, priority: :unset, weight: :unset, enabled: :unset)
  data = Twilio::Values.of({
      'FriendlyName' => friendly_name,
      'Target' => target,
      'Priority' => priority,
      'Weight' => weight,
      'Enabled' => enabled,
  })

  payload = @version.update(
      'POST',
      @uri,
      data: data,
  )

  ConnectionPolicyTargetInstance.new(
      @version,
      payload,
      connection_policy_sid: @solution[:connection_policy_sid],
      sid: @solution[:sid],
  )
end