Class: DeepL::Requests::StyleRule::CreateCustomInstruction
- Includes:
- Helpers
- Defined in:
- lib/deepl/requests/style_rule/create_custom_instruction.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
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(api, style_id, label, prompt, source_language = nil, options = {}) ⇒ CreateCustomInstruction
constructor
A new instance of CreateCustomInstruction.
- #request ⇒ Object
- #to_s ⇒ Object
Methods inherited from Base
accepted_options, accepts_options, #details, inherited, validate_options!
Constructor Details
#initialize(api, style_id, label, prompt, source_language = nil, options = {}) ⇒ CreateCustomInstruction
Returns a new instance of CreateCustomInstruction.
12 13 14 15 16 17 18 19 20 |
# File 'lib/deepl/requests/style_rule/create_custom_instruction.rb', line 12 def initialize(api, style_id, label, prompt, source_language = nil, = {}) super(api, ) @style_id = style_rule_id(style_id) check_non_empty!(label: label, prompt: prompt) @label = label @prompt = prompt validate_language!('source_language', source_language, optional: true) @source_language = source_language end |
Instance Method Details
#request ⇒ Object
22 23 24 25 26 |
# File 'lib/deepl/requests/style_rule/create_custom_instruction.rb', line 22 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_s ⇒ Object
28 29 30 |
# File 'lib/deepl/requests/style_rule/create_custom_instruction.rb', line 28 def to_s "POST #{uri.request_uri}" end |