package Ġno . nav . person br uk er . dit tn av . var sel best iller . dok not ifik as jon Ċ Ċ import Ġno . nav . br uk er not ifik as jon . schemas . internal . B es kj ed Intern Ċ import Ġno . nav . br uk er not ifik as jon . schemas . internal . In n bo ks Intern Ċ import Ġno . nav . br uk er not ifik as jon . schemas . internal . N ok kel Intern Ċ import Ġno . nav . br uk er not ifik as jon . schemas . internal . Opp g ave Intern Ċ import Ġno . nav . dok not ifik as jon . schemas . Prefer erte K anal Ċ import Ġno . nav . person br uk er . dit tn av . var sel best iller . common . exceptions . Field ValidationException Ċ import Ġno . nav . person br uk er . dit tn av . var sel best iller . common . exceptions . Unknown Event type Exception Ċ import Ġno . nav . person br uk er . dit tn av . var sel best iller . config . Event type Ċ Ċ object ĠD ok not ifik as jon Creator Ġ{ ĊĊĠĠĠ Ġfun Ġcreate D ok not ifik as jon From B es kj ed ( nok kel : ĠN ok kel Intern , Ġbes kj ed : ĠBes kj ed Intern ): Ġno . nav . dok not ifik as jon . schemas . D ok not ifik as jon Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdok not ifik as jon Builder Ġ= Ġno . nav . dok not ifik as jon . schemas . D ok not ifik as jon . newBuilder () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Best ill ings Id ( create D ok not ifik as jon Key ( nok kel , ĠEvent type . B ES KJ ED _ INTER N )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Best iller Id ( nok kel . getApp nav n ()) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. set S ik kerhets n iv aa ( bes kj ed . getS ik kerhets n iv aa ()) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. set F od se ls nummer ( nok kel . getF od se ls nummer ()) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. set T it tel ( get D ok not ifik as jon Email Title ( bes kj ed )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. set E post T ek st ( get D ok not ifik as jon Email Text ( bes kj ed )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Sms T ek st ( get D ok not ifik as jon SM ST ext ( bes kj ed )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Ant all Ren ot ifik as jon er ( 0 ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Prefer erte K an aler ( getP refer erte K an aler ( bes kj ed . get Ek st ern Var sl ing (), Ġbes kj ed . getP refer erte K an aler ())) ĊĠĠĠĠĠĠĠ Ġreturn Ġdok not ifik as jon Builder . build () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġcreate D ok not ifik as jon From Opp g ave ( nok kel : ĠN ok kel Intern , Ġopp g ave : ĠO pp g ave Intern ): Ġno . nav . dok not ifik as jon . schemas . D ok not ifik as jon Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdok not ifik as jon Builder Ġ= Ġno . nav . dok not ifik as jon . schemas . D ok not ifik as jon . newBuilder () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Best ill ings Id ( create D ok not ifik as jon Key ( nok kel , ĠEvent type . OP PG AVE _ INTER N )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Best iller Id ( nok kel . getApp nav n ()) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. set S ik kerhets n iv aa ( op pg ave . getS ik kerhets n iv aa ()) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. set F od se ls nummer ( nok kel . getF od se ls nummer ()) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. set T it tel ( get D ok not ifik as jon Email Title ( op pg ave )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. set E post T ek st ( get D ok not ifik as jon Email Text ( op pg ave )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Sms T ek st ( get D ok not ifik as jon SM ST ext ( op pg ave )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Ant all Ren ot ifik as jon er ( 1 ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Ren ot ifik as jon Inter v all ( 7 ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Prefer erte K an aler ( getP refer erte K an aler ( op pg ave . get Ek st ern Var sl ing (), Ġopp g ave . getP refer erte K an aler ())) ĊĠĠĠĠĠĠĠ Ġreturn Ġdok not ifik as jon Builder . build () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġcreate D ok not ifik as jon From In n bo ks ( nok kel : ĠN ok kel Intern , Ġinn bo ks : ĠIn n bo ks Intern ): Ġno . nav . dok not ifik as jon . schemas . D ok not ifik as jon Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġdok not ifik as jon Builder Ġ= Ġno . nav . dok not ifik as jon . schemas . D ok not ifik as jon . newBuilder () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Best ill ings Id ( create D ok not ifik as jon Key ( nok kel , ĠEvent type . IN NB OK S _ INTER N )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Best iller Id ( nok kel . getApp nav n ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. set S ik kerhets n iv aa ( inn bo ks . getS ik kerhets n iv aa ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. set F od se ls nummer ( nok kel . getF od se ls nummer ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. set T it tel ( get D ok not ifik as jon Email Title ( inn bo ks )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. set E post T ek st ( get D ok not ifik as jon Email Text ( inn bo ks )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Sms T ek st ( get D ok not ifik as jon SM ST ext ( inn bo ks )) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Ant all Ren ot ifik as jon er ( 1 ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Ren ot ifik as jon Inter v all ( 4 ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ. set Prefer erte K an aler ( getP refer erte K an aler ( inn bo ks . get Ek st ern Var sl ing (), Ġinn bo ks . getP refer erte K an aler ())) ĊĠĠĠĠĠĠĠ Ġreturn Ġdok not ifik as jon Builder . build () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġcreate D ok not ifik as jon Key ( nok kel : ĠN ok kel Intern , Ġevent type : ĠEvent type ): ĠString Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġevent Id Ġ= Ġnok kel . getEvent Id () ĊĠĠĠĠĠĠĠ Ġval Ġapp nav n Ġ= Ġnok kel . getApp nav n () ĊĠĠĠĠĠĠĠ Ġreturn Ġwhen Ġ( event type ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠEvent type . B ES KJ ED _ INTER N Ġ-> Ġ" B -$ app nav n -$ eventId " ĊĠĠĠĠĠĠĠĠĠĠĠ ĠEvent type . OP PG AVE _ INTER N Ġ-> Ġ" O -$ app nav n -$ eventId " ĊĠĠĠĠĠĠĠĠĠĠĠ ĠEvent type . IN NB OK S _ INTER N Ġ-> Ġ" I -$ app nav n -$ eventId " ĊĠĠĠĠĠĠĠĠĠĠĠ ĠEvent type . DONE _ INTER N Ġ-> Ġ" D -$ app nav n -$ eventId " ĊĠĠĠĠĠĠĠĠĠĠĠ Ġelse Ġ-> Ġthrow ĠUnknown Event type Exception ("$ event type Ġer Ġug y ld ig Ġtype Ġfor ĠÃ¥ Ġgener ere ĠD ok not ifik as jon - key ") ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġget D ok not ifik as jon Email Text ( event : ĠBes kj ed Intern ): ĠString Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ( event . get E post Var sl ing st ek st () Ġ!= Ġnull ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġtitle Ġ= Ġget D ok not ifik as jon Email Title ( event ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġbody Ġ= Ġevent . get E post Var sl ing st ek st () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn Ġreplace In Email Template ( title , Ġbody ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġreturn Ġevent . get E post Var sl ing st ek st () Ġ?: Ġthis :: class . java . getResource ("/ texts / ep ost _ bes kj ed . txt "). read Text ( Charsets . UTF _ 8 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġget D ok not ifik as jon Email Title ( event : ĠBes kj ed Intern ): ĠString Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġevent . get E post Var sl ing st it tel () Ġ?: Ġ" B es kj ed Ġf ra ĠNAV " ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġget D ok not ifik as jon Email Text ( event : ĠO pp g ave Intern ): ĠString Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ( event . get E post Var sl ing st ek st () Ġ!= Ġnull ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġtitle Ġ= Ġget D ok not ifik as jon Email Title ( event ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġbody Ġ= Ġevent . get E post Var sl ing st ek st () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn Ġreplace In Email Template ( title , Ġbody ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġreturn Ġevent . get E post Var sl ing st ek st () Ġ?: Ġthis :: class . java . getResource ("/ texts / ep ost _ op pg ave . txt "). read Text ( Charsets . UTF _ 8 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġget D ok not ifik as jon Email Title ( event : ĠO pp g ave Intern ): ĠString Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġevent . get E post Var sl ing st it tel () Ġ?: Ġ" Du Ġhar Ġf Ã¥ tt Ġen Ġopp g ave Ġf ra ĠNAV " ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġget D ok not ifik as jon Email Text ( event : ĠIn n bo ks Intern ): ĠString Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ( event . get E post Var sl ing st ek st () Ġ!= Ġnull ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġtitle Ġ= Ġget D ok not ifik as jon Email Title ( event ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġbody Ġ= Ġevent . get E post Var sl ing st ek st () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn Ġreplace In Email Template ( title , Ġbody ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġreturn Ġthis :: class . java . getResource ("/ texts / ep ost _ inn bo ks . txt "). read Text ( Charsets . UTF _ 8 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġget D ok not ifik as jon Email Title ( event : ĠIn n bo ks Intern ): ĠString Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġevent . get E post Var sl ing st it tel () Ġ?: Ġ" Du Ġhar Ġf Ã¥ tt Ġen Ġme ld ing Ġf ra ĠNAV " ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġreplace In Email Template ( title : ĠString , Ġbody : ĠString ): ĠString Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġemail Template Ġ= Ġthis :: class . java . getResource ("/ texts / ep ost _ mal . txt "). read Text ( Charsets . UTF _ 8 ) ĊĊĠĠĠĠĠĠĠ Ġreturn Ġemail Template . replace ("\ ${ E POST _ VAR SE LT IT TEL }", Ġtitle ). replace ("\ ${ E POST _ VAR SEL TE K ST }", Ġbody ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġget D ok not ifik as jon SM ST ext ( event : ĠBes kj ed Intern ): ĠString Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġevent . getS ms Var sl ing st ek st () Ġ?: Ġthis :: class . java . getResource ("/ texts / sms _ bes kj ed . txt "). read Text ( Charsets . UTF _ 8 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġget D ok not ifik as jon SM ST ext ( event : ĠO pp g ave Intern ): ĠString Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġevent . getS ms Var sl ing st ek st () Ġ?: Ġthis :: class . java . getResource ("/ texts / sms _ op pg ave . txt "). read Text ( Charsets . UTF _ 8 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġget D ok not ifik as jon SM ST ext ( event : ĠIn n bo ks Intern ): ĠString Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġevent . getS ms Var sl ing st ek st () Ġ?: Ġthis :: class . java . getResource ("/ texts / sms _ inn bo ks . txt "). read Text ( Charsets . UTF _ 8 ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġget Prefer erte K an aler ( ek st ern Var sl ing : ĠBoolean , Ġprefer erte K an aler : ĠList < String >? ): ĠList < Prefer erte K anal > Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġval gte K an aler Ġ= Ġmutable ListOf < Prefer erte K anal >() ĊĠĠĠĠĠĠĠ Ġif (! ek st ern Var sl ing Ġ&& Ġ! prefer erte K an aler . isNull OrEmpty ()) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġthrow ĠField ValidationException (" Prefer erte Ġkan aler Ġkan Ġik ke Ġset tes Ġs Ã¥ Ġlen ge Ġek st ern Ġvar sl ing Ġik ke Ġer Ġbest ilt .") ĊĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġdok not ifik as jon Prefer erte K an aler AsString Ġ= ĠP refer erte K anal . values (). map Ġ{ Ġit . name Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġprefer erte K an aler ?. forEach Ġ{ Ġprefer ert K anal Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġif ( dok not ifik as jon Prefer erte K an aler AsString . contains ( prefer ert K anal )) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval gte K an aler . add ( Prefer erte K anal . valueOf ( prefer ert K anal )) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġthrow ĠField ValidationException (" U kj ent Ġkan al , Ġkan al en Ġ$ prefer ert K anal Ġer Ġik ke Ġdefin ert Ġsom Ġmul ig Ġprefer ert Ġkan al Ġi ĠD ok not ifik as jon .") ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġreturn Ġval gte K an aler ĊĠĠĠ Ġ} Ċ } Ċ