Skip to content

Updated gradle, added metadata to base error object #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ allprojects {
```
* Add the library dependency
```
implementation 'com.github.ZoomCar:android-network-library:1.0.4'
implementation 'com.github.ZoomCar:android-network-library:1.0.5'
```

* Add third party dependencies, [Chuck Http Interceptor](https://github.com/jgilfelt/chuck) for logging,
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {

}
dependencies {
classpath "com.android.tools.build:gradle:4.0.0-alpha07"
classpath 'com.android.tools.build:gradle:4.0.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"

// NOTE: Do not place your application dependencies here; they belong
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Jan 03 19:04:45 IST 2020
#Mon Jun 29 17:06:34 IST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1-milestone-2-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.zoomcar.zcnetwork.core

import com.bluelinelabs.logansquare.LoganSquare
import com.google.gson.Gson
import com.google.gson.JsonElement
import com.zoomcar.zcnetwork.error.NetworkError
import com.zoomcar.zcnetwork.models.BaseErrorVO
Expand All @@ -17,7 +18,7 @@ interface ZcNetworkListener {
fun buildNetworkError(httpCode: Int, data: ByteArray): NetworkError {
val baseErrorVO: BaseErrorVO
return try {
baseErrorVO = LoganSquare.parse(String(data), BaseErrorVO::class.java)
baseErrorVO = Gson().fromJson(String(data), BaseErrorVO::class.java)
NetworkError(httpCode, baseErrorVO)
} catch (e: Exception) {
e.printStackTrace()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,30 @@ package com.zoomcar.zcnetwork.models
import android.os.Parcelable
import com.bluelinelabs.logansquare.annotation.JsonField
import com.bluelinelabs.logansquare.annotation.JsonObject
import com.google.gson.annotations.SerializedName
import kotlinx.android.parcel.Parcelize
import kotlinx.android.parcel.RawValue

@Parcelize
@JsonObject
open class BaseErrorVO : Parcelable {
@JsonField
var status: Int = 0

@SerializedName(value = "error_code")
@JsonField(name = ["error_code"])
var errorCode: Int = 0

@SerializedName(value = "error_title")
@JsonField(name = ["error_title"])
var errorTitle: String? = null

@JsonField
var msg: String? = null

@JsonField
var httpStatusCode: Int = 0

@JsonField(name = ["metadata"])
var metadata: MutableMap<String, @RawValue Any?>? = null
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a key can have null values?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right now we only have one key inside metadata. Technically, values can be null. This is kept just in case.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't generally send a key at all if value is null from backend but since its generic lets keep it this way only.

}