Class: Telnyx::Resources::Addresses

Inherits:
Object
  • Object
show all
Defined in:
lib/telnyx/resources/addresses.rb,
lib/telnyx/resources/addresses/actions.rb

Overview

Operations to work with Address records. Address records are emergency-validated addresses meant to be associated with phone numbers. They are validated for emergency usage purposes at creation time, although you may validate them separately with a custom workflow using the ValidateAddress operation separately. Address records are not usable for physical orders, such as for Telnyx SIM cards, please use UserAddress for that. It is not possible to entirely skip emergency service validation for Address records; if an emergency provider for a phone number rejects the address then it cannot be used on a phone number. To prevent records from getting out of sync, Address records are immutable and cannot be altered once created. If you realize you need to alter an address, a new record must be created with the differing address.

Defined Under Namespace

Classes: Actions

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Addresses

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Addresses.

Parameters:



160
161
162
163
# File 'lib/telnyx/resources/addresses.rb', line 160

def initialize(client:)
  @client = client
  @actions = Telnyx::Resources::Addresses::Actions.new(client: client)
end

Instance Attribute Details

#actionsTelnyx::Resources::Addresses::Actions (readonly)

Operations to work with Address records. Address records are emergency-validated addresses meant to be associated with phone numbers. They are validated for emergency usage purposes at creation time, although you may validate them separately with a custom workflow using the ValidateAddress operation separately. Address records are not usable for physical orders, such as for Telnyx SIM cards, please use UserAddress for that. It is not possible to entirely skip emergency service validation for Address records; if an emergency provider for a phone number rejects the address then it cannot be used on a phone number. To prevent records from getting out of sync, Address records are immutable and cannot be altered once created. If you realize you need to alter an address, a new record must be created with the differing address.



29
30
31
# File 'lib/telnyx/resources/addresses.rb', line 29

def actions
  @actions
end

Instance Method Details

#create(business_name:, country_code:, first_name:, last_name:, locality:, street_address:, address_book: nil, administrative_area: nil, borough: nil, customer_reference: nil, extended_address: nil, neighborhood: nil, phone_number: nil, postal_code: nil, validate_address: nil, request_options: {}) ⇒ Telnyx::Models::AddressCreateResponse

Some parameter documentations has been truncated, see Models::AddressCreateParams for more details.

Creates an address.

Parameters:

  • business_name (String)

    The business name associated with the address. An address must have either a fir

  • country_code (String)

    The two-character (ISO 3166-1 alpha-2) country code of the address.

  • first_name (String)

    The first name associated with the address. An address must have either a first

  • last_name (String)

    The last name associated with the address. An address must have either a first l

  • locality (String)

    The locality of the address. For US addresses, this corresponds to the city of t

  • street_address (String)

    The primary street address information about the address.

  • address_book (Boolean)

    Indicates whether or not the address should be considered part of your list of a

  • administrative_area (String)

    The locality of the address. For US addresses, this corresponds to the state of

  • borough (String)

    The borough of the address. This field is not used for addresses in the US but i

  • customer_reference (String)

    A customer reference string for customer look ups.

  • extended_address (String)

    Additional street address information about the address such as, but not limited

  • neighborhood (String)

    The neighborhood of the address. This field is not used for addresses in the US

  • phone_number (String)

    The phone number associated with the address.

  • postal_code (String)

    The postal code of the address.

  • validate_address (Boolean)

    Indicates whether or not the address should be validated for emergency use upon

  • request_options (Telnyx::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



73
74
75
76
77
78
79
80
81
82
# File 'lib/telnyx/resources/addresses.rb', line 73

def create(params)
  parsed, options = Telnyx::AddressCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "addresses",
    body: parsed,
    model: Telnyx::Models::AddressCreateResponse,
    options: options
  )
end

#delete(id, request_options: {}) ⇒ Telnyx::Models::AddressDeleteResponse

Deletes an existing address.

Parameters:

Returns:

See Also:



148
149
150
151
152
153
154
155
# File 'lib/telnyx/resources/addresses.rb', line 148

def delete(id, params = {})
  @client.request(
    method: :delete,
    path: ["addresses/%1$s", id],
    model: Telnyx::Models::AddressDeleteResponse,
    options: params[:request_options]
  )
end

#list(filter: nil, page_number: nil, page_size: nil, sort: nil, request_options: {}) ⇒ Telnyx::Internal::DefaultFlatPagination<Telnyx::Models::Address>

Some parameter documentations has been truncated, see Models::AddressListParams for more details.

Returns a list of your addresses.

Parameters:

Returns:

See Also:



124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/telnyx/resources/addresses.rb', line 124

def list(params = {})
  parsed, options = Telnyx::AddressListParams.dump_request(params)
  query = Telnyx::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "addresses",
    query: query.transform_keys(page_number: "page[number]", page_size: "page[size]"),
    page: Telnyx::Internal::DefaultFlatPagination,
    model: Telnyx::Address,
    options: options
  )
end

#retrieve(id, request_options: {}) ⇒ Telnyx::Models::AddressRetrieveResponse

Retrieves the details of an existing address.

Parameters:

Returns:

See Also:



95
96
97
98
99
100
101
102
# File 'lib/telnyx/resources/addresses.rb', line 95

def retrieve(id, params = {})
  @client.request(
    method: :get,
    path: ["addresses/%1$s", id],
    model: Telnyx::Models::AddressRetrieveResponse,
    options: params[:request_options]
  )
end