Class: Qnap::DownloadStation
- Inherits:
-
Object
- Object
- Qnap::DownloadStation
- Defined in:
- lib/qnap/download_station.rb
Constant Summary collapse
- PROTOCOL =
'https'
- APP_NAME =
'downloadstation'
- API_VERSION =
'V4'
- API_METHODS =
{ misc: [:dir, :env, :login, :logout, :socks_5], task: [:status, :query, :detail, :add_url, :add_torrent, :start, :stop, :pause, :remove, :priority, :get_file, :set_file], rss: [:add, :query, :update, :remove, :query_feed, :update_feed, :add_job, :query_job, :update_job, :remove_job], config: [:get, :set], account: [:add, :query, :update, :remove], addon: [:query, :enable, :verify, :install, :uninstall, :search], }
Instance Method Summary collapse
- #get_sid ⇒ Object
-
#initialize(host, username, password) ⇒ DownloadStation
constructor
A new instance of DownloadStation.
- #logout ⇒ Object
- #misc_login(params = {}) ⇒ Object
Constructor Details
#initialize(host, username, password) ⇒ DownloadStation
Returns a new instance of DownloadStation.
54 55 56 57 58 59 |
# File 'lib/qnap/download_station.rb', line 54 def initialize(host, username, password) @host = host @username = username @password = password @sid = nil end |
Instance Method Details
#get_sid ⇒ Object
50 51 52 |
# File 'lib/qnap/download_station.rb', line 50 def get_sid @sid ||= misc_login(user: @username, pass: Base64.encode64(@password))[:sid] end |
#logout ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/qnap/download_station.rb', line 20 def logout return unless @sid data = misc_logout @sid = nil data end |
#misc_login(params = {}) ⇒ Object
29 30 31 32 33 |
# File 'lib/qnap/download_station.rb', line 29 def misc_login(params={}) # override the auto-gen method # otherwise `get_sid` is called despatch_query(uri_for_path(:misc, :login), params) end |