Class: Oncall::HTTP
- Inherits:
-
Object
- Object
- Oncall::HTTP
- Defined in:
- lib/oncall/http.rb
Instance Attribute Summary collapse
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#params ⇒ Object
Returns the value of attribute params.
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
- #get ⇒ Object
-
#initialize(path, **opts) ⇒ HTTP
constructor
A new instance of HTTP.
- #post ⇒ Object
- #response_body ⇒ Object
- #response_code ⇒ Object
Constructor Details
#initialize(path, **opts) ⇒ HTTP
Returns a new instance of HTTP.
5 6 7 8 9 10 11 |
# File 'lib/oncall/http.rb', line 5 def initialize(path, **opts) @path = path @client = Net::HTTP.new(Oncall..host, Oncall..port) @headers = opts[:headers] || { 'User-Agent' => "#{Oncall::SCRIPT}/#{Oncall::VERSION}" } @params = opts[:params] || {} @query = opts[:query] || {} end |
Instance Attribute Details
#headers ⇒ Object
Returns the value of attribute headers.
3 4 5 |
# File 'lib/oncall/http.rb', line 3 def headers @headers end |
#params ⇒ Object
Returns the value of attribute params.
3 4 5 |
# File 'lib/oncall/http.rb', line 3 def params @params end |
#path ⇒ Object
Returns the value of attribute path.
3 4 5 |
# File 'lib/oncall/http.rb', line 3 def path @path end |
Instance Method Details
#get ⇒ Object
13 14 15 16 |
# File 'lib/oncall/http.rb', line 13 def get request = Net::HTTP::Get.new(uri) @response = @client.request(request) end |
#post ⇒ Object
18 19 20 21 |
# File 'lib/oncall/http.rb', line 18 def post request = Net::HTTP::Post.new(uri) @response = @client.request(request) end |
#response_body ⇒ Object
23 24 25 |
# File 'lib/oncall/http.rb', line 23 def response_body @response.body end |
#response_code ⇒ Object
27 28 29 |
# File 'lib/oncall/http.rb', line 27 def response_code @response.code end |