Class: Courier::Send::EmailHeader
- Inherits:
-
Object
- Object
- Courier::Send::EmailHeader
- Defined in:
- lib/trycourier/send/types/email_header.rb
Instance Attribute Summary collapse
-
#additional_properties ⇒ Object
readonly
Returns the value of attribute additional_properties.
-
#bar_color ⇒ Object
readonly
Returns the value of attribute bar_color.
-
#inherit_default ⇒ Object
readonly
Returns the value of attribute inherit_default.
-
#logo ⇒ Object
readonly
Returns the value of attribute logo.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Send::EmailHeader
Deserialize a JSON object to an instance of EmailHeader.
-
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object’s property definitions.
Instance Method Summary collapse
- #initialize(logo:, inherit_default: nil, bar_color: nil, additional_properties: nil) ⇒ Send::EmailHeader constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of EmailHeader to a JSON object.
Constructor Details
#initialize(logo:, inherit_default: nil, bar_color: nil, additional_properties: nil) ⇒ Send::EmailHeader
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/trycourier/send/types/email_header.rb', line 16 def initialize(logo:, inherit_default: nil, bar_color: nil, additional_properties: nil) # @type [Boolean] @inherit_default = inherit_default # @type [String] @bar_color = # @type [Send::Logo] @logo = logo # @type [OpenStruct] Additional properties unmapped to the current class definition @additional_properties = additional_properties end |
Instance Attribute Details
#additional_properties ⇒ Object (readonly)
Returns the value of attribute additional_properties.
9 10 11 |
# File 'lib/trycourier/send/types/email_header.rb', line 9 def additional_properties @additional_properties end |
#bar_color ⇒ Object (readonly)
Returns the value of attribute bar_color.
9 10 11 |
# File 'lib/trycourier/send/types/email_header.rb', line 9 def @bar_color end |
#inherit_default ⇒ Object (readonly)
Returns the value of attribute inherit_default.
9 10 11 |
# File 'lib/trycourier/send/types/email_header.rb', line 9 def inherit_default @inherit_default end |
#logo ⇒ Object (readonly)
Returns the value of attribute logo.
9 10 11 |
# File 'lib/trycourier/send/types/email_header.rb', line 9 def logo @logo end |
Class Method Details
.from_json(json_object:) ⇒ Send::EmailHeader
Deserialize a JSON object to an instance of EmailHeader
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/trycourier/send/types/email_header.rb', line 31 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) inherit_default = struct.inheritDefault = struct. if parsed_json["logo"].nil? logo = nil else logo = parsed_json["logo"].to_json logo = Send::Logo.from_json(json_object: logo) end new(inherit_default: inherit_default, bar_color: , logo: logo, additional_properties: struct) end |
.validate_raw(obj:) ⇒ Void
Leveraged for Union-type generation, validate_raw attempts to parse the given hash and check each fields type against the current object’s property definitions.
56 57 58 59 60 |
# File 'lib/trycourier/send/types/email_header.rb', line 56 def self.validate_raw(obj:) obj.inherit_default&.is_a?(Boolean) != false || raise("Passed value for field obj.inherit_default is not the expected type, validation failed.") obj.&.is_a?(String) != false || raise("Passed value for field obj.bar_color is not the expected type, validation failed.") Send::Logo.validate_raw(obj: obj.logo) end |
Instance Method Details
#to_json(*_args) ⇒ JSON
Serialize an instance of EmailHeader to a JSON object
48 49 50 |
# File 'lib/trycourier/send/types/email_header.rb', line 48 def to_json(*_args) { "inheritDefault": @inherit_default, "barColor": @bar_color, "logo": @logo }.to_json end |