Class: Nzbmatrix::Client
- Inherits:
-
Object
- Object
- Nzbmatrix::Client
- Defined in:
- lib/nzbmatrix/client.rb
Constant Summary collapse
- BASE_URL =
"https://api.nzbmatrix.com/v1.1"
Instance Method Summary collapse
- #account ⇒ Object
- #add_bookmark(nzb_id) ⇒ Object
- #details(nzb_id) ⇒ Object
- #download(nzb_id) ⇒ Object
-
#initialize(username, api_key) ⇒ Client
constructor
A new instance of Client.
- #remove_bookmark(nzb_id) ⇒ Object
-
#search(search_term, opts = {}) ⇒ Object
Options :catid => CATEGORYID all categories searched if left blank :num => MAX RESULTS default 15 :age => MAX AGE default full site retention.
Constructor Details
#initialize(username, api_key) ⇒ Client
Returns a new instance of Client.
11 12 13 14 15 16 |
# File 'lib/nzbmatrix/client.rb', line 11 def initialize(username, api_key) @username = username @api_key = api_key @creds = { :username => @username, :apikey => @api_key } @parser = ApiResponseParser.new end |
Instance Method Details
#account ⇒ Object
53 54 55 |
# File 'lib/nzbmatrix/client.rb', line 53 def account RestClient.get "#{BASE_URL}/account.php", :params => @creds end |
#add_bookmark(nzb_id) ⇒ Object
57 58 59 |
# File 'lib/nzbmatrix/client.rb', line 57 def add_bookmark(nzb_id) RestClient.get "#{BASE_URL}/bookmarks.php", :params => { :id => nzb_id, :action => 'add' }.merge(@creds) end |
#details(nzb_id) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/nzbmatrix/client.rb', line 22 def details(nzb_id) params = { :id => nzb_id }.merge(@creds) response = RestClient.get("#{BASE_URL}/details.php", :params => params) parsed_response = @parser.parse(response).first result = SearchResult.new(parsed_response, self) result.id = nzb_id result end |
#download(nzb_id) ⇒ Object
18 19 20 |
# File 'lib/nzbmatrix/client.rb', line 18 def download(nzb_id) RestClient.get "#{BASE_URL}/download.php", :params => { :id => nzb_id }.merge(@creds) end |
#remove_bookmark(nzb_id) ⇒ Object
61 62 63 |
# File 'lib/nzbmatrix/client.rb', line 61 def remove_bookmark(nzb_id) RestClient.get "#{BASE_URL}/bookmarks.php", :params => { :id => nzb_id, :action => 'remove' }.merge(@creds) end |
#search(search_term, opts = {}) ⇒ Object
Options :catid => CATEGORYID all categories searched if left blank :num => MAX RESULTS default 15 :age => MAX AGE default full site retention. Age must be number of “days” eg 200 :region => REGION default not limited. 1 = PAL, 2 = NTSC, 3 = FREE :group => GROUP default all groups will be searched, format is full group name “alt.binaries.X” :larger => MIN SIZE minimum size in MB :smaller => MAX SIZE maximum size in MB :minhits => MIN HITS :maxhits => MAX HITS :maxage => AGE same as :age :englishonly => 1 if added the search will only return ENGLISH and UNKNOWN matches :searchin => SEARCH FIELD default name. possible options: name, subject, weblink
45 46 47 48 49 50 51 |
# File 'lib/nzbmatrix/client.rb', line 45 def search(search_term, opts = {}) params = { :search => search_term }.merge(opts).merge(@creds) response = RestClient.get("#{BASE_URL}/search.php", :params => params) @parser.parse(response).map do |parsed| SearchResult.new(parsed, self) end end |