Class: DeepL::Requests::StyleRule::CreateCustomInstruction

Inherits:
Base
  • Object
show all
Defined in:
lib/deepl/requests/style_rule/create_custom_instruction.rb

Instance Attribute Summary

Attributes inherited from Base

#api, #options, #response

Instance Method Summary collapse

Methods inherited from Base

#details

Constructor Details

#initialize(api, style_id, label, prompt, source_language = nil, options = {}) ⇒ CreateCustomInstruction

Returns a new instance of CreateCustomInstruction.



10
11
12
13
14
15
16
# File 'lib/deepl/requests/style_rule/create_custom_instruction.rb', line 10

def initialize(api, style_id, label, prompt, source_language = nil, options = {})
  super(api, options)
  @style_id = style_id
  @label = label
  @prompt = prompt
  @source_language = source_language
end

Instance Method Details

#requestObject



18
19
20
21
22
# File 'lib/deepl/requests/style_rule/create_custom_instruction.rb', line 18

def request
  payload = { label: @label, prompt: @prompt }
  payload[:source_language] = @source_language if @source_language
  build_custom_instruction(*execute_request_with_retries(post_request(payload)))
end

#to_sObject



24
25
26
# File 'lib/deepl/requests/style_rule/create_custom_instruction.rb', line 24

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