Search in sources :

Example 1 with BoxSharedLink

use of com.box.androidsdk.content.models.BoxSharedLink in project box-android-sdk by box.

the class BoxRequestUpdateSharedItem method setUnsharedAt.

/**
 * Sets the date that this shared link will be deactivated. If this is set to null it will remove the
 * unshared at date that is set on this item.
 * Note: the date will be rounded to the day as the API does not support hours, minutes, or seconds
 *
 * @param unsharedAt the date that this shared link will be deactivated.
 * @return  the updated request
 * @throws ParseException thrown if date provided cannot be properly parsed.
 */
public R setUnsharedAt(Date unsharedAt) throws ParseException {
    JsonObject jsonObject = getSharedLinkJsonObject();
    if (unsharedAt == null) {
        jsonObject.add(BoxSharedLink.FIELD_UNSHARED_AT, JsonValue.NULL);
    } else {
        jsonObject.add(BoxSharedLink.FIELD_UNSHARED_AT, BoxDateFormat.format(unsharedAt));
    }
    BoxSharedLink sharedLink = new BoxSharedLink(jsonObject);
    mBodyMap.put(BoxItem.FIELD_SHARED_LINK, sharedLink);
    return (R) this;
}
Also used : JsonObject(com.eclipsesource.json.JsonObject) BoxSharedLink(com.box.androidsdk.content.models.BoxSharedLink)

Example 2 with BoxSharedLink

use of com.box.androidsdk.content.models.BoxSharedLink in project box-android-sdk by box.

the class BoxRequestUpdateSharedItem method setAccess.

/**
 * Sets the shared link access for the item in the request.
 *
 * @param access    new shared link access for the item.
 * @return  request with the updated shared link access.
 */
public R setAccess(BoxSharedLink.Access access) {
    JsonObject jsonObject = getSharedLinkJsonObject();
    jsonObject.add(BoxSharedLink.FIELD_ACCESS, SdkUtils.getAsStringSafely(access));
    BoxSharedLink sharedLink = new BoxSharedLink(jsonObject);
    mBodyMap.put(BoxItem.FIELD_SHARED_LINK, sharedLink);
    return (R) this;
}
Also used : JsonObject(com.eclipsesource.json.JsonObject) BoxSharedLink(com.box.androidsdk.content.models.BoxSharedLink)

Example 3 with BoxSharedLink

use of com.box.androidsdk.content.models.BoxSharedLink in project box-android-sdk by box.

the class BoxRequestUpdateSharedItem method setPassword.

/**
 * Sets the shared link password in the request.
 *
 * @param password  new password for the shared link, or null to remove the password.
 * @return  request with the updated shared link password.
 */
public R setPassword(final String password) {
    JsonObject jsonObject = getSharedLinkJsonObject();
    jsonObject.add(BoxSharedLink.FIELD_PASSWORD, password);
    BoxSharedLink sharedLink = new BoxSharedLink(jsonObject);
    mBodyMap.put(BoxItem.FIELD_SHARED_LINK, sharedLink);
    return (R) this;
}
Also used : JsonObject(com.eclipsesource.json.JsonObject) BoxSharedLink(com.box.androidsdk.content.models.BoxSharedLink)

Example 4 with BoxSharedLink

use of com.box.androidsdk.content.models.BoxSharedLink in project box-android-sdk by box.

the class BoxRequestUpdateSharedItem method setCanDownload.

/**
 * Sets whether the shared link allows downloads in the request.
 *
 * @param canDownload   new value for whether the shared link allows downloads.
 * @return  request with the updated value for whether the shared link allows downloads.
 */
protected R setCanDownload(boolean canDownload) {
    JsonObject jsonPermissionsObject = getPermissionsJsonObject();
    jsonPermissionsObject.add(BoxSharedLink.Permissions.FIELD_CAN_DOWNLOAD, canDownload);
    BoxSharedLink.Permissions permissions = new BoxSharedLink.Permissions(jsonPermissionsObject);
    JsonObject sharedLinkJsonObject = getSharedLinkJsonObject();
    sharedLinkJsonObject.add(BoxSharedLink.FIELD_PERMISSIONS, permissions.toJsonObject());
    BoxSharedLink sharedLink = new BoxSharedLink(sharedLinkJsonObject);
    mBodyMap.put(BoxItem.FIELD_SHARED_LINK, sharedLink);
    return (R) this;
}
Also used : JsonObject(com.eclipsesource.json.JsonObject) BoxSharedLink(com.box.androidsdk.content.models.BoxSharedLink)

Aggregations

BoxSharedLink (com.box.androidsdk.content.models.BoxSharedLink)4 JsonObject (com.eclipsesource.json.JsonObject)4