Class: Paymo::API
- Inherits:
-
Object
- Object
- Paymo::API
- Defined in:
- lib/paymo/api.rb
Class Method Summary collapse
- .get(resource, method, options = {}) ⇒ Object
- .methodize(resource, method) ⇒ Object
- .post(resource, method, options = {}) ⇒ Object
Class Method Details
.get(resource, method, options = {}) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/paymo/api.rb', line 9 def self.get(resource, method, = {}) method = methodize(resource, method) .merge!({ auth_token: Paymo.auth_token, api_key: Paymo.api_key, format: 'json' }) puts "curl #{API_ENDPOINT}paymo.#{method}?#{URI.encode_www_form()}" if Paymo.debug json = RestClient.get "#{API_ENDPOINT}paymo.#{method}", { params: } JSON.parse(json) end |
.methodize(resource, method) ⇒ Object
4 5 6 7 |
# File 'lib/paymo/api.rb', line 4 def self.methodize(resource, method) method = method.to_s.gsub(/_([a-z]{1})/) { "#{$1.upcase}" } "#{resource}.#{method}" end |
.post(resource, method, options = {}) ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/paymo/api.rb', line 17 def self.post(resource, method, = {}) method = methodize(resource, method) .merge!({ auth_token: Paymo.auth_token, api_key: Paymo.api_key, format: 'json' }) puts "curl -X POST -d '#{URI.encode_www_form()}' #{API_ENDPOINT}paymo.#{method}" if Paymo.debug json = RestClient.post "#{API_ENDPOINT}paymo.#{method}", JSON.parse(json) end |