Class: DeepL::Requests::StyleRule::Create
- Includes:
- Helpers
- Defined in:
- lib/deepl/requests/style_rule/create.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, name, language, options = {}) ⇒ Create
constructor
A new instance of Create.
- #request ⇒ Object
- #to_s ⇒ Object
Methods inherited from Base
accepted_options, accepts_options, #details, inherited, validate_options!
Constructor Details
#initialize(api, name, language, options = {}) ⇒ Create
Returns a new instance of Create.
14 15 16 17 18 19 20 21 22 |
# File 'lib/deepl/requests/style_rule/create.rb', line 14 def initialize(api, name, language, = {}) super(api, ) check_non_empty!(name: name, language: language) @name = name @language = language @configured_rules = delete_option(:configured_rules) @custom_instructions = delete_option(:custom_instructions) validate_instruction_languages!(@custom_instructions) end |
Instance Method Details
#request ⇒ Object
24 25 26 27 28 29 |
# File 'lib/deepl/requests/style_rule/create.rb', line 24 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_s ⇒ Object
31 32 33 |
# File 'lib/deepl/requests/style_rule/create.rb', line 31 def to_s "POST #{uri.request_uri}" end |