package Ġorg . oss ia ust ria . am igo . platform . rest . v 1 . send ables Ċ Ċ import Ġorg . oss ia ust ria . am igo . platform . domain . models . Account Ċ import Ġorg . oss ia ust ria . am igo . platform . domain . models . Send able Ċ import Ġorg . oss ia ust ria . am igo . platform . domain . services . send ables . Send able Service Ċ import Ġorg . oss ia ust ria . am igo . platform . exceptions . BadRequest Exception Ċ import Ġorg . oss ia ust ria . am igo . platform . exceptions . Default NotFoundException Ċ import Ġorg . oss ia ust ria . am igo . platform . exceptions . ErrorCode Ċ import Ġorg . oss ia ust ria . am igo . platform . exceptions . NotFoundException Ċ import Ġjava . time . Z onedDateTime Ċ import Ġjava . util . UUID ĊĊ Ċ internal Ġclass ĠSend able Api Wrapper < T Ġ: ĠSend able < T >>( ĊĠĠĠ Ġprivate Ġval Ġsend able Service : ĠSend able Service < T >, Ċ ) Ġ{ ĊĊĠĠĠ Ġfun Ġget Filtered ( receiver Id : ĠUUID ?, Ġsender Id : ĠUUID ?, Ġaccount : ĠAccount ): ĠList < T > Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġis Receiver Ġ= Ġaccount . has Person Id ( receiver Id ) ĊĠĠĠĠĠĠĠ Ġval Ġis Sender Ġ= Ġaccount . has Person Id ( sender Id ) ĊĠĠĠĠĠĠĠ Ġif Ġ(! is Receiver Ġ&& Ġ! is Sender ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġthrow ĠBadRequest Exception ( ErrorCode . Bad Parameters Request , Ġ" Use Ġreceiver Id = you Ġor Ġsender Id = you ") ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġreturn Ġsend able Service . find With Pers ons ( sender Id , Ġreceiver Id ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġget Own ( person Id : ĠUUID ): ĠList < T > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġsend able Service . find With Person ( person Id ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġget Received ( person Id : ĠUUID ): ĠList < T > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġsend able Service . find With Receiver ( person Id ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġget Sent ( person Id : ĠUUID ): ĠList < T > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġsend able Service . find With Sender ( person Id ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġget One ( person Id : ĠUUID , Ġid : ĠUUID ): ĠT Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġsend able Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsend able Service . getOne ( id ) Ġ?: Ġthrow ĠNotFound Exception ( ErrorCode . NotFound , Ġ" Send able Ġ$ id Ġnot Ġfound !") ĊĠĠĠĠĠĠĠ Ġif Ġ(! send able . is View able By ( person Id )) Ġthrow ĠDefault NotFoundException () ĊĠĠĠĠĠĠĠ Ġreturn Ġsend able ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġmark As Retrie ved ( person Id : ĠUUID , Ġid : ĠUUID ): ĠT Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġitem Ġ= Ġsend able Service . getOne ( id ) Ġ?: Ġthrow ĠNotFound Exception ( ErrorCode . NotFound , Ġ" Send able Ġ$ id Ġnot Ġfound !") ĊĠĠĠĠĠĠĠ Ġif Ġ(! item . is Retrie vable By ( person Id )) Ġthrow ĠDefault NotFoundException () ĊĠĠĠĠĠĠĠ Ġreturn Ġsend able Service . mark As Retrie ved ( id , ĠZ onedDateTime . now ()) ĊĠĠĠ Ġ} Ċ Ċ } Ċ