Class: DeepL::Requests::Document::Download

Inherits:
Base
  • Object
show all
Defined in:
lib/deepl/requests/document/download.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#api, #options, #response

Instance Method Summary collapse

Constructor Details

#initialize(api, document_id, document_key, output_file) ⇒ Download

Returns a new instance of Download.



12
13
14
15
16
17
# File 'lib/deepl/requests/document/download.rb', line 12

def initialize(api, document_id, document_key, output_file)
  super(api, {})
  @document_id = document_id
  @document_key = document_key
  @output_file = output_file
end

Instance Attribute Details

#document_idObject (readonly)

Returns the value of attribute document_id.



10
11
12
# File 'lib/deepl/requests/document/download.rb', line 10

def document_id
  @document_id
end

#document_keyObject (readonly)

Returns the value of attribute document_key.



10
11
12
# File 'lib/deepl/requests/document/download.rb', line 10

def document_key
  @document_key
end

Instance Method Details

#detailsObject



24
25
26
# File 'lib/deepl/requests/document/download.rb', line 24

def details
  "HTTP Headers: #{headers}\nPayload #{{ document_key: document_key }}"
end

#requestObject



19
20
21
22
# File 'lib/deepl/requests/document/download.rb', line 19

def request
  payload = { document_key: document_key }
  extract_file(*execute_request_with_retries(post_request(payload)))
end

#to_sObject



28
29
30
# File 'lib/deepl/requests/document/download.rb', line 28

def to_s
  "POST #{uri.request_uri}"
end