{{description}}

API root:

COPIED!
  • {{value}}
  • {{fieldName}},
  • {{name}}: {{description}}
  • Environment variables

    Biến môi trường có thể được sử dụng trong:
    • filters của findMany
    • matches của các action
    • defaultValue của field
    • query của view
    • query của định nghĩa biến môi trường khác
    $$user_id [Built-in] Mã người dùng hiện tại
    Kiểu dữ liệu: IdRef
    Giá trị: mã người dùng hiện tại, bằng null nếu chưa đăng nhập
    $$user_ip [Built-in] IP của người dùng hiện tại
    Kiểu dữ liệu: string
    Giá trị: ip người dùng hiện tại (nullable)
    $$now [Built-in] Thời điểm hiện tại
    Kiểu dữ liệu: datetime
    Giá trị: Thời điểm hiện tại (có đủ date và time)
    Hỗ trợ lấy giá trị thời gian dựa vào thời điểm hiện tại theo cú pháp sau:
    $$now+Nunit: sau thời điểm hiện tại N đơn vị thời gian
    $$now-Nunit: trước thời điểm hiện tại N đơn vị thời gian
    Trong đó:
    N là giá trị số nguyên (với unit là months hoặc years) số thực với các đơn vị còn lại
    unit là đơn vị thời gian nhận một trong các giá trị sau:
    • days: ngày
    • months: tháng
    • years: năm
    • hours: giờ
    • minutes: phút
    • seconds: giây
    • milliseconds: phần nghìn giây
    • weeks: tuần
    $$today [Built-in] Ngày hôm nay
    Kiểu dữ liệu: datetime
    Giá trị: Thời điểm 0:00:00 của ngày hôm nay (có date, còn time là 0:00:00)
    Hỗ trợ lấy giá trị thời gian dựa vào thời điểm bắt đầu của ngày hôm nay theo cú pháp sau:
    $$today+Nunit: sau thời điểm đầu ngày hôm nay N đơn vị thời gian
    $$today-Nunit: trước thời điểm đầu ngày hôm nay N đơn vị thời gian
    Trong đó:
    N là giá trị số nguyên (với unit là months hoặc years) số thực với các đơn vị còn lại
    unit là đơn vị thời gian nhận một trong các giá trị sau:
    • days: ngày
    • months: tháng
    • years: năm
    • hours: giờ
    • minutes: phút
    • seconds: giây
    • milliseconds: phần nghìn giây
    • weeks: tuần
    $$hash:value [Built-in] Băm giá trị

    Dữ liệu đầu vào: value

    Kiểu dữ liệu: string

    Kết quả

    Kiểu dữ liệu: string
    Giá trị: kết quả sau khi thực hiện băm giá trị theo thuật toán băm sha256

    Tùy biến

    Có thể tùy biến hàm băm:
    • $$hash-sha256:value
    • $$hash-sha512:value
    • $$hash-sha384:value
    • $$hash-sha1:value
    • $$hash-md5:value
    • $$hash-ripemd160:value có thể không được hỗ trợ
    • $$hash-password:value là giải thuật băm mà mushroom server sử dụng để sinh ra mật khẩu
    Có thể tùy biến thêm salt: $$hash-algorithm-salt:value trong đó algorithm là tên các giải thuật ở trên, salt là giá trị salt cho hàm băm.
    $${{name}} [User-defined]

    Mô tả

    {{description}}
    Kiểu dữ liệu: {{type}}

    Authentication extension

    POST {{rootUrl}}auth/login Đăng nhập

    Dữ liệu gửi lên

    account: string, required
    password: string, required

    Dữ liệu trả lại

    Thành công:
    Http Status Code: 200
    Response body:
    {
        code: 0,
        result: {
            token: string
        }
    }

    Thất bại:
    Http Status Code: 403
    Mushroom code:
    • -1: Có lỗi nói chung (Mushroom Auth từ 1.5.0 trở về trước)
    • 37000: đăng nhập thất bại (do sai account hoặc password) (Mushroom Auth từ 1.6.0 trở lên)
      • Nếu vẫn còn login quota
        • meta.remainingCount: number là số lượng quota còn lại
      • Nếu hết login quota
        • subCode:1
        • meta.locked: true
        • meta.lockedTime: datetime
        • meta.lockedReason: string
        • meta.releaseTime: datetime
        • meta.serverTime: datatime
    • 37001: khi tài khoản bị tạm khóa (đã hết login quota) (Mushroom Auth từ 1.6.0 trở lên)
      • meta.locked: true
      • meta.lockedTime: datetime
      • meta.lockedReason: string
      • meta.releaseTime: datetime
      • meta.serverTime: datatime

    Code mẫu

    Đăng nhập
    try {
        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ập
    try
    {
        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}");
    }
    
    Đăng nhập
    POST {{rootUrlPath}}auth/login HTTP/1.1
    Host: {{domain}}
    Content-Type: application/json
    
    {
        "account": "account",
        "password": password
    }
    cURL
    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}'
      
    Đăng nhập
    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();
    }
    Đăng nhập
    /// ---------------- 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
    });
    GET {{rootUrl}}auth/logout Đăng xuất

    Query string

    • inavalidAllSession: boolean, optional, default (false) - Cho biết có logout khỏi toàn bộ các phiên làm việc khác không

    Dữ liệu trả lại

    Thành công:
    Http Status Code: 200
    Response body:
    {
        code: 0
    }

    Code mẫu

    Đăng xuất
    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ất
    var 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}");
    }
    Đă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)
    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
    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}}'
    Đăng xuất
    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();
    }
    Đăng xuất
    /// ---------------- 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
    });
    GET {{rootUrl}}auth/status Truy vấn trạng thái token

    Dữ liệu trả lại

    Http Status Code: 200
    Response body:
    {
        code: 0,
        result: {
            status: string
        }
    }
    status nhận một trong các giá trị sau:
    • logged-in - token hợp lệ (đã đăng nhập)
    • guest - token không hợp lệ hoặc chưa đăng nhập

    Code mẫu

    Kiểm tra trạng thái đăng nhập
    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ập
    try
    {
        var loginStatus = await API.Authentication.Status();
        Console.Write($"Status: {loginStatus.Status}");
    }
    catch (MushroomException ex) 
    {
        Console.Write($"Error: {ex.Message}");
    }
    Kiểm tra trạng thái đăng nhập
    GET {{rootUrlPath}}auth/status HTTP/1.1
    Host: {{domain}}
    Token: your_token (if have)
    cURL
    curl -X GET \
      '{{rootUrl}}auth/status' \
      -H 'Token: {{TOKEN}}'
    Shell
    curl --request GET \
      --url '{{rootUrl}}auth/status' \
      --header 'Token: {{TOKEN}}'
    Kiểm tra trạng thái đăng nhập
    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();
    }
    Kiểm tra trạng thái đăng nhập
    /// ---------------- 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
    });
    GET {{rootUrl}}auth/me Lấy về thông tin người dùng hiện tại

    Dữ liệu trả lại

    Người dùng đã đăng nhập
    Http Status Code: 200
    Response body:
    {
        code: 0,
        result: {
            id: string,
            account: string,
            roles: array of string,
            disabled: boolean
        }
    }

    Người dùng chưa đăng nhập
    Http Status Code: 403

    Code mẫu

    Lấy về thông tin người dùng hiện tại
    try {
        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ại
    try
    {
        var user = await API.Authentication.Me();
        Console.Write($"Info: {JsonConvert.SerializeObject(user)}");
    }
    catch (MushroomException ex) 
    {
        Console.Write($"Error: {ex.Message}");
    }
    Lấy về thông tin người dùng hiện tại
    GET {{rootUrlPath}}auth/me HTTP/1.1
    Host: {{domain}}
    Token: your_token
    cURL
    curl -X GET \
      '{{rootUrl}}auth/me' \
      -H 'Token: {{TOKEN}}'
    Shell
    curl --request GET \
      --url '{{rootUrl}}auth/me' \
      --header 'Token: {{TOKEN}}'
    Lấy về thông tin người dùng hiện tại
    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();
    }
    Lấy về thông tin người dùng hiện tại
    /// ---------------- 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
    });
    POST {{rootUrl}}auth/register Đăng ký tài khoản

    Dữ liệu gửi lên

    account: string, required
    password: string, required

    Dữ liệu trả lại

    Thành công:
    Http Status Code: 201
    Response body:
    {
        code: 0,
        result: {
            id: AutoId, 
            requireActivation: boolean
        }
    }

    Thất bại:
    Http Status Code:
    • 409 - account đã tồn tại
    • Giá trị khác - có lỗi trong quá trình đăng ký
    id là mã người dùng vừa được tạo
    requireActivation: cho biết tài khoản này có phải kích hoạt hay không

    Code mẫu

    Đăng ký tài khoản
    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ản
    try
    {
        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}");
    }
    Đăng ký tài khoản
    POST {{rootUrlPath}}auth/register HTTP/1.1
    Host: {{domain}}
    Content-Type: application/json
    
    {
        "account": "account",
        "password": password
    }
    cURL
    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}'
    Đăng ký tài khoả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();
    }
    Đăng ký tài khoản
    /// ---------------- 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
    });
    POST {{rootUrl}}auth/activate Kích hoạt tài khoản

    Dữ liệu gửi lên

    account: string, required
    code: string, required

    Dữ liệu trả lại

    Thành công:
    Http Status Code: 200
    Response body:
    {
        code: 0,
        result: {
            id: AutoId
        }
    }

    Thất bại:
    Http Status Code: 403

    Code mẫu

    Kích hoạt tài khoản
    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ản
    try
    {
        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}");
    }
    Kích hoạt tài khoản
    POST {{rootUrlPath}}auth/activate HTTP/1.1
    Host: {{domain}}
    Content-Type: application/json
    
    {
        "account": "account",
        "code": code
    }
    cURL
    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}'
    Kích hoạt tài khoả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();
    }
    Kích hoạt tài khoản
    /// ---------------- 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
    });
    POST {{rootUrl}}auth/recover-password Lấy lại mật khẩu

    Dữ liệu gửi lên

    account: string, required

    Dữ liệu trả lại

    Thành công:
    Http Status Code: 200
    Response body:
    {
        code: 0,
        result: {
            id: AutoId
        }
    }

    Thất bại:
    Http Status Code: 403

    Code mẫu

    Lấy lại mật khẩu
    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ẩu
    try
    {
        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}");
    }
    Lấy lại mật khẩu
    POST {{rootUrlPath}}auth/recover-password HTTP/1.1
    Host: {{domain}}
    Content-Type: application/json
    
    {
        "account": "account"
    }
    cURL
    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"}'
    Lấy lại mật khẩu
    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();
    }
    Lấy lại mật khẩu
    /// ---------------- 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
    });
    POST {{rootUrl}}auth/reset-password Khôi phục mật khẩu / Đổi mật khẩu

    Dữ liệu gửi lên

    account: string, required
    oldPassword: string, required if code omitted
    code: string, required if oldPassword omitted
    newPassword: string, required

    Dữ liệu trả lại

    Thành công:
    Http Status Code: 200
    Response body:
    {
        code: 0,
        result: {
            id: AutoId
        }
    }

    Thất bại:
    Http Status Code: 403
    Giải nghĩa:
    • account: tài khoản cần lấy lại mật khẩu (required)
    • oldPassword: mật khẩu hiện tại của người dùng, phải có nếu muốn đổi mật khẩu của người dùng hiện tại
    • code: mã lấy lại mật khẩu, phải có nếu muốn đổi mật khẩu thông qua lấy lại mật khẩu
    • newPassword: mật khẩu mới của người dùng (required)

    Code mẫu

    Khôi phục mật khẩu
    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ẩu
    try
    {
        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}");
    }
    Khôi phục mật khẩu
    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 - Khôi phục mật khẩu
    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}'
    Khôi phục mật khẩu
    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
    });

    File extension

    POST {{rootUrl}}file/upload Upload file

    Dữ liệu gửi lên

    Request header
    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à BINARY
    Request body
    BINARY hoặc BASE64 hoặc FORMDATA

    Dữ liệu trả lại

    Thành công:
    Http Status Code: 200
    Response body:
    {
        code: 0,
        result: AutoId
    }

    Thất bại:
    Http Status Code: 403

    Code mẫu

    Upload file
    // 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 file
    try
    {
        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}");
    }
    Upload file
    POST {{rootUrlPath}}file/upload HTTP/1.1
    Host: {{domain}}
    
    BINARY|BASE64|FORMDATA
    Upload file
    curl --request POST \
      --url '{{rootUrlPath}}auth/upload' \
      --data-binary '@Path_to_file'
    Upload 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();
    }
    Đăng nhập
    /// ---------------- 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
    });
    GET {{rootUrl}}file/download Download file

    Query string

    • id: string, required - Mã của file cần download
    • inline: boolean, optional - Cho biết có download ở chế độ inline hay không. Xem thêm tại Content-Disposition

    Byte serving

    Hỗ trợ download một phần nội dung của file (hỗ trợ pause, resume download) bằng cách truyền lên thông số range qua request header:
    Range: string, optional, là định nghĩa khoảng dữ liệu mong muốn nhận được
    Xem thêm tại Range header document

    Khi có thông số Range, response có định dạng sau:
    Trường hợp có lỗi:
    Http status code: 416 - header Range không đúng định dạng hoặc overflow hoặc underflow

    Thành công:
    Http status code: 206
    Response header:
    Content-Type: {fileContentType}
    Content-Disposition: attachment; filename="{fileName}"
    Accept-Range: bytes
    Content-Length: {length of response data}
    Content-Range: byte {realStartIndex}-{realEndIndex}/{totalLength}
    

    Response body:
    BINARY

    Mẫu javascript

    Lấy về link download file
    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");
    GET {{rootUrl}}file/thumb Download image thumbnail

    Query string

    • id: string, required - Mã của file ảnh cần tạo thumb
    • r: string, optional, chỉ định các thực sinh ảnh, nhận một trong các giá trị sau:
      • stretch: ảnh thumb sinh ra bằng cách co giãn về kích thước (w)x(h) pixel
      • square: ảnh thumb vuông, kích thước (w)x(w) pixel
      • zoom: ảnh thumb sinh ra giữ đúng tỉ lệ với ảnh gốc và nằm trọn trong ảnh (w)x(h) pixel, nhưng phần ảnh bị trống được tô bởi màu (b)
      • x: ảnh thumb sinh ra giữ đúng tỉ lệ với ảnh gốc và có chiều rộng bằng (w)
      • y: ảnh thumb sinh ra giữ đúng tỉ lệ với ảnh gốc và có chiều cao bằng (h)
      • clip: ảnh thumb sinh ra bằng cách cắt bỏ phần thừa để chi tiết ảnh không bị co giản và có kích thước (w)x(h) pixel
      • Nếu không có giá trị:
        • Nếu có w, h: mặc định nhận giá trị stretch
        • Nếu không có w, h: trả về ảnh gốc
    • w: number, optional nếu r không nhận giá trị hoặc bằng y, trái lại required, là độ rộng của ảnh thumb (theo pixel)
    • h: number, optional nếu r không nhận giá trị hoặc bằng square, x, trái lại required, là độ cao của ảnh thumb (theo pixel)
    • va: string, optional, chỉ có ý nghĩa khi r=clip, mặc định: middle, nhận một trong các giá trị sau:
      • top: nếu bị cắt theo chiều ngang thì phần bị cắt sẽ là phần ảnh bên dưới
      • middle: nếu bị cắt theo chiều ngang thì phần bị cắt chia đều trên và dưới
      • bottom: nếu bị cắt theo chiều ngang thì phần bị cắt sẽ là phần ảnh bên trên
    • ha: string, optional, chỉ có ý nghĩa khi r=clip, mặc định: center, nhận một trong các giá trị sau:
      • left: nếu bị cắt theo chiều dọc thì phần bị cắt sẽ là phần ảnh bên phải
      • center: nếu bị cắt theo chiều dọc thì phần bị cắt chia đều trái và phải
      • right: nếu bị cắt theo chiều dọc thì phần bị cắt sẽ là phần ảnh bên trái
    • b: string, optional, chỉ có ý nghĩa khi r=zoom, default: transparent, là mã màu của phần ảnh bị trống, nhận giá trị:
      • transparent
      • [0-9a-fA-F]{6}
    • f: string, optional, mặc định là source, nhận các giá trị sau:
      • source: định dạng trả về giữ nguyên so với nguồn
      • jpg: định dạng ảnh trả về là jpeg
      • png: định dạng ảnh trả về là png
      • gif: định dạng ảnh trả về là gif
      • webp: định dạng ảnh trả về là webp
      • auto: tự động nhận diện định dạng dữ liệu trả về
    • e: string, optional, chỉ định các hiệu ứng xử lý ảnh, nhận một trong các giá trị sau và có thể áp dụng nhiều hiệu ứng, phân cách nhau bằng dấu phảy
      • grayscale - tạo ảnh đen trắng
      • transparent:value - tạo ảnh trong suốt với value là mức độ trong suốt, nhận giá trị từ 0 tới 255
      • flip-horizontal - flip ảnh theo chiều ngang
      • flip-vertical - flip theo chiều dọc
      • rotate90 - xoay ảnh 90 độ
      • rotate180 - xoay ảnh 180 độ
      • rotate270 - xoay ảnh 270 độ
    • o: string, optional, chỉ định các tùy chọn, nhận một trong các giá trị sau, có thể áp dụng nhiều tùy chọn, phân cách nhau bởi dấu phải
      • allow-smaller-size - cho phép sinh ảnh bé hơn kích thước quy định nếu ảnh gốc bé
      • disable-cache - không sử dụng cache server mà yêu cầu sinh ảnh thumb mới

    Dữ liệu trả về

    Response header:
    Content-Type: image/{type}
    Last-Modified: {datetime}

    Response body:
    BINARY

    Code mẫu

    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();
    GET {{rootUrl}}file/zip Download zip file

    Query string

    • id: string, required, danh sách mã các file cần zip, các mã file được phân cách bởi dấu phảy (,)
    • name: string, optional, tên file zip khi download. Mặc định là "No name.zip"
    • inline: boolean, optional - Cho biết có download ở chế độ inline hay không. Xem thêm tại Content-Disposition

    Dữ liệu trả về

    Response header:
    Content-Type: application/zip
    Content-Disposition: attachment; filename="{name}"

    Response body:
    BINARY

    Mẫu javascript

    Lấy về link download zip file
    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");

    Mailing extension

    POST {{rootUrl}}mailing/sent Tạo lệnh gửi mail

    Dữ liệu gửi lên

    Request body
    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
    
    Trong đó:
    • from: optional, người gửi, nếu không có giá trị sẽ lấy bằng giá trị mặc định của service gửi mail
    • from.name: optional, tên người gửi, nếu không có giá trị sẽ lấy bằng from.email
    • from.email: required, email người gửi
    • replyTo: optional, người nhận phản hồi khi reply
    • replyTo.name: optional, tên người nhận phản hồi khi reply, nếu không có giá trị sẽ lấy bằng replyTo.email
    • replyTo.email: required, email người nhận phản hồi khi reply
    • to: optional, người nhận, không cho phép giá trị null trong mảng
    • to.name: optional, tên người nhận, nếu không có giá trị sẽ lấy bằng to.email
    • to.email: required, email người nhận
    • cc: optional, người nhận cc, không cho phép giá trị null trong mảng
    • cc.name: optional, tên người nhận cc, nếu không có giá trị sẽ lấy bằng cc.email
    • cc.email: required, email người nhận cc
    • bcc: optional, người nhận bcc, không cho phép giá trị null trong mảng
    • bcc.name: optional, tên người nhận bcc, nếu không có giá trị sẽ lấy bằng bcc.email
    • bcc.email: required, email người nhận bcc
    • to, cc, bcc: phải tồn tại ít nhất một email (không chấp nhận cả 3 optional)
    • attachments: optional, danh sách các file đính kèm, là các file id (xem thêm extension File)
    • subject: required, tiêu đề mail
    • content: requried, nội dung email
    • isHtml: optional, cho biết content định dạng html hay plain-text, mặc định là false (plain-text)
    • tag: optional, tag tùy biến của email
    • schedule: optional, lịch email sẽ được gửi đi

    Dữ liệu trả lại

    Http Status Code: 200
    Response body:
    {
        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
        }
    }

    Code mẫu

    Lấy về mail đã gửi
    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);
    }
    GET {{rootUrl}}mailing/get Lấy thông tin lệnh gửi mail

    Query string

    • token: string, required - Token của lệnh gửi mail

    Dữ liệu trả lại

    Http Status Code: 200
    Response body:
    {
        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
        }
    }

    Code mẫu

    Gửi mail
    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);
    }
    DELETE {{rootUrl}}mailing/discard Hủy lệnh gửi mail

    Query string

    • token: string, required - Token của lệnh gửi mail

    Dữ liệu trả về

    Response body:
    {
        code: 0,
        result: boolean                        
    }
    Kết quả trả về là true nếu việc hủy thành công. Trả về false nếu việc hủy thất bại (chẳng hạn: mail đã được gửi đi)

    Code mẫu

    Hủy mail
    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);
    }

    driver

    CSharp
    Sử dụng NUGET tại đây
    Java
    Sử dụng Maven tại đây (coming soon)
    Sử dụng Gradle tại đây (coming soon)

    {{name}}
    {{description}}

    {{description}}
    {{actionHttpMethod}} {{actionApiUrl}} {{actionDescription}}
  • {{explainedRole}}
  • Code mẫu

    {{codeSnippetTabPages:html}}
    Javascript UNDEFINED model
    {{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ản
    try
    {
        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}");
    }
    Đơn giản
    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);
    }
    Javascript UNDEFINED model
    {{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ản
    try
    {
        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}");
    }
    Đơn giản
    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();
    }
    Đơn giản
    /// ---------------- 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());
    });
    Tạo mới một {{entityName}}
    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);
    }
    Javascript UNDEFINED model
    {{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}");
    }
    Tạo mới một {{entityName}}
    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();
    }
    Tạo mới một {{entityName}}
    /// ---------------- 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
    });
    Tạo mới hàng loạt {{entityName}}
    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);
    }
    Javascript UNDEFINED model
    {{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}");
    }
    Tạo mới hàng loạt {{entityName}}
    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();
    }
    Tạo mới một {{entityName}}
    /// ---------------- 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
    });
    Cập nhật một {{entityName}}
    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);
    }
    
    Javascript UNDEFINED model
    {{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}");
    }
    Cập nhật một {{entityName}}
    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();
    }
    Tạo mới một {{entityName}}
    /// ---------------- 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
    });
    Cập nhật hàng loạt {{entityName}}
    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);
    }
    Javascript UNDEFINED model
    {{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}");
    }
    Cập nhật hàng loạt {{entityName}}
    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();
    }
    Cập nhật hàng loạt {{entityName}}
    /// ---------------- 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
    });
    Cập nhật một phần {{entityName}}
    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);
    }
    Javascript UNDEFINED model
    {{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}");
    }
    Cập nhật một {{entityName}}
    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();
    }
    Tạo mới một {{entityName}}
    /// ---------------- 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
    });
    Xóa một {{entityName}}
    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}");
    }
    Xóa một {{entityName}}
    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();
    }
    Xóa một {{entityName}}
    /// ---------------- 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
    });
    Xóa hàng loại hàng loạt {{entityName}}
    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}");
    }
    Xóa hàng loạt {{entityName}}
    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();
    }
    Xóa hàng loạt {{entityName}}
    /// ---------------- 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}");
    }
    Code tham khảo:
    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();
    }
    Code tham khảo:
    /// ---------------- 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
    });
    Code tham khảo:
    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);
    }
    Javascript UNDEFINED model
    {{undefinedModel:html}}
    Javascript VALUE model
    {{valueModel:html}}
    Javascript NULL model
    {{nullModel:html}}
    Code tham khảo:
    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();
    }
    Code tham khảo:
    /// ---------------- 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
    });
  • Cho phép tìm kiếm theo kênh {{name}} trên (các) trường: {{htmlFields:html}}
  • {{field}}: {{sortType}}
  • Phân trang dữ liệu

    Kiểu phân trang: {{strPagingType}}
    Số lượng {{entityName}} mặc định trả về trong 1 trang: {{maxRecordCount}}
    limit có thể nhận giá trị tối đa: {{maxPageSize}}
    Có trả về thông tin tổng số lượng bản ghi thỏa mãn
    {
        "meta": {
            "total": Tổng số bản ghi thỏa mãn
        }
    }

    Cache

    Server: {{serverPolicy}}
    Client: {{clientPolicy}}

    Phân quyền

    Từ chối truy cập khi quyền người dùng thỏa điều kiện: {{explainedDenyRoles}}

    Phân quyền dữ liệu

    Chỉ trả về các {{entityName}} thỏa mãn các điều kiện sau:

    Dữ liệu trả về

    Trường hợp không có $fields, kết quả trả về có dạng:
    
            Trường hợp $fields=, kết quả trả về có dạng:
            
        
            

    Lọc dữ liệu

    Trường hợp không gửi lên điều kiện lọc nào thì sẽ áp dụng các điều kiện lọc sau:
      Cho phép lọc theo các trường:
      Cho phép tìm kiếm tiếng Việt không dấu, không phân biệt hoa thường trên (các) trường:
        Bắt buộc phải lọc theo các trường:

        Sắp xếp dữ liệu

        Cho phép sắp xếp theo các trường:

          Mặc định sắp xếp theo các trường (không có $sort):

            Thông tin thêm

            {{description}}

            Phân quyền

            Từ chối truy cập khi quyền người dùng thỏa điều kiện: {{explainedDenyRoles}}

            Phân quyền dữ liệu

            Chỉ trả về {{entityName}} nếu thỏa mãn các điều kiện sau:

            Dữ liệu trả về

            Trường hợp không có $fields, kết quả trả về có dạng:
            
                    Trường hợp $fields=, kết quả trả về có dạng:
                    
            
                

            Thông tin thêm

            {{description}}

            Phân quyền

            Từ chối truy cập khi quyền người dùng thỏa điều kiện: {{explainedDenyRoles}}

            Phân quyền dữ liệu

            Chỉ tạo thành công nếu sau khi tạo, dữ liệu thỏa mãn các điều kiện sau:

            Dữ liệu gửi lên

            
                

            Dữ liệu trả lại

            Http Status Code: 201 Created
            Http Headers: Response body:
            {
                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

            Thông tin thêm

            {{description}}

            Phân quyền

            Từ chối truy cập khi quyền người dùng thỏa điều kiện: {{explainedDenyRoles}}

            Phân quyền dữ liệu

            Chỉ tạo thành công nếu sau khi tạo, dữ liệu thỏa mãn các điều kiện sau:

            Header

            X-Mushroom-Create-Many: true

            Dữ liệu gửi lên: Mảng của các đối tượng

            
                

            Dữ liệu trả lại

            Response body:
            {
                code: 0,
                result: [Mảng các Id của các tài nguyên vừa tạo]
            }

            Thông tin thêm

            {{description}}

            Phân quyền

            Từ chối truy cập khi quyền người dùng thỏa điều kiện: {{explainedDenyRoles}}

            Phân quyền dữ liệu

            Chỉ thực hiện cập nhật {{entityName}} nếu thỏa mãn các điều kiện sau:

            Dữ liệu gửi lên:

            
                

            Dữ liệu trả lại

            Response body:
            {
                code: 0,
                result: Id của tài nguyên vừa được cập nhật
            }

            Thông tin thêm

            {{description}}

            Phân quyền

            Từ chối truy cập khi quyền người dùng thỏa điều kiện: {{explainedDenyRoles}}

            Phân quyền dữ liệu

            Chỉ thực hiện cập nhật {{entityName}} nếu thỏa mãn các điều kiện sau:

            Dữ liệu gửi lên: Mảng của các đối tượng

            
                

            Dữ liệu trả lại

            Response body:
            {
                    code: 0,
                result: [Mảng các Id của các tài nguyên vừa được cập nhật]
            }

            Thông tin thêm

            {{description}}

            Phân quyền

            Từ chối truy cập khi quyền người dùng thỏa điều kiện: {{explainedDenyRoles}}

            Phân quyền dữ liệu

            Chỉ thực hiện cập nhật {{entityName}} nếu thỏa mãn các điều kiện sau:

            Dữ liệu gửi lên:

            
                    Lưu ý:
                    
                

            Dữ liệu trả lại

            Response body:
            {
                code: 0,
                result: Id của tài nguyên vừa được cập nhật
            }

            Thông tin thêm

            {{description}}

            Phân quyền

            Từ chối truy cập khi quyền người dùng thỏa điều kiện: {{explainedDenyRoles}}

            Phân quyền dữ liệu

            Chỉ thực hiện xóa {{entityName}} nếu thỏa mãn các điều kiện sau:

            Dữ liệu trả lại

            Response body:
            {
                code: 0,
                result: number (0 | 1) // Số lượng bản ghi bị xóa
            }

            Thông tin thêm

            {{description}}

            Phân quyền

            Từ chối truy cập khi quyền người dùng thỏa điều kiện: {{explainedDenyRoles}}

            Phân quyền dữ liệu

            Chỉ thực hiện xóa {{entityName}} nếu thỏa mãn các điều kiện sau:

            Dữ liệu gửi lên:

            ["Mảng các Id cần xóa"]

            Dữ liệu trả lại

            Response body:
            {
                code: 0,
                result: number: Số lượng bản ghi bị xóa
            }

            Thông tin thêm

            {{description}}

            Phân quyền

            Từ chối truy cập khi quyền người dùng thỏa điều kiện: {{explainedDenyRoles}}

            Thông tin thêm

            {{description}}

            Query string

            Request body

            
                

            Response body

            
                
            GET {{actionApiUrl}} {{description}}
          • {{explainedRole}}
          • {{field}}: {{type}}, {{required}}{{defaultValue}}{{validation}}, {{description}}
          • Mô tả

            {{description}}

            Phân quyền

            Từ chối truy cập khi quyền người dùng thỏa điều kiện: {{explainedDenyRoles}}

            Query string

            Dữ liệu trả về

            Mảng các object:
            {{outputModel:html}}
            Nếu không có phần tử nào, mảng giá trị sau sẽ được trả về:
            {{outputEmptyResult}}

            Code mẫu

            {{codeSnippetTabPages:html}}