Class: Twilio::REST::Routes::V2::TrunkContext

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

Instance Method Summary collapse

Constructor Details

#initialize(version, sip_trunk_domain) ⇒ TrunkContext

Initialize the TrunkContext

Parameters:

  • Version that contains the resource

  • The absolute URL of the SIP Trunk



50
51
52
53
54
55
56
57
58
59
# File 'lib/twilio-ruby/rest/routes/v2/trunk.rb', line 50

def initialize(version, sip_trunk_domain)
    super(version)
    

    # Path Solution
    @solution = { sip_trunk_domain: sip_trunk_domain,  }
    @uri = "/Trunks/#{@solution[:sip_trunk_domain]}"

    
end

Instance Method Details

#fetchTrunkInstance

Fetch the TrunkInstance

Returns:

  • Fetched TrunkInstance



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

def fetch

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

#fetch_with_metadataTrunkInstance

Fetch the TrunkInstanceMetadata

Returns:

  • Fetched TrunkInstance



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/routes/v2/trunk.rb', line 82

def 

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

#inspectObject

Provide a detailed, user friendly representation



178
179
180
181
# File 'lib/twilio-ruby/rest/routes/v2/trunk.rb', line 178

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

#to_sObject

Provide a user friendly representation



171
172
173
174
# File 'lib/twilio-ruby/rest/routes/v2/trunk.rb', line 171

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

#update(voice_region: :unset, friendly_name: :unset) ⇒ TrunkInstance

Update the TrunkInstance

Parameters:

  • (defaults to: :unset)

    The Inbound Processing Region used for this SIP Trunk for voice

  • (defaults to: :unset)

    A human readable description of this resource, up to 64 characters.

Returns:

  • Updated TrunkInstance



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/twilio-ruby/rest/routes/v2/trunk.rb', line 109

def update(
    voice_region: :unset, 
    friendly_name: :unset
)

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

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

#update_with_metadata(voice_region: :unset, friendly_name: :unset) ⇒ TrunkInstance

Update the TrunkInstanceMetadata

Parameters:

  • (defaults to: :unset)

    The Inbound Processing Region used for this SIP Trunk for voice

  • (defaults to: :unset)

    A human readable description of this resource, up to 64 characters.

Returns:

  • Updated TrunkInstance



138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/twilio-ruby/rest/routes/v2/trunk.rb', line 138

def (
  voice_region: :unset, 
  friendly_name: :unset
)

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

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