Class: Paymium::Api::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/paymium/api/client.rb

Defined Under Namespace

Classes: Error

Instance Method Summary collapse

Constructor Details

#initialize(config = {}) ⇒ Client

Returns a new instance of Client.



12
13
14
15
# File 'lib/paymium/api/client.rb', line 12

def initialize config = {}
  @config = HashWithIndifferentAccess.new config
  @host = URI.parse @config.delete(:host)
end

Instance Method Details

#get(path, params = {}, &block) ⇒ Object



17
18
19
20
21
# File 'lib/paymium/api/client.rb', line 17

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



23
24
25
26
27
# File 'lib/paymium/api/client.rb', line 23

def post path, params = {}, &block
  req = Net::HTTP::Post.new(uri_from_path(path))
  req.body = Oj.dump(params)
  request req, &block
end