API root:
{{value}}{{name}}: {{description}}account: string, required password: string, required
200{
code: 0,
result: {
token: string
}
}403try {
const response = await mushroom.$auth.loginAsync("your account", "your password");
console.log("Đăng nhập thành công, token: " + response.result.token);
} catch (error){
console.log("Đăng nhập thất bại: %o", error);
}
Đăng nhập và nhớ tài khoản tại client
try {
const response = await mushroom.$auth.loginAsync("your account", "your password", true);
console.log("Đăng nhập thành công, token: " + response.result.token);
} catch (error){
console.log("Đăng nhập thất bại: %o", error);
}
Hỗ trợ: DotNet Framework 4.5+, DotNet Core 3.1+, Unity3D, Mono
Đăng nhậptry
{
var loginResult = await API.Authentication.Login("your account", "your password");
Console.Write($"Login success. Token: {loginResult.Token}");
}
catch (Exception ex)
{
Console.Write($"Login fail. Message: {ex.Message}");
}
POST {{rootUrlPath}}auth/login HTTP/1.1
Host: {{domain}}
Content-Type: application/json
{
"account": "account",
"password": password
}
curl -X POST \ '{{rootUrl}}auth/login' \ -H 'Content-Type: application/json' \ -d '{ "account": "account", "password": "password" }'Shell
curl --request POST \ --url '{{rootUrl}}auth/login' \ --header 'Content-Type: application/json' \ --data '{\n"account": "account", \n"password": "password"\n}'
try {
LoginResult loginResult = API.getAuthentication().login("your account", "your password");
System.out.println("Login success. Token: " + loginResult.getToken());
}
catch (MushroomException me) {
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
me.printStackTrace();
}
catch(Exception ex) {
ex.printStackTrace();
}
/// ---------------- JAVA 8 OR ANDROID API Level 24+ (Android 7+) ----------------
try {
LoginResult loginResult = API.getAuthentication().loginAsync("your account", "your password").get();
System.out.println("Login success. Token: " + loginResult.getToken());
}
catch (CompletionException ex) {
if (ex.getCause() instanceof MushroomException) {
MushroomException me = (MushroomException)ex.getCause();
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
}
ex.printStackTrace();
}
catch(Exception ex) {
ex.printStackTrace();
}
/// ---------------- JAVA 7 OR ANDROID API Level 23- ----------------
API.getAuthentication().loginAsync("your account", "your password", loginResult -> {
System.out.println("Login success. Token: " + loginResult.getToken());
}, e -> {
MushroomException me = (MushroomException)ex.getCause();
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
}, (loginResult, e) -> {
// do something with loginResult and exception e
});
200{
code: 0
}
const logoutMode = "invalidClientSession"; // invalidClientSession: chỉ đăng xuất khỏi phiên làm việc của thiết bị hiện thời, không invalid token hiện thời // invalidServerSession: đăng xuất khỏi tất cả các thiết bị sử dụng chung chung phiên làm việc của người dùng hiện tại (token hiện thời) // invalidAllSession: đăng xuất khỏi tất cả các phiên làm việc của người dùng hiện tại try { await mushroom.$auth.logoutAsync({ mode: logoutMode }); console.log("Đã logout"); } catch(e) { console.error("Có lỗi: %o", error); }
Hỗ trợ: DotNet Framework 4.5+, DotNet Core 3.1+, Unity3D, Mono
Đăng xuấtvar logoutMode = LogoutMode.InvalidClientSession; // LogoutMode.InvalidClientSession: chỉ đăng xuất khỏi phiên làm việc của thiết bị hiện thời, không invalid token hiện thời // LogoutMode.InvalidServerSession: đăng xuất khỏi tất cả các thiết bị sử dụng chung chung phiên làm việc của người dùng hiện tại (token hiện thời) // LogoutMode.InvalidAllSession: đăng xuất khỏi tất cả các phiên làm việc của người dùng hiện tại try { await API.Authentication.Logout(logoutMode); } catch (Exception ex) { Console.Write($"Error: {ex.Message}"); }
GET {{rootUrlPath}}auth/logout?invalidAllSession=false HTTP/1.1
Host: {{domain}}
Token: your token
Đăng xuất khỏi tất cả các phiên làm việc của người dùng hiện tại
GET {{rootUrlPath}}auth/logout?invalidAllSession=true HTTP/1.1
Host: {{domain}}
Token: your token
curl -X GET \ '{{rootUrl}}auth/logout?invalidAllSession=true|false' \ -H 'Token: {{TOKEN}}'Shell
curl --request GET \ --url '{{rootUrl}}auth/logout?invalidAllSession=true|false' \ --header 'Token: {{TOKEN}}'
String logoutMode = LogoutMode.INVALID_CLIENT_SESSION; // LogoutMode.INVALID_CLIENT_SESSION: chỉ đăng xuất khỏi phiên làm việc của thiết bị hiện thời, không invalid token hiện thời // LogoutMode.INVALID_SERVER_SESSION: đăng xuất khỏi tất cả các thiết bị sử dụng chung chung phiên làm việc của người dùng hiện tại (token hiện thời) // LogoutMode.INVALID_ALL_SESSION: đăng xuất khỏi tất cả các phiên làm việc của người dùng hiện tại try { API.getAuthentication().logout(logoutMode); } catch (MushroomException me) { System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" + "Code: " + me.getCode() + "\n" + "SubCode: " + me.getSubCode() + "\n" + "Detail: " + me.getDetail()); me.printStackTrace(); } catch(Exception ex) { ex.printStackTrace(); }
/// ---------------- JAVA 8 OR ANDROID API Level 24+ (Android 7+) ---------------- String logoutMode = LogoutMode.INVALID_CLIENT_SESSION; // LogoutMode.INVALID_CLIENT_SESSION: chỉ đăng xuất khỏi phiên làm việc của thiết bị hiện thời, không invalid token hiện thời // LogoutMode.INVALID_SERVER_SESSION: đăng xuất khỏi tất cả các thiết bị sử dụng chung chung phiên làm việc của người dùng hiện tại (token hiện thời) // LogoutMode.INVALID_ALL_SESSION: đăng xuất khỏi tất cả các phiên làm việc của người dùng hiện tại try { API.getAuthentication().logoutAsync(logoutMode).get(); } catch (CompletionException ex) { if (ex.getCause() instanceof MushroomException) { MushroomException me = (MushroomException)ex.getCause(); System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" + "Code: " + me.getCode() + "\n" + "SubCode: " + me.getSubCode() + "\n" + "Detail: " + me.getDetail()); } ex.printStackTrace(); } catch(Exception ex) { ex.printStackTrace(); } /// ---------------- JAVA 7 OR ANDROID API Level 23- ---------------- String logoutMode = LogoutMode.INVALID_CLIENT_SESSION; // LogoutMode.INVALID_CLIENT_SESSION: chỉ đăng xuất khỏi phiên làm việc của thiết bị hiện thời, không invalid token hiện thời // LogoutMode.INVALID_SERVER_SESSION: đăng xuất khỏi tất cả các thiết bị sử dụng chung chung phiên làm việc của người dùng hiện tại (token hiện thời) // LogoutMode.INVALID_ALL_SESSION: đăng xuất khỏi tất cả các phiên làm việc của người dùng hiện tại API.getAuthentication().logoutAsync(logoutMode, () -> { System.out.println("Đã logout"); }, e -> { MushroomException me = (MushroomException)ex.getCause(); System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" + "Code: " + me.getCode() + "\n" + "SubCode: " + me.getSubCode() + "\n" + "Detail: " + me.getDetail()); }, e -> { // do something after both successed or failed });
200{
code: 0,
result: {
status: string
}
}
try {
const response = await mushroom.$auth.statusAsync();
console.log("status = " + response.result.status);
} catch (error) {
console.error("Có lỗi: %o", error);
}
Hỗ trợ: DotNet Framework 4.5+, DotNet Core 3.1+, Unity3D, Mono
Kiểm tra trạng thái đăng nhậptry
{
var loginStatus = await API.Authentication.Status();
Console.Write($"Status: {loginStatus.Status}");
}
catch (MushroomException ex)
{
Console.Write($"Error: {ex.Message}");
}
GET {{rootUrlPath}}auth/status HTTP/1.1
Host: {{domain}}
Token: your_token (if have)
curl -X GET \ '{{rootUrl}}auth/status' \ -H 'Token: {{TOKEN}}'Shell
curl --request GET \ --url '{{rootUrl}}auth/status' \ --header 'Token: {{TOKEN}}'
try {
LoginStatus loginStatus = API.getAuthentication().status();
System.out.println("Status: " + loginStatus.getStatus());
}
catch (MushroomException me) {
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
me.printStackTrace();
}
catch(Exception ex) {
ex.printStackTrace();
}
/// ---------------- JAVA 8 OR ANDROID API Level 24+ (Android 7+) ----------------
try {
LoginStatus loginStatus = API.getAuthentication().statusAsync().get();
System.out.println("Status: " + loginStatus.getStatus());
}
catch (CompletionException ex) {
if (ex.getCause() instanceof MushroomException) {
MushroomException me = (MushroomException)ex.getCause();
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
}
ex.printStackTrace();
}
catch(Exception ex) {
ex.printStackTrace();
}
/// ---------------- JAVA 7 OR ANDROID API Level 23- ----------------
API.getAuthentication().statusAsync(loginStatus -> {
System.out.println("Status: " + loginStatus.getStatus());
}, e -> {
MushroomException me = (MushroomException)ex.getCause();
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
}, (loginStatus, e) -> {
// do something with loginStatus and exception e
});
200{
code: 0,
result: {
id: string,
account: string,
roles: array of string,
disabled: boolean
}
}403try {
const response = await mushroom.$auth.meAsync();
console.log("Info: " + JSON.stringify(response));
} catch (error) {
console.error("Có lỗi: %o", error);
}
Hỗ trợ: DotNet Framework 4.5+, DotNet Core 3.1+, Unity3D, Mono
Lấy về thông tin người dùng hiện tạitry
{
var user = await API.Authentication.Me();
Console.Write($"Info: {JsonConvert.SerializeObject(user)}");
}
catch (MushroomException ex)
{
Console.Write($"Error: {ex.Message}");
}
GET {{rootUrlPath}}auth/me HTTP/1.1
Host: {{domain}}
Token: your_token
curl -X GET \ '{{rootUrl}}auth/me' \ -H 'Token: {{TOKEN}}'Shell
curl --request GET \ --url '{{rootUrl}}auth/me' \ --header 'Token: {{TOKEN}}'
try {
MushroomUser user = API.getAuthentication().me();
System.out.println("Info: id=" + user.getId() + ", account=" + user.getAccount() + ", roles=" + user.getRoles() + ", disabled=" + user.isDisabled());
}
catch (MushroomException me) {
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
me.printStackTrace();
}
catch(Exception ex) {
ex.printStackTrace();
}
/// ---------------- JAVA 8 OR ANDROID API Level 24+ (Android 7+) ----------------
try {
MushroomUser user = API.getAuthentication().meAsync().get();
System.out.println("Info: id=" + user.getId() + ", account=" + user.getAccount() + ", roles=" + user.getRoles() + ", disabled=" + user.isDisabled());
}
catch (CompletionException ex) {
if (ex.getCause() instanceof MushroomException) {
MushroomException me = (MushroomException)ex.getCause();
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
}
ex.printStackTrace();
}
catch(Exception ex) {
ex.printStackTrace();
}
/// ---------------- JAVA 7 OR ANDROID API Level 23- ----------------
API.getAuthentication().meAsync(user -> {
System.out.println("Info: id=" + user.getId() + ", account=" + user.getAccount() + ", roles=" + user.getRoles() + ", disabled=" + user.isDisabled());
}, e -> {
MushroomException me = (MushroomException)ex.getCause();
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
}, (user, e) -> {
// do something with user and exception e
});
account: string, required password: string, required
201{
code: 0,
result: {
id: AutoId,
requireActivation: boolean
}
}409 - account đã tồn tạiGiá trị khác - có lỗi trong quá trình đăng kýtry {
const response = await mushroom.$auth.registerAsync("your account", "your password");
if (response.result.requireActivation)
console.log("Đăng ký thành công, đã gửi mã code để kích hoạt tài khoản");
else
console.log("Đăng ký thành công");
} catch (error) {
console.error("Đăng ký thất bại: %o", error);
}
Hỗ trợ: DotNet Framework 4.5+, DotNet Core 3.1+, Unity3D, Mono
Đăng ký tài khoảntry
{
var registerResult = await API.Authentication.Register("your account", "your password");
if (registerResult.RequireActivation)
Console.Write("Đăng ký thành công, đã gửi mã code để kích hoạt tài khoản");
else
Console.Write("Đăng ký thành công");
}
catch (MushroomException ex)
{
Console.Write($"Error: {ex.Message}");
}
POST {{rootUrlPath}}auth/register HTTP/1.1
Host: {{domain}}
Content-Type: application/json
{
"account": "account",
"password": password
}
curl -X POST \ '{{rootUrl}}auth/register' \ -H 'Content-Type: application/json' \ -d '{ "account": "account", "password": "password" }'Shell
curl --request POST \ --url '{{rootUrl}}auth/register' \ --header 'Content-Type: application/json' \ --data '{\n"account": "account", \n"password": "password"\n}'
try {
RegisterResult registerResult = API.getAuthentication().register("your account", "your password");
if (registerResult.isRequireActivation())
System.out.println("Đăng ký thành công, đã gửi mã code để kích hoạt tài khoản");
else
System.out.println("Đăng ký thành công");
}
catch (MushroomException me) {
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
me.printStackTrace();
}
catch(Exception ex) {
ex.printStackTrace();
}
/// ---------------- JAVA 8 OR ANDROID API Level 24+ (Android 7+) ----------------
try {
RegisterResult registerResult = API.getAuthentication().registerAsync("your account", "your password").get();
if (registerResult.isRequireActivation())
System.out.println("Đăng ký thành công, đã gửi mã code để kích hoạt tài khoản");
else
System.out.println("Đăng ký thành công");
}
catch (CompletionException ex) {
if (ex.getCause() instanceof MushroomException) {
MushroomException me = (MushroomException)ex.getCause();
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
}
ex.printStackTrace();
}
catch(Exception ex) {
ex.printStackTrace();
}
/// ---------------- JAVA 7 OR ANDROID API Level 23- ----------------
API.getAuthentication().registerAsync("your account", "your password", registerResult -> {
if (registerResult.isRequireActivation())
System.out.println("Đăng ký thành công, đã gửi mã code để kích hoạt tài khoản");
else
System.out.println("Đăng ký thành công");
}, e -> {
MushroomException me = (MushroomException)ex.getCause();
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
}, (registerResult, e) -> {
// do something with registerResult and exception e
});
account: string, required code: string, required
200{
code: 0,
result: {
id: AutoId
}
}403
try {
await mushroom.$auth.activateAsync("your account", "activation code");
console.log("Kích hoạt thành công");
} catch (error) {
console.log("Kích hoạt thất bại: %o", error);
}
Hỗ trợ: DotNet Framework 4.5+, DotNet Core 3.1+, Unity3D, Mono
Kích hoạt tài khoảntry
{
await API.Authentication.Activate("your account", "activation code");
Console.Write("Kích hoạt thành công");
}
catch (MushroomException ex)
{
Console.Write($"Error: {ex.Message}");
}
POST {{rootUrlPath}}auth/activate HTTP/1.1
Host: {{domain}}
Content-Type: application/json
{
"account": "account",
"code": code
}
curl -X POST \ '{{rootUrl}}auth/activate' \ -H 'Content-Type: application/json' \ -d '{ "account": "account", "code": "code" }'Shell
curl --request POST \ --url '{{rootUrl}}auth/activate' \ --header 'Content-Type: application/json' \ --data '{\n"account": "account", \n"code": "code"\n}'
try {
API.getAuthentication().activate("your account", "activation code");
System.out.println("Kích hoạt tài khoản thành công");
}
catch (MushroomException me) {
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
me.printStackTrace();
}
catch(Exception ex) {
ex.printStackTrace();
}
/// ---------------- JAVA 8 OR ANDROID API Level 24+ (Android 7+) ----------------
try {
API.getAuthentication().activateAsync("your account", "activation code").get();
System.out.println("Kích hoạt tài khoản thành công");
}
catch (CompletionException ex) {
if (ex.getCause() instanceof MushroomException) {
MushroomException me = (MushroomException)ex.getCause();
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
}
ex.printStackTrace();
}
catch(Exception ex) {
ex.printStackTrace();
}
/// ---------------- JAVA 7 OR ANDROID API Level 23- ----------------
API.getAuthentication().activateAsync("your account", "activation code", id -> {
System.out.println("Kích hoạt tài khoản thành công");
}, e -> {
MushroomException me = (MushroomException)ex.getCause();
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
}, (id, e) -> {
// do something with id and exception e
});
account: string, required
200{
code: 0,
result: {
id: AutoId
}
}403
try {
await mushroom.$auth.recoverPasswordAsync("your account");
console.log("Mã code lấy lại mật khẩu đã được gửi");
} catch (error) {
console.error("Lấy lại mật khẩu thất bại: %o", error);
}
Hỗ trợ: DotNet Framework 4.5+, DotNet Core 3.1+, Unity3D, Mono
Lấy lại mật khẩutry
{
await API.Authentication.RecoverPassword("your account");
Console.Write("Mã code lấy lại mật khẩu đã được gửi");
}
catch (MushroomException ex)
{
Console.Write($"Error: {ex.Message}");
}
POST {{rootUrlPath}}auth/recover-password HTTP/1.1
Host: {{domain}}
Content-Type: application/json
{
"account": "account"
}
curl -X POST \ '{{rootUrl}}auth/recover-password' \ -H 'Content-Type: application/json' \ -d '{"account": "account"}'Shell
curl --request POST \ --url '{{rootUrl}}auth/recover-password' \ --header 'Content-Type: application/json' \ --data '{"account": "account"}'
try {
API.getAuthentication().recoverPassword("your account");
System.out.println("Mã code lấy lại mật khẩu đã được gửi");
}
catch (MushroomException me) {
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
me.printStackTrace();
}
catch(Exception ex) {
ex.printStackTrace();
}
/// ---------------- JAVA 8 OR ANDROID API Level 24+ (Android 7+) ----------------
try {
API.getAuthentication().recoverPasswordAsync("your account").get();
System.out.println("Mã code lấy lại mật khẩu đã được gửi");
}
catch (CompletionException ex) {
if (ex.getCause() instanceof MushroomException) {
MushroomException me = (MushroomException)ex.getCause();
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
}
ex.printStackTrace();
}
catch(Exception ex) {
ex.printStackTrace();
}
/// ---------------- JAVA 7 OR ANDROID API Level 23- ----------------
API.getAuthentication().recoverPasswordAsync("your account", id -> {
System.out.println("Mã code lấy lại mật khẩu đã được gửi");
}, e -> {
MushroomException me = (MushroomException)ex.getCause();
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
}, (id, e) -> {
// do something with id and exception e
});
account: string, required oldPassword: string, required if code omitted code: string, required if oldPassword omitted newPassword: string, required
200{
code: 0,
result: {
id: AutoId
}
}403
try {
await mushroom.$auth.resetPasswordAsync("your account", "your code", "your new password");
console.log("Đã đặt lại mật khẩu dựa trên mã khôi phục mật khẩu");
} catch (error) {
console.error("Có lỗi: %o", error);
}
Đổi mật khẩu
try {
await mushroom.$auth.changePasswordAsync("your account", "your old password", "your new password");
console.log("Đã đổi mật khẩu thành công");
} catch (error) {
console.error("Có lỗi: %o", error);
}
Hỗ trợ: DotNet Framework 4.5+, DotNet Core 3.1+, Unity3D, Mono
Khôi phục mật khẩutry
{
await API.Authentication.ResetPassword("your account", "your code", "your new password");
Console.Write("Đã đặt lại mật khẩu dựa trên mã khôi phục mật khẩu");
}
catch (MushroomException ex)
{
Console.Write($"Error: {ex.Message}");
}
Đổi mật khẩu
try
{
await API.Authentication.ChangePassword("your account", "your old password", "your new password");
Console.Write("Đã đổi mật khẩu thành công");
}
catch (MushroomException ex)
{
Console.Write($"Error: {ex.Message}");
}
POST {{rootUrlPath}}auth/reset-password HTTP/1.1
Host: {{domain}}
Content-Type: application/json
{
"account": "account",
"code": "code",
"newPassword": "newPassword"
}
Đổi mật khẩu
POST {{rootUrlPath}}auth/reset-password HTTP/1.1
Host: {{domain}}
Content-Type: application/json
Token: your_token
{
"account": "account",
"oldPassword": "oldPassword",
"newPassword": "newPassword"
}
curl -X POST \ '{{rootUrl}}auth/reset-password' \ -H 'Content-Type: application/json' \ -d '{ "account": "account", "code": "code", "newPassword": "newPassword" }'cURL - Đổi mật khẩu
curl -X POST \ '{{rootUrl}}auth/reset-password' \ -H 'Content-Type: application/json' \ -H 'Token: {{TOKEN}}' \ -d '{ "account": "account", "oldPassword": "oldPassword", "newPassword": "newPassword" }'Shell - Khôi phục mật khẩu
curl --request POST \
--url '{{rootUrlPath}}auth/reset-password' \
--header 'Host: {{domain}}' \
--header 'Content-Type: application/json' \
--data '{\n"account": "account",\n"code": "code",\n"newPassword": "newPassword"\n}'
Shell - Đổi mật khẩu
curl --request POST \
--url '{{rootUrlPath}}auth/reset-password' \
--header 'Host: {{domain}}' \
--header 'Content-Type: application/json' \
--header 'Token: {{TOKEN}}' \
--data '{\n"account": "account",\n"oldPassword": "oldPassword",\n"newPassword": "newPassword"\n}'
try {
API.getAuthentication().resetPassword("your account", "your code", "your new password");
System.out.println("Đã đặt lại mật khẩu dựa trên mã khôi phục mật khẩu");
}
catch (MushroomException me) {
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
me.printStackTrace();
}
catch(Exception ex) {
ex.printStackTrace();
}
Đổi mật khẩu
try {
API.getAuthentication().changePassword("your account", "your old password", "your new password");
System.out.println("Đã đổi mật khẩu thành công");
}
catch (MushroomException me) {
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
me.printStackTrace();
}
catch(Exception ex) {
ex.printStackTrace();
}
/// ---------------- JAVA 8 OR ANDROID API Level 24+ (Android 7+) ----------------
// Khôi phục mật khẩu
try {
API.getAuthentication().resetPasswordAsync("your account", "your code", "your new password").get();
System.out.println("Đã đặt lại mật khẩu dựa trên mã khôi phục mật khẩu");
}
catch (CompletionException ex) {
if (ex.getCause() instanceof MushroomException) {
MushroomException me = (MushroomException)ex.getCause();
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
}
ex.printStackTrace();
}
catch(Exception ex) {
ex.printStackTrace();
}
// Đổi mật khẩu
try {
API.getAuthentication().changePasswordAsync("your account", "your old password", "your new password").get();
System.out.println("Đã đổi mật khẩu thành công");
}
catch (CompletionException ex) {
if (ex.getCause() instanceof MushroomException) {
MushroomException me = (MushroomException)ex.getCause();
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
}
ex.printStackTrace();
}
catch(Exception ex) {
ex.printStackTrace();
}
/// ---------------- JAVA 7 OR ANDROID API Level 23- ----------------
// Khôi phục mật khẩu
API.getAuthentication().resetPasswordAsync("your account", "your code", "your new password", id -> {
System.out.println("Đã đặt lại mật khẩu dựa trên mã khôi phục mật khẩu");
}, e -> {
MushroomException me = (MushroomException)ex.getCause();
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
}, (id, e) -> {
// do something with id and exception e
});
// Khôi phục mật khẩu
API.getAuthentication().changePasswordAsync("your account", "your old password", "your new password", id -> {
System.out.println("Đã đổi mật khẩu thành công");
}, e -> {
MushroomException me = (MushroomException)ex.getCause();
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
}, (id, e) -> {
// do something with id and exception e
});
FileName: string, optional, tên file MD5: string, optional, giá trị băm md5 của file Tags: string, optional, giá trị các tag của ảnh, mỗi tag cách nhau bởi dấu phảy Content-Format: optional, string, định dạng dữ liệu truyền lên, nhận một trong các giá trị: BINARY, BASE64 hoặc FORMDATA, mặc định là BINARYRequest body
BINARY hoặc BASE64 hoặc FORMDATA
200{
code: 0,
result: AutoId
}403
// upload binary file
let result = await mushroom.$file.uploadAsync({
file: document.getElementById("fileUpload").files[0], // required
name: "Name of file with extension", // optional
tags: [ "tag1", "tag2" ], // optional
contentFormat: "BINARY", // optional, default: BINARY
progress: () => { /* Handle progress event */} // optional
});
// upload BASE64 file
let result = await mushroom.$file.uploadAsync({
file: document.getElementById("txtBase64").value, // required
name: "Name of file with extension", // required
tags: [ "tag1", "tag2" ], // optional
contentFormat: "BASE64", // required
progress: () => { /* Handle progress event */} // optional
});
// upload a FormData
let formData = new FormData();
formData.append("file", value, "Name of file with extension"); // value can be a String or Blob
let result = await mushroom.$file.uploadAsync({
file: formData, // required
name: "Name of file with extension", // required
tags: [ "tag1", "tag2" ], // optional
contentFormat: "FORMDATA", // required
progress: () => { /* Handle progress event */} // optional
});
Hỗ trợ: DotNet Framework 4.5+, DotNet Core 3.1+, Unity3D, Mono
Upload filetry
{
var result = await API.FileExtension.Upload(new UploadArg(stream) // Stream stream or byte[] data or string filePath
{
FileName = "Name of file with extension", // optional
Md5 = "MD5 hash value", // optional
Tags = new List {"tag1", "tag2"}
});
Console.Write("File id = " + result.FileId);
}
catch (Exception ex)
{
Console.Write($"Error: {ex.Message}");
}
POST {{rootUrlPath}}file/upload HTTP/1.1
Host: {{domain}}
BINARY|BASE64|FORMDATA
curl --request POST \
--url '{{rootUrlPath}}auth/upload' \
--data-binary '@Path_to_file'
try {
FileUpload file = new FileUpload(fileStream);
file.setFileName("Name of file with extension");
file.setMd5("MD5 hash value");
file.getTags().add("tag1");
file.getTags().addAll(tags);
FileUploadResult uploadResult = API.fileExtension().upload(file);
System.out.println("Upload file success. File id: " + uploadResult.getResult());
}
catch (MushroomException me) {
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
me.printStackTrace();
}
catch(Exception ex) {
ex.printStackTrace();
}
/// ---------------- JAVA 8 OR ANDROID API Level 24+ (Android 7+) ----------------
try {
FileUpload file = new FileUpload(fileStream);
file.setFileName("Name of file with extension");
file.setMd5("MD5 hash value");
file.getTags().add("tag1");
file.getTags().addAll(tags);
FileUploadResult uploadResult = API.fileExtension().uploadAsync(file).get();
System.out.println("Upload file success. File id: " + uploadResult.getResult());
}
catch (CompletionException ex) {
if (ex.getCause() instanceof MushroomException) {
MushroomException me = (MushroomException)ex.getCause();
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
}
ex.printStackTrace();
}
catch(Exception ex) {
ex.printStackTrace();
}
/// ---------------- JAVA 7 OR ANDROID API Level 23- ----------------
FileUpload file = new FileUpload(fileStream);
file.setFileName("Name of file with extension");
file.setMd5("MD5 hash value");
file.getTags().add("tag1");
file.getTags().addAll(tags);
API.fileExtension().uploadAsync(file, uploadResult -> {
System.out.println("Upload file success. File id: " + uploadResult.getResult());
}, e -> {
MushroomException me = (MushroomException)ex.getCause();
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
}, (loginResult, e) -> {
// do something with loginResult and exception e
});
Range: string, optional, là định nghĩa khoảng dữ liệu mong muốn nhận đượcXem thêm tại Range header document
416 - header Range không đúng định dạng hoặc overflow hoặc underflow206Content-Type: {fileContentType}
Content-Disposition: attachment; filename="{fileName}"
Accept-Range: bytes
Content-Length: {length of response data}
Content-Range: byte {realStartIndex}-{realEndIndex}/{totalLength}
BINARY
mushroom.$file.getDownloadLink("your file id");
Tùy biến lấy về link download inline mode
mushroom.$file.linkBuilder.download.id("your file id").inline().build();
Download file trên trình duyệt
mushroom.$file.download("your file id");
Content-Type: image/{type}
Last-Modified: {datetime}
BINARY
const imgSrc = mushroom.$file.linkBuilder.thumb
.id(fileId) // required
// .stretch(width, height) // width: gt 0; height: gt 0
// .square(size) // size: gt 0
// .zoom(width, height, backgroundColor)
// width: gt: 0
// height: gt 0
// backgroundColor: optional, default: transparent, valid values: transparent | [0-9a-fA-F]{6}
// .x(width) // width: gt 0
// .y(height) // height: gt 0
// .clip(width, height, verticalAlign, horizontalAlign)
// width: gt 0
// height: gt 0
// verticalAlign: optional, default: middle, valid values: top | middle | bottom
// horizontalAlign: optional, default: center, valid values: left | center | right
// .rotate90()
// .rotate180()
// .rotate270()
// .flipVertical()
// .flipHorizontal()
// .transparent(value) // value: from 0 to 255
// .grayscale()
// .allowSmallerSize()
// .format(outputFormat) // outputFormat: source | jpg | png | gif | webp | auto
.build();
Ảnh nguyên bản: <img src="{{rootUrl}}file/thumb?id=your_file_id" /> Ảnh co về kích thước cố định: <img src="{{rootUrl}}file/thumb?id=your_file_id&r=stretch&w=100&h=150" /> Ảnh vuông: <img src="{{rootUrl}}file/thumb?id=your_file_id&r=square&w=50" /> Ảnh được co nằm trong kích thước cố định, phần thừa được tô màu: <img src="{{rootUrl}}file/thumb?id=your_file_id&r=zoom&w=100&h=150&b=0000ff" /> Ảnh giữ tỉ lệ và cố định chiều ngang: <img src="{{rootUrl}}file/thumb?id=your_file_id&r=x&w=100" /> Ảnh giữ tỉ lệ và cố định chiều cao: <img src="{{rootUrl}}file/thumb?id=your_file_id&r=y&h=150" /> Ảnh cắt lấy một phần: <img src="{{rootUrl}}file/thumb?id=your_file_id&r=clip&w=100&h=150&va=top&ha=left" /> Chỉ định định dạng ảnh jpg: <img src="{{rootUrl}}file/thumb?id=your_file_id&f=jpg" /> Tạo hiệu ứng đen trắng: <img src="{{rootUrl}}file/thumb?id=your_file_id&e=grayscale" />
Hỗ trợ: DotNet Framework 4.5+, DotNet Core 3.1+, Unity3D, Mono
var imgSrc = API.FileExtension.GetThumbBuilder(fileId)
// .Stretch(width, height)
// .Square(size)
// .Zoom(width, height, backgroundColor) // backgroundColor: optional, default: transparent, valid values: transparent | [0-9a-fA-F]{6}
// .X(width)
// .Y(height)
// .Clip(150, 75, "top", "left")
// // .Clip(width, height, verticalAlign, horizontalAlign)
// // verticalAlign: optional, default: VerticalAlign.Middle
// // horizontalAlign: optional, default: ceHorizontalAlign.Centernter
// .Rotate90()
// .Rotate180()
// .Rotate270()
// .FlipVertical()
// .FlipHorizontal()
// .Transparent(50) // value: from 0 to 255
// .Grayscale()
// .Format(ThumbFormat.PNG)
.Build();
String imgSrc = API.fileExtension().getThumbBuilder(fileId)
// .stretch(width, height)
// .square(size)
// .zoom(width, height, backgroundColor) // backgroundColor: optional, default: transparent, valid values: transparent | [0-9a-fA-F]{6}
// .x(width)
// .y(height)
// .clip(150, 75, "top", "left")
// // .clip(width, height, verticalAlign, horizontalAlign)
// // verticalAlign: optional, default: VerticalAlign.Middle
// // horizontalAlign: optional, default: ceHorizontalAlign.Centernter
// .rotate90()
// .rotate180()
// .rotate270()
// .flipVertical()
// .flipHorizontal()
// .transparent(50) // value: from 0 to 255
// .grayscale()
// .format(ThumbFormat.PNG)
.build();
Content-Type: application/zip
Content-Disposition: attachment; filename="{name}"
BINARY
mushroom.$file.getZipLink("your file id 1", "your file id 2");
Tùy biến lấy về link download zip file với chế độ inline
mushroom.$file.linkBuilder.zip.add("your file id 1", "your file id 2").inline().build();
Tùy biến lấy về link download zip file chỉ định tên file
mushroom.$file.linkBuilder.zip.add("your file id 1", "your file id 2").attachment("file-name.zip").build();
Download zip file trên trình duyệt
mushroom.$file.zip("your file id 1", "your file id 2");
from: object, optional
name: string, optional
email: string, required
replyTo: object, optional
name: string, optional
email: string, required
to: array of object, optional
name: string, optional
email: string, required
cc: array of object, optional
name: string, optional
email: string, required
bcc: array of object, optional
name: string, optional
email: string, required
attachments: array of IdRef, optional
subject: string, required
content: string, required
isHtml: boolean, optional, default(false)
tag: string, optional
schedule: datetime, optional
200{
code: 0,
result: {
id: AutoId, // id của email mới tạo
token: string // token của email mới tạo, dùng để lấy về nội dung và trạng thái của email
}
}
var now = new Date();
var tomorrow8 = new Date();
tomorrow8.setDate(now.getDate() + 1);
tomorrow8.setHours(8);
tomorrow8.setMinutes(0);
tomorrow8.setSeconds(0);
try {
const result = await mushroom.$mail.sendAsync({
from: {
name: "suco",
email: "hoa.nguyen@siten.vn"
},
replyTo: {
name: "Siten",
email: "tech@siten.vn"
},
to: [{
email: "abc@gmail.com"
}, {
name: "Xyz",
email: "xyz@hotmail.com"
}],
subject: "Your subject",
content: "Your <i>mail</i> content",
isHtml: true,
tag: "your tag",
schedule: tomorrow8
});
console.log("Tạo lệnh gửi mail thành công", result);
} catch (error) {
console.error("Có lỗi: %o", error);
}
200{
code: 0,
result: {
from: {
name: string,
email: string
},
replyTo: {
name: string,
email: string
},
to: [{
name: string,
email: string
}],
cc: [{
name: string,
email: string
}],
bcc: [{
name: string,
email: string
}],
attachments: array of IdRef,
subject: string,
content: string,
isHtml: boolean,
tag: string,
schedule: datetime,
sentTimes: int, // số lần gửi thất bại
sentLogs: [{
time: datetime, // thời điểm gửi
success: bool, // cho biết gửi thành công hay không
failureReason: string, // lý do gửi thất bại
}],
createdTime: datetime, // thời điểm email được tạo
creatorId: IdRef // optional, mã người tạo
}
}
try {
const result = await mushroom.$mail.getAsync("your sent token");
console.log("Dữ liệu lệnh gửi mail: %o", result);
catch (error) {
console.error("Có lỗi: %o", error);
}
{
code: 0,
result: boolean
}
try {
const response = await mushroom.$mail.discardAsync("your sent token");
if (response.result)
console.log("Đã hủy lệnh gửi mail thành công", result);
else
console.log("Không hủy được lệnh gửi mail");
catch (error) {
console.error("Có lỗi: %o", error);
}
{{undefinedModel:html}}
Javascript VALUE model
{{valueModel:html}}
Javascript NULL model
{{nullModel:html}}
Hỗ trợ: DotNet Framework 4.5+, DotNet Core 3.1+, Unity3D, Mono
Đơn giảntry
{
var {{entityName}}s = await API.{{EntityName}}.List();
Console.WriteLine($"Count: {{{entityName}}s.Count}");
foreach (var {{entityName}} in {{entityName}}s)
{
// Use each item
}
}
catch (Exception ex)
{
Console.Write($"Error: {ex.Message}");
}
Tùy biến tham số
try
{
var arg = new ListArg {
Filters = "x.a=1&y<10|y>=30", // Filter.And(Filter.Eq("x.a", 1), Filter.Or(Filter.Lt("y", 10), Filter.Gte("y", 30))).Build(),
Fields = "{{fields:html}}", // Field.Include("x.a", "y", "z").Build(),
SortBy = "{{sortFields:html}}", // Sort.Ascending("a").ThenDescending("b").Build(),
Limit = 10,
Offset = 20
};
var {{entityName}}s = await API.{{EntityName}}.List(arg);
Console.WriteLine($"Count: {{{entityName}}s.Count}");
if (arg.ResponseMetadata != null)
foreach (var kp in arg.ResponseMetadata)
{
Console.WriteLine($"Key: {kp.Key}, Value: {kp.Value}");
}
foreach (var {{entityName}} in {{entityName}}s)
{
// Use each item
}
}
catch (Exception ex)
{
Console.Write($"Error: {ex.Message}");
}
try {
const response = await mushroom.{{entityName}}.findByIdAsync({
id: "id of {{entityName}}" // required
});
console.log("Thông tin {{entityName}} trả về: %o", response);
}
catch (e) {
console.error("Có lỗi: %o", e);
}
Tùy biến trường dữ liệu trả về
try {
const response = await mushroom.{{entityName}}.findByIdAsync({
id: "id of {{entityName}}", // required
fields: "{{fields:html}}"
});
console.log("Thông tin {{entityName}} trả về: %o", response);
}
catch (e) {
console.error("Có lỗi: %o", e);
}
{{undefinedModel:html}}
Javascript VALUE model
{{valueModel:html}}
Javascript NULL model
{{nullModel:html}}
Hỗ trợ: DotNet Framework 4.5+, DotNet Core 3.1+, Unity3D, Mono
Đơn giảntry
{
var {{entityName}}s = await API.{{EntityName}}.FindById(new FindByIdArg("your {{entityName}} id"));
if ({{entityName}} == null)
Console.WriteLine("{{entityName}} not found");
else
{
// Use this {{entityName}}
}
}
catch (Exception ex)
{
Console.Write($"Error: {ex.Message}");
}
Tùy biến tham số
try
{
var arg = new FindByIdArg("your {{entityName}} id")
{
Fields = "{{fields:html}}", // Field.Include("x.a", "y", "z").Build()
};
var {{entityName}}s = await API.{{EntityName}}.FindById(arg);
if ({{entityName}} == null)
Console.WriteLine("{{entityName}} not found");
else
{
// Use this {{entityName}}
}
}
catch (Exception ex)
{
Console.Write($"Error: {ex.Message}");
}
try {
FindByIdArg arg = new FindByIdArg(id);
{{EntityName}} {{entityName}} = API.get{{EntityName}}().findById(arg);
if ({{entityName}} == null)
System.out.println("{{entityName}} not found");
else {
// Use this {{entityName}}
}
}
catch (MushroomException me) {
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
me.printStackTrace();
}
catch(Exception ex) {
ex.printStackTrace();
}
Tùy biến tham số
try {
FindByIdArg arg = new FindByIdArg(id);
arg.setFields("{{fields:html}}"); // Field.include("x.a", "y", "z").build()
{{EntityName}} {{entityName}} = API.get{{EntityName}}().findById(arg);
if ({{entityName}} == null)
System.out.println("{{entityName}} not found");
else {
// Use this {{entityName}}
}
}
catch (MushroomException me) {
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
me.printStackTrace();
}
catch(Exception ex) {
ex.printStackTrace();
}
/// ---------------- JAVA 8 OR ANDROID API Level 24+ (Android 7+) ----------------
try {
FindByIdArg arg = new FindByIdArg(id);
{{EntityName}} {{entityName}} = API.get{{EntityName}}().findByIdAsync(arg).get();
if ({{entityName}} == null)
System.out.println("{{entityName}} not found");
else {
// Use this {{entityName}}
}
}
catch (CompletionException ex) {
if (ex.getCause() instanceof MushroomException) {
MushroomException me = (MushroomException)ex.getCause();
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
}
ex.printStackTrace();
}
catch(Exception ex) {
ex.printStackTrace();
}
/// ---------------- JAVA 7 OR ANDROID API Level 23- ----------------
FindByIdArg arg = new FindByIdArg(id);
API.get{{EntityName}}().findByIdAsync(arg, {{entityName}} -> {
if ({{entityName}} == null)
System.out.println("{{entityName}} not found");
else {
// Use this {{entityName}}
}
}, e -> {
System.err.println("HttpStatusCode: " + e.getHttpStatusCode() + "\n" +
"Code: " + e.getCode() + "\n" +
"SubCode: " + e.getSubCode() + "\n" +
"Detail: " + e.getDetail());
});
Tùy biến tham số
/// ---------------- JAVA 8 OR ANDROID API Level 24+ (Android 7+) ----------------
try {
FindByIdArg arg = new FindByIdArg(id);
arg.setFields("{{fields:html}}"); // Field.include("x.a", "y", "z").build()
{{EntityName}} {{entityName}} = API.get{{EntityName}}().findByIdAsync(arg).get();
if ({{entityName}} == null)
System.out.println("{{entityName}} not found");
else {
// Use this {{entityName}}
}
}
catch (CompletionException ex) {
if (ex.getCause() instanceof MushroomException) {
MushroomException me = (MushroomException)ex.getCause();
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
}
ex.printStackTrace();
}
catch(Exception ex) {
ex.printStackTrace();
}
/// ---------------- JAVA 7 OR ANDROID API Level 23- ----------------
FindByIdArg arg = new FindByIdArg(id);
arg.setFields("{{fields:html}}"); // Field.include("x.a", "y", "z").build()
API.get{{EntityName}}().findByIdAsync(arg, {{entityName}} -> {
if ({{entityName}} == null)
System.out.println("{{entityName}} not found");
else {
// Use this {{entityName}}
}
}, e -> {
System.err.println("HttpStatusCode: " + e.getHttpStatusCode() + "\n" +
"Code: " + e.getCode() + "\n" +
"SubCode: " + e.getSubCode() + "\n" +
"Detail: " + e.getDetail());
});
const {{entityName}}_object = {
// fieldName: value
};
try {
const response = await mushroom.{{entityName}}.createAsync({{entityName}}_object);
console.log("Thêm mới thành công {{entityName}}, new id=", response.result);
} catch (error) {
console.error("Có lỗi: %o", error);
}
{{undefinedModel:html}}
Javascript VALUE model
{{valueModel:html}}
Javascript NULL model
{{nullModel:html}}
Hỗ trợ: DotNet Framework 4.5+, DotNet Core 3.1+, Unity3D, Mono
Tạo mới một {{entityName}}try
{
var {{entityName}} = new {{EntityName}}
{
// set properties here
// PropertyName = Value
};
var arg = new CreateArg<{{EntityName}}>({{entityName}});
var id = await API.{{EntityName}}.Create(arg);
if (string.IsNullOrEmpty(id))
Console.WriteLine("Cannot create {{entityName}}");
else
Console.WriteLine($"Created new {{entityName}} (id={id})");
}
catch (Exception ex)
{
Console.Write($"Error: {ex.Message}");
}
try {
{{EntityName}} {{entityName}} = new {{EntityName}}();
// set properties here
{{entityName}}.setPropertyName(value);
CreateArg arg = new CreateArg({{entityName}});
String id = API.get{{EntityName}}().create(arg);
if (id == null || id == "")
System.out.println("Cannot create {{entityName}}");
else
System.out.println("Created new {{entityName}} (id=" + id + ")");
}
catch (MushroomException me) {
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
me.printStackTrace();
}
catch(Exception ex) {
ex.printStackTrace();
}
/// ---------------- JAVA 8 OR ANDROID API Level 24+ (Android 7+) ----------------
try {
{{EntityName}} {{entityName}} = new {{EntityName}}();
// set properties here
{{entityName}}.setPropertyName(value);
CreateArg arg = new CreateArg({{entityName}});
String id = API.get{{EntityName}}().createAsync(arg).get();
if (id == null || id == "")
System.out.println("Cannot create {{entityName}}");
else
System.out.println("Created new {{entityName}} (id=" + id + ")");
}
catch (CompletionException ex) {
if (ex.getCause() instanceof MushroomException) {
MushroomException me = (MushroomException)ex.getCause();
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
}
ex.printStackTrace();
}
catch(Exception ex) {
ex.printStackTrace();
}
/// ---------------- JAVA 7 OR ANDROID API Level 23- ----------------
{{EntityName}} {{entityName}} = new {{EntityName}}();
// set properties here
{{entityName}}.setPropertyName(value);
CreateArg arg = new CreateArg({{entityName}});
API.get{{EntityName}}().createAsync(arg, id -> {
if (id == null || id == "")
System.out.println("Cannot create {{entityName}}");
else
System.out.println("Created new {{entityName}} (id=" + id + ")");
}, e -> {
MushroomException me = (MushroomException)ex.getCause();
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
}, (id, e) -> {
// do something with id and exception e
});
const arr = [];
arr.push({{entityName}}_object_1);
arr.push({{entityName}}_object_2);
// ...
arr.push({{entityName}}_object_n);
try {
const response = await mushroom.{{entityName}}.batchCreateAsync(arr);
console.log("Thông tin thêm mới hàng loạt: %o", response);
} catch (error) {
console.error("Có lỗi: %o", error);
}
{{undefinedModel:html}}
Javascript VALUE model
{{valueModel:html}}
Javascript NULL model
{{nullModel:html}}
Hỗ trợ: DotNet Framework 4.5+, DotNet Core 3.1+, Unity3D, Mono
Tạo mới hàng loạt {{entityName}}try
{
var {{entityName}}s = new List<{{EntityName}}>();
{{entityName}}s.Add(new {{EntityName}}
{
// set properties here
// PropertyName = Value
});
{{entityName}}s.Add(new {{EntityName}}
{
// set properties here
// PropertyName = Value
});
// ...
var arg = new BatchCreateArg<{{EntityName}}>({{entityName}}s);
var ids = await API.{{EntityName}}.Create(arg);
Console.WriteLine($"Count: {ids.Count}, ids: {string.Join(", ", ids)}");
}
catch (Exception ex)
{
Console.Write($"Error: {ex.Message}");
}
try {
ArrayList<{{EntityName}}> arr = new ArrayList<>();
arr.add({{entityName}}_object_1);
arr.add({{entityName}}_object_2);
// ...
arr.add({{entityName}}_object_n);
BatchCreateArg arg = new BatchCreateArg(arr);
ArrayList<String> ids = API.get{{EntityName}}().batchCreate(arg);
System.out.print("ids: ");
for (int i = 0; i < ids.size(); i++) {
System.out.println(ids.get(i) + ", ");
}
}
catch (MushroomException me) {
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
me.printStackTrace();
}
catch(Exception ex) {
ex.printStackTrace();
}
/// ---------------- JAVA 8 OR ANDROID API Level 24+ (Android 7+) ----------------
try {
ArrayList<{{EntityName}}> arr = new ArrayList<>();
arr.add({{entityName}}_object_1);
arr.add({{entityName}}_object_2);
// ...
arr.add({{entityName}}_object_n);
BatchCreateArg arg = new BatchCreateArg(arr);
ArrayList<String> id = API.get{{EntityName}}().batchCreateAsync(arg).get();
System.out.print("ids: ");
for (int i = 0; i < ids.size(); i++) {
System.out.println(ids.get(i) + ", ");
}
}
catch (CompletionException ex) {
if (ex.getCause() instanceof MushroomException) {
MushroomException me = (MushroomException)ex.getCause();
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
}
ex.printStackTrace();
}
catch(Exception ex) {
ex.printStackTrace();
}
/// ---------------- JAVA 7 OR ANDROID API Level 23- ----------------
ArrayList<{{EntityName}}> arr = new ArrayList<>();
arr.add({{entityName}}_object_1);
arr.add({{entityName}}_object_2);
// ...
arr.add({{entityName}}_object_n);
BatchCreateArg arg = new BatchCreateArg(arr);
API.get{{EntityName}}().batchCreateAsync(arg, ids -> {
System.out.print("ids: ");
for (int i = 0; i < ids.size(); i++) {
System.out.println(ids.get(i) + ", ");
}
}, e -> {
MushroomException me = (MushroomException)ex.getCause();
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
}, (id, e) -> {
// do something with id and exception e
});
var {{entityName}}_object = {
id: {{entityName}}_id,
// fieldName: value
};
try {
const id = await mushroom.{{entityName}}.updateAsync({{entityName}}_object);
if (id == {{entityName}}_id)
console.log("Cập nhật thành công");
else
console.log("Dữ liệu không thay đổi");
} catch (error) {
console.error("Có lỗi: %o", error);
}
{{undefinedModel:html}}
Javascript VALUE model
{{valueModel:html}}
Javascript NULL model
{{nullModel:html}}
Hỗ trợ: DotNet Framework 4.5+, DotNet Core 3.1+, Unity3D, Mono
Cập nhật một {{entityName}}try
{
var {{entityName}} = new {{EntityName}}
{
// set properties here
// PropertyName = Value
};
var arg = new UpdateArg<{{EntityName}}>("id of {{entityName}}", {{entityName}});
var id = await API.{{EntityName}}.Update(arg);
if (string.IsNullOrEmpty(id))
Console.WriteLine("Cannot update {{entityName}}");
else
Console.WriteLine("Updated");
}
catch (Exception ex)
{
Console.Write($"Error: {ex.Message}");
}
try {
{{EntityName}} {{entityName}} = new {{EntityName}}();
{{entityName}}.setId({{entityName}}_id);
// set properties here
{{entityName}}.setPropertyName(value);
UpdateArg arg = new UpdateArg({{entityName}});
String id = API.get{{EntityName}}().update(arg);
if (id == {{entityName}}_id)
System.out.println("Updated");
else
System.out.println("Not changed");
}
catch (MushroomException me) {
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
me.printStackTrace();
}
catch(Exception ex) {
ex.printStackTrace();
}
/// ---------------- JAVA 8 OR ANDROID API Level 24+ (Android 7+) ----------------
try {
{{EntityName}} {{entityName}} = new {{EntityName}}();
{{entityName}}.setId({{entityName}}_id);
// set properties here
{{entityName}}.setPropertyName(value);
UpdateArg arg = new UpdateArg({{entityName}});
String id = API.get{{EntityName}}().updateAsync(arg).get();
if (id == {{entityName}}_id)
System.out.println("Updated");
else
System.out.println("Not changed");
}
catch (CompletionException ex) {
if (ex.getCause() instanceof MushroomException) {
MushroomException me = (MushroomException)ex.getCause();
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
}
ex.printStackTrace();
}
catch(Exception ex) {
ex.printStackTrace();
}
/// ---------------- JAVA 7 OR ANDROID API Level 23- ----------------
{{EntityName}} {{entityName}} = new {{EntityName}}();
{{entityName}}.setId({{entityName}}_id);
// set properties here
{{entityName}}.setPropertyName(value);
UpdateArg arg = new UpdateArg({{entityName}});
API.get{{EntityName}}().createAsync(arg, id -> {
if (id == {{entityName}}_id)
System.out.println("Updated");
else
System.out.println("Not changed");
}, e -> {
MushroomException me = (MushroomException)ex.getCause();
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
}, (id, e) -> {
// do something with id and exception e
});
const arr = [];
arr.push({{entityName}}_object_1);
arr.push({{entityName}}_object_2);
// ...
arr.push({{entityName}}_object_n);
try {
const response = await mushroom.{{entityName}}.batchUpdateAsync(arr);
console.log("Thông tin cập nhật hàng loạt: %o", response);
} catch (error) {
console.error("Có lỗi: %o", error);
}
{{undefinedModel:html}}
Javascript VALUE model
{{valueModel:html}}
Javascript NULL model
{{nullModel:html}}
Hỗ trợ: DotNet Framework 4.5+, DotNet Core 3.1+, Unity3D, Mono
Cập nhật hàng loạt {{entityName}}try
{
var {{entityName}}s = new List<{{EntityName}}>();
{{entityName}}s.Add(new {{EntityName}}
{
// set properties here
// PropertyName = Value
});
{{entityName}}s.Add(new {{EntityName}}
{
// set properties here
// PropertyName = Value
});
// ...
var arg = new BatchUpdateArg<{{EntityName}}>({{entityName}}s);
var ids = await API.{{EntityName}}.Update(arg);
Console.WriteLine($"Count: {ids.Count}, ids: {string.Join(", ", ids)}");
}
catch (Exception ex)
{
Console.Write($"Error: {ex.Message}");
}
try {
ArrayList<{{EntityName}}> arr = new ArrayList<>();
arr.add({{entityName}}_object_1);
arr.add({{entityName}}_object_2);
// ...
arr.add({{entityName}}_object_n);
BatchUpdateArg arg = new BatchUpdateArg(arr);
ArrayList<String> ids = API.get{{EntityName}}().update(arg);
System.out.print("ids: ");
for (int i = 0; i < ids.size(); i++) {
System.out.println(ids.get(i) + ", ");
}
}
catch (MushroomException me) {
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
me.printStackTrace();
}
catch(Exception ex) {
ex.printStackTrace();
}
/// ---------------- JAVA 8 OR ANDROID API Level 24+ (Android 7+) ----------------
try {
ArrayList<{{EntityName}}> arr = new ArrayList<>();
arr.add({{entityName}}_object_1);
arr.add({{entityName}}_object_2);
// ...
arr.add({{entityName}}_object_n);
BatchUpdateArg arg = new BatchUpdateArg(arr);
ArrayList<String> id = API.get{{EntityName}}().updateAsync(arg).get();
System.out.print("ids: ");
for (int i = 0; i < ids.size(); i++) {
System.out.println(ids.get(i) + ", ");
}
}
catch (CompletionException ex) {
if (ex.getCause() instanceof MushroomException) {
MushroomException me = (MushroomException)ex.getCause();
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
}
ex.printStackTrace();
}
catch(Exception ex) {
ex.printStackTrace();
}
/// ---------------- JAVA 7 OR ANDROID API Level 23- ----------------
ArrayList<{{EntityName}}> arr = new ArrayList<>();
arr.add({{entityName}}_object_1);
arr.add({{entityName}}_object_2);
// ...
arr.add({{entityName}}_object_n);
BatchUpdateArg arg = new BatchUpdateArg(arr);
API.get{{EntityName}}().batchUpdateAsync(arg, ids -> {
System.out.print("ids: ");
for (int i = 0; i < ids.size(); i++) {
System.out.println(ids.get(i) + ", ");
}
}, e -> {
MushroomException me = (MushroomException)ex.getCause();
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
}, (id, e) -> {
// do something with id and exception e
});
const {{entityName}}_object = {
id: {{entityName}}_id, // required
field_a: value_1,
field_b: value_2,
};
try {
const response = await mushroom.{{entityName}}.partialUpdateAsync({{entityName}}_object);
if (response.result == {{entityName}}_id)
console.log("Cập nhật thành công");
else
console.log("Dữ liệu không thay đổi");
} catch (error) {
console.error("Có lỗi: %o", error);
}
{{undefinedModel:html}}
Javascript VALUE model
{{valueModel:html}}
Javascript NULL model
{{nullModel:html}}
Hỗ trợ: DotNet Framework 4.5+, DotNet Core 3.1+, Unity3D, Mono
Cập nhật một phần {{entityName}}try
{
var {{entityName}} = new Dictionary<string, object>
{
// only set properties which you want to update here
// { "propertyName1", Value1 },
// { "propertyName2", Value2 }
// ...
};
var arg = new PartialUpdateArg<{{EntityName}}>("id of {{entityName}}", {{entityName}});
var id = await API.{{EntityName}}.Update(arg);
if (string.IsNullOrEmpty(id))
Console.WriteLine("Cannot update {{entityName}}");
else
Console.WriteLine("Updated");
}
catch (Exception ex)
{
Console.Write($"Error: {ex.Message}");
}
try {
{{EntityName}} {{entityName}} = new {{EntityName}}();
{{entityName}}.setId({{entityName}}_id);
// set properties here
{{entityName}}.setPropertyName(value);
PartialUpdateArg arg = new PartialUpdateArg({{entityName}}_id, {{entityName}});
String id = API.get{{EntityName}}().update(arg);
if (id == {{entityName}}_id)
System.out.println("Updated");
else
System.out.println("Not changed");
}
catch (MushroomException me) {
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
me.printStackTrace();
}
catch(Exception ex) {
ex.printStackTrace();
}
/// ---------------- JAVA 8 OR ANDROID API Level 24+ (Android 7+) ----------------
try {
{{EntityName}} {{entityName}} = new {{EntityName}}();
{{entityName}}.setId({{entityName}}_id);
// set properties here
{{entityName}}.setPropertyName(value);
PartialUpdateArg arg = new PartialUpdateArg({{entityName}}_id, {{entityName}});
String id = API.get{{EntityName}}().updateAsync(arg).get();
if (id == {{entityName}}_id)
System.out.println("Updated");
else
System.out.println("Not changed");
}
catch (CompletionException ex) {
if (ex.getCause() instanceof MushroomException) {
MushroomException me = (MushroomException)ex.getCause();
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
}
ex.printStackTrace();
}
catch(Exception ex) {
ex.printStackTrace();
}
/// ---------------- JAVA 7 OR ANDROID API Level 23- ----------------
{{EntityName}} {{entityName}} = new {{EntityName}}();
{{entityName}}.setId({{entityName}}_id);
// set properties here
{{entityName}}.setPropertyName(value);
UpdateArg arg = new UpdateArg({{entityName}});
API.get{{EntityName}}().createAsync(arg, id -> {
if (id == {{entityName}}_id)
System.out.println("Updated");
else
System.out.println("Not changed");
}, e -> {
MushroomException me = (MushroomException)ex.getCause();
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
}, (id, e) -> {
// do something with id and exception e
});
try {
const response = await mushroom.{{entityName}}.deleteAsync({
id: "id của {{entityName}} cần xóa" // required
});
console.log("Thông tin {{entityName}} trả về: %o", response);
}
catch (e) {
console.error("Có lỗi: %o", e);
}
Hỗ trợ: DotNet Framework 4.5+, DotNet Core 3.1+, Unity3D, Mono
Xóa một {{entityName}}try
{
var arg = new DeleteArg("id of {{entityName}}");
var count = await API.{{EntityName}}.Delete(arg);
if (count == 0)
Console.WriteLine("Cannot delete {{entityName}}");
else
Console.WriteLine("Deleted");
}
catch (Exception ex)
{
Console.Write($"Error: {ex.Message}");
}
try {
DeleteArg arg = new DeleteArg({{entityName}}_id);
Long count = API.get{{EntityName}}().delete(arg);
if (count == 1)
System.out.println("Deleted");
else
System.out.println("Unable to delete");
}
catch (MushroomException me) {
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
me.printStackTrace();
}
catch(Exception ex) {
ex.printStackTrace();
}
/// ---------------- JAVA 8 OR ANDROID API Level 24+ (Android 7+) ----------------
try {
DeleteArg arg = new DeleteArg({{entityName}}_id);
Long count = API.get{{EntityName}}().deleteAsync(arg).get();
if (count == 1)
System.out.println("Deleted");
else
System.out.println("Unable to delete");
}
catch (CompletionException ex) {
if (ex.getCause() instanceof MushroomException) {
MushroomException me = (MushroomException)ex.getCause();
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
}
ex.printStackTrace();
}
catch(Exception ex) {
ex.printStackTrace();
}
/// ---------------- JAVA 7 OR ANDROID API Level 23- ----------------
DeleteArg arg = new DeleteArg({{entityName}}_id);
API.get{{EntityName}}().deleteAsync(arg, count -> {
if (count == 1)
System.out.println("Deleted");
else
System.out.println("Unable to delete");
}, e -> {
MushroomException me = (MushroomException)ex.getCause();
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
}, (id, e) -> {
// do something with id and exception e
});
const ids = [];
ids.push(id1);
ids.push(id2);
// ...
ids.push(idn);
try {
const response = await mushroom.{{entityName}}.batchDeleteAsync(ids);
console.log("Thông tin xóa hàng loạt, response: %o", response);
}
catch (e) {
console.error("Có lỗi: %o", e);
}
Hỗ trợ: DotNet Framework 4.5+, DotNet Core 3.1+, Unity3D, Mono
Xóa hàng loạt {{entityName}}try
{
var ids = new List<string>();
ids.Add("id 1");
ids.Add("id 2");
// ...
ids.Add("id N");
var arg = new BatchDeleteArg(ids);
var count = await API.{{EntityName}}.Delete(arg);
Console.WriteLine($"Deleted count: {count}");
}
catch (Exception ex)
{
Console.Write($"Error: {ex.Message}");
}
try {
ArrayList<string> ids = new ArrayList<>();
ids.add(id1);
ids.add(id2);
// ...
ids.add(idn);
BatchDeleteArg arg = new BatchDeleteArg(ids);
Long count = API.get{{EntityName}}().delete(arg);
System.out.println("Deleted count: " + count);
}
catch (MushroomException me) {
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
me.printStackTrace();
}
catch(Exception ex) {
ex.printStackTrace();
}
/// ---------------- JAVA 8 OR ANDROID API Level 24+ (Android 7+) ----------------
try {
ArrayList<string> ids = new ArrayList<>();
ids.add(id1);
ids.add(id2);
// ...
ids.add(idn);
BatchDeleteArg arg = new BatchDeleteArg(ids);
Long count = API.get{{EntityName}}().deleteAsync(arg).get();
System.out.println("Deleted count: " + count);
}
catch (CompletionException ex) {
if (ex.getCause() instanceof MushroomException) {
MushroomException me = (MushroomException)ex.getCause();
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
}
ex.printStackTrace();
}
catch(Exception ex) {
ex.printStackTrace();
}
/// ---------------- JAVA 7 OR ANDROID API Level 23- ----------------
ArrayList<string> ids = new ArrayList<>();
ids.add(id1);
ids.add(id2);
// ...
ids.add(idn);
BatchDeleteArg arg = new BatchDeleteArg(ids);
API.get{{EntityName}}().deleteAsync(arg, count -> {
System.out.println("Deleted count: " + count);
}, e -> {
MushroomException me = (MushroomException)ex.getCause();
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
}, (id, e) -> {
// do something with id and exception e
});
Hỗ trợ: DotNet Framework 4.5+, DotNet Core 3.1+, Unity3D, Mono
Code tham khảo:try
{
var arg = new {{MethodName}}Arg();
// arg.Data = DataValue;
// arg.PropertyName = Value
var result = await API.{{EntityName}}.{{MethodName}}(arg);
// Use result, arg.ResponseMetadata here
}
catch (Exception ex)
{
Console.Write($"Error: {ex.Message}");
}
try {
{{MethodName}}Arg arg = new {{MethodName}}Arg();
// set properties here
arg.setPropertyName(value);
{{MethodName}}Result result = API.get{{EntityName}}().{{methodName}}(arg);
// use result
}
catch (MushroomException me) {
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
me.printStackTrace();
}
catch(Exception ex) {
ex.printStackTrace();
}
/// ---------------- JAVA 8 OR ANDROID API Level 24+ (Android 7+) ----------------
try {
{{MethodName}}Arg arg = new {{MethodName}}Arg();
// set properties here
arg.setPropertyName(value);
{{MethodName}}Result result = API.get{{EntityName}}().{{methodName}}Async(arg).get();
// use result
}
catch (CompletionException ex) {
if (ex.getCause() instanceof MushroomException) {
MushroomException me = (MushroomException)ex.getCause();
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
}
ex.printStackTrace();
}
catch(Exception ex) {
ex.printStackTrace();
}
/// ---------------- JAVA 7 OR ANDROID API Level 23- ----------------
{{MethodName}}Arg arg = new {{MethodName}}Arg();
// set properties here
arg.setPropertyName(value);
API.get{{EntityName}}().{{methodName}}Async(arg, result -> {
// use result
}, e -> {
MushroomException me = (MushroomException)ex.getCause();
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
}, (result, e) -> {
// do something with id and exception e
});
try {
const response = await mushroom.{{entityName}}.views.{{viewName}}Async({{parameters:html}});
console.log("Thông tin {{entityName}} trả về: %o", response);
}
catch (e) {
console.error("Có lỗi: %o", e);
}
{{undefinedModel:html}}
Javascript VALUE model
{{valueModel:html}}
Javascript NULL model
{{nullModel:html}}
try {
View{{ViewName}}Arg arg = new View{{ViewName}}Arg();
{{parameters:html}}
ArrayList<View{{ViewName}}Item> result = API.get{{EntityName}}().getViews().{{viewName}}(arg);
System.out.println("Count: " + result.size());
for (View{{ViewName}}Item item : result) {
// use item
}
}
catch (MushroomException me) {
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
me.printStackTrace();
}
catch(Exception ex) {
ex.printStackTrace();
}
/// ---------------- JAVA 8 OR ANDROID API Level 24+ (Android 7+) ----------------
try {
View{{ViewName}}Arg arg = new View{{ViewName}}Arg();
{{parameters:html}}
ArrayList<View{{ViewName}}Item> result = API.get{{EntityName}}().getViews().{{viewName}}Async(arg).get();
System.out.println("Count: " + result.size());
for (View{{ViewName}}Item item : result) {
// use item
}
}
catch (CompletionException ex) {
if (ex.getCause() instanceof MushroomException) {
MushroomException me = (MushroomException)ex.getCause();
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
}
ex.printStackTrace();
}
catch(Exception ex) {
ex.printStackTrace();
}
/// ---------------- JAVA 7 OR ANDROID API Level 23- ----------------
View{{ViewName}}Arg arg = new View{{ViewName}}Arg();
{{parameters:html}}
API.get{{EntityName}}().getViews().{{viewName}}Async(arg, result -> {
System.out.println("Count: " + result.size());
for (View{{ViewName}}Item item : result) {
// use item
}
}, e -> {
MushroomException me = (MushroomException)ex.getCause();
System.err.println("HttpStatusCode: " + me.getHttpStatusCode() + "\n" +
"Code: " + me.getCode() + "\n" +
"SubCode: " + me.getSubCode() + "\n" +
"Detail: " + me.getDetail());
}, (result, e) -> {
// do something with result and exception e
});
{{name}} trên (các) trường: {{htmlFields:html}}{{field}}: {{sortType}}
{{strPagingType}}
{{maxRecordCount}}
limit có thể nhận giá trị tối đa: {{maxPageSize}}
{
"meta": {
"total": Tổng số bản ghi thỏa mãn
}
}
{{serverPolicy}}
{{clientPolicy}}
{{explainedDenyRoles}}
$fields, kết quả trả về có dạng:
Trường hợp $fields=, kết quả trả về có dạng:
$sort):
{{description}}
{{explainedDenyRoles}}
$fields, kết quả trả về có dạng:
Trường hợp $fields=, kết quả trả về có dạng:
{{description}}
{{explainedDenyRoles}}
201 Created{{rootUrlPath}}{{entityName}}s/{resource-id}{
code: 0,
result: "{resource-id}"
}
Lưu ý: nếu dữ liệu trả về không có result hoặc result bằng null nghĩa là tài nguyên chưa được tạo mới
{{description}}
{{explainedDenyRoles}}
{
code: 0,
result: [Mảng các Id của các tài nguyên vừa tạo]
}
{{description}}
{{explainedDenyRoles}}
{
code: 0,
result: Id của tài nguyên vừa được cập nhật
}
{{description}}
{{explainedDenyRoles}}
{
code: 0,
result: [Mảng các Id của các tài nguyên vừa được cập nhật]
}
{{description}}
{{explainedDenyRoles}}
{
code: 0,
result: Id của tài nguyên vừa được cập nhật
}
{{description}}
{{explainedDenyRoles}}
{
code: 0,
result: number (0 | 1) // Số lượng bản ghi bị xóa
}
{{description}}
{{explainedDenyRoles}}
["Mảng các Id cần xóa"]
{
code: 0,
result: number: Số lượng bản ghi bị xóa
}
{{description}}
{{explainedDenyRoles}}
{{description}}
{{explainedDenyRoles}}
{{outputModel:html}}
{{outputEmptyResult}}