package Ġcom . example . android . polit ical prepared ness . represent ative Ċ Ċ import Ġcom . example . android . polit ical prepared ness . network . C iv ics Api Ċ import Ġcom . example . android . polit ical prepared ness . network . models . Address Ċ import Ġcom . example . android . polit ical prepared ness . network . models . Represent ative Response Ċ import Ġcom . example . android . polit ical prepared ness . represent ative . model . Represent ative Ċ import Ġkotlinx . coroutines . Dispatch ers Ċ import Ġkotlinx . coroutines . with Context Ċ import Ġretrofit 2 . HttpException Ċ import Ġjava . io . IOException Ċ Ċ class ĠRepresent ative Repository Ġ: ĠRepresent ative DataSource Ġ{ ĊĠĠĠ Ġoverride Ġsuspend Ġfun Ġget Represent ative ( address : ĠAddress ): ĠList < Represent ative > Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġwith Context ( Dispatch ers . IO ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtry Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġrepresentative Response Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠC iv ics Api . ret rofit Service . get Represent atives ( address . to Formatted String ()) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. execute (). body () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġrepresentative Response ?. as Represent atives () Ġ?: ĠlistOf () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} Ġcatch Ġ( e : ĠHttp Exception ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠlistOf < Represent ative >() ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} Ġcatch Ġ( e : ĠIOException ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠlistOf < Represent ative >() ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ Ċ fun ĠRepresent ative Response . as Represent atives (): ĠList < Represent ative > Ġ{ ĊĠĠĠ Ġval Ġmutable List Ġ= Ġmutable ListOf < Represent ative >() ĊĠĠĠ Ġfor Ġ( index Ġin Ġthis . off ices . indices ) Ġ{ ĊĠĠĠĠĠĠĠ Ġmutable List . add ( Represent ative ( this . official s [ index ], Ġthis . off ices [ index ])) ĊĠĠĠ Ġ} ĊĠĠĠ Ġreturn Ġmutable List Ċ }