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 fetch.


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

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


198
199
200
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy.rb', line 198

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

#fetchConnectionPolicyInstance

Fetch the ConnectionPolicyInstance

Returns:


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

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

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

#inspectObject

Provide a detailed, user friendly representation


229
230
231
232
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy.rb', line 229

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)

206
207
208
209
210
211
212
213
214
215
216
217
218
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy.rb', line 206

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


222
223
224
225
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy.rb', line 222

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:


187
188
189
190
191
192
193
# File 'lib/twilio-ruby/rest/voice/v1/connection_policy.rb', line 187

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

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

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