Class: Digto::Session
- Inherits:
-
Object
- Object
- Digto::Session
- Defined in:
- lib/digto.rb
Overview
Session
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#headers ⇒ Object
Returns the value of attribute headers.
-
#method ⇒ Object
Returns the value of attribute method.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(url, res) ⇒ Session
constructor
A new instance of Session.
- #response(status = 200, headers = {}, data = { body: '' }) ⇒ Object
Constructor Details
#initialize(url, res) ⇒ Session
Returns a new instance of Session.
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/digto.rb', line 35 def initialize(url, res) @url = res.headers['Digto-URL'] @method = res.headers['Digto-Method'] @headers = res.headers @body = res.body @api_url = url @res = res @done = false end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
33 34 35 |
# File 'lib/digto.rb', line 33 def body @body end |
#headers ⇒ Object
Returns the value of attribute headers.
33 34 35 |
# File 'lib/digto.rb', line 33 def headers @headers end |
#method ⇒ Object
Returns the value of attribute method.
33 34 35 |
# File 'lib/digto.rb', line 33 def method @method end |
#url ⇒ Object
Returns the value of attribute url.
33 34 35 |
# File 'lib/digto.rb', line 33 def url @url end |
Instance Method Details
#response(status = 200, headers = {}, data = { body: '' }) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/digto.rb', line 46 def response(status = 200, headers = {}, data = { body: '' }) raise 'already sent response' if @done @done = true headers['Digto-ID'] = @res.headers['Digto-ID'] headers['Digto-Status'] = status res = HTTP.headers(headers).post(@api_url, data) Digto.check_res_err(res) res end |