Class: Recurly::HTTP::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/recurly/http.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#bodyObject

Returns the value of attribute body.



4
5
6
# File 'lib/recurly/http.rb', line 4

def body
  @body
end

#content_typeObject

Returns the value of attribute content_type.



4
5
6
# File 'lib/recurly/http.rb', line 4

def content_type
  @content_type
end

#dateObject

Returns the value of attribute date.



4
5
6
# File 'lib/recurly/http.rb', line 4

def date
  @date
end

#proxy_metadataObject

Returns the value of attribute proxy_metadata.



4
5
6
# File 'lib/recurly/http.rb', line 4

def 
  @proxy_metadata
end

#rate_limitObject

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_remainingObject

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_resetObject

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

#requestObject

Returns the value of attribute request.



4
5
6
# File 'lib/recurly/http.rb', line 4

def request
  @request
end

#request_idObject

Returns the value of attribute request_id.



4
5
6
# File 'lib/recurly/http.rb', line 4

def request_id
  @request_id
end

#statusObject

Returns the value of attribute status.



4
5
6
# File 'lib/recurly/http.rb', line 4

def status
  @status
end

#total_recordsObject

Returns the value of attribute total_records.



4
5
6
# File 'lib/recurly/http.rb', line 4

def total_records
  @total_records
end