[med-svn] [Git][med-team/python-fitbit][upstream] New upstream version 0.3.1

Dylan Aïssi gitlab at salsa.debian.org
Fri Jul 12 18:11:36 BST 2019



Dylan Aïssi pushed to branch upstream at Debian Med / python-fitbit


Commits:
bcdce147 by Dylan Aïssi at 2019-07-12T17:10:13Z
New upstream version 0.3.1
- - - - -


8 changed files:

- .travis.yml
- CHANGELOG.rst
- README.rst
- docs/index.rst
- fitbit/__init__.py
- fitbit/api.py
- setup.py
- tox.ini


Changes:

=====================================
.travis.yml
=====================================
@@ -1,15 +1,12 @@
 language: python
-python: 3.5
-env:
-  # Avoid testing pypy on travis until the following issue is fixed:
-  #   https://github.com/travis-ci/travis-ci/issues/4756
-  #- TOX_ENV=pypy
-  - TOX_ENV=py35
-  - TOX_ENV=py34
-  - TOX_ENV=py33
-  - TOX_ENV=py27
-  - TOX_ENV=docs
+python:
+  - pypy
+  - pypy3.5
+  - 2.7
+  - 3.4
+  - 3.5
+  - 3.6
 install:
-  - pip install coveralls tox
-script: tox -e  $TOX_ENV
+  - pip install coveralls tox-travis
+script: tox
 after_success: coveralls


=====================================
CHANGELOG.rst
=====================================
@@ -1,3 +1,12 @@
+0.3.1 (2019-05-24)
+==================
+* Fix auth with newer versions of OAuth libraries while retaining backward compatibility
+
+0.3.0 (2017-01-24)
+==================
+* Surface errors better
+* Use requests-oauthlib auto refresh to automatically refresh tokens if possible
+
 0.2.4 (2016-11-10)
 ==================
 * Call a hook if it exists when tokens are refreshed


=====================================
README.rst
=====================================
@@ -10,6 +10,9 @@ python-fitbit
 .. image:: https://requires.io/github/orcasgit/python-fitbit/requirements.png?branch=master
    :target: https://requires.io/github/orcasgit/python-fitbit/requirements/?branch=master
    :alt: Requirements Status
+.. image:: https://badges.gitter.im/orcasgit/python-fitbit.png
+   :target: https://gitter.im/orcasgit/python-fitbit
+   :alt: Gitter chat
 
 Fitbit API Python Client Implementation
 


=====================================
docs/index.rst
=====================================
@@ -40,9 +40,90 @@ either ``None`` or a ``date`` or ``datetime`` object
 as ``%Y-%m-%d``.
 
 .. autoclass:: fitbit.Fitbit
-    :private-members:
     :members:
 
+    .. method:: body(date=None, user_id=None, data=None)
+
+       Get body data: https://dev.fitbit.com/docs/body/
+
+    .. method:: activities(date=None, user_id=None, data=None)
+
+       Get body data: https://dev.fitbit.com/docs/activity/
+
+    .. method:: foods_log(date=None, user_id=None, data=None)
+
+       Get food logs data: https://dev.fitbit.com/docs/food-logging/#get-food-logs
+
+    .. method:: foods_log_water(date=None, user_id=None, data=None)
+
+       Get water logs data: https://dev.fitbit.com/docs/food-logging/#get-water-logs
+
+    .. method:: sleep(date=None, user_id=None, data=None)
+
+       Get sleep data: https://dev.fitbit.com/docs/sleep/
+
+    .. method:: heart(date=None, user_id=None, data=None)
+
+       Get heart rate data: https://dev.fitbit.com/docs/heart-rate/
+
+    .. method:: bp(date=None, user_id=None, data=None)
+
+       Get blood pressure data: https://dev.fitbit.com/docs/heart-rate/
+
+    .. method:: delete_body(log_id)
+
+       Delete a body log, given a log id
+
+    .. method:: delete_activities(log_id)
+
+       Delete an activity log, given a log id
+
+    .. method:: delete_foods_log(log_id)
+
+       Delete a food log, given a log id
+
+    .. method:: delete_foods_log_water(log_id)
+
+       Delete a water log, given a log id
+
+    .. method:: delete_sleep(log_id)
+
+       Delete a sleep log, given a log id
+
+    .. method:: delete_heart(log_id)
+
+       Delete a heart log, given a log id
+
+    .. method:: delete_bp(log_id)
+
+       Delete a blood pressure log, given a log id
+
+    .. method:: recent_foods(user_id=None, qualifier='')
+
+       Get recently logged foods: https://dev.fitbit.com/docs/food-logging/#get-recent-foods
+
+    .. method:: frequent_foods(user_id=None, qualifier='')
+
+       Get frequently logged foods: https://dev.fitbit.com/docs/food-logging/#get-frequent-foods
+
+    .. method:: favorite_foods(user_id=None, qualifier='')
+
+       Get favorited foods: https://dev.fitbit.com/docs/food-logging/#get-favorite-foods
+
+    .. method:: recent_activities(user_id=None, qualifier='')
+
+       Get recently logged activities: https://dev.fitbit.com/docs/activity/#get-recent-activity-types
+
+    .. method:: frequent_activities(user_id=None, qualifier='')
+
+       Get frequently logged activities: https://dev.fitbit.com/docs/activity/#get-frequent-activities
+
+    .. method:: favorite_activities(user_id=None, qualifier='')
+
+       Get favorited foods: https://dev.fitbit.com/docs/activity/#get-favorite-activities
+
+
+
 Indices and tables
 ==================
 


