Class: Cloudflare::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/record_store/provider/cloudflare/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_responseObject (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_messagesObject



50
51
52
# File 'lib/record_store/provider/cloudflare/response.rb', line 50

def error_messages
  errors.map { |error| error['message'] }
end

#errorsObject



42
43
44
# File 'lib/record_store/provider/cloudflare/response.rb', line 42

def errors
  json.fetch('errors', [])
end

#messagesObject



46
47
48
# File 'lib/record_store/provider/cloudflare/response.rb', line 46

def messages
  json.fetch('messages', [])
end

#resultObject



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_rawObject



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_rawObject



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_codeObject



11
12
13
# File 'lib/record_store/provider/cloudflare/response.rb', line 11

def status_code
  @http_response.code.to_i
end

#successObject



38
39
40
# File 'lib/record_store/provider/cloudflare/response.rb', line 38

def success
  json['success']
end