Class: DeepL::Requests::StyleProfile::Create

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

Constant Summary

Constants inherited from Base

Base::COMPONENT_ID_FIELDS

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 collapse

Attributes inherited from Base

#api, #options, #response

Instance Method Summary collapse

Methods inherited from Base

accepted_options, accepts_options, #details, inherited, validate_options!

Constructor Details

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

Returns a new instance of Create.



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

def initialize(api, name, fields, options = {})
  super(api, options)
  @name = name
  @fields = fields
end

Instance Attribute Details

#fields ⇒ Object (readonly)

Returns the value of attribute fields.



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

def fields
  @fields
end

#name ⇒ Object (readonly)

Returns the value of attribute name.



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

def name
  @name
end

Instance Method Details

#request ⇒ Object



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

def request
  payload = { name: name }.merge(optional_fields_payload(fields))
  build_style_profile(*execute_request_with_retries(post_request(payload)))
end

#to_s ⇒ Object



23
24
25
# File 'lib/deepl/requests/style_profile/create.rb', line 23

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