Class: Telnyx::Resources::Enterprises::Reputation::Numbers

Inherits:
Object
  • Object
show all
Defined in:
lib/telnyx/resources/enterprises/reputation/numbers.rb

Overview

Associate phone numbers with an enterprise for reputation monitoring and retrieve reputation scores

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Numbers

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

Parameters:



167
168
169
# File 'lib/telnyx/resources/enterprises/reputation/numbers.rb', line 167

def initialize(client:)
  @client = client
end

Instance Method Details

#associate(enterprise_id, phone_numbers:, request_options: {}) ⇒ Telnyx::Models::Enterprises::Reputation::NumberAssociateResponse

Associate one or more phone numbers with an enterprise for Number Reputation monitoring.

Validations:

  • Phone numbers must be in E.164 format (e.g., ‘+16035551234`)

  • Phone numbers must be in-service and belong to your account (verified via Warehouse)

  • Phone numbers must be US local numbers

  • Phone numbers cannot already be associated with any enterprise

Note: This operation is atomic — if any number fails validation, the entire request fails.

Maximum: 100 phone numbers per request.

Parameters:

  • enterprise_id (String)

    Unique identifier of the enterprise (UUID)

  • phone_numbers (Array<String>)

    List of phone numbers to associate for reputation monitoring (max 100)

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

Returns:

See Also:



123
124
125
126
127
128
129
130
131
132
# File 'lib/telnyx/resources/enterprises/reputation/numbers.rb', line 123

def associate(enterprise_id, params)
  parsed, options = Telnyx::Enterprises::Reputation::NumberAssociateParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["enterprises/%1$s/reputation/numbers", enterprise_id],
    body: parsed,
    model: Telnyx::Models::Enterprises::Reputation::NumberAssociateResponse,
    options: options
  )
end

#disassociate(phone_number, enterprise_id:, request_options: {}) ⇒ nil

Remove a phone number from Number Reputation monitoring for an enterprise.

The number will no longer be tracked and reputation data will no longer be refreshed.

Parameters:

  • phone_number (String)

    Phone number in E.164 format

  • enterprise_id (String)

    Unique identifier of the enterprise (UUID)

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

Returns:

  • (nil)

See Also:



150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/telnyx/resources/enterprises/reputation/numbers.rb', line 150

def disassociate(phone_number, params)
  parsed, options = Telnyx::Enterprises::Reputation::NumberDisassociateParams.dump_request(params)
  enterprise_id =
    parsed.delete(:enterprise_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :delete,
    path: ["enterprises/%1$s/reputation/numbers/%2$s", enterprise_id, phone_number],
    model: NilClass,
    options: options
  )
end

#list(enterprise_id, page_number: nil, page_size: nil, phone_number: nil, request_options: {}) ⇒ Telnyx::Internal::DefaultFlatPagination<Telnyx::Models::ReputationPhoneNumberWithReputationData>

List all phone numbers associated with an enterprise for Number Reputation monitoring.

Returns phone numbers with their cached reputation data (if available). Supports pagination and filtering by phone number.

Parameters:

  • enterprise_id (String)

    Unique identifier of the enterprise (UUID)

  • page_number (Integer)

    Page number (1-indexed)

  • page_size (Integer)

    Number of items per page

  • phone_number (String)

    Filter by specific phone number (E.164 format)

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

Returns:

See Also:



83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/telnyx/resources/enterprises/reputation/numbers.rb', line 83

def list(enterprise_id, params = {})
  parsed, options = Telnyx::Enterprises::Reputation::NumberListParams.dump_request(params)
  query = Telnyx::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: ["enterprises/%1$s/reputation/numbers", enterprise_id],
    query: query.transform_keys(page_number: "page[number]", page_size: "page[size]"),
    page: Telnyx::Internal::DefaultFlatPagination,
    model: Telnyx::ReputationPhoneNumberWithReputationData,
    options: options
  )
end

#retrieve(phone_number, enterprise_id:, fresh: nil, request_options: {}) ⇒ Telnyx::Models::Enterprises::Reputation::NumberRetrieveResponse

Some parameter documentations has been truncated, see Models::Enterprises::Reputation::NumberRetrieveParams for more details.

Get detailed reputation data for a specific phone number associated with an enterprise.

**Query Parameters:**

  • ‘fresh` (default: `false`): When `true`, fetches fresh reputation data (incurs API cost). When `false`, returns cached data. If no cached data exists, fresh data is automatically fetched.

Returns:

  • ‘spam_risk`: Overall spam risk level (`low`, `medium`, `high`)

  • ‘spam_category`: Spam category classification

  • ‘maturity_score`: Maturity metric (0–100)

  • ‘connection_score`: Connection quality metric (0–100)

  • ‘engagement_score`: Engagement metric (0–100)

  • ‘sentiment_score`: Sentiment metric (0–100)

  • ‘last_refreshed_at`: Timestamp of last data refresh

Parameters:

  • phone_number (String)

    Path param: Phone number in E.164 format

  • enterprise_id (String)

    Path param: Unique identifier of the enterprise (UUID)

  • fresh (Boolean)

    Query param: When true, fetches fresh reputation data (incurs API cost). When fa

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

Returns:

See Also:



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/telnyx/resources/enterprises/reputation/numbers.rb', line 46

def retrieve(phone_number, params)
  parsed, options = Telnyx::Enterprises::Reputation::NumberRetrieveParams.dump_request(params)
  query = Telnyx::Internal::Util.encode_query_params(parsed)
  enterprise_id =
    parsed.delete(:enterprise_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["enterprises/%1$s/reputation/numbers/%2$s", enterprise_id, phone_number],
    query: query,
    model: Telnyx::Models::Enterprises::Reputation::NumberRetrieveResponse,
    options: options
  )
end