Class: VaultedBilling::HTTP
- Inherits:
-
Object
- Object
- VaultedBilling::HTTP
- 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
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #get(options = {}) ⇒ Object
-
#initialize(caller, uri, options = {}) ⇒ HTTP
constructor
A new instance of HTTP.
- #post(body, options = {}) ⇒ Object
- #put(body, options = {}) ⇒ Object
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, = {}) @uri = [uri].flatten.compact.collect { |u| URI.parse(u.to_s).normalize } @headers = [:headers] || {} @basic_auth = [:basic_auth] @content_type = [:content_type] @caller = caller @before_request = [:before_request] @on_success = [:on_success] @on_error = [:on_error] @on_complete = [:on_complete] end |
Instance Attribute Details
#uri ⇒ Object (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( = {}) request(:get, uri.dup, nil, ) end |
#post(body, options = {}) ⇒ Object
58 59 60 |
# File 'lib/vaulted_billing/http.rb', line 58 def post(body, = {}) request(:post, uri.dup, body, ) end |
#put(body, options = {}) ⇒ Object
66 67 68 |
# File 'lib/vaulted_billing/http.rb', line 66 def put(body, = {}) request(:put, uri.dup, body, ) end |