package Ġnet . cord a . attachment demo Ċ Ċ import Ġcom . google . common . net . Host And Port Ċ import Ġnet . cord a . testing . http . Http Api Ċ import Ġokhttp 3 . Ok HttpClient Ċ import Ġokhttp 3 . Request Ċ import Ġjava . util . concurrent . TimeUnit Ċ Ċ /** Ċ Ġ* ĠInterface Ġfor Ġusing Ġthe Ġattachment Ġdemo ĠAPI Ġfrom Ġa Ġclient . Ċ Ġ*/ Ċ class ĠAttachment Demo Client Api ( val Ġhost And Port : ĠHost And Port ) Ġ{ ĊĠĠĠ Ġprivate Ġval Ġapi Ġ= ĠHttp Api . from Host And Port ( host And Port , Ġapi Root ) ĊĊĠĠĠ Ġfun Ġrun Recipient (): ĠBoolean Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġapi . post Json (" await - transaction ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġrun Sender ( other Side : ĠString ): ĠBoolean Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġapi . post Json ("$ other Side / send ") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġget Other Side Key (): ĠString Ġ{ ĊĠĠĠĠĠĠĠ Ġ// ĠTODO : ĠAdd Ġget Json Ġto Ġthe ĠAPI Ġutils ĊĠĠĠĠĠĠĠ Ġval Ġclient Ġ= ĠOk HttpClient . Builder (). connect Timeout ( 5 , ĠTimeUnit . SECONDS ). read Timeout ( 6 0 , ĠTimeUnit . SECONDS ). build () ĊĠĠĠĠĠĠĠ Ġval Ġrequest Ġ= ĠRequest . Builder (). url (" http :// $ host And Port /$ api Root / other - side - key "). build () ĊĠĠĠĠĠĠĠ Ġval Ġresponse Ġ= Ġclient . new Call ( request ). execute () ĊĠĠĠĠĠĠĠ Ġrequire ( response . is Successful ) Ġ// ĠTODO : ĠHandle Ġmore Ġgrace fully . ĊĠĠĠĠĠĠĠ Ġreturn Ġresponse . body (). string () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġprivate Ġval Ġapi Root Ġ= Ġ" api / attachment demo " ĊĠĠĠ Ġ} Ċ } Ċ