use of io.ionic.demo.ecommerce.data.model.User in project portals-ecommerce-demo by ionic-team.
the class DataServiceTest method getUserShouldReturnUser.
@Test
public void getUserShouldReturnUser() {
User user = dataService.getUser();
assertNotNull(user);
assertEquals("Joe", user.firstName);
}
use of io.ionic.demo.ecommerce.data.model.User in project portals-ecommerce-demo by ionic-team.
the class DataServiceTest method setUserShouldStoreNewUser.
@Test
public void setUserShouldStoreNewUser() {
User user = dataService.getUser();
user.firstName = "Jane";
dataService.setUser(user);
user = null;
User user2 = dataService.getUser();
assertEquals("Jane", user2.firstName);
}
use of io.ionic.demo.ecommerce.data.model.User in project portals-ecommerce-demo by ionic-team.
the class ShopAPIPlugin method getUserDetails.
@PluginMethod
public void getUserDetails(PluginCall call) {
try {
User user = dataService.getUser();
String userJson = new Gson().toJson(user);
JSObject userJSObject = JSObject.fromJSONObject(new JSONObject(userJson));
call.resolve(userJSObject);
} catch (JSONException e) {
call.reject("error decoding user object");
}
}
use of io.ionic.demo.ecommerce.data.model.User in project portals-ecommerce-demo by ionic-team.
the class ShopAPIPlugin method setUserPicture.
@PluginMethod
public void setUserPicture(PluginCall call) {
String picture = call.getString("picture");
if (picture != null && !picture.isEmpty()) {
User user = dataService.getUser();
dataService.storeUserImage(getContext(), user, picture);
dataService.setUser(user);
}
call.resolve();
}
use of io.ionic.demo.ecommerce.data.model.User in project portals-ecommerce-demo by ionic-team.
the class ShopAPIPlugin method getUserPicture.
@PluginMethod
public void getUserPicture(PluginCall call) {
User user = dataService.getUser();
if (user.image != null && !user.image.isEmpty()) {
String picture = user.getImageBase64(getContext());
if (picture != null) {
JSObject returnPicture = new JSObject();
returnPicture.put("picture", picture);
call.resolve(returnPicture);
return;
}
}
call.reject("No picture available");
}
Aggregations