Class: Qube::HTTP
- Inherits:
-
Object
- Object
- Qube::HTTP
- Defined in:
- lib/qube/transport/http.rb
Defined Under Namespace
Classes: Response
Constant Summary collapse
- VERBS =
{ get: Net::HTTP::Get, post: Net::HTTP::Post, put: Net::HTTP::Put, delete: Net::HTTP::Delete }
Instance Method Summary collapse
- #base_headers ⇒ Object
- #delete(path, options = {}) ⇒ Object
- #get(path, options = {}) ⇒ Object
-
#initialize ⇒ HTTP
constructor
A new instance of HTTP.
- #post(path, options = {}) ⇒ Object
- #put(path, options = {}) ⇒ Object
Constructor Details
#initialize ⇒ HTTP
Returns a new instance of HTTP.
18 19 20 21 22 23 24 25 26 |
# File 'lib/qube/transport/http.rb', line 18 def initialize @config = Qube.config @connection = Net::HTTP::Persistent.new @api_uri = @config.api_uri @api_token = @config.api_token @user_agent = @config.user_agent @logger = @config.logger end |
Instance Method Details
#base_headers ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/qube/transport/http.rb', line 28 def base_headers { 'X-Auth-Token' => @api_token, 'User-Agent' => @user_agent, 'Content-Type' => 'application/json' } end |
#delete(path, options = {}) ⇒ Object
48 49 50 |
# File 'lib/qube/transport/http.rb', line 48 def delete(path, = {}) execute(path, :delete, ) end |
#get(path, options = {}) ⇒ Object
36 37 38 |
# File 'lib/qube/transport/http.rb', line 36 def get(path, = {}) execute(path, :get, ) end |
#post(path, options = {}) ⇒ Object
40 41 42 |
# File 'lib/qube/transport/http.rb', line 40 def post(path, = {}) execute(path, :post, ) end |
#put(path, options = {}) ⇒ Object
44 45 46 |
# File 'lib/qube/transport/http.rb', line 44 def put(path, = {}) execute(path, :put, ) end |