diff --git a/HISTORY.rst b/HISTORY.rst index d27943758..d2c3f2d49 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -15,6 +15,10 @@ Release History - ``client.get_memberships(...)`` has a change in signature. The limit and offset parameters have swapped positions to keep consistency with the rest of the SDK. - ``client.groups(...)`` has been changed to ``client.get_groups``. The limit and offset parameters have swapped positions. +- The ``unshared_at`` parameter for ``item.create_shared_link(...)`` and ``file.get_shared_link_download_url(...)`` + now takes an `RFC3339-formatted ` ``unicode`` string instead of a + ``datetime.date``. Users migrating from v1.x can pass the value of ``date.isoformat()`` instead of the ``date`` + object itself. - ``Events.get_events(...)`` now returns a list of ``Event`` instances rather than a list of ``dict`` representing events. ``Event`` inherits from ``Mapping`` but will not have all the same capabilities as ``dict``. diff --git a/boxsdk/object/file.py b/boxsdk/object/file.py index a76fa0d13..6a07d5fe4 100644 --- a/boxsdk/object/file.py +++ b/boxsdk/object/file.py @@ -259,9 +259,11 @@ def get_shared_link_download_url( `unicode` or None :param unshared_at: The date on which this link should be disabled. May only be set if the current user is not a free user - and has permission to set expiration dates. + and has permission to set expiration dates. Takes an RFC3339-formatted string, e.g. + '2018-10-31T23:59:59-07:00' for 11:59:59 PM on October 31, 2018 in the America/Los_Angeles timezone. + The time portion can be omitted, which defaults to midnight (00:00:00) on that date. :type unshared_at: - :class:`datetime.date` or None + `unicode` or None :param allow_preview: Whether or not the item being shared can be previewed when accessed via the shared link. If this parameter is None, the default setting will be used. diff --git a/boxsdk/object/item.py b/boxsdk/object/item.py index f2fb24ea0..08ad8b60f 100644 --- a/boxsdk/object/item.py +++ b/boxsdk/object/item.py @@ -193,9 +193,11 @@ def create_shared_link( `unicode` or None :param unshared_at: The date on which this link should be disabled. May only be set if the current user is not a free user - and has permission to set expiration dates. + and has permission to set expiration dates. Takes an RFC3339-formatted string, e.g. + '2018-10-31T23:59:59-07:00' for 11:59:59 PM on October 31, 2018 in the America/Los_Angeles timezone. + The time portion can be omitted, which defaults to midnight (00:00:00) on that date. :type unshared_at: - :class:`datetime.date` or None + `unicode` or None :param allow_download: Whether or not the item being shared can be downloaded when accessed via the shared link. If this parameter is None, the default setting will be used. @@ -225,7 +227,7 @@ def create_shared_link( } if unshared_at is not None: - data['shared_link']['unshared_at'] = unshared_at.isoformat() + data['shared_link']['unshared_at'] = unshared_at if allow_download is not None or allow_preview is not None: data['shared_link']['permissions'] = permissions = {} diff --git a/test/unit/object/conftest.py b/test/unit/object/conftest.py index 6625efaf8..9d795946a 100644 --- a/test/unit/object/conftest.py +++ b/test/unit/object/conftest.py @@ -1,7 +1,6 @@ # coding: utf-8 from __future__ import unicode_literals -from datetime import date import os from mock import Mock import pytest @@ -325,7 +324,7 @@ def shared_link_password(request): return request.param -@pytest.fixture(params=(date(2015, 5, 5), None)) +@pytest.fixture(params=('2018-10-31', '2018-10-31T23:59:59-07:00', None)) def shared_link_unshared_at(request): return request.param diff --git a/test/unit/object/test_file.py b/test/unit/object/test_file.py index 8c93f3f81..068ffb6e1 100644 --- a/test/unit/object/test_file.py +++ b/test/unit/object/test_file.py @@ -316,7 +316,7 @@ def test_get_shared_link_download_url( if shared_link_access is not None: expected_data['shared_link']['access'] = shared_link_access if shared_link_unshared_at is not None: - expected_data['shared_link']['unshared_at'] = shared_link_unshared_at.isoformat() + expected_data['shared_link']['unshared_at'] = shared_link_unshared_at if shared_link_can_preview is not None: expected_data['shared_link']['permissions'] = permissions = {} permissions['can_preview'] = shared_link_can_preview diff --git a/test/unit/object/test_item.py b/test/unit/object/test_item.py index e577980a4..8fa248389 100644 --- a/test/unit/object/test_item.py +++ b/test/unit/object/test_item.py @@ -125,7 +125,7 @@ def test_get_shared_link( if shared_link_access is not None: expected_data['shared_link']['access'] = shared_link_access if shared_link_unshared_at is not None: - expected_data['shared_link']['unshared_at'] = shared_link_unshared_at.isoformat() + expected_data['shared_link']['unshared_at'] = shared_link_unshared_at if shared_link_can_download is not None or shared_link_can_preview is not None: expected_data['shared_link']['permissions'] = permissions = {} if shared_link_can_download is not None: