# -*- coding: utf-8 -*-
from setuptools import setup

modules = \
['oura_ring']
install_requires = \
['requests>=2.28.1,<3.0.0']

setup_kwargs = {
    'name': 'oura-ring',
    'version': '0.2.0',
    'description': 'Tools for acquiring and analyzing Oura API data.',
    'long_description': '# Oura Ring for Python <!-- omit in toc -->\n\nTools for acquiring and analyzing Oura API data.\n\n[Oura](https://ouraring.com) is a wearable ring for monitoring sleep, activity, and workouts.\n\n## Contents <!-- omit in toc -->\n\n- [Installation](#installation)\n- [Getting Started](#getting-started)\n- [API Requests](#api-requests)\n  - [Get Personal Info](#get-personal-info)\n  - [Get Daily Sleep](#get-daily-sleep)\n  - [Get Daily Activity](#get-daily-activity)\n  - [Get Daily Readiness](#get-daily-readiness)\n  - [Get Heart Rate](#get-heart-rate)\n  - [Get Sleep Periods](#get-sleep-periods)\n  - [Get Sessions](#get-sessions)\n  - [Get Tags](#get-tags)\n  - [Get Workouts](#get-workouts)\n- [Usage With DataFrame](#usage-with-dataframe)\n\n## Installation\n\nThe `oura_ring` module can be installed via pip:\n\n`pip install oura-ring`\n\n## Getting Started\n\nIn order to use the Oura client, you must first generate a [`personal_access_token`](https://cloud.ouraring.com/personal-access-tokens) for your Oura account.\n\nIt is best practice to store this value in a `.env` file:\n\n```bash\n# Oura credentials\nPERSONAL_ACCESS_TOKEN="<PERSONAL_ACCESS_TOKEN>"\n```\n\nYou can use [`python-dotenv`](https://github.com/theskumar/python-dotenv) to load the enviroment variables for use in code:\n\n```python\nimport os\nfrom dotenv import load_dotenv\n\nload_dotenv()\n\npat = os.getenv("PERSONAL_ACCESS_TOKEN") or ""\n```\n\nOnce the environment variables are loaded, an `OuraClient` object can be created:\n\n```python\n# Using a traditional constructor and destructor\nimport oura_ring as ou\n\nclient = ou.OuraClient(pat)\n\n...\n\ndel client\n\n# Using a context manager that destructs automatically\nwith ou.OuraClient(pat) as client:\n    ...\n```\n\n## API Requests\n\nThere are nine different API requests that `OuraClient` can make. Full Oura API v2 documentation can be found on [Oura\'s website](https://cloud.ouraring.com/v2/docs).\n\n### Get Personal Info\n\n**Method**: `get_personal_info()`\n\n**Payload**: None\n\n**Example Response**:\n\n```python\n{\n    "age": 31,\n    "weight": 74.8,\n    "height": 1.8,\n    "biological_sex": "male",\n    "email": "example@example.com"\n}\n```\n\n### Get Daily Sleep\n\n**Method**: `get_daily_sleep(start_date: str = <end_date - 1 day>, end_date: str = <today\'s date>)`\n\n**Payload**:\n\n- `start_date`: The earliest date for which to get data. Expected in ISO 8601 format (YYYY-MM-DD). Defaults to one day before the `end_date` parameter.\n- `end_date`: The latest date for which to get data. Expected in ISO 8601 format (YYYY-MM-DD). Defaults to today\'s date.\n\n**Example Response**:\n\n```python\n[\n    {\n        "contributors": {\n            "deep_sleep": 57,\n            "efficiency": 98,\n            "latency": 81,\n            "rem_sleep": 20,\n            "restfulness": 54,\n            "timing": 84,\n            "total_sleep": 60\n        },\n        "day": "2022-07-14",\n        "score": 63,\n        "timestamp": "2022-07-14T00:00:00+00:00"\n    },\n    ...\n]\n```\n\n### Get Daily Activity\n\n**Method**: `get_daily_activity(start_date: str = <end_date - 1 day>, end_date: str = <today\'s date>)`\n\n**Payload**:\n\n- `start_date`: The earliest date for which to get data. Expected in ISO 8601 format (YYYY-MM-DD). Defaults to one day before the `end_date` parameter.\n- `end_date`: The latest date for which to get data. Expected in ISO 8601 format (YYYY-MM-DD). Defaults to today\'s date.\n\n**Example Response**:\n\n```python\n[\n    {\n        "class_5_min": "<long sequence of 0|1|2|3|4|5>",\n        "score": 82,\n        "active_calories": 1222,\n        "average_met_minutes": 1.90625,\n        "contributors": {\n            "meet_daily_targets": 43,\n            "move_every_hour": 100,\n            "recovery_time": 100,\n            "stay_active": 98,\n            "training_frequency": 71,\n            "training_volume": 98\n        },\n        "equivalent_walking_distance": 20122,\n        "high_activity_met_minutes": 444,\n        "high_activity_time": 3000,\n        "inactivity_alerts": 0,\n        "low_activity_met_minutes": 117,\n        "low_activity_time": 10020,\n        "medium_activity_met_minutes": 391,\n        "medium_activity_time": 6060,\n        "met": {\n            "interval": 60,\n            "items": [\n                0.1,\n                ...\n            ],\n            "timestamp": "2021-11-26T04:00:00.000-08:00"\n        },\n        "meters_to_target": -16200,\n        "non_wear_time": 27480,\n        "resting_time": 18840,\n        "sedentary_met_minutes": 10,\n        "sedentary_time": 21000,\n        "steps": 18430,\n        "target_calories": 350,\n        "target_meters": 7000,\n        "total_calories": 3446,\n        "day": "2021-11-26",\n        "timestamp": "2021-11-26T04:00:00-08:00"\n    },\n    ...\n]\n```\n\n### Get Daily Readiness\n\n**Method**: `get_daily_sleep(start_date: str = <end_date - 1 day>, end_date: str = <today\'s date>)`\n\n**Payload**:\n\n- `start_date`: The earliest date for which to get data. Expected in ISO 8601 format (YYYY-MM-DD). Defaults to one day before the `end_date` parameter.\n- `end_date`: The latest date for which to get data. Expected in ISO 8601 format (YYYY-MM-DD). Defaults to today\'s date.\n\n**Example Response**:\n\n```python\n[\n    {\n        "contributors": {\n            "activity_balance": 56,\n            "body_temperature": 98,\n            "hrv_balance": 75,\n            "previous_day_activity": null,\n            "previous_night": 35,\n            "recovery_index": 47,\n            "resting_heart_rate": 94,\n            "sleep_balance": 73\n        },\n        "day": "2021-10-27",\n        "score": 66,\n        "temperature_deviation": -0.2,\n        "temperature_trend_deviation": 0.1,\n        "timestamp": "2021-10-27T00:00:00+00:00"\n    },\n    ...\n]\n```\n\n### Get Heart Rate\n\n**Method**: `get_daily_sleep(start_date: str = <end_date - 1 day>, end_date: str = <today\'s date>)`\n\n**Payload**:\n\n- `start_date`: The earliest date for which to get data. Expected in ISO 8601 format (YYYY-MM-DD). Defaults to one day before the `end_date` parameter.\n- `end_date`: The latest date for which to get data. Expected in ISO 8601 format (YYYY-MM-DD). Defaults to today\'s date.\n\n**Example Response**:\n\n```python\n[\n    {\n        "bpm": 60,\n        "source": "sleep",\n        "timestamp": "2021-01-01T01:02:03+00:00"\n    },\n    ...\n]\n```\n\n### Get Sleep Periods\n\n**Method**: `get_daily_sleep(start_date: str = <end_date - 1 day>, end_date: str = <today\'s date>)`\n\n**Payload**:\n\n- `start_date`: The earliest date for which to get data. Expected in ISO 8601 format (YYYY-MM-DD). Defaults to one day before the `end_date` parameter.\n- `end_date`: The latest date for which to get data. Expected in ISO 8601 format (YYYY-MM-DD). Defaults to today\'s date.\n\n**Example Response**:\n\n```python\n[\n    {\n        "average_breath": 12.625,\n        "average_heart_rate": 4.25,\n        "average_hrv": 117,\n        "awake_time": 4800,\n        "bedtime_end": "2022-07-12T09:25:14-07:00",\n        "bedtime_start": "2022-07-12T01:05:14-07:00",\n        "day": "2022-07-12",\n        "deep_sleep_duration": 4170,\n        "efficiency": 84,\n        "heart_rate": {\n            "interval": 300,\n            "items": [\n                null,\n                50,\n                46,\n                ...\n            ],\n            "timestamp": "2022-07-12T01:05:14.000-07:00"\n        },\n        "hrv": {\n            "interval": 300,\n            "items": [\n                null,\n                -102,\n                -122,\n                ...\n            ],\n            "timestamp": "2022-07-12T01:05:14.000-07:00"\n        },\n        "latency": 540,\n        "light_sleep_duration": 18750,\n        "low_battery_alert": false,\n        "lowest_heart_rate": 48,\n        "movement_30_sec": "<long sequence of 1|2|3>",\n        "period": 0,\n        "readiness_score_delta": 0,\n        "rem_sleep_duration": 2280,\n        "restless_periods": 415,\n        "sleep_phase_5_min": "<long sequence of 1|2|3|4>",\n        "sleep_score_delta": 0,\n        "time_in_bed": 30000,\n        "total_sleep_duration": null,\n        "type": "long_sleep"\n    },\n    ...\n]\n```\n\n### Get Sessions\n\n**Method**: `get_daily_sleep(start_date: str = <end_date - 1 day>, end_date: str = <today\'s date>)`\n\n**Payload**:\n\n- `start_date`: The earliest date for which to get data. Expected in ISO 8601 format (YYYY-MM-DD). Defaults to one day before the `end_date` parameter.\n- `end_date`: The latest date for which to get data. Expected in ISO 8601 format (YYYY-MM-DD). Defaults to today\'s date.\n\n**Example Response**:\n\n```python\n[\n    {\n        "day": "2021-11-12",\n        "start_datetime": "2021-11-12T12:32:09-08:00",\n        "end_datetime": "2021-11-12T12:40:49-08:00",\n        "type": "rest",\n        "heart_rate": null,\n        "heart_rate_variability": null,\n        "mood": null,\n        "motion_count": {\n            "interval": 5,\n            "items": [\n                0\n            ],\n            "timestamp": "2021-11-12T12:32:09.000-08:00"\n        }\n    },\n    ...\n]\n```\n\n### Get Tags\n\n**Method**: `get_daily_sleep(start_date: str = <end_date - 1 day>, end_date: str = <today\'s date>)`\n\n**Payload**:\n\n- `start_date`: The earliest date for which to get data. Expected in ISO 8601 format (YYYY-MM-DD). Defaults to one day before the `end_date` parameter.\n- `end_date`: The latest date for which to get data. Expected in ISO 8601 format (YYYY-MM-DD). Defaults to today\'s date.\n\n**Example Response**:\n\n```python\n[\n    {\n        "day": "2021-01-01",\n        "text": "Need coffee",\n        "timestamp": "2021-01-01T01:02:03-08:00",\n        "tags": [\n            "tag_generic_nocaffeine"\n        ]\n    },\n    ...\n]\n```\n\n### Get Workouts\n\n**Method**: `get_daily_sleep(start_date: str = <end_date - 1 day>, end_date: str = <today\'s date>)`\n\n**Payload**:\n\n- `start_date`: The earliest date for which to get data. Expected in ISO 8601 format (YYYY-MM-DD). Defaults to one day before the `end_date` parameter.\n- `end_date`: The latest date for which to get data. Expected in ISO 8601 format (YYYY-MM-DD). Defaults to today\'s date.\n\n**Example Response**:\n\n```python\n[\n    {\n        "activity": "cycling",\n        "calories": 300,\n        "day": "2021-01-01",\n        "distance": 13500.5,\n        "end_datetime": "2021-01-01T01:00:00.000000+00:00",\n        "intensity": "moderate",\n        "label": null,\n        "source": "manual",\n        "start_datetime": "2021-01-01T01:30:00.000000+00:00"\n    },\n    ...\n]\n```\n\n## Usage With DataFrame\n\nUsing Oura API data with a Pandas DataFrame is very straightforward:\n\n```python\n>>> import pandas as pd\n\n>>> sleep = client.get_daily_sleep()\n>>> pd.json_normalize(sleep)\n\n          day  score                  timestamp  contributors.deep_sleep  \\\n0  2022-09-01     76  2022-09-01T00:00:00+00:00                       99\n1  2022-09-02     81  2022-09-02T00:00:00+00:00                      100\n\n   contributors.efficiency  contributors.latency  contributors.rem_sleep  \\\n0                       90                    99                      79\n1                       88                    75                      95\n\n   contributors.restfulness  contributors.timing  contributors.total_sleep\n0                        55                   15                        85\n1                        56                   28                        96\n\n[2 rows x 10 columns]\n\n>>> readiness = client.get_daily_readiness()\n>>> pd.json_normalize(readiness)\n\n          day  score  temperature_deviation  temperature_trend_deviation  \\\n0  2022-09-01     87                  -0.09                         0.24\n1  2022-09-02     91                  -0.03                         0.11\n\n                   timestamp  contributors.activity_balance  \\\n0  2022-09-01T00:00:00+00:00                             80\n1  2022-09-02T00:00:00+00:00                             86\n\n   contributors.body_temperature  contributors.hrv_balance  \\\n0                            100                        84\n1                            100                        85\n\n  contributors.previous_day_activity  contributors.previous_night  \\\n0                               None                           75\n1                               None                           88\n\n   contributors.recovery_index  contributors.resting_heart_rate  \\\n0                          100                              100\n1                           94                               98\n\n   contributors.sleep_balance\n0                          87\n1                          93\n\n[2 rows x 13 columns]\n```\n',
    'author': 'Josh Hejka',
    'author_email': 'josh@joshhejka.com',
    'maintainer': 'None',
    'maintainer_email': 'None',
    'url': 'None',
    'py_modules': modules,
    'install_requires': install_requires,
    'python_requires': '>=3.10,<4.0',
}


setup(**setup_kwargs)