=====================================
fitbit/__init__.py
=====================================
@@ -3,7 +3,7 @@
 Fitbit API Library
 ------------------
 
-:copyright: 2012-2017 ORCAS.
+:copyright: 2012-2019 ORCAS.
 :license: BSD, see LICENSE for more details.
 """
 
@@ -17,8 +17,8 @@ __author_email__ = 'bpitcher at orcasinc.com'
 __copyright__ = 'Copyright 2012-2017 ORCAS'
 __license__ = 'Apache 2.0'
 
-__version__ = '0.3.0'
-__release__ = '0.3.0'
+__version__ = '0.3.1'
+__release__ = '0.3.1'
 
 # Module namespace.
 


=====================================
fitbit/api.py
=====================================
@@ -106,7 +106,7 @@ class FitbitOauth2Client(object):
         URL, open their browser to it, or tell them to copy the URL into their
         browser.
             - scope: pemissions that that are being requested [default ask all]
-            - redirect_uri: url to which the reponse will posted. required here
+            - redirect_uri: url to which the response will posted. required here
               unless you specify only one Callback URL on the fitbit app or
               you already passed it to the constructor
             for more info see https://dev.fitbit.com/docs/oauth2/
@@ -143,6 +143,7 @@ class FitbitOauth2Client(object):
             self.access_token_url,
             username=self.client_id,
             password=self.client_secret,
+            client_secret=self.client_secret,
             code=code)
 
     def refresh_token(self):
@@ -162,6 +163,27 @@ class FitbitOauth2Client(object):
 
 
 class Fitbit(object):
+    """
+    Before using this class, create a Fitbit app
+    `here <https://dev.fitbit.com/apps/new>`_. There you will get the client id
+    and secret needed to instantiate this class. When first authorizing a user,
+    make sure to pass the `redirect_uri` keyword arg so fitbit will know where
+    to return to when the authorization is complete. See
+    `gather_keys_oauth2.py <https://github.com/orcasgit/python-fitbit/blob/master/gather_keys_oauth2.py>`_
+    for a reference implementation of the authorization process. You should
+    save ``access_token``, ``refresh_token``, and ``expires_at`` from the
+    returned token for each user you authorize.
+
+    When instantiating this class for use with an already authorized user, pass
+    in the ``access_token``, ``refresh_token``, and ``expires_at`` keyword
+    arguments. We also strongly recommend passing in a ``refresh_cb`` keyword
+    argument, which should be a function taking one argument: a token dict.
+    When that argument is present, we will automatically refresh the access
+    token when needed and call this function so that you can save the updated
+    token data. If you don't save the updated information, then you could end
+    up with invalid access and refresh tokens, and the only way to recover from
+    that is to reauthorize the user.
+    """
     US = 'en_US'
     METRIC = 'en_UK'
 
@@ -187,12 +209,23 @@ class Fitbit(object):
         'frequent',
     ]
 
-    def __init__(self, client_id, client_secret, system=US, **kwargs):
+    def __init__(self, client_id, client_secret, access_token=None,
+            refresh_token=None, expires_at=None, refresh_cb=None,
+            redirect_uri=None, system=US, **kwargs):
         """
         Fitbit(<id>, <secret>, access_token=<token>, refresh_token=<token>)
         """
         self.system = system
-        self.client = FitbitOauth2Client(client_id, client_secret, **kwargs)
+        self.client = FitbitOauth2Client(
+            client_id,
+            client_secret,
+            access_token=access_token,
+            refresh_token=refresh_token,
+            expires_at=expires_at,
+            refresh_cb=refresh_cb,
+            redirect_uri=redirect_uri,
+            **kwargs
+        )
 
         # All of these use the same patterns, define the method for accessing
         # creating and deleting records once, and use curry to make individual


=====================================
setup.py
=====================================
@@ -35,9 +35,9 @@ setup(
         'Programming Language :: Python',
         'Programming Language :: Python :: 2.7',
         'Programming Language :: Python :: 3',
-        'Programming Language :: Python :: 3.3',
         'Programming Language :: Python :: 3.4',
         'Programming Language :: Python :: 3.5',
+        'Programming Language :: Python :: 3.6',
         'Programming Language :: Python :: Implementation :: PyPy'
     ),
 )


=====================================
tox.ini
=====================================
@@ -1,25 +1,8 @@
 [tox]
-envlist = pypy,py35,py34,py33,py27,docs
+envlist = pypy-test,pypy3-test,py36-test,py35-test,py34-test,py27-test,py36-docs
 
 [testenv]
-commands = coverage run --source=fitbit setup.py test
+commands =
+  test: coverage run --source=fitbit setup.py test
+  docs: sphinx-build -W -b html docs docs/_build
 deps = -r{toxinidir}/requirements/test.txt
-
-[testenv:pypy]
-basepython = pypy
-
-[testenv:py35]
-basepython = python3.5
-
-[testenv:py34]
-basepython = python3.4
-
-[testenv:py33]
-basepython = python3.3
-
-[testenv:py27]
-basepython = python2.7
-
-[testenv:docs]
-basepython = python3.4
-commands = sphinx-build -W -b html docs docs/_build



View it on GitLab: https://salsa.debian.org/med-team/python-fitbit/commit/bcdce14761e22b7105fc9040484dc616c433722f

-- 
View it on GitLab: https://salsa.debian.org/med-team/python-fitbit/commit/bcdce14761e22b7105fc9040484dc616c433722f
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20190712/97202a97/attachment-0001.html>


More information about the debian-med-commit mailing list