Class: CloudParty::Responses::IPs
Instance Attribute Summary collapse
Instance Method Summary
collapse
#check_result_type, #filter_by_account, included
Constructor Details
#initialize(method_name, endpoint, response, options) ⇒ IPs
Returns a new instance of IPs.
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/cloud_party/responses/ips.rb', line 9
def initialize(method_name, endpoint, response, options)
@code = response.code
@body = JSON.parse(response.body, symbolize_names: true)
@success = @body[:success]
unless successful?
message = <<~MESSAGE
Unable to #{method_name.to_s.upcase} to endpoint:
#{endpoint}. Inspect CloudParty::APIError#response
for further details
MESSAGE
raise CloudParty::APIError.new(message, response)
end
@result = CloudParty::Responses::Result.new(@body[:result])
@results = [@result]
@errors = []
@body[:errors].each do |err|
@errors << CloudParty::Responses::Error.new(err)
end
@messages = []
@body[:messages].each do |msg|
@messages << CloudParty::Responses::Message.new(msg)
end
end
|
Instance Attribute Details
#messages ⇒ Object
Returns the value of attribute messages.
45
46
47
|
# File 'lib/cloud_party/responses/ips.rb', line 45
def messages
@messages
end
|
#results ⇒ Object
Returns the value of attribute results.
51
52
53
|
# File 'lib/cloud_party/responses/ips.rb', line 51
def results
@results
end
|
Instance Method Details
#code ⇒ Object
38
39
40
|
# File 'lib/cloud_party/responses/ips.rb', line 38
def code
@code
end
|
#inspect ⇒ Object
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/cloud_party/responses/ips.rb', line 53
def inspect
wanted_methods = %i[errors messages success results result]
our_methods = methods.select do |m|
wanted_methods.include? m
end
outputs = []
our_methods.each do |m|
outputs << "#{m}=#{send(m)}"
end
"#<Response: #{outputs.join(', ')}>"
end
|
#result ⇒ Object
47
48
49
|
# File 'lib/cloud_party/responses/ips.rb', line 47
def result
@results.first
end
|
#successful? ⇒ Boolean
Also known as:
success
41
42
43
|
# File 'lib/cloud_party/responses/ips.rb', line 41
def successful?
@success
end
|
#to_s ⇒ Object
65
66
67
|
# File 'lib/cloud_party/responses/ips.rb', line 65
def to_s
inspect
end
|