@@ -31,8 +31,8 @@ typealias Serialized = Map<String, Any?>
3131 * It receives serialized params.
3232 */
3333internal object HyperTrackSdkWrapper {
34- fun addGeotag (args : Serialized ): WrapperResult <Serialized > {
35- return deserializeGeotagData(args)
34+ fun addGeotag (args : Serialized ): WrapperResult <Serialized > =
35+ deserializeGeotagData(args)
3636 .flatMapSuccess { geotag ->
3737 // TODO: return proper error if JSON is wrong
3838 val geotagMetadata = Json .fromMap(geotag.data)!!
@@ -60,18 +60,17 @@ internal object HyperTrackSdkWrapper {
6060 )
6161 } else {
6262 HyperTrack .addGeotag(geotagMetadata, expectedLocation)
63- }
64- .let {
65- when (it) {
66- is Result .Failure -> {
67- serializeLocationErrorFailure(it.failure)
68- }
69-
70- is Result .Success -> {
71- serializeLocationWithDeviationSuccess(it.success)
72- }
63+ }.let {
64+ when (it) {
65+ is Result .Failure -> {
66+ serializeLocationErrorFailure(it.failure)
67+ }
68+
69+ is Result .Success -> {
70+ serializeLocationWithDeviationSuccess(it.success)
7371 }
7472 }
73+ }
7574 } else {
7675 if (orderHandle != null || orderStatus != null ) {
7776 if (orderHandle == null || orderStatus == null ) {
@@ -84,116 +83,94 @@ internal object HyperTrackSdkWrapper {
8483 )
8584 } else {
8685 HyperTrack .addGeotag(geotagMetadata)
87- }
88- .let { serializeLocationResult(it) }
86+ }.let { serializeLocationResult(it) }
8987 }.let {
9088 Success (it)
9189 }
9290 }
93- }
9491
95- fun getDeviceId (): WrapperResult <Serialized > {
96- return Success (serializeDeviceId(HyperTrack .deviceID))
97- }
92+ fun getDeviceId (): WrapperResult <Serialized > = Success (serializeDeviceId(HyperTrack .deviceID))
9893
99- fun getDynamicPublishableKey (): WrapperResult <Serialized > {
100- return Success (serializeDynamicPublishableKey(HyperTrack .dynamicPublishableKey))
101- }
94+ fun getDynamicPublishableKey (): WrapperResult <Serialized > = Success (serializeDynamicPublishableKey(HyperTrack .dynamicPublishableKey))
10295
103- fun getErrors (): WrapperResult <List <Serialized >> {
104- return Success (serializeErrors(HyperTrack .errors))
105- }
96+ fun getErrors (): WrapperResult <List <Serialized >> = Success (serializeErrors(HyperTrack .errors))
10697
107- fun getIsAvailable (): WrapperResult <Serialized > {
108- return Success (
98+ fun getIsAvailable (): WrapperResult <Serialized > =
99+ Success (
109100 serializeIsAvailable(HyperTrack .isAvailable),
110101 )
111- }
112102
113- fun getIsTracking (): WrapperResult <Serialized > {
114- return Success (
103+ fun getIsTracking (): WrapperResult <Serialized > =
104+ Success (
115105 serializeIsTracking(HyperTrack .isTracking),
116106 )
117- }
118107
119- fun getLocation (): WrapperResult <Serialized > {
120- return HyperTrack
108+ fun getLocation (): WrapperResult <Serialized > =
109+ HyperTrack
121110 .location
122111 .let {
123112 when (it) {
124113 is Result .Failure -> serializeLocationErrorFailure(it.failure)
125114 is Result .Success -> serializeLocationSuccess(it.success)
126115 }
127- }
128- .let { Success (it) }
129- }
116+ }.let { Success (it) }
130117
131- fun getMetadata (): WrapperResult <Serialized > {
132- return Success (
118+ fun getMetadata (): WrapperResult <Serialized > =
119+ Success (
133120 serializeMetadata(HyperTrack .metadata.toMap()),
134121 )
135- }
136122
137- fun getName (): WrapperResult <Serialized > {
138- return Success (
123+ fun getName (): WrapperResult <Serialized > =
124+ Success (
139125 serializeName(HyperTrack .name),
140126 )
141- }
142127
143- fun getOrders (): WrapperResult <Serialized > {
144- return Success (
128+ fun getOrders (): WrapperResult <Serialized > =
129+ Success (
145130 serializeOrders(HyperTrack .orders.values),
146131 )
147- }
148132
149- fun getWorkerHandle (): WrapperResult <Serialized > {
150- return Success (
133+ fun getWorkerHandle (): WrapperResult <Serialized > =
134+ Success (
151135 serializeWorkerHandle(HyperTrack .workerHandle),
152136 )
153- }
154137
155- fun setDynamicPublishableKey (args : Serialized ): WrapperResult <Unit > {
156- return deserializeDynamicPublishableKey(args)
138+ fun setDynamicPublishableKey (args : Serialized ): WrapperResult <Unit > =
139+ deserializeDynamicPublishableKey(args)
157140 .mapSuccess { publishableKey ->
158141 HyperTrack .dynamicPublishableKey = publishableKey
159142 }
160- }
161143
162- fun setIsAvailable (args : Serialized ): WrapperResult <Unit > {
163- return deserializeIsAvailable(args)
144+ fun setIsAvailable (args : Serialized ): WrapperResult <Unit > =
145+ deserializeIsAvailable(args)
164146 .mapSuccess { isAvailable ->
165147 HyperTrack .isAvailable = isAvailable
166148 }
167- }
168149
169- fun setIsTracking (args : Serialized ): WrapperResult <Unit > {
170- return deserializeIsTracking(args)
150+ fun setIsTracking (args : Serialized ): WrapperResult <Unit > =
151+ deserializeIsTracking(args)
171152 .mapSuccess { isTracking ->
172153 HyperTrack .isTracking = isTracking
173154 }
174- }
175155
176- fun setMetadata (args : Serialized ): WrapperResult <Unit > {
177- return deserializeMetadata(args)
156+ fun setMetadata (args : Serialized ): WrapperResult <Unit > =
157+ deserializeMetadata(args)
178158 .flatMapSuccess { metadata ->
179159 WrapperResult .tryAsResult {
180160 // TODO: return proper error if JSON is wrong
181161 HyperTrack .metadata = Json .fromMap(metadata)!!
182162 }
183163 }
184- }
185164
186- fun setName (args : Serialized ): WrapperResult <Unit > {
187- return deserializeName(args)
165+ fun setName (args : Serialized ): WrapperResult <Unit > =
166+ deserializeName(args)
188167 .mapSuccess { name ->
189168 HyperTrack .name = name
190169 }
191- }
192170
193- fun setWorkerHandle (args : Serialized ): WrapperResult <Unit > {
194- return deserializeWorkerHandle(args)
171+ fun setWorkerHandle (args : Serialized ): WrapperResult <Unit > =
172+ deserializeWorkerHandle(args)
195173 .mapSuccess { workerHandle ->
196174 HyperTrack .workerHandle = workerHandle
197175 }
198- }
199176}
0 commit comments