class CloudParty::Responses::Memberships
Attributes
messages[R]
results[R]
Public Class Methods
new(method_name, endpoint, response)
click to toggle source
# File lib/cloud_party/responses/memberships.rb, line 8 def initialize(method_name, endpoint, response) @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 @results = [] @body[:result].each do |res| @results << CloudParty::Responses::Result.new(res) end @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
Public Instance Methods
inspect()
click to toggle source
# File lib/cloud_party/responses/memberships.rb, line 47 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()
click to toggle source
# File lib/cloud_party/responses/memberships.rb, line 41 def result @results.first end
successful?()
click to toggle source
# File lib/cloud_party/responses/memberships.rb, line 35 def successful? @success end
Also aliased as: success
to_s()
click to toggle source
# File lib/cloud_party/responses/memberships.rb, line 59 def to_s inspect end