Repository: box/box-python-sdk
Pull request #358 (2018-10-26 21:47:23)

Use RFC3339 string for datetime params

boxcla: Verified that @mattwiller has signed the CLA. Thanks for the pull request!
coveralls: ## Pull Request Test Coverage Report for [Build 1237](https://coveralls.io/builds/19751703)

* **1** of **1**   **(100.0%)**  changed or added relevant line in **1** file are covered.
* No unchanged relevant lines lost coverage.
* Overall coverage remained the same at **95.368%**

---



|  Totals | [![Coverage Status](https://coveralls.io/builds/19751703/badge)](https://coveralls.io/builds/19751703) |
| :-- | --: |
| Change from base [Build 1230](https://coveralls.io/builds/19750723): |  0.0% |
| Covered Lines: | 2244 |
| Relevant Lines: | 2353 |

---
##### 💛  - [Coveralls](https://coveralls.io)


Patch:
diff --git a/HISTORY.rst b/HISTORY.rst
index d279437..d2c3f2d 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 <https://tools.ietf.org/html/rfc3339#section-5.8>` ``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 a76fa0d..6a07d5f 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 f2fb24e..08ad8b6 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 = {}


Test patch:
diff --git a/test/unit/object/conftest.py b/test/unit/object/conftest.py
index 6625efa..9d79594 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 8c93f3f..068ffb6 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 e577980..8fa2483 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: