Class: Twilio::REST::Messaging::V1::ServiceContext::ShortCodeInstance

Inherits:
InstanceResource
  • Object
show all
Defined in:
lib/twilio-ruby/rest/messaging/v1/service/short_code.rb

Overview

PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, service_sid: nil, sid: nil) ⇒ ShortCodeInstance

Initialize the ShortCodeInstance

Parameters:

  • version (Version) —

    Version that contains the resource

  • payload (Hash) —

    payload that contains response from Twilio

  • service_sid (String) (defaults to: nil) —

    The SID of the Service this resource is associated with.

  • sid (String) (defaults to: nil) —

    The Twilio-provided string that uniquely identifies the ShortCode resource to fetch



240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
# File 'lib/twilio-ruby/rest/messaging/v1/service/short_code.rb', line 240

def initialize(version, payload, service_sid: nil, sid: nil)
  super(version)

  # Marshaled Properties
  @properties = {
      'sid' => payload['sid'],
      'account_sid' => payload['account_sid'],
      'service_sid' => payload['service_sid'],
      'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
      'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
      'short_code' => payload['short_code'],
      'country_code' => payload['country_code'],
      'capabilities' => payload['capabilities'],
      'url' => payload['url'],
  }

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

Instance Method Details

#account_sid ⇒ String

Returns The SID of the Account that created this resource.

Returns:

  • (String) —

    The SID of the Account that created this resource



280
281
282
# File 'lib/twilio-ruby/rest/messaging/v1/service/short_code.rb', line 280

def 
  @properties['account_sid']
end

#capabilities ⇒ Hash

Returns Any array of values that indicate whether the number can receive calls or messages.

Returns:

  • (Hash) —

    Any array of values that indicate whether the number can receive calls or messages.



316
317
318
# File 'lib/twilio-ruby/rest/messaging/v1/service/short_code.rb', line 316

def capabilities
  @properties['capabilities']
end

#context ⇒ ShortCodeContext

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

Returns:



265
266
267
268
269
270
# File 'lib/twilio-ruby/rest/messaging/v1/service/short_code.rb', line 265

def context
  unless @instance_context
    @instance_context = ShortCodeContext.new(@version, @params['service_sid'], @params['sid'], )
  end
  @instance_context
end

#country_code ⇒ String

Returns The 2-character ISO Country Code of the number.

Returns:

  • (String) —

    The 2-character ISO Country Code of the number.



310
311
312
# File 'lib/twilio-ruby/rest/messaging/v1/service/short_code.rb', line 310

def country_code
  @properties['country_code']
end

#date_created ⇒ Time

Returns The RFC 2822 date and time in GMT that this resource was created.

Returns:

  • (Time) —

    The RFC 2822 date and time in GMT that this resource was created



292
293
294
# File 'lib/twilio-ruby/rest/messaging/v1/service/short_code.rb', line 292

def date_created
  @properties['date_created']
end

#date_updated ⇒ Time

Returns The RFC 2822 date and time in GMT that this resource was last updated.

Returns:

  • (Time) —

    The RFC 2822 date and time in GMT that this resource was last updated



298
299
300
# File 'lib/twilio-ruby/rest/messaging/v1/service/short_code.rb', line 298

def date_updated
  @properties['date_updated']
end

#delete ⇒ Boolean

Deletes the ShortCodeInstance

Returns:

  • (Boolean) —

    true if delete succeeds, true otherwise



329
330
331
# File 'lib/twilio-ruby/rest/messaging/v1/service/short_code.rb', line 329

def delete
  context.delete
end

#fetch ⇒ ShortCodeInstance

Fetch a ShortCodeInstance

Returns:



336
337
338
# File 'lib/twilio-ruby/rest/messaging/v1/service/short_code.rb', line 336

def fetch
  context.fetch
end

#inspect ⇒ Object

Provide a detailed, user friendly representation



349
350
351
352
# File 'lib/twilio-ruby/rest/messaging/v1/service/short_code.rb', line 349

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

#service_sid ⇒ String

Returns The SID of the Service that this resource is associated with.

Returns:

  • (String) —

    The SID of the Service that this resource is associated with



286
287
288
# File 'lib/twilio-ruby/rest/messaging/v1/service/short_code.rb', line 286

def service_sid
  @properties['service_sid']
end

#short_code ⇒ String

Returns The E.164 format of the short code.

Returns:

  • (String) —

    The E.164 format of the short code.



304
305
306
# File 'lib/twilio-ruby/rest/messaging/v1/service/short_code.rb', line 304

def short_code
  @properties['short_code']
end

#sid ⇒ String

Returns The unique string that identifies this resource.

Returns:

  • (String) —

    The unique string that identifies this resource



274
275
276
# File 'lib/twilio-ruby/rest/messaging/v1/service/short_code.rb', line 274

def sid
  @properties['sid']
end

#to_s ⇒ Object

Provide a user friendly representation



342
343
344
345
# File 'lib/twilio-ruby/rest/messaging/v1/service/short_code.rb', line 342

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

#url ⇒ String

Returns The absolute URL of this ShortCode resource.

Returns:

  • (String) —

    The absolute URL of this ShortCode resource



322
323
324
# File 'lib/twilio-ruby/rest/messaging/v1/service/short_code.rb', line 322

def url
  @properties['url']
end