class MyCashflow::Client
Public Class Methods
new(config = {})
click to toggle source
# File lib/mycashflow/client.rb, line 5 def initialize(config = {}) @path_parts = [] @username = config[:username] || ENV['MYCASHFLOW_USERNAME'] @password = config[:password] || ENV['MYCASHFLOW_PASSWORD'] @base_url = config[:base_url] || ENV['MYCASHFLOW_BASE_URL'] self.class.base_uri(@base_url) self.class.headers({ 'Accept' => 'application/json' }) self.class.basic_auth(@username, @password) end
Public Instance Methods
create(params = {})
click to toggle source
# File lib/mycashflow/client.rb, line 37 def create(params = {}) self.class.create(path, params) ensure reset end
delete(params = {})
click to toggle source
# File lib/mycashflow/client.rb, line 49 def delete(params = {}) self.class.delete(path, params) ensure reset end
get(params = {})
click to toggle source
# File lib/mycashflow/client.rb, line 31 def get(params = {}) self.class.get(path) ensure reset end
method_missing(method, *args)
click to toggle source
# File lib/mycashflow/client.rb, line 16 def method_missing(method, *args) @path_parts << method.to_s.gsub('_', '-').downcase @path_parts << args if args.length > 0 @path_parts.flatten! self end
path()
click to toggle source
# File lib/mycashflow/client.rb, line 23 def path "/#{@path_parts.join('/')}" end
reset()
click to toggle source
# File lib/mycashflow/client.rb, line 27 def reset @path_parts = [] end
update(params = {})
click to toggle source
# File lib/mycashflow/client.rb, line 43 def update(params = {}) self.class.update(path, params) ensure reset end