Class: Retell::SDK::Unofficial::Client
- Inherits:
-
Object
- Object
- Retell::SDK::Unofficial::Client
- Defined in:
- lib/retell/sdk/unofficial/client.rb
Constant Summary collapse
- DEFAULT_BASE_URL =
'https://api.retellai.com'.freeze
- DEFAULT_TIMEOUT =
60
Instance Method Summary collapse
- #agent ⇒ Object
- #agents ⇒ Object
- #call ⇒ Object
- #calls(**params) ⇒ Object
- #concurrency ⇒ Object
- #delete(path, params = {}, **options) ⇒ Object
- #get(path, params = {}, **options) ⇒ Object
-
#initialize(api_key:, base_url: nil, timeout: DEFAULT_TIMEOUT) ⇒ Client
constructor
A new instance of Client.
- #make_request_options(extra_headers: nil, extra_query: nil, extra_body: nil, timeout: nil) ⇒ Object
- #patch(path, params = {}, **options) ⇒ Object
- #phone_number ⇒ Object
- #phone_numbers ⇒ Object
- #post(path, params = {}, **options) ⇒ Object
- #request(method, path, params = {}, **options) ⇒ Object
- #retell_llm ⇒ Object
- #retell_llms ⇒ Object
- #voice ⇒ Object
- #voices ⇒ Object
Constructor Details
#initialize(api_key:, base_url: nil, timeout: DEFAULT_TIMEOUT) ⇒ Client
Returns a new instance of Client.
18 19 20 21 22 |
# File 'lib/retell/sdk/unofficial/client.rb', line 18 def initialize(api_key:, base_url: nil, timeout: DEFAULT_TIMEOUT) @api_key = api_key @base_url = base_url || DEFAULT_BASE_URL @timeout = timeout end |
Instance Method Details
#agent ⇒ Object
24 25 26 |
# File 'lib/retell/sdk/unofficial/client.rb', line 24 def agent @agent ||= Retell::SDK::Unofficial::API::Agent.new(self) end |
#agents ⇒ Object
48 49 50 |
# File 'lib/retell/sdk/unofficial/client.rb', line 48 def agents agent.list end |
#call ⇒ Object
28 29 30 |
# File 'lib/retell/sdk/unofficial/client.rb', line 28 def call @call ||= Retell::SDK::Unofficial::API::Call.new(self) end |
#calls(**params) ⇒ Object
52 53 54 |
# File 'lib/retell/sdk/unofficial/client.rb', line 52 def calls(**params) call.list(**params) end |
#concurrency ⇒ Object
44 45 46 |
# File 'lib/retell/sdk/unofficial/client.rb', line 44 def concurrency @concurrency ||= Retell::SDK::Unofficial::API::Concurrency.new(self) end |
#delete(path, params = {}, **options) ⇒ Object
118 119 120 121 |
# File 'lib/retell/sdk/unofficial/client.rb', line 118 def delete(path, params = {}, **) request(:delete, path, params, **) nil end |
#get(path, params = {}, **options) ⇒ Object
106 107 108 |
# File 'lib/retell/sdk/unofficial/client.rb', line 106 def get(path, params = {}, **) request(:get, path, params, **) end |
#make_request_options(extra_headers: nil, extra_query: nil, extra_body: nil, timeout: nil) ⇒ Object
123 124 125 126 127 128 129 130 |
# File 'lib/retell/sdk/unofficial/client.rb', line 123 def (extra_headers: nil, extra_query: nil, extra_body: nil, timeout: nil) = {} [:headers] = extra_headers || {} [:query] = extra_query || {} [:body] = extra_body || {} [:timeout] = timeout if timeout end |
#patch(path, params = {}, **options) ⇒ Object
114 115 116 |
# File 'lib/retell/sdk/unofficial/client.rb', line 114 def patch(path, params = {}, **) request(:patch, path, params, **) end |
#phone_number ⇒ Object
36 37 38 |
# File 'lib/retell/sdk/unofficial/client.rb', line 36 def phone_number @phone_number ||= Retell::SDK::Unofficial::API::PhoneNumber.new(self) end |
#phone_numbers ⇒ Object
60 61 62 |
# File 'lib/retell/sdk/unofficial/client.rb', line 60 def phone_numbers phone_number.list end |
#post(path, params = {}, **options) ⇒ Object
110 111 112 |
# File 'lib/retell/sdk/unofficial/client.rb', line 110 def post(path, params = {}, **) request(:post, path, params, **) end |
#request(method, path, params = {}, **options) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/retell/sdk/unofficial/client.rb', line 68 def request(method, path, params = {}, **) url = "#{@base_url}#{path}" = { headers: headers.merge([:headers] || {}), format: :json, timeout: [:timeout] || @timeout } body_params = [:body] || {} if [:get, :delete].include?(method) [:query] = [:query].merge(params) else [:body] = [:body].merge(params) end [:query] = [:query] unless [:query].empty? if [:post, :patch].include?(method) [:body] = [:body].to_json elsif !body_params.empty? [:body] = body_params.to_json end begin response = HTTParty.send( method, url, ) rescue Net::OpenTimeout, Net::ReadTimeout, Timeout::Error, Errno::ETIMEDOUT => e raise APITimeoutError.new() end handle_response(response) end |
#retell_llm ⇒ Object
32 33 34 |
# File 'lib/retell/sdk/unofficial/client.rb', line 32 def retell_llm @retell_llm ||= Retell::SDK::Unofficial::API::RetellLLM.new(self) end |
#retell_llms ⇒ Object
56 57 58 |
# File 'lib/retell/sdk/unofficial/client.rb', line 56 def retell_llms retell_llm.list end |
#voice ⇒ Object
40 41 42 |
# File 'lib/retell/sdk/unofficial/client.rb', line 40 def voice @voice ||= Retell::SDK::Unofficial::API::Voice.new(self) end |
#voices ⇒ Object
64 65 66 |
# File 'lib/retell/sdk/unofficial/client.rb', line 64 def voices voice.list end |