Skip to content

Commit 80ad3e4

Browse files
committed
Add audience API endpoints
1 parent 3e7eb70 commit 80ad3e4

File tree

1 file changed

+121
-0
lines changed

1 file changed

+121
-0
lines changed

lib/line/bot/client.rb

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,127 @@ def delete_liff_app(liff_id)
673673
delete(liff_endpoint, endpoint_path, credentials)
674674
end
675675

676+
# Create an audience group by uploading user_ids
677+
#
678+
# Parameters are described here.
679+
# https://developers.line.biz/en/reference/messaging-api/#create-upload-audience-group
680+
#
681+
# @param opts [Hash] options
682+
#
683+
# @return [Net::HTTPResponse] This response includes an audience_group_id.
684+
def create_user_id_audience(params)
685+
channel_token_required
686+
687+
endpoint_path = '/bot/audienceGroup/upload'
688+
post(endpoint, endpoint_path, params.to_json, credentials)
689+
end
690+
691+
# Create an audience group of users that clicked a URL in a message sent in the past
692+
#
693+
# Parameters are described here.
694+
# https://developers.line.biz/en/reference/messaging-api/#create-click-audience-group
695+
#
696+
# @param opts [Hash] options
697+
#
698+
# @return [Net::HTTPResponse] This response includes an audience_group_id.
699+
def create_click_audience(params)
700+
channel_token_required
701+
702+
endpoint_path = '/bot/audienceGroup/click'
703+
post(endpoint, endpoint_path, params.to_json, credentials)
704+
end
705+
706+
# Create an audience group of users that opened a message sent in the past
707+
#
708+
# Parameters are described here.
709+
# https://developers.line.biz/en/reference/messaging-api/#create-imp-audience-group
710+
#
711+
# @param opts [Hash] options
712+
#
713+
# @return [Net::HTTPResponse] This response includes an audience_group_id.
714+
def create_impression_audience
715+
channel_token_required
716+
717+
endpoint_path = '/bot/audienceGroup/imp'
718+
post(endpoint, endpoint_path, params.to_json, credentials)
719+
end
720+
721+
# Rename an existing audience group
722+
#
723+
# @param audience_group_id [Integer]
724+
# @param description [String]
725+
#
726+
# @return [Net::HTTPResponse]
727+
def rename_audience(audience_group_id, description)
728+
channel_token_required
729+
730+
endpoint_path = "/bot/audienceGroup/#{audience_group_id}"
731+
body = {description: description}
732+
put(endpoint, endpoint_path, body.to_json, credentials)
733+
end
734+
735+
# Delete an existing audience group
736+
#
737+
# @param audience_group_id [Integer]
738+
#
739+
# @return [Net::HTTPResponse]
740+
def delete_audience(audience_group_id)
741+
channel_token_required
742+
743+
endpoint_path = "/bot/audienceGroup/#{audience_group_id}"
744+
delete(endpoint, endpoint_path, credentials)
745+
end
746+
747+
# Get audience group data
748+
#
749+
# @param audience_group_id [Integer]
750+
#
751+
# @return [Net::HTTPResponse]
752+
def get_audience(audience_group_id)
753+
channel_token_required
754+
755+
endpoint_path = "/bot/audienceGroup/#{audience_group_id}"
756+
get(endpoint, endpoint_path, credentials)
757+
end
758+
759+
# Get data for more than one audience group
760+
#
761+
# Parameters are described here.
762+
# https://developers.line.biz/en/reference/messaging-api/#get-audience-groups
763+
#
764+
# @param params [Hash] key name `size` is required
765+
#
766+
# @return [Net::HTTPResponse]
767+
def get_audiences(params)
768+
channel_token_required
769+
770+
endpoint_path = "/bot/audienceGroup/list?" + params.map{|k, v| "#{k}=#{v}"}.join('&')
771+
get(endpoint, endpoint_path, credentials)
772+
end
773+
774+
# Get the authority level of the audience
775+
#
776+
# @return [Net::HTTPResponse]
777+
def get_audience_authority_level
778+
channel_token_required
779+
780+
endpoint_path = "/bot/audienceGroup/authorityLevel"
781+
get(endpoint, endpoint_path, credentials)
782+
end
783+
784+
# Change the authority level of the audience
785+
#
786+
# @param authority_level [String] value must be `PUBLIC` or `PRIVATE`
787+
#
788+
# @return [Net::HTTPResponse]
789+
def update_audience_authority_level(authority_level)
790+
channel_token_required
791+
792+
endpoint_path = "/bot/audienceGroup/authorityLevel"
793+
body = {authorityLevel: authority_level}
794+
put(endpoint, endpoint_path, body.to_json, credentials)
795+
end
796+
676797
# Fetch data, get content of specified URL.
677798
#
678799
# @param endpoint_base [String]

0 commit comments

Comments
 (0)