class Safettp::HTTPOptions

Constants

AUTH_TYPES
DEFAULT_HEADERS

Attributes

options_hash[R]

Public Class Methods

new(options_hash = {}) click to toggle source
# File lib/safettp/http_options.rb, line 14
def initialize(options_hash = {})
  @options_hash = options_hash
end

Public Instance Methods

auth() click to toggle source
# File lib/safettp/http_options.rb, line 34
def auth
  auth_options = options_hash.fetch(:auth, { type: :none })
  AUTH_TYPES.fetch(auth_options[:type], Safettp::NoneAuthenticator)
            .new(auth_options)
end
body() click to toggle source
# File lib/safettp/http_options.rb, line 30
def body
  options_hash.fetch(:body, "")
end
headers() click to toggle source
# File lib/safettp/http_options.rb, line 18
def headers
  options_hash.fetch(:headers, DEFAULT_HEADERS)
end
parser() click to toggle source
# File lib/safettp/http_options.rb, line 22
def parser
  options_hash.fetch(:parser, Safettp::Parsers::JSON)
end
query() click to toggle source
# File lib/safettp/http_options.rb, line 26
def query
  URI.encode_www_form(options_hash.fetch(:query, {}))
end