Class: PostProxy::MessageCard

Inherits:
Model
  • Object
show all
Defined in:
lib/postproxy/types.rb

Overview

Extra fields for the generic-template element that carries buttons. Requires buttons. subtitle is capped at 80 characters, and both URLs must be https.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**attrs) ⇒ MessageCard

Returns a new instance of MessageCard.



481
482
483
484
485
486
487
488
489
# File 'lib/postproxy/types.rb', line 481

def initialize(**attrs)
  @subtitle = nil
  @image_url = nil
  @default_action = nil
  super
  if @default_action && !@default_action.is_a?(CardDefaultAction)
    @default_action = CardDefaultAction.new(**@default_action.transform_keys(&:to_sym))
  end
end

Instance Attribute Details

#default_actionObject

Returns the value of attribute default_action.



479
480
481
# File 'lib/postproxy/types.rb', line 479

def default_action
  @default_action
end

#image_urlObject

Returns the value of attribute image_url.



479
480
481
# File 'lib/postproxy/types.rb', line 479

def image_url
  @image_url
end

#subtitleObject

Returns the value of attribute subtitle.



479
480
481
# File 'lib/postproxy/types.rb', line 479

def subtitle
  @subtitle
end

Instance Method Details

#to_hObject



491
492
493
494
495
496
497
# File 'lib/postproxy/types.rb', line 491

def to_h
  {
    subtitle: @subtitle,
    image_url: @image_url,
    default_action: @default_action&.to_h
  }.compact
end