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.



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

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:



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

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

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

Fetch the PortingPortabilityInstanceMetadata

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:



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/twilio-ruby/rest/numbers/v1/porting_portability.rb', line 93

def (
  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', })
    
    
    
    
    
    response = @version.('GET', @uri, params: params, headers: headers)
    porting_portability_instance = PortingPortabilityInstance.new(
        @version,
        response.body,
        phone_number: @solution[:phone_number],
    )
    .new(
        @version,
        porting_portability_instance,
        response.headers,
        response.status_code
    )
end

#inspectObject

Provide a detailed, user friendly representation



132
133
134
135
# File 'lib/twilio-ruby/rest/numbers/v1/porting_portability.rb', line 132

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

#to_sObject

Provide a user friendly representation



125
126
127
128
# File 'lib/twilio-ruby/rest/numbers/v1/porting_portability.rb', line 125

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