Sha256: 7949b5f4d70b743e32fda53267bcec4d8ac7766a155725a49cccee20b2bc1b60

Contents?: true

Size: 470 Bytes

Versions: 3

Compression:

Stored size: 470 Bytes

Contents

require 'http'

module Selly
  module Operations
    module Destroy
      def destroy(resource_id, params = {})
        response = HTTP.delete("#{API_ROOT}#{resource_url}/#{resource_id}", headers: Selly.request_headers, json: params)

        parsed = response.parse
        if parsed.class == Hash && (response.code < 200 || response.code > 300)
          raise SellyError.new(parsed['errors']), parsed['message']
        end

        parsed
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
selly-2.0.9 lib/selly/operations/destroy.rb
selly-2.0.8 lib/selly/operations/destroy.rb
selly-2.0.7 lib/selly/operations/destroy.rb