Class: Pinnacle::CardStyle
- Inherits:
-
Object
- Object
- Pinnacle::CardStyle
- Defined in:
- lib/rcs/types/card_style.rb
Constant Summary collapse
- OMIT =
Object.new
Instance Attribute Summary collapse
-
#additional_properties ⇒ OpenStruct
readonly
Additional properties unmapped to the current class definition.
-
#image_alignment ⇒ Pinnacle::CardStyleImageAlignment
readonly
Alignment of the image in the card.
-
#media_height ⇒ Pinnacle::CardStyleMediaHeight
readonly
Height of the media in the card.
-
#orientation ⇒ Pinnacle::CardStyleOrientation
readonly
Orientation of the card.
-
#thumbnail_url ⇒ String
readonly
URL of the thumbnail image.
-
#width ⇒ Pinnacle::CardStyleWidth
readonly
Width of the card.
Class Method Summary collapse
-
.from_json(json_object:) ⇒ Pinnacle::CardStyle
Deserialize a JSON object to an instance of CardStyle.
-
.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(image_alignment: OMIT, media_height: OMIT, thumbnail_url: OMIT, width: OMIT, orientation: OMIT, additional_properties: nil) ⇒ Pinnacle::CardStyle constructor
-
#to_json(*_args) ⇒ String
Serialize an instance of CardStyle to a JSON object.
Constructor Details
#initialize(image_alignment: OMIT, media_height: OMIT, thumbnail_url: OMIT, width: OMIT, orientation: OMIT, additional_properties: nil) ⇒ Pinnacle::CardStyle
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/rcs/types/card_style.rb', line 37 def initialize(image_alignment: OMIT, media_height: OMIT, thumbnail_url: OMIT, width: OMIT, orientation: OMIT, additional_properties: nil) @image_alignment = image_alignment if image_alignment != OMIT @media_height = media_height if media_height != OMIT @thumbnail_url = thumbnail_url if thumbnail_url != OMIT @width = width if width != OMIT @orientation = orientation if orientation != OMIT @additional_properties = additional_properties @_field_set = { "image_alignment": image_alignment, "media_height": media_height, "thumbnail_url": thumbnail_url, "width": width, "orientation": orientation }.reject do |_k, v| v == OMIT end end |
Instance Attribute Details
#additional_properties ⇒ OpenStruct (readonly)
Returns Additional properties unmapped to the current class definition.
23 24 25 |
# File 'lib/rcs/types/card_style.rb', line 23 def additional_properties @additional_properties end |
#image_alignment ⇒ Pinnacle::CardStyleImageAlignment (readonly)
Returns Alignment of the image in the card. Only available for horizontal cards.
13 14 15 |
# File 'lib/rcs/types/card_style.rb', line 13 def image_alignment @image_alignment end |
#media_height ⇒ Pinnacle::CardStyleMediaHeight (readonly)
Returns Height of the media in the card. Only available for vertical cards.
15 16 17 |
# File 'lib/rcs/types/card_style.rb', line 15 def media_height @media_height end |
#orientation ⇒ Pinnacle::CardStyleOrientation (readonly)
Returns Orientation of the card.
21 22 23 |
# File 'lib/rcs/types/card_style.rb', line 21 def orientation @orientation end |
#thumbnail_url ⇒ String (readonly)
Returns URL of the thumbnail image.
17 18 19 |
# File 'lib/rcs/types/card_style.rb', line 17 def thumbnail_url @thumbnail_url end |
#width ⇒ Pinnacle::CardStyleWidth (readonly)
Returns Width of the card.
19 20 21 |
# File 'lib/rcs/types/card_style.rb', line 19 def width @width end |
Class Method Details
.from_json(json_object:) ⇒ Pinnacle::CardStyle
Deserialize a JSON object to an instance of CardStyle
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/rcs/types/card_style.rb', line 60 def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) image_alignment = parsed_json["image_alignment"] media_height = parsed_json["media_height"] thumbnail_url = parsed_json["thumbnail_url"] width = parsed_json["width"] orientation = parsed_json["orientation"] new( image_alignment: image_alignment, media_height: media_height, thumbnail_url: thumbnail_url, width: width, orientation: orientation, 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.
91 92 93 94 95 96 97 |
# File 'lib/rcs/types/card_style.rb', line 91 def self.validate_raw(obj:) obj.image_alignment&.is_a?(Pinnacle::CardStyleImageAlignment) != false || raise("Passed value for field obj.image_alignment is not the expected type, validation failed.") obj.media_height&.is_a?(Pinnacle::CardStyleMediaHeight) != false || raise("Passed value for field obj.media_height is not the expected type, validation failed.") obj.thumbnail_url&.is_a?(String) != false || raise("Passed value for field obj.thumbnail_url is not the expected type, validation failed.") obj.width&.is_a?(Pinnacle::CardStyleWidth) != false || raise("Passed value for field obj.width is not the expected type, validation failed.") obj.orientation&.is_a?(Pinnacle::CardStyleOrientation) != false || raise("Passed value for field obj.orientation is not the expected type, validation failed.") end |
Instance Method Details
#to_json(*_args) ⇒ String
Serialize an instance of CardStyle to a JSON object
81 82 83 |
# File 'lib/rcs/types/card_style.rb', line 81 def to_json(*_args) @_field_set&.to_json end |