Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/line/bot/v2/insight/.openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ model/get_message_event_response_message.rb
model/get_message_event_response_overview.rb
model/get_number_of_followers_response.rb
model/get_number_of_message_deliveries_response.rb
model/get_rich_menu_insight_daily_response.rb
model/get_rich_menu_insight_daily_response_bounds.rb
model/get_rich_menu_insight_daily_response_click.rb
model/get_rich_menu_insight_daily_response_daily_metrics.rb
model/get_rich_menu_insight_daily_response_impression.rb
model/get_rich_menu_insight_summary_response.rb
model/get_rich_menu_insight_summary_response_bounds.rb
model/get_rich_menu_insight_summary_response_click.rb
model/get_rich_menu_insight_summary_response_impression.rb
model/get_rich_menu_insight_summary_response_metrics.rb
model/get_statistics_per_unit_response.rb
model/get_statistics_per_unit_response_click.rb
model/get_statistics_per_unit_response_message.rb
Expand Down
166 changes: 166 additions & 0 deletions lib/line/bot/v2/insight/api/insight_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,172 @@ def get_number_of_message_deliveries(
response_body
end

# Gets rich menu statistics broken down by day for the specified period, for a rich menu created via the Messaging API. Returns the daily impression count for the whole rich menu and the daily click count for each tappable area. When the total number of unique clicks during the period is below the privacy threshold, only `richMenuId` is returned and the other fields are omitted.
# This requests to <code>GET https://api.line.me/v2/bot/insight/richmenu/{richMenuId}/daily</code>
# This returns an array containing response, HTTP status code, and header in order. Please specify all header keys in lowercase.
#
# @param rich_menu_id [String] ID of the rich menu created via the Messaging API.
# @param from [String] Start date of the aggregation period (inclusive). Must be within the most recent 3 years. Format: yyyyMMdd (e.g. 20260213) Time zone: UTC+9
# @param to [String] End date of the aggregation period (inclusive). The end date can be specified for up to 99 days after the start date. Format: yyyyMMdd (e.g. 20260215) Time zone: UTC+9
# @see https://developers.line.biz/en/reference/messaging-api/#get-rich-menu-insight-daily
# @return [Array(Line::Bot::V2::Insight::GetRichMenuInsightDailyResponse, Integer, Hash{String => String})] when HTTP status code is 200
# @return [Array(Line::Bot::V2::Insight::ErrorResponse, Integer, Hash{String => String})] when HTTP status code is 400
# @return [Array(Line::Bot::V2::Insight::ErrorResponse, Integer, Hash{String => String})] when HTTP status code is 404
# @return [Array((String|nil), Integer, Hash{String => String})] when other HTTP status code is returned. String is HTTP response body itself.
def get_rich_menu_insight_daily_with_http_info(
rich_menu_id:,
from:,
to:
)
path = Line::Bot::V2::Utils.build_path("/v2/bot/insight/richmenu/{richMenuId}/daily", {
"richMenuId": rich_menu_id
})
query_params = {
"from": from,
"to": to
}.compact

response = @http_client.get(
path: path,
query_params: query_params,
)

case response.code.to_i
when 200
json = Line::Bot::V2::Utils.deep_underscore(JSON.parse(response.body))
json.transform_keys! do |key|
Line::Bot::V2::RESERVED_WORDS.include?(key) ? "_#{key}".to_sym : key
end
response_body = Line::Bot::V2::Insight::GetRichMenuInsightDailyResponse.create(json)
[response_body, 200, response.each_header.to_h]
when 400
json = Line::Bot::V2::Utils.deep_underscore(JSON.parse(response.body))
json.transform_keys! do |key|
Line::Bot::V2::RESERVED_WORDS.include?(key) ? "_#{key}".to_sym : key
end
response_body = Line::Bot::V2::Insight::ErrorResponse.create(json)
[response_body, 400, response.each_header.to_h]
when 404
json = Line::Bot::V2::Utils.deep_underscore(JSON.parse(response.body))
json.transform_keys! do |key|
Line::Bot::V2::RESERVED_WORDS.include?(key) ? "_#{key}".to_sym : key
end
response_body = Line::Bot::V2::Insight::ErrorResponse.create(json)
[response_body, 404, response.each_header.to_h]
else
[response.body, response.code.to_i, response.each_header.to_h]
end
end

# Gets rich menu statistics broken down by day for the specified period, for a rich menu created via the Messaging API. Returns the daily impression count for the whole rich menu and the daily click count for each tappable area. When the total number of unique clicks during the period is below the privacy threshold, only `richMenuId` is returned and the other fields are omitted.
# This requests to <code>GET https://api.line.me/v2/bot/insight/richmenu/{richMenuId}/daily</code>
# When you want to get HTTP status code or response headers, use {#get_rich_menu_insight_daily_with_http_info} instead of this.
#
# @param rich_menu_id [String] ID of the rich menu created via the Messaging API.
# @param from [String] Start date of the aggregation period (inclusive). Must be within the most recent 3 years. Format: yyyyMMdd (e.g. 20260213) Time zone: UTC+9
# @param to [String] End date of the aggregation period (inclusive). The end date can be specified for up to 99 days after the start date. Format: yyyyMMdd (e.g. 20260215) Time zone: UTC+9
# @see https://developers.line.biz/en/reference/messaging-api/#get-rich-menu-insight-daily
# @return [Line::Bot::V2::Insight::GetRichMenuInsightDailyResponse] when HTTP status code is 200
# @return [Line::Bot::V2::Insight::ErrorResponse] when HTTP status code is 400
# @return [Line::Bot::V2::Insight::ErrorResponse] when HTTP status code is 404
# @return [String, nil] when other HTTP status code is returned. This String is HTTP response body itself.
def get_rich_menu_insight_daily(
rich_menu_id:,
from:,
to:
)
response_body, _status_code, _headers = get_rich_menu_insight_daily_with_http_info(
rich_menu_id: rich_menu_id,
from: from,
to: to
)

response_body
end

# Gets a summary of rich menu statistics for the specified period, for a rich menu created via the Messaging API. Returns the total impression count for the whole rich menu and the click count for each tappable area, aggregated over the entire period as a single result. When the total number of unique clicks during the period is below the privacy threshold, only `richMenuId` is returned and the other fields are omitted.
# This requests to <code>GET https://api.line.me/v2/bot/insight/richmenu/{richMenuId}/summary</code>
# This returns an array containing response, HTTP status code, and header in order. Please specify all header keys in lowercase.
#
# @param rich_menu_id [String] ID of the rich menu created via the Messaging API.
# @param from [String] Start date of the aggregation period (inclusive). Must be within the most recent 3 years. Format: yyyyMMdd (e.g. 20260213) Time zone: UTC+9
# @param to [String] End date of the aggregation period (inclusive). The end date can be specified for up to 396 days after the start date. Format: yyyyMMdd (e.g. 20260215) Time zone: UTC+9
# @see https://developers.line.biz/en/reference/messaging-api/#get-rich-menu-insight-summary
# @return [Array(Line::Bot::V2::Insight::GetRichMenuInsightSummaryResponse, Integer, Hash{String => String})] when HTTP status code is 200
# @return [Array(Line::Bot::V2::Insight::ErrorResponse, Integer, Hash{String => String})] when HTTP status code is 400
# @return [Array(Line::Bot::V2::Insight::ErrorResponse, Integer, Hash{String => String})] when HTTP status code is 404
# @return [Array((String|nil), Integer, Hash{String => String})] when other HTTP status code is returned. String is HTTP response body itself.
def get_rich_menu_insight_summary_with_http_info(
rich_menu_id:,
from:,
to:
)
path = Line::Bot::V2::Utils.build_path("/v2/bot/insight/richmenu/{richMenuId}/summary", {
"richMenuId": rich_menu_id
})
query_params = {
"from": from,
"to": to
}.compact

response = @http_client.get(
path: path,
query_params: query_params,
)

case response.code.to_i
when 200
json = Line::Bot::V2::Utils.deep_underscore(JSON.parse(response.body))
json.transform_keys! do |key|
Line::Bot::V2::RESERVED_WORDS.include?(key) ? "_#{key}".to_sym : key
end
response_body = Line::Bot::V2::Insight::GetRichMenuInsightSummaryResponse.create(json)
[response_body, 200, response.each_header.to_h]
when 400
json = Line::Bot::V2::Utils.deep_underscore(JSON.parse(response.body))
json.transform_keys! do |key|
Line::Bot::V2::RESERVED_WORDS.include?(key) ? "_#{key}".to_sym : key
end
response_body = Line::Bot::V2::Insight::ErrorResponse.create(json)
[response_body, 400, response.each_header.to_h]
when 404
json = Line::Bot::V2::Utils.deep_underscore(JSON.parse(response.body))
json.transform_keys! do |key|
Line::Bot::V2::RESERVED_WORDS.include?(key) ? "_#{key}".to_sym : key
end
response_body = Line::Bot::V2::Insight::ErrorResponse.create(json)
[response_body, 404, response.each_header.to_h]
else
[response.body, response.code.to_i, response.each_header.to_h]
end
end

# Gets a summary of rich menu statistics for the specified period, for a rich menu created via the Messaging API. Returns the total impression count for the whole rich menu and the click count for each tappable area, aggregated over the entire period as a single result. When the total number of unique clicks during the period is below the privacy threshold, only `richMenuId` is returned and the other fields are omitted.
# This requests to <code>GET https://api.line.me/v2/bot/insight/richmenu/{richMenuId}/summary</code>
# When you want to get HTTP status code or response headers, use {#get_rich_menu_insight_summary_with_http_info} instead of this.
#
# @param rich_menu_id [String] ID of the rich menu created via the Messaging API.
# @param from [String] Start date of the aggregation period (inclusive). Must be within the most recent 3 years. Format: yyyyMMdd (e.g. 20260213) Time zone: UTC+9
# @param to [String] End date of the aggregation period (inclusive). The end date can be specified for up to 396 days after the start date. Format: yyyyMMdd (e.g. 20260215) Time zone: UTC+9
# @see https://developers.line.biz/en/reference/messaging-api/#get-rich-menu-insight-summary
# @return [Line::Bot::V2::Insight::GetRichMenuInsightSummaryResponse] when HTTP status code is 200
# @return [Line::Bot::V2::Insight::ErrorResponse] when HTTP status code is 400
# @return [Line::Bot::V2::Insight::ErrorResponse] when HTTP status code is 404
# @return [String, nil] when other HTTP status code is returned. This String is HTTP response body itself.
def get_rich_menu_insight_summary(
rich_menu_id:,
from:,
to:
)
response_body, _status_code, _headers = get_rich_menu_insight_summary_with_http_info(
rich_menu_id: rich_menu_id,
from: from,
to: to
)

response_body
end

# You can check the per-unit statistics of how users interact with push messages and multicast messages sent from your LINE Official Account.
# This requests to <code>GET https://api.line.me/v2/bot/insight/message/event/aggregation</code>
# This returns an array containing response, HTTP status code, and header in order. Please specify all header keys in lowercase.
Expand Down
10 changes: 10 additions & 0 deletions lib/line/bot/v2/insight/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@
require_relative './model/get_message_event_response_overview'
require_relative './model/get_number_of_followers_response'
require_relative './model/get_number_of_message_deliveries_response'
require_relative './model/get_rich_menu_insight_daily_response'
require_relative './model/get_rich_menu_insight_daily_response_bounds'
require_relative './model/get_rich_menu_insight_daily_response_click'
require_relative './model/get_rich_menu_insight_daily_response_daily_metrics'
require_relative './model/get_rich_menu_insight_daily_response_impression'
require_relative './model/get_rich_menu_insight_summary_response'
require_relative './model/get_rich_menu_insight_summary_response_bounds'
require_relative './model/get_rich_menu_insight_summary_response_click'
require_relative './model/get_rich_menu_insight_summary_response_impression'
require_relative './model/get_rich_menu_insight_summary_response_metrics'
require_relative './model/get_statistics_per_unit_response'
require_relative './model/get_statistics_per_unit_response_click'
require_relative './model/get_statistics_per_unit_response_message'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# LINE Messaging API(Insight)
# This document describes LINE Messaging API(Insight).
#
# The version of the OpenAPI document: 0.0.1
#
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
# https://openapi-generator.tech
# Do not edit the class manually.

module Line
module Bot
module V2
module Insight
# Daily impression and click statistics for a rich menu created via the Messaging API.
class GetRichMenuInsightDailyResponse
# @!attribute [rw] rich_menu_id
# @return [String] Rich menu ID.
attr_accessor :rich_menu_id
# @!attribute [rw] metrics_from
# @return [String,nil] Start date (JST) of the period actually covered by the returned metrics. Format: yyyyMMdd (e.g. 20260213).
attr_accessor :metrics_from
# @!attribute [rw] metrics_to
# @return [String,nil] End date (JST) of the period actually covered by the returned metrics. Format: yyyyMMdd (e.g. 20260215).
attr_accessor :metrics_to
# @!attribute [rw] impression
# @return [GetRichMenuInsightDailyResponseImpression,nil]
attr_accessor :impression
# @!attribute [rw] clicks
# @return [Array[GetRichMenuInsightDailyResponseClick],nil] Daily click metrics for each tappable area of the rich menu.
attr_accessor :clicks

# @param rich_menu_id [String] Rich menu ID.
# @param metrics_from [String,nil] Start date (JST) of the period actually covered by the returned metrics. Format: yyyyMMdd (e.g. 20260213).
# @param metrics_to [String,nil] End date (JST) of the period actually covered by the returned metrics. Format: yyyyMMdd (e.g. 20260215).
# @param impression [GetRichMenuInsightDailyResponseImpression, Hash[Symbol, untyped], nil]
# @param clicks [Array[GetRichMenuInsightDailyResponseClick, Hash[Symbol, untyped]],nil] Daily click metrics for each tappable area of the rich menu.
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::GetRichMenuInsightDailyResponseImpression) || impression.nil? ? impression : Line::Bot::V2::Insight::GetRichMenuInsightDailyResponseImpression.create(**impression)
@clicks = clicks&.map do |item|
if item.is_a?(Hash)
Line::Bot::V2::Insight::GetRichMenuInsightDailyResponseClick.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

# Create an instance of the class from a hash
# @param args [Hash] Hash containing all the required attributes
# @return [Line::Bot::V2::Insight::GetRichMenuInsightDailyResponse] Instance of the class
def self.create(args)
symbolized_args = Line::Bot::V2::Utils.deep_symbolize(args)
return new(**symbolized_args) # steep:ignore InsufficientKeywordArguments
end

# @param other [Object] Object to compare
# @return [Boolean] true if the objects are equal, false otherwise
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

# @return [Integer] Hash code of the object
def hash
[self.class, *instance_variables.map { |var| instance_variable_get(var) }].hash
end
end
end
end
end
end
Loading