Class: DeepL::Requests::TranslationMemory::UploadFile

Inherits:
StorageBase show all
Defined in:
lib/deepl/requests/translation_memory/upload_file.rb

Constant Summary collapse

DEFAULT_CONTENT_TYPE =
'application/xml'

Constants inherited from Base

Base::MAX_GLOSSARY_IDS

Instance Attribute Summary collapse

Attributes inherited from StorageBase

#storage_url

Attributes inherited from Base

#api, #options, #response

Instance Method Summary collapse

Constructor Details

#initialize(api, upload_url, file_content, content_type = DEFAULT_CONTENT_TYPE) ⇒ UploadFile

Returns a new instance of UploadFile.



14
15
16
17
18
# File 'lib/deepl/requests/translation_memory/upload_file.rb', line 14

def initialize(api, upload_url, file_content, content_type = DEFAULT_CONTENT_TYPE)
  super(api, upload_url)
  @file_content = file_content
  @content_type = content_type || DEFAULT_CONTENT_TYPE
end

Instance Attribute Details

#content_typeObject (readonly)

Returns the value of attribute content_type.



12
13
14
# File 'lib/deepl/requests/translation_memory/upload_file.rb', line 12

def content_type
  @content_type
end

#file_contentObject (readonly)

Returns the value of attribute file_content.



12
13
14
# File 'lib/deepl/requests/translation_memory/upload_file.rb', line 12

def file_content
  @file_content
end

Instance Method Details

#detailsObject



24
25
26
# File 'lib/deepl/requests/translation_memory/upload_file.rb', line 24

def details
  "HTTP Headers: #{headers}\nPayload #{file_content.bytesize} byte(s)"
end

#requestObject



20
21
22
# File 'lib/deepl/requests/translation_memory/upload_file.rb', line 20

def request
  build_response(*execute_request_with_retries(put_request))
end

#to_sObject



28
29
30
# File 'lib/deepl/requests/translation_memory/upload_file.rb', line 28

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