Class: Pinnacle::CardStyle

Inherits:
Object
  • Object
show all
Defined in:
lib/rcs/types/card_style.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(image_alignment: OMIT, media_height: OMIT, thumbnail_url: OMIT, width: OMIT, orientation: OMIT, additional_properties: nil) ⇒ Pinnacle::CardStyle

Parameters:

  • image_alignment (Pinnacle::CardStyleImageAlignment) (defaults to: OMIT)

    Alignment of the image in the card. Only available for horizontal cards.

  • media_height (Pinnacle::CardStyleMediaHeight) (defaults to: OMIT)

    Height of the media in the card. Only available for vertical cards.

  • thumbnail_url (String) (defaults to: OMIT)

    URL of the thumbnail image

  • width (Pinnacle::CardStyleWidth) (defaults to: OMIT)

    Width of the card

  • orientation (Pinnacle::CardStyleOrientation) (defaults to: OMIT)

    Orientation of the card

  • additional_properties (OpenStruct) (defaults to: nil)

    Additional properties unmapped to the current class definition



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_propertiesOpenStruct (readonly)

Returns Additional properties unmapped to the current class definition.

Returns:

  • (OpenStruct)

    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_alignmentPinnacle::CardStyleImageAlignment (readonly)

Returns Alignment of the image in the card. Only available for horizontal cards.

Returns:



13
14
15
# File 'lib/rcs/types/card_style.rb', line 13

def image_alignment
  @image_alignment
end

#media_heightPinnacle::CardStyleMediaHeight (readonly)

Returns Height of the media in the card. Only available for vertical cards.

Returns:



15
16
17
# File 'lib/rcs/types/card_style.rb', line 15

def media_height
  @media_height
end

#orientationPinnacle::CardStyleOrientation (readonly)

Returns Orientation of the card.

Returns:



21
22
23
# File 'lib/rcs/types/card_style.rb', line 21

def orientation
  @orientation
end

#thumbnail_urlString (readonly)

Returns URL of the thumbnail image.

Returns:

  • (String)

    URL of the thumbnail image



17
18
19
# File 'lib/rcs/types/card_style.rb', line 17

def thumbnail_url
  @thumbnail_url
end

#widthPinnacle::CardStyleWidth (readonly)

Returns Width of the card.

Returns:



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

Parameters:

  • json_object (String)

Returns:



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.

Parameters:

  • obj (Object)

Returns:

  • (Void)


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

Returns:

  • (String)


81
82
83
# File 'lib/rcs/types/card_style.rb', line 81

def to_json(*_args)
  @_field_set&.to_json
end