Class: Courier::Messages::RenderOutput
- Inherits:
-
Object
- Object
- Courier::Messages::RenderOutput
- Defined in:
- lib/trycourier/messages/types/render_output.rb
Instance Attribute Summary collapse
-
#additional_properties ⇒ Object
readonly
Returns the value of attribute additional_properties.
-
#channel ⇒ Object
readonly
Returns the value of attribute channel.
-
#channel_id ⇒ Object
readonly
Returns the value of attribute channel_id.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Messages::RenderOutput
Deserialize a JSON object to an instance of RenderOutput.
-
.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(channel:, channel_id:, content:, additional_properties: nil) ⇒ Messages::RenderOutput constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of RenderOutput to a JSON object.
Constructor Details
#initialize(channel:, channel_id:, content:, additional_properties: nil) ⇒ Messages::RenderOutput
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/trycourier/messages/types/render_output.rb', line 16 def initialize(channel:, channel_id:, content:, additional_properties: nil) # @type [String] The channel used for rendering the message. @channel = channel # @type [String] The ID of channel used for rendering the message. @channel_id = channel_id # @type [Messages::RenderedMessageContent] Content details of the rendered message. @content = content # @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/messages/types/render_output.rb', line 9 def additional_properties @additional_properties end |
#channel ⇒ Object (readonly)
Returns the value of attribute channel.
9 10 11 |
# File 'lib/trycourier/messages/types/render_output.rb', line 9 def channel @channel end |
#channel_id ⇒ Object (readonly)
Returns the value of attribute channel_id.
9 10 11 |
# File 'lib/trycourier/messages/types/render_output.rb', line 9 def channel_id @channel_id end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
9 10 11 |
# File 'lib/trycourier/messages/types/render_output.rb', line 9 def content @content end |
Class Method Details
.from_json(json_object:) ⇒ Messages::RenderOutput
Deserialize a JSON object to an instance of RenderOutput
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/trycourier/messages/types/render_output.rb', line 31 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) channel = struct.channel channel_id = struct.channel_id if parsed_json["content"].nil? content = nil else content = parsed_json["content"].to_json content = Messages::RenderedMessageContent.from_json(json_object: content) end new(channel: channel, channel_id: channel_id, content: content, 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/messages/types/render_output.rb', line 56 def self.validate_raw(obj:) obj.channel.is_a?(String) != false || raise("Passed value for field obj.channel is not the expected type, validation failed.") obj.channel_id.is_a?(String) != false || raise("Passed value for field obj.channel_id is not the expected type, validation failed.") Messages::RenderedMessageContent.validate_raw(obj: obj.content) end |
Instance Method Details
#to_json(*_args) ⇒ JSON
Serialize an instance of RenderOutput to a JSON object
48 49 50 |
# File 'lib/trycourier/messages/types/render_output.rb', line 48 def to_json(*_args) { "channel": @channel, "channel_id": @channel_id, "content": @content }.to_json end |