Sha256: 3df4388fe9e274638b350af136afb5f41e779aac3657c0f476653a4b80e0a7b2
Contents?: true
Size: 1.43 KB
Versions: 81
Compression:
Stored size: 1.43 KB
Contents
module Alula module ApiOperations module Delete def self.extended(base) base.include(InstanceMethods) end module InstanceMethods def delete # payload = { # data: { # id: id, # attributes: as_patchable_json # } # } response = Alula::Client.request(:delete, resource_url) return true if response.ok? handle_errors(response) end private def handle_errors(response) # Should never see a 300-range response code if (300..399).cover?(response.http_status) raise Alula::UnknownError, "The Alula-Ruby gem encountered a response code of #{response.code}, that should not happen" # Server errors, malformed crap, etc elsif (500..599).cover?(response.http_status) return AlulaError.for_response(response) # Validation errors usually elsif (400..499).cover?(response.http_status) model_errors = Util.model_errors_from_response(response) if model_errors annotate_errors(model_errors) return false else return AlulaError.for_response(response) end else raise Alula::UnknownError, "Unknown HTTP response code, aborting. Code: #{response.http_status}" end end end end end end
Version data entries
81 entries across 81 versions & 1 rubygems