Sha256: 76f3c2bd10f845c95db72dde2a20d29c472f3be22bd95cf5981b1ed34b358556
Contents?: true
Size: 945 Bytes
Versions: 1
Compression:
Stored size: 945 Bytes
Contents
require 'net/http' require 'net/https' module Spreedly class Connection attr_accessor :endpoint def initialize(endpoint) @endpoint = URI.parse(endpoint) end def request(method, body, headers = {}) case method when :get http.get(endpoint.request_uri, headers) when :post http.post(endpoint.request_uri, body, headers) when :put http.put(endpoint.request_uri, body, headers) when :delete http.delete(endpoint.request_uri, headers) else raise ArgumentError, "Unsupported request method #{method.to_s.upcase}" end end private def http http = Net::HTTP.new(endpoint.host, endpoint.port) http.open_timeout = 60 http.read_timeout = 60 http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_PEER http.ca_file = File.dirname(__FILE__) + '/../certs/cacert.pem' http end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
spreedly-2.0.0 | lib/spreedly/connection.rb |