Class: Pinnacle::Card
- Inherits:
-
Object
- Object
- Pinnacle::Card
- Defined in:
- lib/rcs/types/card.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#buttons ⇒ Array<Pinnacle::Action>
readonly
Optional list of buttons on the card (max 4).
-
#media_url ⇒ String
readonly
Optional media URL displayed with the card.
-
#subtitle ⇒ String
readonly
Optional subtitle for the card.
-
#title ⇒ String
readonly
The title of the card.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Pinnacle::Card
Deserialize a JSON object to an instance of Card.
-
.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(title:, subtitle: OMIT, media_url: OMIT, buttons: OMIT, additional_properties: nil) ⇒ Pinnacle::Card constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of Card to a JSON object.
Constructor Details
#initialize(title:, subtitle: OMIT, media_url: OMIT, buttons: OMIT, additional_properties: nil) ⇒ Pinnacle::Card
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rcs/types/card.rb', line 31 def initialize(title:, subtitle: OMIT, media_url: OMIT, buttons: OMIT, additional_properties: nil) @title = title @subtitle = subtitle if subtitle != OMIT @media_url = media_url if media_url != OMIT @buttons = if != OMIT @additional_properties = additional_properties @_field_set = { "title": title, "subtitle": subtitle, "mediaUrl": media_url, "buttons": }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
18 19 20 |
# File 'lib/rcs/types/card.rb', line 18 def additional_properties @additional_properties end |
#buttons ⇒ Array<Pinnacle::Action> (readonly)
Returns Optional list of buttons on the card (max 4).
16 17 18 |
# File 'lib/rcs/types/card.rb', line 16 def @buttons end |
#media_url ⇒ String (readonly)
Returns Optional media URL displayed with the card.
14 15 16 |
# File 'lib/rcs/types/card.rb', line 14 def media_url @media_url end |
#subtitle ⇒ String (readonly)
Returns Optional subtitle for the card.
12 13 14 |
# File 'lib/rcs/types/card.rb', line 12 def subtitle @subtitle end |
#title ⇒ String (readonly)
Returns The title of the card.
10 11 12 |
# File 'lib/rcs/types/card.rb', line 10 def title @title end |
Class Method Details
.from_json(json_object:) ⇒ Pinnacle::Card
Deserialize a JSON object to an instance of Card
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/rcs/types/card.rb', line 51 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) title = parsed_json["title"] subtitle = parsed_json["subtitle"] media_url = parsed_json["mediaUrl"] = parsed_json["buttons"]&.map do |item| item = item.to_json Pinnacle::Action.from_json(json_object: item) end new( title: title, subtitle: subtitle, media_url: media_url, buttons: , 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.
83 84 85 86 87 88 |
# File 'lib/rcs/types/card.rb', line 83 def self.validate_raw(obj:) obj.title.is_a?(String) != false || raise("Passed value for field obj.title is not the expected type, validation failed.") obj.subtitle&.is_a?(String) != false || raise("Passed value for field obj.subtitle is not the expected type, validation failed.") obj.media_url&.is_a?(String) != false || raise("Passed value for field obj.media_url is not the expected type, validation failed.") obj.&.is_a?(Array) != false || raise("Passed value for field obj.buttons is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of Card to a JSON object
73 74 75 |
# File 'lib/rcs/types/card.rb', line 73 def to_json(*_args) @_field_set&.to_json end |