@@ -259,6 +259,11 @@ interface CallNextRequest extends TicketCallRequest {
259259 lines : string ;
260260}
261261
262+ interface LabelRemoveRequest {
263+ value : string ;
264+ user ?: string ;
265+ }
266+
262267type TicketCreationResponse = Pick < Ticket , 'id' > ;
263268
264269export function search ( search : TicketSearchCriteria ) : Promise < Array < Ticket > > {
@@ -548,10 +553,10 @@ export function setLabels(
548553export function removeLabel (
549554 ticket : IdOrObject < Ticket > ,
550555 label : string ,
551- user : IdOrObject < User > ,
556+ user ? : IdOrObject < User > ,
552557) : Promise < 'success' > {
553558 const ticketId = extractId ( ticket ) ;
554- const userId = extractId ( user ) ;
559+ const userId = user ? extractId ( user ) : undefined ;
555560
556561 if ( ! ticketId || typeof ticketId !== 'string' ) {
557562 throw new Error ( ERROR_NO_TICKET_ID ) ;
@@ -561,17 +566,15 @@ export function removeLabel(
561566 throw new Error ( 'No label given.' ) ;
562567 }
563568
564- if ( ! userId || typeof userId !== 'string' ) {
565- throw new Error ( 'No user given' ) ;
566- }
567-
568- const body = {
569+ const requestBody : LabelRemoveRequest = {
569570 value : label ,
570- user : userId ,
571571 } ;
572+ if ( userId ) {
573+ requestBody . user = userId ;
574+ }
572575
573576 return ApiBase . request ( `v1/tickets/${ ticketId } /labels/remove` , {
574- body : body ,
577+ body : requestBody ,
575578 method : 'POST' ,
576579 } ) . then ( ( response : { result : 'success' } ) => response . result ) ;
577580}
0 commit comments