Class: Line::Bot::V2::Insight::GetRichMenuInsightSummaryResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/line/bot/v2/insight/model/get_rich_menu_insight_summary_response.rb,
sig/line/bot/v2/insight/model/get_rich_menu_insight_summary_response.rbs

Overview

Summary of impression and click statistics for a rich menu created via the Messaging API.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rich_menu_id:, metrics_from: nil, metrics_to: nil, impression: nil, clicks: nil, **dynamic_attributes) ⇒ Object

Parameters:

  • rich_menu_id (String)

    Rich menu ID.

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

    Start date (JST) of the period actually covered by the returned metrics. Format: yyyyMMdd (e.g. 20260213).

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

    End date (JST) of the period actually covered by the returned metrics. Format: yyyyMMdd (e.g. 20260215).

  • impression (GetRichMenuInsightSummaryResponseImpression, Hash[Symbol, untyped], nil) (defaults to: nil)
  • clicks (Array[GetRichMenuInsightSummaryResponseClick, Hash[Symbol, untyped]], nil) (defaults to: nil)

    Click metrics for each tappable area of the rich menu.



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/line/bot/v2/insight/model/get_rich_menu_insight_summary_response.rb', line 37

def initialize(
  rich_menu_id:,
  metrics_from: nil,
  metrics_to: nil,
  impression: nil,
  clicks: nil,
  **dynamic_attributes
)
  
  @rich_menu_id = rich_menu_id
  @metrics_from = metrics_from
  @metrics_to = metrics_to
  @impression = impression.is_a?(Line::Bot::V2::Insight::GetRichMenuInsightSummaryResponseImpression) || impression.nil? ? impression : Line::Bot::V2::Insight::GetRichMenuInsightSummaryResponseImpression.create(**impression)
  @clicks = clicks&.map do |item|
    if item.is_a?(Hash)
      Line::Bot::V2::Insight::GetRichMenuInsightSummaryResponseClick.create(**item)
    else
      item
    end
  end

  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

#clicksArray[GetRichMenuInsightSummaryResponseClick]?

Returns Click metrics for each tappable area of the rich menu.

Returns:



30
31
32
# File 'lib/line/bot/v2/insight/model/get_rich_menu_insight_summary_response.rb', line 30

def clicks
  @clicks
end

#impressionGetRichMenuInsightSummaryResponseImpression?



27
28
29
# File 'lib/line/bot/v2/insight/model/get_rich_menu_insight_summary_response.rb', line 27

def impression
  @impression
end

#metrics_fromString?

Returns Start date (JST) of the period actually covered by the returned metrics. Format: yyyyMMdd (e.g. 20260213).

Returns:

  • (String, nil)

    Start date (JST) of the period actually covered by the returned metrics. Format: yyyyMMdd (e.g. 20260213).



21
22
23
# File 'lib/line/bot/v2/insight/model/get_rich_menu_insight_summary_response.rb', line 21

def metrics_from
  @metrics_from
end

#metrics_toString?

Returns End date (JST) of the period actually covered by the returned metrics. Format: yyyyMMdd (e.g. 20260215).

Returns:

  • (String, nil)

    End date (JST) of the period actually covered by the returned metrics. Format: yyyyMMdd (e.g. 20260215).



24
25
26
# File 'lib/line/bot/v2/insight/model/get_rich_menu_insight_summary_response.rb', line 24

def metrics_to
  @metrics_to
end

#rich_menu_idString

Returns Rich menu ID.

Returns:

  • (String)

    Rich menu ID.



18
19
20
# File 'lib/line/bot/v2/insight/model/get_rich_menu_insight_summary_response.rb', line 18

def rich_menu_id
  @rich_menu_id
end

Class Method Details

.create(args) ⇒ Line::Bot::V2::Insight::GetRichMenuInsightSummaryResponse

Create an instance of the class from a hash

Parameters:

  • args (Hash)

    Hash containing all the required attributes

  • (Hash[Symbol, untyped])

Returns:



74
75
76
77
# File 'lib/line/bot/v2/insight/model/get_rich_menu_insight_summary_response.rb', line 74

def self.create(args)
  symbolized_args = Line::Bot::V2::Utils.deep_symbolize(args)
  return new(**symbolized_args) # steep:ignore InsufficientKeywordArguments
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



81
82
83
84
85
86
87
# File 'lib/line/bot/v2/insight/model/get_rich_menu_insight_summary_response.rb', line 81

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



90
91
92
# File 'lib/line/bot/v2/insight/model/get_rich_menu_insight_summary_response.rb', line 90

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