Class: DeepL::Requests::TranslationMemory::CreateImport

Inherits:
Base
  • Object
show all
Defined in:
lib/deepl/requests/translation_memory/create_import.rb

Constant Summary

Constants inherited from Base

Base::MAX_GLOSSARY_IDS, Base::NETWORK_ERRORS, Base::RESPONSE_FORMAT_ERRORS, Base::RETRYABLE_NETWORK_ERRORS, Base::TECHNICAL_HEADERS

Instance Attribute Summary collapse

Attributes inherited from Base

#api, #options, #response

Instance Method Summary collapse

Methods inherited from Base

accepted_options, accepts_options, inherited, validate_options!

Constructor Details

#initialize(api, file_name, content_length, options = {}, additional_headers = {}) ⇒ CreateImport

Returns a new instance of CreateImport.

Raises:

  • (ArgumentError)


14
15
16
17
18
19
20
21
22
23
# File 'lib/deepl/requests/translation_memory/create_import.rb', line 14

def initialize(api, file_name, content_length, options = {}, additional_headers = {})
  super(api, options, additional_headers)
  raise ArgumentError, '`file_name` must not be empty' if file_name.to_s.empty?
  raise ArgumentError, '`content_length` must be positive' unless content_length.positive?

  @file_name = file_name
  @content_length = content_length
  @content_type = delete_option(:content_type)
  @display_name = delete_option(:display_name)
end

Instance Attribute Details

#content_length ⇒ Object (readonly)

Returns the value of attribute content_length.



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

def content_length
  @content_length
end

#file_name ⇒ Object (readonly)

Returns the value of attribute file_name.



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

def file_name
  @file_name
end

Instance Method Details

#details ⇒ Object



29
30
31
# File 'lib/deepl/requests/translation_memory/create_import.rb', line 29

def details
  "HTTP Headers: #{loggable_headers}\nPayload #{payload}"
end

#request ⇒ Object



25
26
27
# File 'lib/deepl/requests/translation_memory/create_import.rb', line 25

def request
  build_translation_memory_import(*execute_request_with_retries(post_request(payload)))
end

#to_s ⇒ Object



33
34
35
# File 'lib/deepl/requests/translation_memory/create_import.rb', line 33

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