class Line::Bot::V2::Insight::ApiClient
Public Class Methods
Source
# File lib/line/bot/v2/insight/api/insight_client.rb, line 38 def initialize(base_url: nil, channel_access_token:, http_options: {}) @http_client = HttpClient.new( base_url: base_url || 'https://api.line.me', http_headers: { Authorization: "Bearer #{channel_access_token}" }, http_options: http_options ) end
Initializes a new {Line::Bot::V2::Insight::ApiClient} instance.
@param base_url [String] The base URL for requests (optional).
Defaults to 'https://api.line.me' if none is provided. You can override this for testing or to use a mock server.
@param channel_access_token [String] The channel access token for authorization. @param http_options [Hash] HTTP options (same as Net::HTTP options).
See: https://docs.ruby-lang.org/en/3.4/Net/HTTP.html to understand the options.
@example
@client ||= Line::Bot::V2::Insight::ApiClient.new( channel_access_token: "YOUR_CHANNEL_ACCESS_TOKEN", http_options: { open_timeout: 5, read_timeout: 5, } )
Public Instance Methods
Source
# File lib/line/bot/v2/insight/api/insight_client.rb, line 83 def get_friends_demographics( ) response_body, _status_code, _headers = get_friends_demographics_with_http_info( ) response_body end
Retrieves the demographic attributes for a LINE Official Account’s friends.You can only retrieve information about friends for LINE Official Accounts created by users in Japan (JP), Thailand (TH), Taiwan (TW) and Indonesia (ID). This requests to GET https://api.line.me/v2/bot/insight/demographic
When you want to get HTTP status code or response headers, use {#get_friends_demographics_with_http_info} instead of this.
@see developers.line.biz/en/reference/messaging-api/#get-demographic @return [Line::Bot::V2::Insight::GetFriendsDemographicsResponse] when HTTP status code is 200 @return [String, nil] when other HTTP status code is returned. This String is HTTP response body itself.
Source
# File lib/line/bot/v2/insight/api/insight_client.rb, line 55 def get_friends_demographics_with_http_info( # steep:ignore MethodBodyTypeMismatch ) path = "/v2/bot/insight/demographic" response = @http_client.get( path: path, ) 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::GetFriendsDemographicsResponse.create(json) # steep:ignore InsufficientKeywordArguments [response_body, 200, response.each_header.to_h] else [response.body, response.code.to_i, response.each_header.to_h] end end
Retrieves the demographic attributes for a LINE Official Account’s friends.You can only retrieve information about friends for LINE Official Accounts created by users in Japan (JP), Thailand (TH), Taiwan (TW) and Indonesia (ID). This requests to GET https://api.line.me/v2/bot/insight/demographic
This returns an array containing response, HTTP status code, and header in order. Please specify all header keys in lowercase.
@see developers.line.biz/en/reference/messaging-api/#get-demographic @return [Array(Line::Bot::V2::Insight::GetFriendsDemographicsResponse
, Integer, Hash{String => String})] when HTTP status code is 200 @return [Array((String|nil), Integer, Hash{String => String})] when other HTTP status code is returned. String is HTTP response body itself.
Source
# File lib/line/bot/v2/insight/api/insight_client.rb, line 133 def get_message_event( request_id: ) response_body, _status_code, _headers = get_message_event_with_http_info( request_id: request_id ) response_body end
Returns statistics about how users interact with narrowcast messages or broadcast messages sent from your LINE Official Account. This requests to GET https://api.line.me/v2/bot/insight/message/event
When you want to get HTTP status code or response headers, use {#get_message_event_with_http_info} instead of this.
@param request_id [String] Request ID of a narrowcast message or broadcast message. Each Messaging API request has a request ID. @see developers.line.biz/en/reference/messaging-api/#get-message-event @return [Line::Bot::V2::Insight::GetMessageEventResponse] when HTTP status code is 200 @return [String, nil] when other HTTP status code is returned. This String is HTTP response body itself.
Source
# File lib/line/bot/v2/insight/api/insight_client.rb, line 99 def get_message_event_with_http_info( # steep:ignore MethodBodyTypeMismatch request_id: ) path = "/v2/bot/insight/message/event" query_params = { "requestId": request_id }.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::GetMessageEventResponse.create(json) # steep:ignore InsufficientKeywordArguments [response_body, 200, response.each_header.to_h] else [response.body, response.code.to_i, response.each_header.to_h] end end
Returns statistics about how users interact with narrowcast messages or broadcast messages sent from your LINE Official Account. This requests to GET https://api.line.me/v2/bot/insight/message/event
This returns an array containing response, HTTP status code, and header in order. Please specify all header keys in lowercase.
@param request_id [String] Request ID of a narrowcast message or broadcast message. Each Messaging API request has a request ID. @see developers.line.biz/en/reference/messaging-api/#get-message-event @return [Array(Line::Bot::V2::Insight::GetMessageEventResponse
, Integer, Hash{String => String})] when HTTP status code is 200 @return [Array((String|nil), Integer, Hash{String => String})] when other HTTP status code is returned. String is HTTP response body itself.
Source
# File lib/line/bot/v2/insight/api/insight_client.rb, line 185 def get_number_of_followers( date: nil ) response_body, _status_code, _headers = get_number_of_followers_with_http_info( date: date ) response_body end
Returns the number of users who have added the LINE Official Account on or before a specified date. This requests to GET https://api.line.me/v2/bot/insight/followers
When you want to get HTTP status code or response headers, use {#get_number_of_followers_with_http_info} instead of this.
@param date [String, nil] Date for which to retrieve the number of followers. Format: yyyyMMdd (e.g. 20191231) Timezone: UTC+9 @see developers.line.biz/en/reference/messaging-api/#get-number-of-followers @return [Line::Bot::V2::Insight::GetNumberOfFollowersResponse] when HTTP status code is 200 @return [String, nil] when other HTTP status code is returned. This String is HTTP response body itself.
Source
# File lib/line/bot/v2/insight/api/insight_client.rb, line 151 def get_number_of_followers_with_http_info( # steep:ignore MethodBodyTypeMismatch date: nil ) path = "/v2/bot/insight/followers" query_params = { "date": date }.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::GetNumberOfFollowersResponse.create(json) # steep:ignore InsufficientKeywordArguments [response_body, 200, response.each_header.to_h] else [response.body, response.code.to_i, response.each_header.to_h] end end
Returns the number of users who have added the LINE Official Account on or before a specified date. This requests to GET https://api.line.me/v2/bot/insight/followers
This returns an array containing response, HTTP status code, and header in order. Please specify all header keys in lowercase.
@param date [String, nil] Date for which to retrieve the number of followers. Format: yyyyMMdd (e.g. 20191231) Timezone: UTC+9 @see developers.line.biz/en/reference/messaging-api/#get-number-of-followers @return [Array(Line::Bot::V2::Insight::GetNumberOfFollowersResponse
, Integer, Hash{String => String})] when HTTP status code is 200 @return [Array((String|nil), Integer, Hash{String => String})] when other HTTP status code is returned. String is HTTP response body itself.
Source
# File lib/line/bot/v2/insight/api/insight_client.rb, line 237 def get_number_of_message_deliveries( date: ) response_body, _status_code, _headers = get_number_of_message_deliveries_with_http_info( date: date ) response_body end
Returns the number of messages sent from LINE Official Account on a specified day. This requests to GET https://api.line.me/v2/bot/insight/message/delivery
When you want to get HTTP status code or response headers, use {#get_number_of_message_deliveries_with_http_info} instead of this.
@param date [String] Date for which to retrieve number of sent messages. - Format: yyyyMMdd (e.g. 20191231) - Timezone: UTC+9 @see developers.line.biz/en/reference/messaging-api/#get-number-of-delivery-messages @return [Line::Bot::V2::Insight::GetNumberOfMessageDeliveriesResponse] when HTTP status code is 200 @return [String, nil] when other HTTP status code is returned. This String is HTTP response body itself.
Source
# File lib/line/bot/v2/insight/api/insight_client.rb, line 203 def get_number_of_message_deliveries_with_http_info( # steep:ignore MethodBodyTypeMismatch date: ) path = "/v2/bot/insight/message/delivery" query_params = { "date": date }.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::GetNumberOfMessageDeliveriesResponse.create(json) # steep:ignore InsufficientKeywordArguments [response_body, 200, response.each_header.to_h] else [response.body, response.code.to_i, response.each_header.to_h] end end
Returns the number of messages sent from LINE Official Account on a specified day. This requests to GET https://api.line.me/v2/bot/insight/message/delivery
This returns an array containing response, HTTP status code, and header in order. Please specify all header keys in lowercase.
@param date [String] Date for which to retrieve number of sent messages. - Format: yyyyMMdd (e.g. 20191231) - Timezone: UTC+9 @see developers.line.biz/en/reference/messaging-api/#get-number-of-delivery-messages @return [Array(Line::Bot::V2::Insight::GetNumberOfMessageDeliveriesResponse
, Integer, Hash{String => String})] when HTTP status code is 200 @return [Array((String|nil), Integer, Hash{String => String})] when other HTTP status code is returned. String is HTTP response body itself.
Source
# File lib/line/bot/v2/insight/api/insight_client.rb, line 297 def get_statistics_per_unit( custom_aggregation_unit:, from:, to: ) response_body, _status_code, _headers = get_statistics_per_unit_with_http_info( custom_aggregation_unit: custom_aggregation_unit, 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 GET https://api.line.me/v2/bot/insight/message/event/aggregation
When you want to get HTTP status code or response headers, use {#get_statistics_per_unit_with_http_info} instead of this.
@param custom_aggregation_unit [String] Name of aggregation unit specified when sending the message. Case-sensitive. For example, ‘Promotion_a` and `Promotion_A` are regarded as different unit names. @param from [String] Start date of aggregation period. Format: yyyyMMdd (e.g. 20210301) Time zone: UTC+9 @param to [String] End date of aggregation period. The end date can be specified for up to 30 days later. For example, if the start date is 20210301, the latest end date is 20210331. Format: yyyyMMdd (e.g. 20210301) Time zone: UTC+9 @see developers.line.biz/en/reference/messaging-api/#get-statistics-per-unit @return [Line::Bot::V2::Insight::GetStatisticsPerUnitResponse] when HTTP status code is 200 @return [String, nil] when other HTTP status code is returned. This String is HTTP response body itself.
Source
# File lib/line/bot/v2/insight/api/insight_client.rb, line 257 def get_statistics_per_unit_with_http_info( # steep:ignore MethodBodyTypeMismatch custom_aggregation_unit:, from:, to: ) path = "/v2/bot/insight/message/event/aggregation" query_params = { "customAggregationUnit": custom_aggregation_unit, "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::GetStatisticsPerUnitResponse.create(json) # steep:ignore InsufficientKeywordArguments [response_body, 200, response.each_header.to_h] else [response.body, response.code.to_i, response.each_header.to_h] end 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 GET https://api.line.me/v2/bot/insight/message/event/aggregation
This returns an array containing response, HTTP status code, and header in order. Please specify all header keys in lowercase.
@param custom_aggregation_unit [String] Name of aggregation unit specified when sending the message. Case-sensitive. For example, ‘Promotion_a` and `Promotion_A` are regarded as different unit names. @param from [String] Start date of aggregation period. Format: yyyyMMdd (e.g. 20210301) Time zone: UTC+9 @param to [String] End date of aggregation period. The end date can be specified for up to 30 days later. For example, if the start date is 20210301, the latest end date is 20210331. Format: yyyyMMdd (e.g. 20210301) Time zone: UTC+9 @see developers.line.biz/en/reference/messaging-api/#get-statistics-per-unit @return [Array(Line::Bot::V2::Insight::GetStatisticsPerUnitResponse
, Integer, Hash{String => String})] when HTTP status code is 200 @return [Array((String|nil), Integer, Hash{String => String})] when other HTTP status code is returned. String is HTTP response body itself.