Class: Courier::Templates::NotificationTemplates
- Inherits:
-
Object
- Object
- Courier::Templates::NotificationTemplates
- Defined in:
- lib/trycourier/templates/types/notification_templates.rb
Instance Attribute Summary collapse
-
#additional_properties ⇒ Object
readonly
Returns the value of attribute additional_properties.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#routing ⇒ Object
readonly
Returns the value of attribute routing.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#updated_at ⇒ Object
readonly
Returns the value of attribute updated_at.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Templates::NotificationTemplates
Deserialize a JSON object to an instance of NotificationTemplates.
-
.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(created_at:, id:, routing:, tags:, title:, updated_at:, additional_properties: nil) ⇒ Templates::NotificationTemplates constructor
-
#to_json(*_args) ⇒ JSON
Serialize an instance of NotificationTemplates to a JSON object.
Constructor Details
#initialize(created_at:, id:, routing:, tags:, title:, updated_at:, additional_properties: nil) ⇒ Templates::NotificationTemplates
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/trycourier/templates/types/notification_templates.rb', line 20 def initialize(created_at:, id:, routing:, tags:, title:, updated_at:, additional_properties: nil) # @type [Integer] A UTC timestamp at which notification was created. This is stored as a millisecond representation of the Unix epoch (the time passed since January 1, 1970). @created_at = created_at # @type [String] A unique identifier associated with the notification. @id = id # @type [Templates::RoutingStrategy] Routing strategy used by this notification. @routing = routing # @type [Array<Templates::Tag>] A list of tags attached to the notification. @tags = # @type [String] The title of the notification. @title = title # @type [Integer] A UTC timestamp at which notification was updated. This is stored as a millisecond representation of the Unix epoch (the time passed since January 1, 1970). @updated_at = updated_at # @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.
10 11 12 |
# File 'lib/trycourier/templates/types/notification_templates.rb', line 10 def additional_properties @additional_properties end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
10 11 12 |
# File 'lib/trycourier/templates/types/notification_templates.rb', line 10 def created_at @created_at end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
10 11 12 |
# File 'lib/trycourier/templates/types/notification_templates.rb', line 10 def id @id end |
#routing ⇒ Object (readonly)
Returns the value of attribute routing.
10 11 12 |
# File 'lib/trycourier/templates/types/notification_templates.rb', line 10 def routing @routing end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
10 11 12 |
# File 'lib/trycourier/templates/types/notification_templates.rb', line 10 def @tags end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
10 11 12 |
# File 'lib/trycourier/templates/types/notification_templates.rb', line 10 def title @title end |
#updated_at ⇒ Object (readonly)
Returns the value of attribute updated_at.
10 11 12 |
# File 'lib/trycourier/templates/types/notification_templates.rb', line 10 def updated_at @updated_at end |
Class Method Details
.from_json(json_object:) ⇒ Templates::NotificationTemplates
Deserialize a JSON object to an instance of NotificationTemplates
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/trycourier/templates/types/notification_templates.rb', line 41 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) created_at = struct.created_at id = struct.id if parsed_json["routing"].nil? routing = nil else routing = parsed_json["routing"].to_json routing = Templates::RoutingStrategy.from_json(json_object: routing) end = parsed_json["tags"]&.map do |v| v = v.to_json Templates::Tag.from_json(json_object: v) end title = struct.title updated_at = struct.updated_at new(created_at: created_at, id: id, routing: routing, tags: , title: title, updated_at: updated_at, 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.
80 81 82 83 84 85 86 87 |
# File 'lib/trycourier/templates/types/notification_templates.rb', line 80 def self.validate_raw(obj:) obj.created_at.is_a?(Integer) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") Templates::RoutingStrategy.validate_raw(obj: obj.routing) obj..is_a?(Array) != false || raise("Passed value for field obj.tags is not the expected type, validation failed.") obj.title.is_a?(String) != false || raise("Passed value for field obj.title is not the expected type, validation failed.") obj.updated_at.is_a?(Integer) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ JSON
Serialize an instance of NotificationTemplates to a JSON object
65 66 67 68 69 70 71 72 73 74 |
# File 'lib/trycourier/templates/types/notification_templates.rb', line 65 def to_json(*_args) { "created_at": @created_at, "id": @id, "routing": @routing, "tags": @tags, "title": @title, "updated_at": @updated_at }.to_json end |