Class: Line::Bot::V2::MessagingApi::FlexBubble

Inherits:
FlexContainer show all
Defined in:
lib/line/bot/v2/messaging_api/model/flex_bubble.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(direction: nil, styles: nil, header: nil, hero: nil, body: nil, footer: nil, size: nil, action: nil, **dynamic_attributes) ⇒ FlexBubble

Returns a new instance of FlexBubble.

Parameters:

  • direction (String, nil) (defaults to: nil)

    (‘ltr’|‘rtl’)

  • styles (FlexBubbleStyles, Hash[Symbol, untyped], nil) (defaults to: nil)
  • header (FlexBox, Hash[Symbol, untyped], nil) (defaults to: nil)
  • hero (FlexComponent, Hash[Symbol, untyped], nil) (defaults to: nil)
  • body (FlexBox, Hash[Symbol, untyped], nil) (defaults to: nil)
  • footer (FlexBox, Hash[Symbol, untyped], nil) (defaults to: nil)
  • size (String, nil) (defaults to: nil)

    (‘nano’|‘micro’|‘deca’|‘hecto’|‘kilo’|‘mega’|‘giga’)

  • action (Action, Hash[Symbol, untyped], nil) (defaults to: nil)


53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/line/bot/v2/messaging_api/model/flex_bubble.rb', line 53

def initialize(
  direction: nil,
  styles: nil,
  header: nil,
  hero: nil,
  body: nil,
  footer: nil,
  size: nil,
  action: nil,
  **dynamic_attributes
)
  @type = "bubble"
  
  @direction = direction
  @styles = styles.is_a?(Line::Bot::V2::MessagingApi::FlexBubbleStyles) || styles.nil? ? styles : Line::Bot::V2::MessagingApi::FlexBubbleStyles.create(**styles) # steep:ignore
  @header = header.is_a?(Line::Bot::V2::MessagingApi::FlexBox) || header.nil? ? header : Line::Bot::V2::MessagingApi::FlexBox.create(**header) # steep:ignore
  @hero = hero.is_a?(Line::Bot::V2::MessagingApi::FlexComponent) || hero.nil? ? hero : Line::Bot::V2::MessagingApi::FlexComponent.create(**hero) # steep:ignore
  @body = body.is_a?(Line::Bot::V2::MessagingApi::FlexBox) || body.nil? ? body : Line::Bot::V2::MessagingApi::FlexBox.create(**body) # steep:ignore
  @footer = footer.is_a?(Line::Bot::V2::MessagingApi::FlexBox) || footer.nil? ? footer : Line::Bot::V2::MessagingApi::FlexBox.create(**footer) # steep:ignore
  @size = size
  @action = action.is_a?(Line::Bot::V2::MessagingApi::Action) || action.nil? ? action : Line::Bot::V2::MessagingApi::Action.create(**action) # steep:ignore

  dynamic_attributes.each do |key, value|
    self.class.attr_accessor key

    if value.is_a?(Hash)
      struct_klass = Struct.new(*value.keys.map(&:to_sym))
      struct_values = value.map { |_k, v| v.is_a?(Hash) ? Line::Bot::V2::Utils.hash_to_struct(v) : v }
      instance_variable_set("@#{key}", struct_klass.new(*struct_values))
    else
      instance_variable_set("@#{key}", value)
    end
  end
end

Instance Attribute Details

#actionAction?

Returns:



43
44
45
# File 'lib/line/bot/v2/messaging_api/model/flex_bubble.rb', line 43

def action
  @action
end

#bodyFlexBox?

Returns:



34
35
36
# File 'lib/line/bot/v2/messaging_api/model/flex_bubble.rb', line 34

def body
  @body
end

#directionString?

Returns (‘ltr’|‘rtl’).

Returns:

  • (String, nil)

    (‘ltr’|‘rtl’)



22
23
24
# File 'lib/line/bot/v2/messaging_api/model/flex_bubble.rb', line 22

def direction
  @direction
end

Returns:



37
38
39
# File 'lib/line/bot/v2/messaging_api/model/flex_bubble.rb', line 37

def footer
  @footer
end

#headerFlexBox?

Returns:



28
29
30
# File 'lib/line/bot/v2/messaging_api/model/flex_bubble.rb', line 28

def header
  @header
end

#heroFlexComponent?

Returns:



31
32
33
# File 'lib/line/bot/v2/messaging_api/model/flex_bubble.rb', line 31

def hero
  @hero
end

#sizeString?

Returns (‘nano’|‘micro’|‘deca’|‘hecto’|‘kilo’|‘mega’|‘giga’).

Returns:

  • (String, nil)

    (‘nano’|‘micro’|‘deca’|‘hecto’|‘kilo’|‘mega’|‘giga’)



40
41
42
# File 'lib/line/bot/v2/messaging_api/model/flex_bubble.rb', line 40

def size
  @size
end

#stylesFlexBubbleStyles?

Returns:



25
26
27
# File 'lib/line/bot/v2/messaging_api/model/flex_bubble.rb', line 25

def styles
  @styles
end

#typeObject (readonly)

Returns the value of attribute type.



19
20
21
# File 'lib/line/bot/v2/messaging_api/model/flex_bubble.rb', line 19

def type
  @type
end

Class Method Details

.create(args) ⇒ Line::Bot::V2::MessagingApi::FlexBubble

Create an instance of the class from a hash

Parameters:

  • args (Hash)

    Hash containing all the required attributes

Returns:



91
92
93
94
# File 'lib/line/bot/v2/messaging_api/model/flex_bubble.rb', line 91

def self.create(args) # steep:ignore
  symbolized_args = Line::Bot::V2::Utils.deep_symbolize(args)
  return new(**symbolized_args) # steep:ignore
end

Instance Method Details

#==(other) ⇒ Boolean

Returns true if the objects are equal, false otherwise.

Parameters:

  • other (Object)

    Object to compare

Returns:

  • (Boolean)

    true if the objects are equal, false otherwise



98
99
100
101
102
103
104
# File 'lib/line/bot/v2/messaging_api/model/flex_bubble.rb', line 98

def ==(other)
  return false unless self.class == other.class

  instance_variables.all? do |var|
      instance_variable_get(var) == other.instance_variable_get(var)
  end
end

#hashInteger

Returns Hash code of the object.

Returns:

  • (Integer)

    Hash code of the object



107
108
109
# File 'lib/line/bot/v2/messaging_api/model/flex_bubble.rb', line 107

def hash
  [self.class, *instance_variables.map { |var| instance_variable_get(var) }].hash
end