Class: Nzbn::Api::Watchlists
- Inherits:
-
Object
- Object
- Nzbn::Api::Watchlists
- Defined in:
- lib/nzbn/api/watchlists.rb
Overview
Watchlists API - Manage change notification watchlists
Instance Method Summary collapse
-
#add_nzbns(watchlist_id:, nzbns:) ⇒ Boolean
Add NZBNs to a watchlist.
-
#create(watchlist:) ⇒ Models::Watchlist
Create a new watchlist.
-
#delete(watchlist_id:) ⇒ Boolean
Delete a watchlist.
-
#get(watchlist_id:) ⇒ Models::Watchlist
Get a watchlist by ID.
-
#initialize(client) ⇒ Watchlists
constructor
A new instance of Watchlists.
-
#list(name: nil, organisation_id: nil, page: nil, page_size: nil, sort_by: nil, sort_order: nil, change_event_types: nil) ⇒ Models::SearchResponse
List watchlists.
-
#list_nzbns(watchlist_id:) ⇒ Array<String>
List NZBNs in a watchlist.
-
#remove_nzbns(watchlist_id:, nzbns:) ⇒ Boolean
Remove NZBNs from a watchlist.
-
#update(watchlist_id:, watchlist:) ⇒ Models::Watchlist
Update a watchlist.
Constructor Details
#initialize(client) ⇒ Watchlists
Returns a new instance of Watchlists.
7 8 9 |
# File 'lib/nzbn/api/watchlists.rb', line 7 def initialize(client) @client = client end |
Instance Method Details
#add_nzbns(watchlist_id:, nzbns:) ⇒ Boolean
Add NZBNs to a watchlist
103 104 105 106 |
# File 'lib/nzbn/api/watchlists.rb', line 103 def add_nzbns(watchlist_id:, nzbns:) @client.post("/watchlists/#{watchlist_id}/nzbns", { nzbns: nzbns }) true end |
#create(watchlist:) ⇒ Models::Watchlist
Create a new watchlist
61 62 63 64 |
# File 'lib/nzbn/api/watchlists.rb', line 61 def create(watchlist:) response = @client.post('/watchlists', watchlist) Models::Watchlist.new(response) end |
#delete(watchlist_id:) ⇒ Boolean
Delete a watchlist
82 83 84 85 |
# File 'lib/nzbn/api/watchlists.rb', line 82 def delete(watchlist_id:) @client.delete("/watchlists/#{watchlist_id}") true end |
#get(watchlist_id:) ⇒ Models::Watchlist
Get a watchlist by ID
42 43 44 45 |
# File 'lib/nzbn/api/watchlists.rb', line 42 def get(watchlist_id:) response = @client.get("/watchlists/#{watchlist_id}") Models::Watchlist.new(response) end |
#list(name: nil, organisation_id: nil, page: nil, page_size: nil, sort_by: nil, sort_order: nil, change_event_types: nil) ⇒ Models::SearchResponse
List watchlists
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/nzbn/api/watchlists.rb', line 22 def list(name: nil, organisation_id: nil, page: nil, page_size: nil, sort_by: nil, sort_order: nil, change_event_types: nil) params = {} params['name'] = name if name params['organisation-id'] = organisation_id if organisation_id params['page'] = page if page params['page-size'] = page_size if page_size params['sort-by'] = sort_by if sort_by params['sortorder'] = sort_order if sort_order params['change-event-types'] = change_event_types if change_event_types response = @client.get('/watchlists', params) Models::SearchResponse.new(response, item_class: Models::Watchlist) end |
#list_nzbns(watchlist_id:) ⇒ Array<String>
List NZBNs in a watchlist
92 93 94 95 |
# File 'lib/nzbn/api/watchlists.rb', line 92 def list_nzbns(watchlist_id:) response = @client.get("/watchlists/#{watchlist_id}/nzbns") response['nzbns'] || [] end |
#remove_nzbns(watchlist_id:, nzbns:) ⇒ Boolean
Remove NZBNs from a watchlist
114 115 116 117 |
# File 'lib/nzbn/api/watchlists.rb', line 114 def remove_nzbns(watchlist_id:, nzbns:) @client.delete("/watchlists/#{watchlist_id}/nzbns", { nzbns: nzbns }) true end |
#update(watchlist_id:, watchlist:) ⇒ Models::Watchlist
Update a watchlist
72 73 74 75 |
# File 'lib/nzbn/api/watchlists.rb', line 72 def update(watchlist_id:, watchlist:) response = @client.put("/watchlists/#{watchlist_id}", watchlist) Models::Watchlist.new(response) end |