Class: Recurly::HTTP::Response
- Inherits:
-
Object
- Object
- Recurly::HTTP::Response
- Defined in:
- lib/recurly/http.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#content_type ⇒ Object
Returns the value of attribute content_type.
-
#date ⇒ Object
Returns the value of attribute date.
-
#proxy_metadata ⇒ Object
Returns the value of attribute proxy_metadata.
-
#rate_limit ⇒ Object
Returns the value of attribute rate_limit.
-
#rate_limit_remaining ⇒ Object
Returns the value of attribute rate_limit_remaining.
-
#rate_limit_reset ⇒ Object
Returns the value of attribute rate_limit_reset.
-
#request ⇒ Object
Returns the value of attribute request.
-
#request_id ⇒ Object
Returns the value of attribute request_id.
-
#status ⇒ Object
Returns the value of attribute status.
-
#total_records ⇒ Object
Returns the value of attribute total_records.
Instance Method Summary collapse
-
#initialize(resp, request) ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize(resp, request) ⇒ Response
Returns a new instance of Response.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/recurly/http.rb', line 9 def initialize(resp, request) @request = Request.new(request.method, request.path, request.body) @status = resp.code.to_i @request_id = resp["x-request-id"] @rate_limit = resp["x-ratelimit-limit"].to_i @rate_limit_remaining = resp["x-ratelimit-remaining"].to_i @rate_limit_reset = Time.at(resp["x-ratelimit-reset"].to_i).to_datetime @total_records = resp["recurly-total-records"]&.to_i if resp["content-type"] @content_type = resp["content-type"].split(";").first else @content_type = resp.content_type end if resp.body && !resp.body.empty? @body = resp.body else @body = nil end end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
4 5 6 |
# File 'lib/recurly/http.rb', line 4 def body @body end |
#content_type ⇒ Object
Returns the value of attribute content_type.
4 5 6 |
# File 'lib/recurly/http.rb', line 4 def content_type @content_type end |
#date ⇒ Object
Returns the value of attribute date.
4 5 6 |
# File 'lib/recurly/http.rb', line 4 def date @date end |
#proxy_metadata ⇒ Object
Returns the value of attribute proxy_metadata.
4 5 6 |
# File 'lib/recurly/http.rb', line 4 def @proxy_metadata end |
#rate_limit ⇒ Object
Returns the value of attribute rate_limit.
4 5 6 |
# File 'lib/recurly/http.rb', line 4 def rate_limit @rate_limit end |
#rate_limit_remaining ⇒ Object
Returns the value of attribute rate_limit_remaining.
4 5 6 |
# File 'lib/recurly/http.rb', line 4 def rate_limit_remaining @rate_limit_remaining end |
#rate_limit_reset ⇒ Object
Returns the value of attribute rate_limit_reset.
4 5 6 |
# File 'lib/recurly/http.rb', line 4 def rate_limit_reset @rate_limit_reset end |
#request ⇒ Object
Returns the value of attribute request.
4 5 6 |
# File 'lib/recurly/http.rb', line 4 def request @request end |
#request_id ⇒ Object
Returns the value of attribute request_id.
4 5 6 |
# File 'lib/recurly/http.rb', line 4 def request_id @request_id end |
#status ⇒ Object
Returns the value of attribute status.
4 5 6 |
# File 'lib/recurly/http.rb', line 4 def status @status end |
#total_records ⇒ Object
Returns the value of attribute total_records.
4 5 6 |
# File 'lib/recurly/http.rb', line 4 def total_records @total_records end |