Module: ElevenLabs::Connection
- Included in:
- Client
- Defined in:
- lib/eleven_labs/connection.rb
Overview
Network layer for API clients.
Constant Summary collapse
- DEFAULT_MEDIA_TYPE =
"application/json"
- USER_AGENT =
"ElevenLabs Ruby Gem"
- CONVENIENCE_HEADERS =
Set.new(%i[accept content_type])
Instance Method Summary collapse
-
#agent ⇒ Sawyer::Agent
Hypermedia agent for the datatrans API.
-
#delete(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP DELETE request.
-
#get(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP GET request.
-
#head(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP HEAD request.
-
#last_response ⇒ Sawyer::Response
Response for last HTTP request.
-
#patch(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP PATCH request.
-
#post(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP POST request.
-
#put(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP PUT request.
Instance Method Details
#agent ⇒ Sawyer::Agent
Hypermedia agent for the datatrans API
74 75 76 77 78 79 80 81 82 83 |
# File 'lib/eleven_labs/connection.rb', line 74 def agent @agent ||= Faraday.new(url: endpoint) do |conn| conn.request :retry conn.headers['XI-API-KEY'] = api_key conn.headers["Content-Type"] = DEFAULT_MEDIA_TYPE conn.headers["Accept"] = DEFAULT_MEDIA_TYPE conn.adapter :net_http end end |
#delete(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP DELETE request
58 59 60 |
# File 'lib/eleven_labs/connection.rb', line 58 def delete(url, = {}) request :delete, url, end |
#get(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP GET request
22 23 24 |
# File 'lib/eleven_labs/connection.rb', line 22 def get(url, = {}) request :get, url, end |
#head(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP HEAD request
67 68 69 |
# File 'lib/eleven_labs/connection.rb', line 67 def head(url, = {}) request :head, url, end |
#last_response ⇒ Sawyer::Response
Response for last HTTP request
88 89 90 |
# File 'lib/eleven_labs/connection.rb', line 88 def last_response @last_response if defined? @last_response end |
#patch(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP PATCH request
49 50 51 |
# File 'lib/eleven_labs/connection.rb', line 49 def patch(url, = {}) request :patch, url, .to_json end |
#post(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP POST request
31 32 33 |
# File 'lib/eleven_labs/connection.rb', line 31 def post(url, = {}) request :post, url, .to_json end |
#put(url, options = {}) ⇒ Sawyer::Resource
Make a HTTP PUT request
40 41 42 |
# File 'lib/eleven_labs/connection.rb', line 40 def put(url, = {}) request :put, url, .to_json end |