Class: MyLocalPutio::PutioCli

Inherits:
Object
  • Object
show all
Defined in:
lib/my-local-putio/putio_cli.rb

Constant Summary collapse

ROOT =
"https://api.put.io/v2/"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(configuration) ⇒ PutioCli

Returns a new instance of PutioCli.



6
7
8
9
10
11
# File 'lib/my-local-putio/putio_cli.rb', line 6

def initialize(configuration)
  @configuration = configuration
  @logger = configuration.logger
  @endpoint = URI(ROOT)
  setup_connection
end

Instance Attribute Details

#configurationObject (readonly)

Returns the value of attribute configuration.



4
5
6
# File 'lib/my-local-putio/putio_cli.rb', line 4

def configuration
  @configuration
end

#endpointObject (readonly)

Returns the value of attribute endpoint.



4
5
6
# File 'lib/my-local-putio/putio_cli.rb', line 4

def endpoint
  @endpoint
end

#httpObject (readonly)

Returns the value of attribute http.



4
5
6
# File 'lib/my-local-putio/putio_cli.rb', line 4

def http
  @http
end

#loggerObject (readonly)

Returns the value of attribute logger.



4
5
6
# File 'lib/my-local-putio/putio_cli.rb', line 4

def logger
  @logger
end

Instance Method Details

#delete_file(id) ⇒ Object



18
19
20
21
# File 'lib/my-local-putio/putio_cli.rb', line 18

def delete_file(id)
  args = {file_ids: id}
  post("files/delete", args)
end

#get_download_url(id) ⇒ Object



27
28
29
# File 'lib/my-local-putio/putio_cli.rb', line 27

def get_download_url(id)
  get("files/#{id}/url")
end

#get_files(parent_id = nil) ⇒ Object



13
14
15
16
# File 'lib/my-local-putio/putio_cli.rb', line 13

def get_files(parent_id=nil)
  args = parent_id ? {parent_id: parent_id, sort: "NAME_DESC"} : {sort: "DATE_DESC"}
  get("files/list", args)
end

#get_subtitles(id) ⇒ Object



23
24
25
# File 'lib/my-local-putio/putio_cli.rb', line 23

def get_subtitles(id)
  get("files/#{id}/subtitles")
end