class Xfrtuc::Client
Attributes
base_url[R]
Public Class Methods
new(username, password, base_url='https://transferatu.heroku.com')
click to toggle source
# File lib/xfrtuc.rb, line 8 def initialize(username, password, base_url='https://transferatu.heroku.com') @base_url = base_url @username = username @password = password @resource = RestClient::Resource.new(base_url, user: username, password: password, headers: { content_type: 'application/json', accept: 'application/json' }) end
Public Instance Methods
delete(path)
click to toggle source
# File lib/xfrtuc.rb, line 48 def delete(path) JSON.parse(@resource[path].delete) end
get(path, params={})
click to toggle source
# File lib/xfrtuc.rb, line 36 def get(path, params={}) JSON.parse(@resource[path].get(params)) end
group(name=nil)
click to toggle source
# File lib/xfrtuc.rb, line 27 def group(name=nil) if name.nil? @group_client ||= Xfrtuc::Group.new(self) else self.class.new(@username, @password, @base_url + "/groups/#{CGI.escape(name)}") end end
post(path, data={})
click to toggle source
# File lib/xfrtuc.rb, line 40 def post(path, data={}) JSON.parse(@resource[path].post(JSON.generate(data))) end
put(path, data={})
click to toggle source
# File lib/xfrtuc.rb, line 44 def put(path, data={}) JSON.parse(@resource[path].put(JSON.generate(data))) end
schedule()
click to toggle source
# File lib/xfrtuc.rb, line 23 def schedule @sched_client ||= Xfrtuc::Schedule.new(self) end
transfer()
click to toggle source
# File lib/xfrtuc.rb, line 19 def transfer @xfer_client ||= Xfrtuc::Transfer.new(self) end