@@ -31,8 +31,8 @@ typealias Serialized = Map<String, Any?>
31
31
* It receives serialized params.
32
32
*/
33
33
internal object HyperTrackSdkWrapper {
34
- fun addGeotag (args : Serialized ): WrapperResult <Serialized > {
35
- return deserializeGeotagData(args)
34
+ fun addGeotag (args : Serialized ): WrapperResult <Serialized > =
35
+ deserializeGeotagData(args)
36
36
.flatMapSuccess { geotag ->
37
37
// TODO: return proper error if JSON is wrong
38
38
val geotagMetadata = Json .fromMap(geotag.data)!!
@@ -60,18 +60,17 @@ internal object HyperTrackSdkWrapper {
60
60
)
61
61
} else {
62
62
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)
73
71
}
74
72
}
73
+ }
75
74
} else {
76
75
if (orderHandle != null || orderStatus != null ) {
77
76
if (orderHandle == null || orderStatus == null ) {
@@ -84,116 +83,94 @@ internal object HyperTrackSdkWrapper {
84
83
)
85
84
} else {
86
85
HyperTrack .addGeotag(geotagMetadata)
87
- }
88
- .let { serializeLocationResult(it) }
86
+ }.let { serializeLocationResult(it) }
89
87
}.let {
90
88
Success (it)
91
89
}
92
90
}
93
- }
94
91
95
- fun getDeviceId (): WrapperResult <Serialized > {
96
- return Success (serializeDeviceId(HyperTrack .deviceID))
97
- }
92
+ fun getDeviceId (): WrapperResult <Serialized > = Success (serializeDeviceId(HyperTrack .deviceID))
98
93
99
- fun getDynamicPublishableKey (): WrapperResult <Serialized > {
100
- return Success (serializeDynamicPublishableKey(HyperTrack .dynamicPublishableKey))
101
- }
94
+ fun getDynamicPublishableKey (): WrapperResult <Serialized > = Success (serializeDynamicPublishableKey(HyperTrack .dynamicPublishableKey))
102
95
103
- fun getErrors (): WrapperResult <List <Serialized >> {
104
- return Success (serializeErrors(HyperTrack .errors))
105
- }
96
+ fun getErrors (): WrapperResult <List <Serialized >> = Success (serializeErrors(HyperTrack .errors))
106
97
107
- fun getIsAvailable (): WrapperResult <Serialized > {
108
- return Success (
98
+ fun getIsAvailable (): WrapperResult <Serialized > =
99
+ Success (
109
100
serializeIsAvailable(HyperTrack .isAvailable),
110
101
)
111
- }
112
102
113
- fun getIsTracking (): WrapperResult <Serialized > {
114
- return Success (
103
+ fun getIsTracking (): WrapperResult <Serialized > =
104
+ Success (
115
105
serializeIsTracking(HyperTrack .isTracking),
116
106
)
117
- }
118
107
119
- fun getLocation (): WrapperResult <Serialized > {
120
- return HyperTrack
108
+ fun getLocation (): WrapperResult <Serialized > =
109
+ HyperTrack
121
110
.location
122
111
.let {
123
112
when (it) {
124
113
is Result .Failure -> serializeLocationErrorFailure(it.failure)
125
114
is Result .Success -> serializeLocationSuccess(it.success)
126
115
}
127
- }
128
- .let { Success (it) }
129
- }
116
+ }.let { Success (it) }
130
117
131
- fun getMetadata (): WrapperResult <Serialized > {
132
- return Success (
118
+ fun getMetadata (): WrapperResult <Serialized > =
119
+ Success (
133
120
serializeMetadata(HyperTrack .metadata.toMap()),
134
121
)
135
- }
136
122
137
- fun getName (): WrapperResult <Serialized > {
138
- return Success (
123
+ fun getName (): WrapperResult <Serialized > =
124
+ Success (
139
125
serializeName(HyperTrack .name),
140
126
)
141
- }
142
127
143
- fun getOrders (): WrapperResult <Serialized > {
144
- return Success (
128
+ fun getOrders (): WrapperResult <Serialized > =
129
+ Success (
145
130
serializeOrders(HyperTrack .orders.values),
146
131
)
147
- }
148
132
149
- fun getWorkerHandle (): WrapperResult <Serialized > {
150
- return Success (
133
+ fun getWorkerHandle (): WrapperResult <Serialized > =
134
+ Success (
151
135
serializeWorkerHandle(HyperTrack .workerHandle),
152
136
)
153
- }
154
137
155
- fun setDynamicPublishableKey (args : Serialized ): WrapperResult <Unit > {
156
- return deserializeDynamicPublishableKey(args)
138
+ fun setDynamicPublishableKey (args : Serialized ): WrapperResult <Unit > =
139
+ deserializeDynamicPublishableKey(args)
157
140
.mapSuccess { publishableKey ->
158
141
HyperTrack .dynamicPublishableKey = publishableKey
159
142
}
160
- }
161
143
162
- fun setIsAvailable (args : Serialized ): WrapperResult <Unit > {
163
- return deserializeIsAvailable(args)
144
+ fun setIsAvailable (args : Serialized ): WrapperResult <Unit > =
145
+ deserializeIsAvailable(args)
164
146
.mapSuccess { isAvailable ->
165
147
HyperTrack .isAvailable = isAvailable
166
148
}
167
- }
168
149
169
- fun setIsTracking (args : Serialized ): WrapperResult <Unit > {
170
- return deserializeIsTracking(args)
150
+ fun setIsTracking (args : Serialized ): WrapperResult <Unit > =
151
+ deserializeIsTracking(args)
171
152
.mapSuccess { isTracking ->
172
153
HyperTrack .isTracking = isTracking
173
154
}
174
- }
175
155
176
- fun setMetadata (args : Serialized ): WrapperResult <Unit > {
177
- return deserializeMetadata(args)
156
+ fun setMetadata (args : Serialized ): WrapperResult <Unit > =
157
+ deserializeMetadata(args)
178
158
.flatMapSuccess { metadata ->
179
159
WrapperResult .tryAsResult {
180
160
// TODO: return proper error if JSON is wrong
181
161
HyperTrack .metadata = Json .fromMap(metadata)!!
182
162
}
183
163
}
184
- }
185
164
186
- fun setName (args : Serialized ): WrapperResult <Unit > {
187
- return deserializeName(args)
165
+ fun setName (args : Serialized ): WrapperResult <Unit > =
166
+ deserializeName(args)
188
167
.mapSuccess { name ->
189
168
HyperTrack .name = name
190
169
}
191
- }
192
170
193
- fun setWorkerHandle (args : Serialized ): WrapperResult <Unit > {
194
- return deserializeWorkerHandle(args)
171
+ fun setWorkerHandle (args : Serialized ): WrapperResult <Unit > =
172
+ deserializeWorkerHandle(args)
195
173
.mapSuccess { workerHandle ->
196
174
HyperTrack .workerHandle = workerHandle
197
175
}
198
- }
199
176
}
0 commit comments