Sha256: f9eca24318a6588873a9e5f11c0ff947dadda8080b2e063e77739672e55da8c6

Contents?: true

Size: 699 Bytes

Versions: 2

Compression:

Stored size: 699 Bytes

Contents

# frozen_string_literal: true

# rubocop:disable Metrics/MethodLength
require 'net/http'
require 'uri'

module Trav3
  module REST
    def self.delete(travis, url)
      uri = URI( url.sub(/\?.*$/, '') )
      req = Net::HTTP::Delete.new(uri.request_uri)
      travis.headers.each_pair do |header, value|
        req[header] = value
      end
      http = Net::HTTP.new(uri.host, uri.port)
      http.use_ssl = (uri.scheme == 'https')
      response = http.request(req)

      if [Net::HTTPAccepted, Net::HTTPOK].include? response.code_type
        Success.new(travis, response)
      else
        RequestError.new(travis, response)
      end
    end
  end
end
# rubocop:enable Metrics/MethodLength

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
trav3-0.2.5 lib/trav3/rest/delete.rb
trav3-0.2.4 lib/trav3/rest/delete.rb