Class: VaultedBilling::HTTP

Inherits:
Object
  • Object
show all
Defined in:
lib/vaulted_billing/http.rb

Defined Under Namespace

Classes: Response

Constant Summary collapse

HTTP_ERRORS =
[
  Timeout::Error,
  Errno::ETIMEDOUT,
  Errno::EINVAL,
  Errno::ECONNRESET,
  Errno::ECONNREFUSED,
  Errno::EHOSTUNREACH,
  EOFError,
  Net::HTTPBadResponse,
  Net::HTTPHeaderSyntaxError,
  Net::ProtocolError
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(caller, uri, options = {}) ⇒ HTTP

Returns a new instance of HTTP.



46
47
48
49
50
51
52
53
54
55
56
# File 'lib/vaulted_billing/http.rb', line 46

def initialize(caller, uri, options = {})
  @uri = [uri].flatten.compact.collect { |u| URI.parse(u.to_s).normalize }
  @headers = options[:headers] || {}
  @basic_auth = options[:basic_auth]
  @content_type = options[:content_type]
  @caller = caller
  @before_request = options[:before_request]
  @on_success = options[:on_success]
  @on_error = options[:on_error]
  @on_complete = options[:on_complete]
end

Instance Attribute Details

#uriObject (readonly)

Returns the value of attribute uri.



44
45
46
# File 'lib/vaulted_billing/http.rb', line 44

def uri
  @uri
end

Instance Method Details

#get(options = {}) ⇒ Object



62
63
64
# File 'lib/vaulted_billing/http.rb', line 62

def get(options = {})
  request(:get, uri.dup, nil, options)
end

#post(body, options = {}) ⇒ Object



58
59
60
# File 'lib/vaulted_billing/http.rb', line 58

def post(body, options = {})
  request(:post, uri.dup, body, options)
end

#put(body, options = {}) ⇒ Object



66
67
68
# File 'lib/vaulted_billing/http.rb', line 66

def put(body, options = {})
  request(:put, uri.dup, body, options)
end