Sha256: 1f9beee84c2b1ec5ec631ff36a481d7f9bfb894e9c0112ec32598fd5f5401d07

Contents?: true

Size: 699 Bytes

Versions: 1

Compression:

Stored size: 699 Bytes

Contents

# frozen_string_literal: true

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

module Trav3
  module DELETE
    def self.call(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

1 entries across 1 versions & 1 rubygems

Version Path
trav3-0.2.3 lib/trav3/delete.rb