Class: Pinnacle::Rcs::Client

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

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ void



9
10
11
# File 'lib/pinnacle/rcs/client.rb', line 9

def initialize(client:)
  @client = client
end

Instance Method Details

#agentsPinnacle::Agents::Client

Returns:

  • (Pinnacle::Agents::Client)


125
126
127
# File 'lib/pinnacle/rcs/client.rb', line 125

def agents
  @agents ||= Pinnacle::Rcs::Agents::Client.new(client: @client)
end

#get_agent(request_options: {}, **params) ⇒ Pinnacle::Types::RcsAgentResponse

Retrieve details of an RCS agent by its ID.

Returns the agent’s configuration including display name, description, logo, hero image, contact information, and other settings.

Parameters:

  • request_options (Hash) (defaults to: {})
  • params (Hash)

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Options Hash (**params):

  • :agent_id (String)

Returns:



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/pinnacle/rcs/client.rb', line 28

def get_agent(request_options: {}, **params)
  params = Pinnacle::Internal::Types::Utils.normalize_keys(params)
  request = Pinnacle::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "GET",
    path: "rcs/#{params[:agent_id]}",
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Pinnacle::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Pinnacle::Types::RcsAgentResponse.load(response.body)
  else
    error_class = Pinnacle::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#get_capabilities(request_options: {}, **params) ⇒ Hash[String, Pinnacle::Types::RcsCapability, nil]

Check RCS capabilities for one or more phone numbers.

This endpoint allows you to verify which RCS features (cards, buttons, etc.) are supported on specific phone numbers before sending RCS messages to them.

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/pinnacle/rcs/client.rb', line 64

def get_capabilities(request_options: {}, **params)
  params = Pinnacle::Internal::Types::Utils.normalize_keys(params)
  request = Pinnacle::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "rcs/capabilities",
    body: Pinnacle::Rcs::Types::RcsCapabilitiesQuery.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Pinnacle::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Pinnacle::Types::RcsCapabilitiesResult.load(response.body)
  else
    error_class = Pinnacle::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

Generate a link for initiating an RCS conversation with your agent.

Users can click these links to start conversations with your RCS agent directly from websites, emails, or other applications.

Parameters:

Options Hash (request_options:):

  • :base_url (String)
  • :additional_headers (Hash{String => Object})
  • :additional_query_parameters (Hash{String => Object})
  • :additional_body_parameters (Hash{String => Object})
  • :timeout_in_seconds (Integer)

Returns:



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/pinnacle/rcs/client.rb', line 101

def get_link(request_options: {}, **params)
  params = Pinnacle::Internal::Types::Utils.normalize_keys(params)
  request = Pinnacle::Internal::JSON::Request.new(
    base_url: request_options[:base_url],
    method: "POST",
    path: "rcs/link",
    body: Pinnacle::Rcs::Types::RcsLinkRequest.new(params).to_h,
    request_options: request_options
  )
  begin
    response = @client.send(request)
  rescue Net::HTTPRequestTimeout
    raise Pinnacle::Errors::TimeoutError
  end
  code = response.code.to_i
  if code.between?(200, 299)
    Pinnacle::Types::RcsLinkResult.load(response.body)
  else
    error_class = Pinnacle::Errors::ResponseError.subclass_for_code(code)
    raise error_class.new(response.body, code: code)
  end
end

#testPinnacle::Test::Client

Returns:

  • (Pinnacle::Test::Client)


135
136
137
# File 'lib/pinnacle/rcs/client.rb', line 135

def test
  @test ||= Pinnacle::Rcs::Test::Client.new(client: @client)
end

#whitelisted_numbersPinnacle::WhitelistedNumbers::Client

Returns:

  • (Pinnacle::WhitelistedNumbers::Client)


130
131
132
# File 'lib/pinnacle/rcs/client.rb', line 130

def whitelisted_numbers
  @whitelisted_numbers ||= Pinnacle::Rcs::WhitelistedNumbers::Client.new(client: @client)
end