Module: OpConnect::Connection
- Included in:
- Client
- Defined in:
- lib/op_connect/connection.rb
Overview
Network layer for API clients.
Instance Method Summary collapse
-
#connection ⇒ Faraday::Client
Connection object for the 1Password Connect API.
-
#delete(url, params: {}, headers: {}) ⇒ Faraday::Response
Make an HTTP DELETE request.
-
#get(url, params: {}, headers: {}) ⇒ Faraday::Response
Make an HTTP GET request.
-
#last_response ⇒ Faraday::Response
Response for the last HTTP request.
-
#patch(url, body:, headers: {}) ⇒ Faraday::Response
Make an HTTP PATCH request.
-
#post(url, body:, headers: {}) ⇒ Faraday::Response
Make an HTTP POST request.
-
#put(url, body:, headers: {}) ⇒ Faraday::Response
Make an HTTP PUT request.
Instance Method Details
#connection ⇒ Faraday::Client
Connection object for the 1Password Connect API.
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/op_connect/connection.rb', line 69 def connection @connection ||= Faraday.new(api_endpoint) do |http| http.headers[:user_agent] = user_agent http.request :authorization, :Bearer, access_token http.request :json http.use OpConnect::Response::RaiseError http.response :dates http.response :json, content_type: "application/json" http.adapter adapter, @stubs end end |
#delete(url, params: {}, headers: {}) ⇒ Faraday::Response
Make an HTTP DELETE request.
61 62 63 |
# File 'lib/op_connect/connection.rb', line 61 def delete(url, params: {}, headers: {}) request :delete, url, params, headers end |
#get(url, params: {}, headers: {}) ⇒ Faraday::Response
Make an HTTP GET request.
13 14 15 |
# File 'lib/op_connect/connection.rb', line 13 def get(url, params: {}, headers: {}) request :get, url, params, headers end |
#last_response ⇒ Faraday::Response
Response for the last HTTP request.
89 90 91 |
# File 'lib/op_connect/connection.rb', line 89 def last_response @last_response if defined? @last_response end |
#patch(url, body:, headers: {}) ⇒ Faraday::Response
Make an HTTP PATCH request.
49 50 51 |
# File 'lib/op_connect/connection.rb', line 49 def patch(url, body:, headers: {}) request :patch, url, body, headers end |
#post(url, body:, headers: {}) ⇒ Faraday::Response
Make an HTTP POST request.
25 26 27 |
# File 'lib/op_connect/connection.rb', line 25 def post(url, body:, headers: {}) request :post, url, body, headers end |
#put(url, body:, headers: {}) ⇒ Faraday::Response
Make an HTTP PUT request.
37 38 39 |
# File 'lib/op_connect/connection.rb', line 37 def put(url, body:, headers: {}) request :put, url, body, headers end |