Class: ShopifyCLI::HttpRequest
- Inherits:
-
Object
- Object
- ShopifyCLI::HttpRequest
- Defined in:
- lib/shopify_cli/http_request.rb
Class Method Summary collapse
- .delete(uri, body, headers) ⇒ Object
- .get(uri, body, headers) ⇒ Object
- .post(uri, body, headers) ⇒ Object
- .put(uri, body, headers) ⇒ Object
- .request(uri, body, headers, req) ⇒ Object
Class Method Details
.delete(uri, body, headers) ⇒ Object
22 23 24 25 |
# File 'lib/shopify_cli/http_request.rb', line 22 def delete(uri, body, headers) req = ::Net::HTTP::Delete.new(uri.request_uri) request(uri, body, headers, req) end |
.get(uri, body, headers) ⇒ Object
17 18 19 20 |
# File 'lib/shopify_cli/http_request.rb', line 17 def get(uri, body, headers) req = ::Net::HTTP::Get.new(uri.request_uri) request(uri, body, headers, req) end |
.post(uri, body, headers) ⇒ Object
7 8 9 10 |
# File 'lib/shopify_cli/http_request.rb', line 7 def post(uri, body, headers) req = ::Net::HTTP::Post.new(uri.request_uri) request(uri, body, headers, req) end |
.put(uri, body, headers) ⇒ Object
12 13 14 15 |
# File 'lib/shopify_cli/http_request.rb', line 12 def put(uri, body, headers) req = ::Net::HTTP::Put.new(uri.request_uri) request(uri, body, headers, req) end |
.request(uri, body, headers, req) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/shopify_cli/http_request.rb', line 27 def request(uri, body, headers, req) cert_store = OpenSSL::X509::Store.new cert_store.set_default_paths http = ::Net::HTTP.new(uri.host, uri.port) http.use_ssl = true http.cert_store = cert_store http.verify_mode = OpenSSL::SSL::VERIFY_NONE if ENV["SSL_VERIFY_NONE"] req.body = body unless body.nil? req["Content-Type"] = "application/json" headers.each { |header, value| req[header] = value } http.request(req) end |