Class: Cloudflare::Response
- Inherits:
-
Object
- Object
- Cloudflare::Response
- Defined in:
- lib/record_store/provider/cloudflare/response.rb
Instance Attribute Summary collapse
-
#http_response ⇒ Object
readonly
Returns the value of attribute http_response.
Instance Method Summary collapse
- #error_messages ⇒ Object
- #errors ⇒ Object
-
#initialize(http_response) ⇒ Response
constructor
A new instance of Response.
- #messages ⇒ Object
- #result ⇒ Object
- #result_info_raw ⇒ Object
- #result_raw ⇒ Object
- #status_code ⇒ Object
- #success ⇒ Object
Constructor Details
#initialize(http_response) ⇒ Response
Returns a new instance of Response.
7 8 9 |
# File 'lib/record_store/provider/cloudflare/response.rb', line 7 def initialize(http_response) @http_response = http_response end |
Instance Attribute Details
#http_response ⇒ Object (readonly)
Returns the value of attribute http_response.
5 6 7 |
# File 'lib/record_store/provider/cloudflare/response.rb', line 5 def http_response @http_response end |
Instance Method Details
#error_messages ⇒ Object
50 51 52 |
# File 'lib/record_store/provider/cloudflare/response.rb', line 50 def errors.map { |error| error['message'] } end |
#errors ⇒ Object
42 43 44 |
# File 'lib/record_store/provider/cloudflare/response.rb', line 42 def errors json.fetch('errors', []) end |
#messages ⇒ Object
46 47 48 |
# File 'lib/record_store/provider/cloudflare/response.rb', line 46 def json.fetch('messages', []) end |
#result ⇒ Object
23 24 25 26 27 28 |
# File 'lib/record_store/provider/cloudflare/response.rb', line 23 def result result = result_raw return result.first if result.is_a?(Array) result end |
#result_info_raw ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/record_store/provider/cloudflare/response.rb', line 30 def result_info_raw result_info_raw = json['result_info'] return if result_info_raw.nil? || result_info_raw.empty? || !success result_info_raw end |
#result_raw ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/record_store/provider/cloudflare/response.rb', line 15 def result_raw result = json['result'] return if result.nil? || result.empty? || !success result end |
#status_code ⇒ Object
11 12 13 |
# File 'lib/record_store/provider/cloudflare/response.rb', line 11 def status_code @http_response.code.to_i end |
#success ⇒ Object
38 39 40 |
# File 'lib/record_store/provider/cloudflare/response.rb', line 38 def success json['success'] end |