Class: Twilio::REST::Routes::V2::PhoneNumberInstance

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

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, phone_number: nil) ⇒ PhoneNumberInstance

Initialize the PhoneNumberInstance



152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/twilio-ruby/rest/routes/v2/phone_number.rb', line 152

def initialize(version, payload , phone_number: nil)
    super(version)
    
    # Marshaled Properties
    @properties = { 
        'phone_number' => payload['phone_number'],
        'url' => payload['url'],
        'sid' => payload['sid'],
        'account_sid' => payload['account_sid'],
        'friendly_name' => payload['friendly_name'],
        'voice_region' => payload['voice_region'],
        'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
        'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
    }

    # Context
    @instance_context = nil
    @params = { 'phone_number' => phone_number  || @properties['phone_number']  , }
end

Instance Method Details

#account_sidString



203
204
205
# File 'lib/twilio-ruby/rest/routes/v2/phone_number.rb', line 203

def 
    @properties['account_sid']
end

#contextPhoneNumberContext

Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context



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

def context
    unless @instance_context
        @instance_context = PhoneNumberContext.new(@version , @params['phone_number'])
    end
    @instance_context
end

#date_createdTime



221
222
223
# File 'lib/twilio-ruby/rest/routes/v2/phone_number.rb', line 221

def date_created
    @properties['date_created']
end

#date_updatedTime



227
228
229
# File 'lib/twilio-ruby/rest/routes/v2/phone_number.rb', line 227

def date_updated
    @properties['date_updated']
end

#fetchPhoneNumberInstance

Fetch the PhoneNumberInstance



234
235
236
237
# File 'lib/twilio-ruby/rest/routes/v2/phone_number.rb', line 234

def fetch

    context.fetch
end

#friendly_nameString



209
210
211
# File 'lib/twilio-ruby/rest/routes/v2/phone_number.rb', line 209

def friendly_name
    @properties['friendly_name']
end

#inspectObject

Provide a detailed, user friendly representation



264
265
266
267
# File 'lib/twilio-ruby/rest/routes/v2/phone_number.rb', line 264

def inspect
    values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
    "<Twilio.Routes.V2.PhoneNumberInstance #{values}>"
end

#phone_numberString



185
186
187
# File 'lib/twilio-ruby/rest/routes/v2/phone_number.rb', line 185

def phone_number
    @properties['phone_number']
end

#sidString



197
198
199
# File 'lib/twilio-ruby/rest/routes/v2/phone_number.rb', line 197

def sid
    @properties['sid']
end

#to_sObject

Provide a user friendly representation



257
258
259
260
# File 'lib/twilio-ruby/rest/routes/v2/phone_number.rb', line 257

def to_s
    values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
    "<Twilio.Routes.V2.PhoneNumberInstance #{values}>"
end

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

Update the PhoneNumberInstance



244
245
246
247
248
249
250
251
252
253
# File 'lib/twilio-ruby/rest/routes/v2/phone_number.rb', line 244

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

    context.update(
        voice_region: voice_region, 
        friendly_name: friendly_name, 
    )
end

#urlString



191
192
193
# File 'lib/twilio-ruby/rest/routes/v2/phone_number.rb', line 191

def url
    @properties['url']
end

#voice_regionString



215
216
217
# File 'lib/twilio-ruby/rest/routes/v2/phone_number.rb', line 215

def voice_region
    @properties['voice_region']
end