Class: DropboxApi::Endpoints::ContentDownload

Inherits:
Base
  • Object
show all
Defined in:
lib/dropbox_api/endpoints/content_download.rb

Instance Method Summary collapse

Methods inherited from Base

add_endpoint

Constructor Details

#initialize(builder) ⇒ ContentDownload

Returns a new instance of ContentDownload.



3
4
5
6
7
# File 'lib/dropbox_api/endpoints/content_download.rb', line 3

def initialize(builder)
  @connection = builder.build("https://content.dropboxapi.com") do |c|
    c.response :decode_result
  end
end

Instance Method Details

#build_request(params) ⇒ Object



9
10
11
12
13
14
15
16
17
# File 'lib/dropbox_api/endpoints/content_download.rb', line 9

def build_request(params)
  body = nil
  headers = {
    'Dropbox-API-Arg' => JSON.dump(params),
    'Content-Type' => ''
  }

  return body, headers
end

#perform_request(params) {|response.body| ... } ⇒ Object

Yields:

  • (response.body)


19
20
21
22
23
24
25
26
27
28
# File 'lib/dropbox_api/endpoints/content_download.rb', line 19

def perform_request(params)
  response = get_response(params)
  api_result = process_response response

  # TODO: Stream response, current implementation will fail with very large
  #       files.
  yield response.body if block_given?

  api_result
end