package Ġorg . w ats i . enrollment . device . repositories Ċ Ċ import Ġio . reactivex . Comp letable Ċ import Ġio . reactivex . schedul ers . Schedulers Ċ import Ġokhttp 3 . Ok HttpClient Ċ import Ġorg . th reet en . bp . Clock Ċ import Ġorg . w ats i . enrollment . device . api . Coverage Api Ċ import Ġorg . w ats i . enrollment . device . api . House hold Enrollment Record Api Ċ import Ġorg . w ats i . enrollment . device . db . da os . House hold Enrollment Record Dao Ċ import Ġorg . w ats i . enrollment . device . db . models . Delta Model Ċ import Ġorg . w ats i . enrollment . device . db . models . House hold Enrollment Record Model Ċ import Ġorg . w ats i . enrollment . device . managers . Session Manager Ċ import Ġorg . w ats i . enrollment . domain . entities . Delta Ċ import Ġorg . w ats i . enrollment . domain . entities . House hold Enrollment Record Ċ import Ġorg . w ats i . enrollment . domain . repositories . House hold Enrollment Record Repository Ċ Ċ class ĠHouse hold Enrollment Record Repository Impl Ġconstructor ( ĊĠĠĠ Ġprivate Ġval Ġhouse hold Enrollment Record Dao : ĠHouse hold Enrollment Record Dao , ĊĠĠĠ Ġprivate Ġval Ġapi : ĠCoverage Api , ĊĠĠĠ Ġprivate Ġval Ġclock : ĠClock , ĊĠĠĠ Ġprivate Ġval Ġsession Manager : ĠSession Manager , ĊĠĠĠ Ġprivate Ġval Ġok HttpClient : ĠOk HttpClient Ċ ) Ġ: ĠHouse hold Enrollment Record Repository Ġ{ ĊĊĠĠĠ Ġoverride Ġfun Ġsave ( house hold Enrollment Record : ĠHouse hold Enrollment Record , Ġdelta : ĠDelta ): ĠComp letable Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠComp letable . from Action Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġhouse hold Enrollment Record Dao . insert ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠHouse hold Enrollment Record Model . from House hold Enrollment Record ( house hold Enrollment Record , Ġclock ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠDelta Model . from Delta ( delta , Ġclock ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ}. subscribe On ( Schedulers . io ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġsync ( delt as : ĠList < Delta >): ĠComp letable Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġsession Manager . current Authentication Token ()?. let Ġ{ Ġauth Token Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġhouse hold Enrollment Record Dao . get ( delt as . first (). model Id ). flatMap Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġhouse hold Enrollment Record Ġ= Ġit . to House hold Enrollment Record () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( delt as . any Ġ{ Ġit . action Ġ== ĠDelta . Action . ADD Ġ}) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġapi . post House hold Enrollment Record ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġauthorization Ġ= Ġauth Token . getHeader String (), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġhouse hold Enrollment Record Ġ= ĠHouse hold Enrollment Record Api ( house hold Enrollment Record ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġthrow ĠIllegalStateException (" Del tas Ġwith Ġ${ delt as . map Ġ{ Ġit . action Ġ} Ġ} Ġactions Ġnot Ġsupported Ġfor ĠHouse hold Enrollment Record ") ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ}. to Comp letable (). subscribe On ( Schedulers . io ()) ĊĠĠĠĠĠĠĠ Ġ} Ġ?: ĠComp letable . complete () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġdelete All (): ĠComp letable Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn ĠComp letable . from Action Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġok HttpClient . cache ()?. ev ict All () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġhouse hold Enrollment Record Dao . delete All () ĊĠĠĠĠĠĠĠ Ġ}. subscribe On ( Schedulers . io ()) ĊĠĠĠ Ġ} Ċ } Ċ