File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -1162,6 +1162,18 @@ def get_aggregation_list(limit: nil, start: nil)
11621162 get ( endpoint , endpoint_path , credentials )
11631163 end
11641164
1165+ # Gets the status of a narrowcast message.
1166+ #
1167+ # @param request_id [String] The narrowcast message's request ID. Each Messaging API request has a request ID. Find it in the response headers.
1168+ #
1169+ # @return [Net::HTTPResponse]
1170+ def get_narrowcast_message_status ( request_id )
1171+ channel_token_required
1172+
1173+ endpoint_path = "/bot/message/progress/narrowcast?requestId=#{ request_id } "
1174+ get ( endpoint , endpoint_path , credentials )
1175+ end
1176+
11651177 # Fetch data, get content of specified URL.
11661178 #
11671179 # @param endpoint_base [String]
Original file line number Diff line number Diff line change 200200}
201201EOS
202202
203+ NARROWCAST_MESSAGE_STATUS_CONTENT = <<"EOS"
204+ {
205+ "phase": "succeeded",
206+ "successCount": 65535,
207+ "failureCount": 128,
208+ "targetCount": 65663,
209+ "acceptedTime": "2020-12-03T10:15:30.121Z",
210+ "completedTime": "2020-12-03T10:15:30.121Z"
211+ }
212+ EOS
213+
203214describe Line ::Bot ::Client do
204215 def dummy_config
205216 {
@@ -477,4 +488,22 @@ def generate_client
477488 markAsReadMode : 'manual'
478489 )
479490 end
491+
492+ it 'get narrowcast message status' do
493+ uri_template = Addressable ::Template . new Line ::Bot ::API ::DEFAULT_ENDPOINT + '/bot/message/progress/narrowcast?requestId=request_id'
494+ stub_request ( :get , uri_template ) . to_return ( body : NARROWCAST_MESSAGE_STATUS_CONTENT , status : 200 )
495+
496+ client = generate_client
497+ response = client . get_narrowcast_message_status ( 'request_id' )
498+
499+ json = JSON . parse ( response . body , symbolize_names : true )
500+ expect ( json ) . to eq (
501+ phase : "succeeded" ,
502+ successCount : 65535 ,
503+ failureCount : 128 ,
504+ targetCount : 65663 ,
505+ acceptedTime : "2020-12-03T10:15:30.121Z" ,
506+ completedTime : "2020-12-03T10:15:30.121Z"
507+ )
508+ end
480509end
You can’t perform that action at this time.
0 commit comments