Class: Paymongo::Http
- Inherits:
-
Object
- Object
- Paymongo::Http
- Defined in:
- lib/paymongo/http.rb
Instance Method Summary collapse
-
#initialize(config) ⇒ Http
constructor
A new instance of Http.
- #post(path, params = nil) ⇒ Object
Constructor Details
#initialize(config) ⇒ Http
Returns a new instance of Http.
3 4 5 |
# File 'lib/paymongo/http.rb', line 3 def initialize(config) @config = config end |
Instance Method Details
#post(path, params = nil) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/paymongo/http.rb', line 7 def post(path, params = nil) header = { 'Content-Type': 'application/json' } uri = URI.parse(path) https = Net::HTTP.new(uri.host, uri.port) https.use_ssl = true req = Net::HTTP::Post.new(uri.path, header) # TODO: Put password in basic_auth as part of config req.basic_auth(@config.secret_key, '') req.body = params[:transaction].to_json res = https.request(req) JSON.parse(res.body).with_indifferent_access end |