appwrite / sdk-for-android

[READ-ONLY] Official Appwrite Android SDK 💚 🤖
https://appwrite.io
BSD 3-Clause "New" or "Revised" License
98 stars 21 forks source link

More encapsulation in the SDK #7

Closed JohannHilbold closed 2 years ago

JohannHilbold commented 3 years ago

I think that all calls should return a better type than "OkHttp.Response"

For example, wouldn't it be nice to type: val session = Account(Client.client).createSession("user", "pass") and then the session would be (for example) of the AppwriteSession type. That object could have members like "isSuccess", "sessionID" or stuff like that.

With the current version, you have to type var response = accountService.createSession(email.toString(), password.toString()) var json = response.body?.string() ?: "" json = JSONObject(json).toString(8) _response.postValue(Event(json))

Encapsulating the "Response" would also allow for a SDK side json parsing and also error handling. The AppwriteSession object I described above could contain an AppwriteException if the call failed, for example. But more importantly, it would remove the need to parse the json on the non sdk side.

christyjacob4 commented 3 years ago

@JohannHilbold Thanks a lot for the feedback :) We are actually working on a RFC for Response Models as you mentioned https://github.com/appwrite/rfc/pull/19 We are waiting for some final comments before we can implement it across all our SDKs. I'd encourage you to give it a read and maybe drop your thoughts over there as well :)

lohanidamodar commented 2 years ago

Closing this as the response models were released. If the issue still exist feel free to reopen the issue.