Class: Twilio::REST::Numbers::V1::PortingPortabilityContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/numbers/v1/porting_portability.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, phone_number) ⇒ PortingPortabilityContext

Initialize the PortingPortabilityContext

Parameters:

  • version (Version)

    Version that contains the resource

  • phone_number (String)

    Phone number to check portability in e164 format.



49
50
51
52
53
54
55
56
57
# File 'lib/twilio-ruby/rest/numbers/v1/porting_portability.rb', line 49

def initialize(version, phone_number)
    super(version)

    # Path Solution
    @solution = { phone_number: phone_number,  }
    @uri = "/Porting/Portability/PhoneNumber/#{CGI.escape(@solution[:phone_number]).gsub("+", "%20")}"

    
end

Instance Method Details

#fetch(target_account_sid: :unset, address_sid: :unset) ⇒ PortingPortabilityInstance

Fetch the PortingPortabilityInstance

Parameters:

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

    Account Sid to which the number will be ported. This can be used to determine if a sub account already has the number in its inventory or a different sub account. If this is not provided, the authenticated account will be assumed to be the target account.

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

    Address Sid of customer to which the number will be ported.

Returns:



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/twilio-ruby/rest/numbers/v1/porting_portability.rb', line 63

def fetch(
    target_account_sid: :unset, 
    address_sid: :unset
)

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

#inspectObject

Provide a detailed, user friendly representation



96
97
98
99
# File 'lib/twilio-ruby/rest/numbers/v1/porting_portability.rb', line 96

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

#to_sObject

Provide a user friendly representation



89
90
91
92
# File 'lib/twilio-ruby/rest/numbers/v1/porting_portability.rb', line 89

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