package Ġbr . com . z up . edu . pix . registry . service čĊč Ċ import Ġbr . com . z up . edu . pix . Pix Key č Ċ import Ġbr . com . z up . edu . pix . registry . service . request . Register Pix Key Request č Ċ import Ġbr . com . z up . edu . pix . repository . Pix Key Repository č Ċ import Ġbr . com . z up . edu . pix . registry . exception . Pix Key AlreadyExists Exception č Ċ import Ġbr . com . z up . edu . integration . B CB č Ċ import Ġbr . com . z up . edu . integration . ER P It au č Ċ import Ġbr . com . z up . edu . integration . request . Create Pix Key Request č Ċ import Ġbr . com . z up . edu . integration . response . Bank Account Query Response č Ċ import Ġio . mic ronaut . validation . Validated č Ċ import Ġjava . lang . IllegalArgumentException č Ċ import Ġjavax . inject . Singleton č Ċ import Ġjavax . transaction . Transactional č Ċ import Ġjavax . validation . Valid čĊč Ċ @ Singleton č Ċ @ Validated č Ċ class ĠRegister Pix Key Service ( čĊĠĠĠ Ġval Ġrepository : ĠP ix Key Repository , čĊĠĠĠ Ġval Ġer p It au : ĠE RP It au , čĊĠĠĠ Ġval Ġb cb : ĠB CB č Ċ ) Ġ{ čĊčĊĠĠĠ Ġ@ Transactional čĊĠĠĠ Ġfun Ġregister Key (@ Valid Ġrequest : ĠRegister Pix Key Request ): ĠP ix Key Ġ{ čĊĠĠĠĠĠĠĠ Ġif Ġ( repository . exists By KeyValue ( request . key Value )) Ġthrow ĠP ix Key AlreadyExists Exception () čĊĠĠĠĠĠĠĠ Ġval Ġbank Account Response : ĠBank Account Query Response Ġ= čĊĠĠĠĠĠĠĠĠĠĠĠ Ġer p It au . find Bank Account ( request . clientId . toString (), Ġrequest . account Type ) čĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ?: Ġthrow ĠIllegalArgumentException (" Client Ġnot Ġfound ") čĊĠĠĠĠĠĠĠ Ġval Ġpix Key Ġ= Ġrequest . to Model ( bank Account Response . to Model ()) čĊĠĠĠĠĠĠĠ Ġrepository . save ( pix Key ) čĊĠĠĠĠĠĠĠ Ġb cb . create Pix Key ( Create Pix Key Request . from ( pix Key )) čĊĠĠĠĠĠĠĠ Ġreturn Ġpix Key čĊĠĠĠ Ġ} č Ċ }