Sha256: 7494eb63c21c6021c9a9039cc8de53de82643126da781916342c978d4d11d695

Contents?: true

Size: 682 Bytes

Versions: 11

Compression:

Stored size: 682 Bytes

Contents

require "net/http"

module ShopifyCli
  class HttpRequest
    class << self
      def post(uri, body, headers)
        req = ::Net::HTTP::Post.new(uri.request_uri)
        request(uri, body, headers, req)
      end

      def get(uri, body, headers)
        req = ::Net::HTTP::Get.new(uri.request_uri)
        request(uri, body, headers, req)
      end

      def request(uri, body, headers, req)
        http = ::Net::HTTP.new(uri.host, uri.port)
        http.use_ssl = true

        req.body = body unless body.nil?
        req["Content-Type"] = "application/json"
        headers.each { |header, value| req[header] = value }
        http.request(req)
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
shopify-cli-1.14.0 lib/shopify-cli/http_request.rb
shopify-cli-1.13.1 lib/shopify-cli/http_request.rb
shopify-cli-1.13.0 lib/shopify-cli/http_request.rb
shopify-cli-1.12.0 lib/shopify-cli/http_request.rb
shopify-cli-1.11.0 lib/shopify-cli/http_request.rb
shopify-cli-1.10.0 lib/shopify-cli/http_request.rb
shopify-cli-1.9.1 lib/shopify-cli/http_request.rb
shopify-cli-1.9.0 lib/shopify-cli/http_request.rb
shopify-cli-1.8.0 lib/shopify-cli/http_request.rb
shopify-cli-1.7.1 lib/shopify-cli/http_request.rb
shopify-cli-1.7.0 lib/shopify-cli/http_request.rb