Android-CleanArchitecture icon indicating copy to clipboard operation
Android-CleanArchitecture copied to clipboard

POST & PUT methods implementation

Open adnbal89 opened this issue 8 years ago • 3 comments

Hello, Could you please clarify how to implement post method with a use case, because post method requires request body(json) and our UseCase<T, Params> doesn't support a Model to be passed to data layer.

For example : what if you want to add a User in to your cloud database, how to build use case in order to post User json string to your cloud.

Thank you.

adnbal89 avatar Jul 03 '17 10:07 adnbal89

Why do you say the current solution doesn't allow you to pass an entire model? You just have to set it as a filed in your Param object. Just remember that this model should be from the domain layer so you don't break the architecture.

Remember, you should not passed a json to your use case let the data layer decide how it will serialize the data. What you could do, depending on the complexity of the object you want to store is either pass each field as a Param field or you could have the press.ration layer send a whole model (business model) as a Parm field.

kevin-barrientos avatar Jul 03 '17 13:07 kevin-barrientos

yeap, you are right, i've implemented what you've suggested just after I opened the topic, but by this way, I need to write another model mapper class for presentation layer model to domain layer model. that's fine. Thank you.

adnbal89 avatar Jul 03 '17 18:07 adnbal89

Hello there, I have a similar question regarding post, delete, edit methods. Should I create a cloudDataStore for each methods like this this.userDataStoreFactory.createCloudDataStore() ?

regards,

Deep21 avatar Jan 14 '18 00:01 Deep21