Sha256: b23abf579b3efc53cdfc2de8bba77de06c40b1d71f8ec7054bc4622471de7d27
Contents?: true
Size: 1.37 KB
Versions: 1
Compression:
Stored size: 1.37 KB
Contents
require "net/http" require "net/https" module Moiper class Request CA_FILE = File.expand_path(File.dirname(__FILE__)) + "/cacert.pem" # Process a given payload # @param payload [String] # @return [Response] the response from Moip def process(payload) response = post(payload) Response.new(response.body) end # @!group HTTP handling # @return [Net::HTTP::Session] the http session client def client @client ||= Net::HTTP.new(uri.host, uri.port).tap do |http| http.use_ssl = true http.ca_file = CA_FILE http.verify_mode = OpenSSL::SSL::VERIFY_PEER end end # @return [Net::HTTP::Post] the http POST request already # configured with the right agent, content type and # basic authentication headers def request @request ||= Net::HTTP::Post.new(uri.path).tap do |request| request.basic_auth Moiper.token, Moiper.key request.content_type = "text/xml" request["User-Agent"] = "Moiper/#{Moiper::VERSION}" end end # @!endgroup private def post(payload) request.body = payload client.request(request) end def uri @uri ||= URI(Moiper.api_entrypoint + path) end # @api private # @return [String] path where the request should be made def path "ws/alpha/EnviarInstrucao/Unica" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
moiper-0.1.2 | lib/moiper/request.rb |