Class: Paymium::Api::Client
- Inherits:
-
Object
- Object
- Paymium::Api::Client
- Defined in:
- lib/paymium/api/client.rb
Defined Under Namespace
Classes: Error
Instance Method Summary collapse
- #get(path, params = {}, &block) ⇒ Object
-
#initialize(config = {}) ⇒ Client
constructor
A new instance of Client.
- #post(path, params = {}, &block) ⇒ Object
Constructor Details
#initialize(config = {}) ⇒ Client
Returns a new instance of Client.
14 15 16 17 |
# File 'lib/paymium/api/client.rb', line 14 def initialize config = {} @config = HashWithIndifferentAccess.new config @host = URI.parse @config.delete(:host) end |
Instance Method Details
#get(path, params = {}, &block) ⇒ Object
19 20 21 22 23 |
# File 'lib/paymium/api/client.rb', line 19 def get path, params = {}, &block uri = uri_from_path(path) uri.query = URI.encode_www_form params unless params.empty? request Net::HTTP::Get.new(uri), &block end |
#post(path, params = {}, &block) ⇒ Object
25 26 27 28 29 |
# File 'lib/paymium/api/client.rb', line 25 def post path, params = {}, &block req = Net::HTTP::Post.new(uri_from_path(path)) req.set_form_data params unless params.empty? request req, &block end |