package Ġcom . android . ometri as dk . core . network Ċ Ċ import Ġcom . android . ometri as dk . core . event . O met ria Basket Ċ import Ġcom . android . ometri as dk . core . event . O met ria Basket Item Ċ import Ġcom . android . ometri as dk . core . event . O met ria Event Ċ import Ġcom . android . ometri as dk . core . network . model . O met ria ApiRequest Ċ import Ġorg . json . JSONArray Ċ import Ġorg . json . JSONObject Ċ Ċ /** Ċ Ġ* ĠCreated Ġby Ġc rist i and reg an Ċ Ġ* Ġon Ġ 2 1 / 0 8 / 2 0 2 0 . Ċ Ġ*/ Ċ Ċ internal Ġfun ĠCollection < O met ria Event >. toJson (): ĠJSONArray Ġ{ ĊĠĠĠ Ġval Ġjson Array Ġ= ĠJSONArray () ĊĊĠĠĠ ĠforEach Ġ{ ĊĠĠĠĠĠĠĠ Ġjson Array . put ( it . toJson ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġreturn Ġjson Array Ċ } Ċ Ċ internal Ġfun ĠO met ria Event . toJson (): ĠJSONObject Ġ{ ĊĠĠĠ Ġval ĠjsonObject Ġ= ĠJSONObject () ĊĠĠĠ ĠjsonObject . put (" eventId ", Ġevent Id ) ĊĠĠĠ ĠjsonObject . put (" is Being Fl ushed ", Ġis Being Fl ushed ) ĊĠĠĠ ĠjsonObject . put (" dt Occurred ", Ġdt Occurred ) ĊĠĠĠ ĠjsonObject . put (" appId ", ĠappId ) ĊĠĠĠ ĠjsonObject . put (" installation Id ", Ġinstallation Id ) ĊĠĠĠ ĠjsonObject . put (" app Version ", Ġapp Version ) ĊĠĠĠ ĠjsonObject . put (" app Build Number ", Ġapp Build Number ) ĊĠĠĠ ĠjsonObject . put (" sdk Version ", Ġsdk Version ) ĊĠĠĠ ĠjsonObject . put (" platform ", Ġplatform ) ĊĠĠĠ ĠjsonObject . put (" os Version ", Ġos Version ) ĊĠĠĠ ĠjsonObject . put (" device Manufacturer ", Ġdevice Manufacturer ) ĊĠĠĠ ĠjsonObject . put (" device Model ", Ġdevice Model ) ĊĠĠĠ ĠjsonObject . put (" type ", Ġtype ) ĊĠĠĠ ĠjsonObject . put (" data ", Ġdata ?. data ToJson () Ġ?: ĠJSONObject ()) ĊĊĠĠĠ Ġreturn ĠjsonObject Ċ } Ċ Ċ internal Ġfun ĠMap < String , ĠAny >. data ToJson (): ĠJSONObject Ġ{ ĊĠĠĠ Ġval Ġmap JsonObject Ġ= ĠJSONObject () ĊĠĠĠ Ġthis . forEach Ġ{ Ġ( key , Ġvalue ) Ġ-> ĊĠĠĠĠĠĠĠ Ġval Ġdata Value Ġ= Ġif Ġ( value Ġis ĠO met ria Basket ) Ġvalue . toJson () Ġelse ĠJSONObject . wrap ( value ) ĊĠĠĠĠĠĠĠ Ġmap JsonObject . put ( key , Ġdata Value ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġreturn Ġmap JsonObject Ċ } Ċ Ċ internal Ġfun ĠO met ria Basket . toJson (): ĠJSONObject Ġ{ ĊĠĠĠ Ġval ĠjsonObject Ġ= ĠJSONObject () ĊĠĠĠ ĠjsonObject . put (" total Price ", Ġtotal Price ) ĊĠĠĠ ĠjsonObject . put (" currency ", Ġcurrency ) ĊĠĠĠ ĠjsonObject . put (" link ", Ġlink ) ĊĊĠĠĠ Ġval Ġjson Array Ġ= ĠJSONArray () ĊĊĠĠĠ Ġitems . forEach Ġ{ ĊĠĠĠĠĠĠĠ Ġjson Array . put ( it . toJson ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ ĠjsonObject . put (" items ", Ġjson Array ) ĊĊĠĠĠ Ġreturn ĠjsonObject Ċ } Ċ Ċ internal Ġfun ĠO met ria Basket Item . toJson (): ĠJSONObject Ġ{ ĊĠĠĠ Ġval ĠjsonObject Ġ= ĠJSONObject () ĊĠĠĠ ĠjsonObject . put (" productId ", ĠproductId ) ĊĠĠĠ ĠjsonObject . put (" sku ", Ġsku ) ĊĠĠĠ ĠjsonObject . put (" quantity ", Ġquantity ) ĊĠĠĠ ĠjsonObject . put (" price ", Ġprice ) ĊĊĠĠĠ Ġreturn ĠjsonObject Ċ } Ċ Ċ internal Ġfun ĠO met ria ApiRequest . toJson (): ĠJSONObject Ġ{ ĊĠĠĠ Ġval ĠjsonObject Ġ= ĠJSONObject () ĊĠĠĠ ĠjsonObject . put (" appId ", ĠappId ) ĊĠĠĠ ĠjsonObject . put (" app Version ", Ġapp Version ) ĊĠĠĠ ĠjsonObject . put (" installation Id ", Ġinstallation Id ) ĊĠĠĠ ĠjsonObject . put (" app Build Number ", Ġapp Build Number ) ĊĠĠĠ ĠjsonObject . put (" sdk Version ", Ġsdk Version ) ĊĠĠĠ ĠjsonObject . put (" platform ", Ġplatform ) ĊĠĠĠ ĠjsonObject . put (" os Version ", Ġos Version ) ĊĠĠĠ ĠjsonObject . put (" device Manufacturer ", Ġdevice Manufacturer ) ĊĠĠĠ ĠjsonObject . put (" device Model ", Ġdevice Model ) ĊĠĠĠ ĠjsonObject . put (" dt Sent ", Ġdt Sent ) ĊĠĠĠ ĠjsonObject . put (" events ", Ġevents ?. to API Json ()) ĊĊĠĠĠ Ġreturn ĠjsonObject Ċ } Ċ Ċ internal Ġfun ĠCollection < O met ria Event >. to API Json (): ĠJSONArray Ġ{ ĊĠĠĠ Ġval Ġjson Array Ġ= ĠJSONArray () ĊĊĠĠĠ ĠforEach Ġ{ ĊĠĠĠĠĠĠĠ Ġjson Array . put ( it . to API Json ()) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġreturn Ġjson Array Ċ } Ċ Ċ internal Ġfun ĠO met ria Event . to API Json (): ĠJSONObject Ġ{ ĊĠĠĠ Ġval ĠjsonObject Ġ= ĠJSONObject () ĊĠĠĠ ĠjsonObject . put (" eventId ", Ġevent Id ) ĊĠĠĠ ĠjsonObject . put (" dt Occurred ", Ġdt Occurred ) ĊĠĠĠ ĠjsonObject . put (" type ", Ġtype ) ĊĠĠĠ ĠjsonObject . put (" data ", Ġdata ?. data ToJson ()) ĊĊĠĠĠ Ġreturn ĠjsonObject Ċ }