Class: Telnyx::Resources::CallReasons

Inherits:
Object
  • Object
show all
Defined in:
lib/telnyx/resources/call_reasons.rb

Overview

Static reference values the API accepts: call reasons, document types, rejection types.

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ CallReasons

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

Parameters:



72
73
74
# File 'lib/telnyx/resources/call_reasons.rb', line 72

def initialize(client:)
  @client = client
end

Instance Method Details

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

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

Telnyx maintains a library of pre-vetted call-reason phrases (e.g. “Appointment reminders”, “Billing inquiries”) that carry through DIR vetting smoothly. You can use any string that fits your use case in ‘DirCreateRequest.call_reasons`, but matching one of these reduces the chance the vetting team flags the phrasing for clarification.

Parameters:

  • page_number (Integer)

    1-based page number. Out-of-range values return an empty page with correct meta.

  • page_size (Integer)

    Items per page. Default ‘100` for this endpoint (the call-reason library is smal

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

Returns:

See Also:



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

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

#validate(body:, request_options: {}) ⇒ Telnyx::Models::CallReasonValidateResponse

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

Check up to 10 candidate ‘call_reasons` strings against Telnyx’s vetting heuristics before sending them on a DIR create or update. The endpoint flags strings that are likely to be rejected during vetting (too generic, banned phrases, length issues, etc.) so you can fix them up front.

Parameters:

  • body (Array<String>)

    **Bare JSON array** of candidate call-reason strings (NOT an object - there is n

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

Returns:

See Also:



58
59
60
61
62
63
64
65
66
67
# File 'lib/telnyx/resources/call_reasons.rb', line 58

def validate(params)
  parsed, options = Telnyx::CallReasonValidateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "call_reasons/validate",
    body: parsed[:body],
    model: Telnyx::Models::CallReasonValidateResponse,
    options: options
  )
end