Class: Courier::Notifications::NotificationChannel
- Inherits:
-
Object
- Object
- Courier::Notifications::NotificationChannel
- Defined in:
- lib/trycourier/notifications/types/notification_channel.rb
Instance Attribute Summary collapse
-
#additional_properties ⇒ Object
readonly
Returns the value of attribute additional_properties.
-
#checksum ⇒ Object
readonly
Returns the value of attribute checksum.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#locales ⇒ Object
readonly
Returns the value of attribute locales.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Notifications::NotificationChannel
Deserialize a JSON object to an instance of NotificationChannel.
-
.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(id:, type: nil, content: nil, locales: nil, checksum: nil, additional_properties: nil) ⇒ Notifications::NotificationChannel constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of NotificationChannel to a JSON object.
Constructor Details
#initialize(id:, type: nil, content: nil, locales: nil, checksum: nil, additional_properties: nil) ⇒ Notifications::NotificationChannel
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/trycourier/notifications/types/notification_channel.rb', line 18 def initialize(id:, type: nil, content: nil, locales: nil, checksum: nil, additional_properties: nil) # @type [String] @id = id # @type [String] @type = type # @type [Notifications::NotificationChannelContent] @content = content # @type [Hash{String => String}] @locales = locales # @type [String] @checksum = checksum # @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/notifications/types/notification_channel.rb', line 9 def additional_properties @additional_properties end |
#checksum ⇒ Object (readonly)
Returns the value of attribute checksum.
9 10 11 |
# File 'lib/trycourier/notifications/types/notification_channel.rb', line 9 def checksum @checksum end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
9 10 11 |
# File 'lib/trycourier/notifications/types/notification_channel.rb', line 9 def content @content end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
9 10 11 |
# File 'lib/trycourier/notifications/types/notification_channel.rb', line 9 def id @id end |
#locales ⇒ Object (readonly)
Returns the value of attribute locales.
9 10 11 |
# File 'lib/trycourier/notifications/types/notification_channel.rb', line 9 def locales @locales end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
9 10 11 |
# File 'lib/trycourier/notifications/types/notification_channel.rb', line 9 def type @type end |
Class Method Details
.from_json(json_object:) ⇒ Notifications::NotificationChannel
Deserialize a JSON object to an instance of NotificationChannel
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/trycourier/notifications/types/notification_channel.rb', line 37 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) id = struct.id type = struct.type if parsed_json["content"].nil? content = nil else content = parsed_json["content"].to_json content = Notifications::NotificationChannelContent.from_json(json_object: content) end locales = struct.locales checksum = struct.checksum new(id: id, type: type, content: content, locales: locales, checksum: checksum, 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.
64 65 66 67 68 69 70 |
# File 'lib/trycourier/notifications/types/notification_channel.rb', line 64 def self.validate_raw(obj:) obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") obj.type&.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.content.nil? || Notifications::NotificationChannelContent.validate_raw(obj: obj.content) obj.locales&.is_a?(Hash) != false || raise("Passed value for field obj.locales is not the expected type, validation failed.") obj.checksum&.is_a?(String) != false || raise("Passed value for field obj.checksum is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ JSON
Serialize an instance of NotificationChannel to a JSON object
56 57 58 |
# File 'lib/trycourier/notifications/types/notification_channel.rb', line 56 def to_json(*_args) { "id": @id, "type": @type, "content": @content, "locales": @locales, "checksum": @checksum }.to_json end |