Skip to content

Commit 287b6c7

Browse files
authored
Merge pull request #13 from utsavdotpro/LIB-10
create mutateResponse()
2 parents 4a6aa6b + 430ec57 commit 287b6c7

3 files changed

Lines changed: 12 additions & 4 deletions

File tree

Connection/src/main/java/com/isolpro/library/connection/Connection.kt

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,16 +225,18 @@ abstract class Connection<T>() {
225225
return
226226
}
227227

228-
onResponseReceived(responseString)
228+
val mutatedResponseString = mutateResponse(responseString);
229+
230+
onResponseReceived(mutatedResponseString)
229231

230232
try {
231-
val res: T = Gson().fromJson(responseString, getClassType());
233+
val res: T = Gson().fromJson(mutatedResponseString, getClassType());
232234

233235
onSuccess(res);
234236

235237
if (hasOfflineEndpoint()) {
236238
try {
237-
offlineEndpoint?.let { Utils.writeToFile(getContext(), it, responseString) }
239+
offlineEndpoint?.let { Utils.writeToFile(getContext(), it, mutatedResponseString) }
238240
} catch (e: IOException) {
239241
onError(e)
240242
}
@@ -261,6 +263,8 @@ abstract class Connection<T>() {
261263

262264
abstract fun handleOnRequestCreated(endpoint: String, data: Any?)
263265

266+
abstract fun mutateResponse(data: String?): String?
267+
264268
abstract fun handleOnResponseReceived(data: String?)
265269

266270
abstract fun handleOnNoResponseError()

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ allprojects {
1717

1818
```gradle
1919
dependencies {
20-
implementation 'com.github.u-barnwal:ConnectionLibrary:VERSION'
20+
implementation 'com.github.utsavdotpro:ConnectionLibrary:VERSION'
2121
}
2222
```
2323

app/src/main/java/com/isolpro/library/connection/helpers/ConnectionHelper.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ class ConnectionHelper<T>(private val ctx: Context, private val typeClass: Class
3333
Log.e(endpoint, data.toString());
3434
}
3535

36+
override fun mutateResponse(data: String?): String? {
37+
return data;
38+
}
39+
3640
override fun handleOnResponseReceived(data: String?) {
3741
Log.e("---------", "handleOnResponseReceived");
3842
data?.let { Log.e("---------", it) };

0 commit comments

Comments
 (0)