fernandohackbart / BikeRide

BikeRide is one mobile application to join bikers to ride over tracks
0 stars 0 forks source link

How to generate the Java classes for the JSON payloads to be used within the mobile application? #1

Closed fernandohackbart closed 7 years ago

fernandohackbart commented 7 years ago

Make it easy to reference the payload received

fernandohackbart commented 7 years ago

Checking the JSON Model Generator plugin, looks promising

fernandohackbart commented 7 years ago

https://github.com/misakuo/JsonModelGenerator

fernandohackbart commented 7 years ago

After moving to Kotling the procedure changed

https://github.com/cbeust/klaxon

fernandohackbart commented 7 years ago
    fun createBiker(context: Context, createBikerrequest: BikerCreateRequest) {
        defaults(context)
        val preferences: Preferences? = Preferences(context)
        val gson = GsonBuilder().setPrettyPrinting().create()
        Fuel.post("/api/authn/biker").body(gson.toJson(createBikerrequest)).responseObject(BikerToken.Deserializer()){ req, res, result ->
            val (bikerTokenRsp, err) = result
             preferences?.clientToken=bikerTokenRsp?.token!!.authToken
            preferences?.bikerID=bikerTokenRsp?.bikerID!!.bikerID
        }
    }
fernandohackbart commented 7 years ago

Use gson