Class: DeepL::Requests::Glossary::Create

Inherits:
Base
  • Object
show all
Defined in:
lib/deepl/requests/glossary/create.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#api, #options, #response

Instance Method Summary collapse

Constructor Details

#initialize(api, name, source_lang, target_lang, entries, options = {}) ⇒ Create

Returns a new instance of Create.



12
13
14
15
16
17
18
19
# File 'lib/deepl/requests/glossary/create.rb', line 12

def initialize(api, name, source_lang, target_lang, entries, options = {})
  super(api, options)
  @name = name
  @source_lang = source_lang
  @target_lang = target_lang
  @entries = entries
  @entries_format = delete_option(:entries_format) || 'tsv'
end

Instance Attribute Details

#entriesObject (readonly)

Returns the value of attribute entries.



10
11
12
# File 'lib/deepl/requests/glossary/create.rb', line 10

def entries
  @entries
end

#entries_formatObject (readonly)

Returns the value of attribute entries_format.



10
11
12
# File 'lib/deepl/requests/glossary/create.rb', line 10

def entries_format
  @entries_format
end

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'lib/deepl/requests/glossary/create.rb', line 10

def name
  @name
end

#source_langObject (readonly)

Returns the value of attribute source_lang.



10
11
12
# File 'lib/deepl/requests/glossary/create.rb', line 10

def source_lang
  @source_lang
end

#target_langObject (readonly)

Returns the value of attribute target_lang.



10
11
12
# File 'lib/deepl/requests/glossary/create.rb', line 10

def target_lang
  @target_lang
end

Instance Method Details

#detailsObject



29
30
31
32
33
34
# File 'lib/deepl/requests/glossary/create.rb', line 29

def details
  "HTTP Headers: #{headers}\nPayload #{{
    name: name, source_lang: source_lang, target_lang: target_lang, entries: entries_to_tsv,
    entries_format: entries_format
  }}"
end

#requestObject



21
22
23
24
25
26
27
# File 'lib/deepl/requests/glossary/create.rb', line 21

def request
  payload = {
    name: name, source_lang: source_lang, target_lang: target_lang, entries: entries_to_tsv,
    entries_format: entries_format
  }
  build_glossary(*execute_request_with_retries(post_request(payload)))
end

#to_sObject



36
37
38
# File 'lib/deepl/requests/glossary/create.rb', line 36

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