Class: DeepL::Requests::StyleRule::Create

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

Instance Attribute Summary

Attributes inherited from Base

#api, #options, #response

Instance Method Summary collapse

Methods inherited from Base

#details

Constructor Details

#initialize(api, name, language, options = {}) ⇒ Create

Returns a new instance of Create.



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

def initialize(api, name, language, options = {})
  super(api, options)
  @name = name
  @language = language
  @configured_rules = delete_option(:configured_rules)
  @custom_instructions = delete_option(:custom_instructions)
end

Instance Method Details

#requestObject



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

def request
  payload = { name: @name, language: @language }
  payload[:configured_rules] = @configured_rules if @configured_rules
  payload[:custom_instructions] = @custom_instructions if @custom_instructions
  build_style_rule(*execute_request_with_retries(post_request(payload)))
end

#to_sObject



25
26
27
# File 'lib/deepl/requests/style_rule/create.rb', line 25

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