Sha256: 6d834c9536646af9eaffa83b82032a0139897b79a758c658c1aad30d4335f0cd

Contents?: true

Size: 788 Bytes

Versions: 1

Compression:

Stored size: 788 Bytes

Contents

module NedbankApi
  class Http
    def initialize(url:)
      @url = URI(url)
    end

    def net_http
      @net_http ||= Net::HTTP.new(@url.host, @url.port).tap do |http|
        http.use_ssl = true
        http.verify_mode = OpenSSL::SSL::VERIFY_PEER
      end
    end

    def get(body: {}, headers: {})
      request = Net::HTTP::Get.new(@url)

      headers.each do |key,value|
        request[key] = value
      end

      request.body = body
      response = net_http.request(request)

      return response
    end
    def post(body: {}, headers: {})
      request = Net::HTTP::Post.new(@url)

      headers.each do |key,value|
        request[key] = value
      end

      request.body = body
      response = net_http.request(request)

      return response
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nedbank_api-0.2.2 lib/nedbank_api/services/http.rb