Class: Pinnacle::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/rcs.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key:, base_url: nil, environment: Pinnacle::Environment::DEFAULT, max_retries: nil, timeout_in_seconds: nil) ⇒ Pinnacle::Client

Parameters:

  • base_url (String) (defaults to: nil)
  • environment (Pinnacle::Environment) (defaults to: Pinnacle::Environment::DEFAULT)
  • max_retries (Long) (defaults to: nil)

    The number of times to retry a failed request, defaults to 2.

  • timeout_in_seconds (Long) (defaults to: nil)
  • api_key (String)


23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/rcs.rb', line 23

def initialize(api_key:, base_url: nil, environment: Pinnacle::Environment::DEFAULT, max_retries: nil,
               timeout_in_seconds: nil)
  @request_client = Pinnacle::RequestClient.new(
    base_url: base_url,
    environment: environment,
    max_retries: max_retries,
    timeout_in_seconds: timeout_in_seconds,
    api_key: api_key
  )
  @company = Pinnacle::CompanyClient.new(request_client: @request_client)
  @send = Pinnacle::SendClient.new(request_client: @request_client)
end

Instance Attribute Details

#companyPinnacle::CompanyClient (readonly)



13
14
15
# File 'lib/rcs.rb', line 13

def company
  @company
end

#sendPinnacle::SendClient (readonly)



15
16
17
# File 'lib/rcs.rb', line 15

def send
  @send
end

Instance Method Details

#get_rcs_functionality(phone_number: nil, request_options: nil) ⇒ Pinnacle::RcsFunctionalities

Retrieve the RCS functionality of a phone number. For example checks if a phone

number can receive RCS message and if it can receive RCS carousels.

Examples:

api = Pinnacle::Client.new(
  base_url: "https://api.example.com",
  environment: Pinnacle::Environment::DEFAULT,
  api_key: "YOUR_API_KEY"
)
api.get_rcs_functionality

Parameters:

  • phone_number (String) (defaults to: nil)

    The phone number to check for RCS functionality. Should be in E.164 format (i.e. +12345678901).

  • request_options (Pinnacle::RequestOptions) (defaults to: nil)

Returns:



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/rcs.rb', line 50

def get_rcs_functionality(phone_number: nil, request_options: nil)
  response = @request_client.conn.get do |req|
    req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
    req.headers["PINNACLE-API-Key"] = request_options.api_key unless request_options&.api_key.nil?
    req.headers = {
  **(req.headers || {}),
  **@request_client.get_headers,
  **(request_options&.additional_headers || {})
    }.compact
    req.params = { **(request_options&.additional_query_parameters || {}), "phoneNumber": phone_number }.compact
    unless request_options.nil? || request_options&.additional_body_parameters.nil?
      req.body = { **(request_options&.additional_body_parameters || {}) }.compact
    end
    req.url "#{@request_client.get_url(request_options: request_options)}/rcs_functionality"
  end
  Pinnacle::RcsFunctionalities.from_json(json_object: response.body)
end