Class: Telnyx::Resources::Whatsapp::PhoneNumbers

Inherits:
Object
  • Object
show all
Defined in:
lib/telnyx/resources/whatsapp/phone_numbers.rb,
lib/telnyx/resources/whatsapp/phone_numbers/profile.rb,
lib/telnyx/resources/whatsapp/phone_numbers/profile/photo.rb,
lib/telnyx/resources/whatsapp/phone_numbers/calling_settings.rb

Overview

Manage Whatsapp phone numbers

Defined Under Namespace

Classes: CallingSettings, Profile

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ PhoneNumbers

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 PhoneNumbers.

Parameters:



111
112
113
114
115
# File 'lib/telnyx/resources/whatsapp/phone_numbers.rb', line 111

def initialize(client:)
  @client = client
  @calling_settings = Telnyx::Resources::Whatsapp::PhoneNumbers::CallingSettings.new(client: client)
  @profile = Telnyx::Resources::Whatsapp::PhoneNumbers::Profile.new(client: client)
end

Instance Attribute Details

#calling_settingsTelnyx::Resources::Whatsapp::PhoneNumbers::CallingSettings (readonly)

Manage Whatsapp phone numbers



10
11
12
# File 'lib/telnyx/resources/whatsapp/phone_numbers.rb', line 10

def calling_settings
  @calling_settings
end

#profileTelnyx::Resources::Whatsapp::PhoneNumbers::Profile (readonly)

Manage Whatsapp phone numbers



14
15
16
# File 'lib/telnyx/resources/whatsapp/phone_numbers.rb', line 14

def profile
  @profile
end

Instance Method Details

#delete(phone_number, request_options: {}) ⇒ nil

Delete a Whatsapp phone number

Parameters:

  • phone_number (String)

    Phone number (E.164 format)

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

Returns:

  • (nil)

See Also:



51
52
53
54
55
56
57
58
# File 'lib/telnyx/resources/whatsapp/phone_numbers.rb', line 51

def delete(phone_number, params = {})
  @client.request(
    method: :delete,
    path: ["v2/whatsapp/phone_numbers/%1$s", phone_number],
    model: NilClass,
    options: params[:request_options]
  )
end

#list(page_number: nil, page_size: nil, request_options: {}) ⇒ Telnyx::Internal::DefaultFlatPagination<Telnyx::Models::Whatsapp::PhoneNumberListResponse>

List Whatsapp phone numbers

Parameters:

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

Returns:

See Also:



27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/telnyx/resources/whatsapp/phone_numbers.rb', line 27

def list(params = {})
  parsed, options = Telnyx::Whatsapp::PhoneNumberListParams.dump_request(params)
  query = Telnyx::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "v2/whatsapp/phone_numbers",
    query: query.transform_keys(page_number: "page[number]", page_size: "page[size]"),
    page: Telnyx::Internal::DefaultFlatPagination,
    model: Telnyx::Models::Whatsapp::PhoneNumberListResponse,
    options: options
  )
end

#resend_verification(phone_number, verification_method: nil, request_options: {}) ⇒ nil

Resend verification code

Parameters:

Returns:

  • (nil)

See Also:



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

def resend_verification(phone_number, params = {})
  parsed, options = Telnyx::Whatsapp::PhoneNumberResendVerificationParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["v2/whatsapp/phone_numbers/%1$s/resend_verification", phone_number],
    body: parsed,
    model: NilClass,
    options: options
  )
end

#verify(phone_number, code:, request_options: {}) ⇒ nil

Submit verification code for a phone number

Parameters:

  • phone_number (String)

    Phone number (E.164 format)

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

Returns:

  • (nil)

See Also:



97
98
99
100
101
102
103
104
105
106
# File 'lib/telnyx/resources/whatsapp/phone_numbers.rb', line 97

def verify(phone_number, params)
  parsed, options = Telnyx::Whatsapp::PhoneNumberVerifyParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["v2/whatsapp/phone_numbers/%1$s/verify", phone_number],
    body: parsed,
    model: NilClass,
    options: options
  )
end