Sha256: 02c2c2296d0422f0ae34bfc80d372362f1a32b09a6e652679c92243d9ab0ca34
Contents?: true
Size: 977 Bytes
Versions: 1
Compression:
Stored size: 977 Bytes
Contents
module Paymo class API def self.methodize(resource, method) method = method.to_s.gsub(/_([a-z]{1})/) { "#{$1.upcase}" } "#{resource}.#{method}" end def self.get(resource, method, options = {}) method = methodize(resource, method) options.merge!({ auth_token: Paymo.auth_token, api_key: Paymo.api_key, format: 'json' }) puts "curl #{API_ENDPOINT}paymo.#{method}?#{URI.encode_www_form(options)}" if Paymo.debug json = RestClient.get "#{API_ENDPOINT}paymo.#{method}", { params: options } JSON.parse(json) end def self.post(resource, method, options = {}) method = methodize(resource, method) options.merge!({ auth_token: Paymo.auth_token, api_key: Paymo.api_key, format: 'json' }) puts "curl -X POST -d '#{URI.encode_www_form(options)}' #{API_ENDPOINT}paymo.#{method}" if Paymo.debug json = RestClient.post "#{API_ENDPOINT}paymo.#{method}", options JSON.parse(json) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
paymo-0.0.1 | lib/paymo/api.rb |