diff --git a/oura_api_client/api/client.py b/oura_api_client/api/client.py index 90a2f80..a017d96 100644 --- a/oura_api_client/api/client.py +++ b/oura_api_client/api/client.py @@ -71,7 +71,7 @@ def _make_request( """Make a request to the Oura API. Args: - endpoint (str): The API endpoint to call + endpoint (str): The API endpoint to call (should start with /) params (dict, optional): Query parameters for the request method (str): HTTP method to use (default: GET) @@ -81,6 +81,14 @@ def _make_request( Raises: requests.exceptions.RequestException: If the API request fails """ + # Ensure endpoint starts with / + if not endpoint.startswith('/'): + endpoint = f"/{endpoint}" + + # Remove any duplicate /v2 prefix if present + if endpoint.startswith('/v2/'): + endpoint = endpoint[3:] # Remove '/v2' prefix + url = f"{self.BASE_URL}{endpoint}" if method.upper() == "GET": diff --git a/oura_api_client/api/daily_activity.py b/oura_api_client/api/daily_activity.py index 2233f84..3923ddf 100644 --- a/oura_api_client/api/daily_activity.py +++ b/oura_api_client/api/daily_activity.py @@ -33,7 +33,7 @@ def get_daily_activity_documents( } params = {k: v for k, v in params.items() if v is not None} response = self.client._make_request( - "/v2/usercollection/daily_activity", params=params + "/usercollection/daily_activity", params=params ) return DailyActivityResponse(**response) @@ -50,6 +50,6 @@ def get_daily_activity_document( DailyActivityModel: Response containing daily activity data. """ response = self.client._make_request( - f"/v2/usercollection/daily_activity/{document_id}" + f"/usercollection/daily_activity/{document_id}" ) return DailyActivityModel(**response) diff --git a/oura_api_client/api/daily_cardiovascular_age.py b/oura_api_client/api/daily_cardiovascular_age.py index 80f1bd3..e238300 100644 --- a/oura_api_client/api/daily_cardiovascular_age.py +++ b/oura_api_client/api/daily_cardiovascular_age.py @@ -37,7 +37,7 @@ def get_daily_cardiovascular_age_documents( } params = {k: v for k, v in params.items() if v is not None} response = self.client._make_request( - "/v2/usercollection/daily_cardiovascular_age", params=params + "/usercollection/daily_cardiovascular_age", params=params ) return DailyCardiovascularAgeResponse(**response) @@ -55,6 +55,6 @@ def get_daily_cardiovascular_age_document( cardiovascular age data. """ response = self.client._make_request( - f"/v2/usercollection/daily_cardiovascular_age/{document_id}" + f"/usercollection/daily_cardiovascular_age/{document_id}" ) return DailyCardiovascularAgeModel(**response) diff --git a/oura_api_client/api/daily_readiness.py b/oura_api_client/api/daily_readiness.py index 3fc7923..ab3611c 100644 --- a/oura_api_client/api/daily_readiness.py +++ b/oura_api_client/api/daily_readiness.py @@ -36,7 +36,7 @@ def get_daily_readiness_documents( } params = {k: v for k, v in params.items() if v is not None} response = self.client._make_request( - "/v2/usercollection/daily_readiness", params=params + "/usercollection/daily_readiness", params=params ) return DailyReadinessResponse(**response) @@ -53,6 +53,6 @@ def get_daily_readiness_document( DailyReadinessModel: Response containing daily readiness data. """ response = self.client._make_request( - f"/v2/usercollection/daily_readiness/{document_id}" + f"/usercollection/daily_readiness/{document_id}" ) return DailyReadinessModel(**response) diff --git a/oura_api_client/api/daily_resilience.py b/oura_api_client/api/daily_resilience.py index a5139f8..284b518 100644 --- a/oura_api_client/api/daily_resilience.py +++ b/oura_api_client/api/daily_resilience.py @@ -36,7 +36,7 @@ def get_daily_resilience_documents( } params = {k: v for k, v in params.items() if v is not None} response = self.client._make_request( - "/v2/usercollection/daily_resilience", params=params + "/usercollection/daily_resilience", params=params ) return DailyResilienceResponse(**response) @@ -53,6 +53,6 @@ def get_daily_resilience_document( DailyResilienceModel: Response containing daily resilience data. """ response = self.client._make_request( - f"/v2/usercollection/daily_resilience/{document_id}" + f"/usercollection/daily_resilience/{document_id}" ) return DailyResilienceModel(**response) diff --git a/oura_api_client/api/daily_sleep.py b/oura_api_client/api/daily_sleep.py index 848ccd9..c068c05 100644 --- a/oura_api_client/api/daily_sleep.py +++ b/oura_api_client/api/daily_sleep.py @@ -36,7 +36,7 @@ def get_daily_sleep_documents( } params = {k: v for k, v in params.items() if v is not None} response = self.client._make_request( - "/v2/usercollection/daily_sleep", params=params + "/usercollection/daily_sleep", params=params ) return DailySleepResponse(**response) @@ -51,6 +51,6 @@ def get_daily_sleep_document(self, document_id: str) -> DailySleepModel: DailySleepModel: Response containing daily sleep data. """ response = self.client._make_request( - f"/v2/usercollection/daily_sleep/{document_id}" + f"/usercollection/daily_sleep/{document_id}" ) return DailySleepModel(**response) diff --git a/oura_api_client/api/daily_spo2.py b/oura_api_client/api/daily_spo2.py index 7ef56a7..9479be8 100644 --- a/oura_api_client/api/daily_spo2.py +++ b/oura_api_client/api/daily_spo2.py @@ -36,7 +36,7 @@ def get_daily_spo2_documents( # Renamed method } params = {k: v for k, v in params.items() if v is not None} response = self.client._make_request( - "/v2/usercollection/daily_spo2", params=params + "/usercollection/daily_spo2", params=params ) return DailySpO2Response(**response) @@ -53,6 +53,6 @@ def get_daily_spo2_document( DailySpO2Model: Response containing daily SpO2 data. """ response = self.client._make_request( - f"/v2/usercollection/daily_spo2/{document_id}" + f"/usercollection/daily_spo2/{document_id}" ) return DailySpO2Model(**response) diff --git a/oura_api_client/api/daily_stress.py b/oura_api_client/api/daily_stress.py index b8d0d3b..5951641 100644 --- a/oura_api_client/api/daily_stress.py +++ b/oura_api_client/api/daily_stress.py @@ -36,7 +36,7 @@ def get_daily_stress_documents( } params = {k: v for k, v in params.items() if v is not None} response = self.client._make_request( - "/v2/usercollection/daily_stress", params=params + "/usercollection/daily_stress", params=params ) return DailyStressResponse(**response) @@ -51,6 +51,6 @@ def get_daily_stress_document(self, document_id: str) -> DailyStressModel: DailyStressModel: Response containing daily stress data. """ response = self.client._make_request( - f"/v2/usercollection/daily_stress/{document_id}" + f"/usercollection/daily_stress/{document_id}" ) return DailyStressModel(**response) diff --git a/oura_api_client/api/enhanced_tag.py b/oura_api_client/api/enhanced_tag.py index ffcfea9..a74146e 100644 --- a/oura_api_client/api/enhanced_tag.py +++ b/oura_api_client/api/enhanced_tag.py @@ -36,7 +36,7 @@ def get_enhanced_tag_documents( } params = {k: v for k, v in params.items() if v is not None} response = self.client._make_request( - "/v2/usercollection/enhanced_tag", params=params + "/usercollection/enhanced_tag", params=params ) return EnhancedTagResponse(**response) @@ -51,6 +51,6 @@ def get_enhanced_tag_document(self, document_id: str) -> EnhancedTagModel: EnhancedTagModel: Response containing enhanced_tag data. """ response = self.client._make_request( - f"/v2/usercollection/enhanced_tag/{document_id}" + f"/usercollection/enhanced_tag/{document_id}" ) return EnhancedTagModel(**response) diff --git a/oura_api_client/api/rest_mode_period.py b/oura_api_client/api/rest_mode_period.py index 695f62c..e081848 100644 --- a/oura_api_client/api/rest_mode_period.py +++ b/oura_api_client/api/rest_mode_period.py @@ -36,7 +36,7 @@ def get_rest_mode_period_documents( } params = {k: v for k, v in params.items() if v is not None} response = self.client._make_request( - "/v2/usercollection/rest_mode_period", params=params + "/usercollection/rest_mode_period", params=params ) return RestModePeriodResponse(**response) @@ -53,6 +53,6 @@ def get_rest_mode_period_document( RestModePeriodModel: Response containing rest_mode_period data. """ response = self.client._make_request( - f"/v2/usercollection/rest_mode_period/{document_id}" + f"/usercollection/rest_mode_period/{document_id}" ) return RestModePeriodModel(**response) diff --git a/oura_api_client/api/ring_configuration.py b/oura_api_client/api/ring_configuration.py index 434846f..ce26457 100644 --- a/oura_api_client/api/ring_configuration.py +++ b/oura_api_client/api/ring_configuration.py @@ -49,7 +49,7 @@ def get_ring_configuration_documents( final_params = {k: v for k, v in params.items() if v is not None} response = self.client._make_request( - "/v2/usercollection/ring_configuration", + "/usercollection/ring_configuration", params=final_params if final_params else None ) return RingConfigurationResponse(**response) @@ -67,6 +67,6 @@ def get_ring_configuration_document( RingConfigurationModel: Response containing ring configuration data. """ response = self.client._make_request( - f"/v2/usercollection/ring_configuration/{document_id}" + f"/usercollection/ring_configuration/{document_id}" ) return RingConfigurationModel(**response) diff --git a/oura_api_client/api/session.py b/oura_api_client/api/session.py index 3245128..091b058 100644 --- a/oura_api_client/api/session.py +++ b/oura_api_client/api/session.py @@ -36,7 +36,7 @@ def get_session_documents( } params = {k: v for k, v in params.items() if v is not None} response = self.client._make_request( - "/v2/usercollection/session", params=params + "/usercollection/session", params=params ) return SessionResponse(**response) @@ -51,6 +51,6 @@ def get_session_document(self, document_id: str) -> SessionModel: SessionModel: Response containing session data. """ response = self.client._make_request( - f"/v2/usercollection/session/{document_id}" + f"/usercollection/session/{document_id}" ) return SessionModel(**response) diff --git a/oura_api_client/api/sleep.py b/oura_api_client/api/sleep.py index 7b24d8a..b10f2a7 100644 --- a/oura_api_client/api/sleep.py +++ b/oura_api_client/api/sleep.py @@ -39,7 +39,7 @@ def get_sleep_documents( # Renamed method params = {k: v for k, v in params.items() if v is not None} # Corrected endpoint URL from daily_sleep to sleep response = self.client._make_request( - "/v2/usercollection/sleep", params=params + "/usercollection/sleep", params=params ) return SleepResponse(**response) @@ -57,6 +57,6 @@ def get_sleep_document( """ # Corrected endpoint URL from daily_sleep to sleep response = self.client._make_request( - f"/v2/usercollection/sleep/{document_id}" + f"/usercollection/sleep/{document_id}" ) return SleepModel(**response) diff --git a/oura_api_client/api/sleep_time.py b/oura_api_client/api/sleep_time.py index 090132f..affe6d6 100644 --- a/oura_api_client/api/sleep_time.py +++ b/oura_api_client/api/sleep_time.py @@ -36,7 +36,7 @@ def get_sleep_time_documents( } params = {k: v for k, v in params.items() if v is not None} response = self.client._make_request( - "/v2/usercollection/sleep_time", params=params + "/usercollection/sleep_time", params=params ) return SleepTimeResponse(**response) @@ -58,6 +58,6 @@ def get_sleep_time_document(self, document_id: str) -> SleepTimeModel: # sleep_time. Proceeding with the assumption it might exist or # for future compatibility. response = self.client._make_request( - f"/v2/usercollection/sleep_time/{document_id}" + f"/usercollection/sleep_time/{document_id}" ) return SleepTimeModel(**response) diff --git a/oura_api_client/api/tag.py b/oura_api_client/api/tag.py index bf75cc8..30b228d 100644 --- a/oura_api_client/api/tag.py +++ b/oura_api_client/api/tag.py @@ -33,7 +33,7 @@ def get_tag_documents( } params = {k: v for k, v in params.items() if v is not None} response = self.client._make_request( - "/v2/usercollection/tag", params=params + "/usercollection/tag", params=params ) return TagResponse(**response) @@ -48,6 +48,6 @@ def get_tag_document(self, document_id: str) -> TagModel: TagModel: Response containing tag data. """ response = self.client._make_request( - f"/v2/usercollection/tag/{document_id}" + f"/usercollection/tag/{document_id}" ) return TagModel(**response) diff --git a/oura_api_client/api/vo2_max.py b/oura_api_client/api/vo2_max.py index 19b3afd..cf316f1 100644 --- a/oura_api_client/api/vo2_max.py +++ b/oura_api_client/api/vo2_max.py @@ -33,7 +33,7 @@ def get_vo2_max_documents( } params = {k: v for k, v in params.items() if v is not None} response = self.client._make_request( - "/v2/usercollection/vO2_max", params=params + "/usercollection/vO2_max", params=params ) return Vo2MaxResponse(**response) @@ -48,6 +48,6 @@ def get_vo2_max_document(self, document_id: str) -> Vo2MaxModel: Vo2MaxModel: Response containing VO2 max data. """ response = self.client._make_request( - f"/v2/usercollection/vO2_max/{document_id}" + f"/usercollection/vO2_max/{document_id}" ) return Vo2MaxModel(**response) diff --git a/oura_api_client/api/webhook.py b/oura_api_client/api/webhook.py index 96551a8..943a7b4 100644 --- a/oura_api_client/api/webhook.py +++ b/oura_api_client/api/webhook.py @@ -46,7 +46,7 @@ def list_webhook_subscriptions(self) -> List[WebhookSubscriptionModel]: """ headers = self._get_webhook_headers() response_data = self.client._make_request( - "/v2/webhook/subscription", + "/webhook/subscription", headers=headers ) # API returns a list of subscriptions directly @@ -77,7 +77,7 @@ def create_webhook_subscription( verification_token=verification_token, ) response_data = self.client._make_request( - "/v2/webhook/subscription", + "/webhook/subscription", method="POST", json_data=request_body.model_dump( by_alias=True @@ -95,7 +95,7 @@ def get_webhook_subscription( """ headers = self._get_webhook_headers() response_data = self.client._make_request( - f"/v2/webhook/subscription/{subscription_id}", + f"/webhook/subscription/{subscription_id}", headers=headers ) return WebhookSubscriptionModel(**response_data) @@ -123,7 +123,7 @@ def update_webhook_subscription( data_type=data_type, ) response_data = self.client._make_request( - f"/v2/webhook/subscription/{subscription_id}", + f"/webhook/subscription/{subscription_id}", method="PUT", json_data=request_body.model_dump( by_alias=True, exclude_none=True @@ -139,7 +139,7 @@ def delete_webhook_subscription(self, subscription_id: str) -> None: """ headers = self._get_webhook_headers() self.client._make_request( - f"/v2/webhook/subscription/{subscription_id}", + f"/webhook/subscription/{subscription_id}", method="DELETE", headers=headers ) @@ -160,7 +160,7 @@ def renew_webhook_subscription( # headers['Content-Type'] = 'application/json' response_data = self.client._make_request( - f"/v2/webhook/subscription/renew/{subscription_id}", + f"/webhook/subscription/renew/{subscription_id}", method="PUT", headers=headers # No json_data for this specific renew endpoint as per typical diff --git a/oura_api_client/api/workout.py b/oura_api_client/api/workout.py index 590315f..dbee601 100644 --- a/oura_api_client/api/workout.py +++ b/oura_api_client/api/workout.py @@ -33,7 +33,7 @@ def get_workout_documents( } params = {k: v for k, v in params.items() if v is not None} response = self.client._make_request( - "/v2/usercollection/workout", params=params + "/usercollection/workout", params=params ) return WorkoutResponse(**response) @@ -48,6 +48,6 @@ def get_workout_document(self, document_id: str) -> WorkoutModel: WorkoutModel: Response containing workout data. """ response = self.client._make_request( - f"/v2/usercollection/workout/{document_id}" + f"/usercollection/workout/{document_id}" ) return WorkoutModel(**response) diff --git a/tests/test_client.py b/tests/test_client.py index f9460fb..5c107fe 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -181,7 +181,7 @@ def test_get_daily_activity_documents(self, mock_get): # if client.get is not available actual_call_url = mock_get.call_args[0][0] base_url = self.client.BASE_URL - expected_url = f"{base_url}/v2/usercollection/daily_activity" + expected_url = f"{base_url}/usercollection/daily_activity" self.assertTrue(actual_call_url.endswith(expected_url)) called_params = mock_get.call_args[1]['params'] @@ -215,7 +215,7 @@ def test_get_daily_activity_documents_with_string_dates(self, mock_get): ) actual_call_url = mock_get.call_args[0][0] base_url = self.client.BASE_URL - expected_url = f"{base_url}/v2/usercollection/daily_activity" + expected_url = f"{base_url}/usercollection/daily_activity" self.assertTrue(actual_call_url.endswith(expected_url)) called_params = mock_get.call_args[1]['params'] @@ -283,7 +283,7 @@ def test_get_daily_activity_document(self, mock_get): actual_call_url = mock_get.call_args[0][0] base_url = self.client.BASE_URL - expected_url = f"{base_url}/v2/usercollection/daily_activity/{document_id}" + expected_url = f"{base_url}/usercollection/daily_activity/{document_id}" self.assertTrue(actual_call_url.endswith(expected_url)) called_params = mock_get.call_args[1]['params'] @@ -362,7 +362,7 @@ def test_get_daily_sleep_documents(self, mock_get): self.assertEqual(daily_sleep_response.next_token, "next_sleep_token") mock_get.assert_called_once_with( - f"{self.client.BASE_URL}/v2/usercollection/daily_sleep", + f"{self.client.BASE_URL}/usercollection/daily_sleep", headers=self.client.headers, params={ "start_date": start_date_str, @@ -396,7 +396,7 @@ def test_get_daily_sleep_documents_with_string_dates(self, mock_get): ) mock_get.assert_called_once_with( - f"{self.client.BASE_URL}/v2/usercollection/daily_sleep", + f"{self.client.BASE_URL}/usercollection/daily_sleep", headers=self.client.headers, params={"start_date": start_date_str, "end_date": end_date_str}, @@ -456,7 +456,7 @@ def test_get_daily_sleep_document(self, mock_get): ) mock_get.assert_called_once_with( - f"{self.client.BASE_URL}/v2/usercollection/daily_sleep/{document_id}", + f"{self.client.BASE_URL}/usercollection/daily_sleep/{document_id}", headers=self.client.headers, params=None, @@ -525,7 +525,7 @@ def test_get_daily_readiness_documents(self, mock_get): ) mock_get.assert_called_once_with( - f"{self.client.BASE_URL}/v2/usercollection/daily_readiness", + f"{self.client.BASE_URL}/usercollection/daily_readiness", headers=self.client.headers, params={ "start_date": start_date_str, @@ -560,7 +560,7 @@ def test_get_daily_readiness_documents_with_string_dates(self, mock_get): ) mock_get.assert_called_once_with( - f"{self.client.BASE_URL}/v2/usercollection/daily_readiness", + f"{self.client.BASE_URL}/usercollection/daily_readiness", headers=self.client.headers, params={"start_date": start_date_str, "end_date": end_date_str}, @@ -623,7 +623,7 @@ def test_get_daily_readiness_document(self, mock_get): self.assertEqual(daily_readiness_document.spo2_percentage, 98.5) mock_get.assert_called_once_with( - f"{self.client.BASE_URL}/v2/usercollection/daily_readiness/{document_id}", + f"{self.client.BASE_URL}/usercollection/daily_readiness/{document_id}", headers=self.client.headers, params=None, @@ -717,7 +717,7 @@ def test_get_sleep_documents(self, mock_get): self.assertEqual(sleep_response.next_token, "next_sleep_doc_token") mock_get.assert_called_once_with( - f"{self.client.BASE_URL}/v2/usercollection/sleep", + f"{self.client.BASE_URL}/usercollection/sleep", headers=self.client.headers, params={ "start_date": start_date_str, @@ -750,7 +750,7 @@ def test_get_sleep_documents_with_string_dates(self, mock_get): ) mock_get.assert_called_once_with( - f"{self.client.BASE_URL}/v2/usercollection/sleep", + f"{self.client.BASE_URL}/usercollection/sleep", headers=self.client.headers, params={"start_date": start_date_str, "end_date": end_date_str}, @@ -801,7 +801,7 @@ def test_get_sleep_document(self, mock_get): ) mock_get.assert_called_once_with( - f"{self.client.BASE_URL}/v2/usercollection/sleep/{document_id}", + f"{self.client.BASE_URL}/usercollection/sleep/{document_id}", headers=self.client.headers, params=None, @@ -863,7 +863,7 @@ def test_get_session_documents(self, mock_get): self.assertEqual(session_response.next_token, "next_session_token") mock_get.assert_called_once_with( - f"{self.client.BASE_URL}/v2/usercollection/session", + f"{self.client.BASE_URL}/usercollection/session", headers=self.client.headers, params={ "start_date": start_date_str, @@ -898,7 +898,7 @@ def test_get_session_documents_with_string_dates(self, mock_get): ) mock_get.assert_called_once_with( - f"{self.client.BASE_URL}/v2/usercollection/session", + f"{self.client.BASE_URL}/usercollection/session", headers=self.client.headers, params={"start_date": start_date_str, "end_date": end_date_str}, @@ -946,7 +946,7 @@ def test_get_session_document(self, mock_get): ) mock_get.assert_called_once_with( - f"{self.client.BASE_URL}/v2/usercollection/session/{document_id}", + f"{self.client.BASE_URL}/usercollection/session/{document_id}", headers=self.client.headers, params=None, @@ -1003,7 +1003,7 @@ def test_get_tag_documents(self, mock_get): self.assertEqual(tag_response.next_token, "next_tag_token") mock_get.assert_called_once_with( - f"{self.client.BASE_URL}/v2/usercollection/tag", + f"{self.client.BASE_URL}/usercollection/tag", headers=self.client.headers, params={ "start_date": start_date_str, @@ -1037,7 +1037,7 @@ def test_get_tag_documents_with_string_dates(self, mock_get): ) mock_get.assert_called_once_with( - f"{self.client.BASE_URL}/v2/usercollection/tag", + f"{self.client.BASE_URL}/usercollection/tag", headers=self.client.headers, params={"start_date": start_date_str, "end_date": end_date_str}, @@ -1078,7 +1078,7 @@ def test_get_tag_document(self, mock_get): ) mock_get.assert_called_once_with( - f"{self.client.BASE_URL}/v2/usercollection/tag/{document_id}", + f"{self.client.BASE_URL}/usercollection/tag/{document_id}", headers=self.client.headers, params=None, @@ -1143,7 +1143,7 @@ def test_get_workout_documents(self, mock_get): self.assertEqual(workout_response.next_token, "next_workout_token") mock_get.assert_called_once_with( - f"{self.client.BASE_URL}/v2/usercollection/workout", + f"{self.client.BASE_URL}/usercollection/workout", headers=self.client.headers, params={ "start_date": start_date_str, @@ -1180,7 +1180,7 @@ def test_get_workout_documents_with_string_dates(self, mock_get): ) mock_get.assert_called_once_with( - f"{self.client.BASE_URL}/v2/usercollection/workout", + f"{self.client.BASE_URL}/usercollection/workout", headers=self.client.headers, params={"start_date": start_date_str, "end_date": end_date_str}, @@ -1230,7 +1230,7 @@ def test_get_workout_document(self, mock_get): ) mock_get.assert_called_once_with( - f"{self.client.BASE_URL}/v2/usercollection/workout/{document_id}", + f"{self.client.BASE_URL}/usercollection/workout/{document_id}", headers=self.client.headers, params=None, @@ -1302,7 +1302,7 @@ def test_get_enhanced_tag_documents(self, mock_get): ) mock_get.assert_called_once_with( - f"{self.client.BASE_URL}/v2/usercollection/enhanced_tag", + f"{self.client.BASE_URL}/usercollection/enhanced_tag", headers=self.client.headers, params={ "start_date": start_date_str, @@ -1336,7 +1336,7 @@ def test_get_enhanced_tag_documents_with_string_dates(self, mock_get): ) mock_get.assert_called_once_with( - f"{self.client.BASE_URL}/v2/usercollection/enhanced_tag", + f"{self.client.BASE_URL}/usercollection/enhanced_tag", headers=self.client.headers, params={"start_date": start_date_str, "end_date": end_date_str}, @@ -1384,7 +1384,7 @@ def test_get_enhanced_tag_document(self, mock_get): ) mock_get.assert_called_once_with( - f"{self.client.BASE_URL}/v2/usercollection/enhanced_tag/{document_id}", + f"{self.client.BASE_URL}/usercollection/enhanced_tag/{document_id}", headers=self.client.headers, params=None, @@ -1452,7 +1452,7 @@ def test_get_daily_spo2_documents(self, mock_get): self.assertEqual(daily_spo2_response.data[0].spo2_percentage, 97.5) mock_get.assert_called_once_with( - f"{self.client.BASE_URL}/v2/usercollection/daily_spo2", + f"{self.client.BASE_URL}/usercollection/daily_spo2", headers=self.client.headers, params={ "start_date": start_date_str, @@ -1486,7 +1486,7 @@ def test_get_daily_spo2_documents_with_string_dates(self, mock_get): ) mock_get.assert_called_once_with( - f"{self.client.BASE_URL}/v2/usercollection/daily_spo2", + f"{self.client.BASE_URL}/usercollection/daily_spo2", headers=self.client.headers, params={"start_date": start_date_str, "end_date": end_date_str}, @@ -1530,7 +1530,7 @@ def test_get_daily_spo2_document(self, mock_get): ) mock_get.assert_called_once_with( - f"{self.client.BASE_URL}/v2/usercollection/daily_spo2/{document_id}", + f"{self.client.BASE_URL}/usercollection/daily_spo2/{document_id}", headers=self.client.headers, params=None, @@ -1620,7 +1620,7 @@ def test_get_sleep_time_documents(self, mock_get): self.assertEqual(sleep_time_response.data[0].day, date(2024, 3, 10)) mock_get.assert_called_once_with( - f"{self.client.BASE_URL}/v2/usercollection/sleep_time", + f"{self.client.BASE_URL}/usercollection/sleep_time", headers=self.client.headers, params={ "start_date": start_date_str, @@ -1654,7 +1654,7 @@ def test_get_sleep_time_documents_with_string_dates(self, mock_get): ) mock_get.assert_called_once_with( - f"{self.client.BASE_URL}/v2/usercollection/sleep_time", + f"{self.client.BASE_URL}/usercollection/sleep_time", headers=self.client.headers, params={"start_date": start_date_str, "end_date": end_date_str}, @@ -1713,7 +1713,7 @@ def test_get_sleep_time_document(self, mock_get): ) mock_get.assert_called_once_with( - f"{self.client.BASE_URL}/v2/usercollection/sleep_time/{document_id}", + f"{self.client.BASE_URL}/usercollection/sleep_time/{document_id}", headers=self.client.headers, params=None, @@ -1783,7 +1783,7 @@ def test_get_rest_mode_period_documents(self, mock_get): ) mock_get.assert_called_once_with( - f"{self.client.BASE_URL}/v2/usercollection/rest_mode_period", + f"{self.client.BASE_URL}/usercollection/rest_mode_period", headers=self.client.headers, params={ "start_date": start_date_str, @@ -1817,7 +1817,7 @@ def test_get_rest_mode_period_documents_with_string_dates(self, mock_get): ) mock_get.assert_called_once_with( - f"{self.client.BASE_URL}/v2/usercollection/rest_mode_period", + f"{self.client.BASE_URL}/usercollection/rest_mode_period", headers=self.client.headers, params={"start_date": start_date_str, "end_date": end_date_str}, @@ -1865,7 +1865,7 @@ def test_get_rest_mode_period_document(self, mock_get): ) mock_get.assert_called_once_with( - f"{self.client.BASE_URL}/v2/usercollection/rest_mode_period/{document_id}", + f"{self.client.BASE_URL}/usercollection/rest_mode_period/{document_id}", headers=self.client.headers, params=None, @@ -1897,7 +1897,7 @@ def test_get_daily_stress_documents_no_params(self, mock_get): response = self.client.daily_stress.get_daily_stress_documents() self.assertIsInstance(response, DailyStressResponse) mock_get.assert_called_once_with( - f"{self.base_url}/v2/usercollection/daily_stress", + f"{self.base_url}/usercollection/daily_stress", headers=self.client.headers, params={}, ) @@ -1914,7 +1914,7 @@ def test_get_daily_stress_documents_start_date(self, mock_get): start_date="2024-01-01" ) mock_get.assert_called_once_with( - f"{self.base_url}/v2/usercollection/daily_stress", + f"{self.base_url}/usercollection/daily_stress", headers=self.client.headers, params={"start_date": "2024-01-01"}, ) @@ -1929,7 +1929,7 @@ def test_get_daily_stress_documents_end_date(self, mock_get): self.client.daily_stress.get_daily_stress_documents(end_date="2024-01-31") mock_get.assert_called_once_with( - f"{self.base_url}/v2/usercollection/daily_stress", + f"{self.base_url}/usercollection/daily_stress", headers=self.client.headers, params={"end_date": "2024-01-31"}, ) @@ -1946,7 +1946,7 @@ def test_get_daily_stress_documents_start_and_end_date(self, mock_get): start_date="2024-01-01", end_date="2024-01-31" ) mock_get.assert_called_once_with( - f"{self.base_url}/v2/usercollection/daily_stress", + f"{self.base_url}/usercollection/daily_stress", headers=self.client.headers, params={"start_date": "2024-01-01", "end_date": "2024-01-31"}, ) @@ -1963,7 +1963,7 @@ def test_get_daily_stress_documents_next_token(self, mock_get): next_token="some_token" ) mock_get.assert_called_once_with( - f"{self.base_url}/v2/usercollection/daily_stress", + f"{self.base_url}/usercollection/daily_stress", headers=self.client.headers, params={"next_token": "some_token"}, ) @@ -2001,7 +2001,7 @@ def test_get_daily_stress_documents_success(self, mock_get): self.assertEqual(response.data[0].day_summary, "restored") self.assertEqual(response.next_token, "stress_next_token") mock_get.assert_called_with( - f"{self.base_url}/v2/usercollection/daily_stress", + f"{self.base_url}/usercollection/daily_stress", headers=self.client.headers, params={"start_date": "2024-03-15"}, ) @@ -2061,7 +2061,7 @@ def test_get_daily_stress_document_success(self, mock_get): self.assertEqual(response.day_summary, "stressful") mock_get.assert_called_once_with( - f"{self.base_url}/v2/usercollection/daily_stress/{document_id}", + f"{self.base_url}/usercollection/daily_stress/{document_id}", headers=self.client.headers, params=None, # No params for single document GET ) @@ -2095,7 +2095,7 @@ def test_get_daily_resilience_documents_no_params(self, mock_get): response = self.client.daily_resilience.get_daily_resilience_documents() self.assertIsInstance(response, DailyResilienceResponse) mock_get.assert_called_once_with( - f"{self.base_url}/v2/usercollection/daily_resilience", + f"{self.base_url}/usercollection/daily_resilience", headers=self.client.headers, params={}, ) @@ -2112,7 +2112,7 @@ def test_get_daily_resilience_documents_start_date(self, mock_get): start_date="2024-02-01" ) mock_get.assert_called_once_with( - f"{self.base_url}/v2/usercollection/daily_resilience", + f"{self.base_url}/usercollection/daily_resilience", headers=self.client.headers, params={"start_date": "2024-02-01"}, ) @@ -2129,7 +2129,7 @@ def test_get_daily_resilience_documents_end_date(self, mock_get): end_date="2024-02-28" ) mock_get.assert_called_once_with( - f"{self.base_url}/v2/usercollection/daily_resilience", + f"{self.base_url}/usercollection/daily_resilience", headers=self.client.headers, params={"end_date": "2024-02-28"}, ) @@ -2146,7 +2146,7 @@ def test_get_daily_resilience_documents_start_and_end_date(self, mock_get): start_date="2024-02-01", end_date="2024-02-28" ) mock_get.assert_called_once_with( - f"{self.base_url}/v2/usercollection/daily_resilience", + f"{self.base_url}/usercollection/daily_resilience", headers=self.client.headers, params={"start_date": "2024-02-01", "end_date": "2024-02-28"}, ) @@ -2163,7 +2163,7 @@ def test_get_daily_resilience_documents_next_token(self, mock_get): next_token="res_token" ) mock_get.assert_called_once_with( - f"{self.base_url}/v2/usercollection/daily_resilience", + f"{self.base_url}/usercollection/daily_resilience", headers=self.client.headers, params={"next_token": "res_token"}, ) @@ -2207,7 +2207,7 @@ def test_get_daily_resilience_documents_success(self, mock_get): self.assertEqual(model_item.level, "solid") self.assertEqual(response.next_token, "res_next_token") mock_get.assert_called_with( - f"{self.base_url}/v2/usercollection/daily_resilience", + f"{self.base_url}/usercollection/daily_resilience", headers=self.client.headers, params={"start_date": "2024-03-18"}, ) @@ -2274,7 +2274,7 @@ def test_get_daily_resilience_document_success(self, mock_get): self.assertEqual(response.level, "exceptional") mock_get.assert_called_once_with( - f"{self.base_url}/v2/usercollection/daily_resilience/{document_id}", + f"{self.base_url}/usercollection/daily_resilience/{document_id}", headers=self.client.headers, params=None, ) @@ -2312,7 +2312,7 @@ def test_get_daily_cardiovascular_age_documents_no_params(self, mock_get): ) self.assertIsInstance(response, DailyCardiovascularAgeResponse) mock_get.assert_called_once_with( - f"{self.base_url}/v2/usercollection/daily_cardiovascular_age", + f"{self.base_url}/usercollection/daily_cardiovascular_age", headers=self.client.headers, params={}, ) @@ -2329,7 +2329,7 @@ def test_get_daily_cardiovascular_age_documents_start_date(self, mock_get): start_date="2024-03-01" ) mock_get.assert_called_once_with( - f"{self.base_url}/v2/usercollection/daily_cardiovascular_age", + f"{self.base_url}/usercollection/daily_cardiovascular_age", headers=self.client.headers, params={"start_date": "2024-03-01"}, ) @@ -2346,7 +2346,7 @@ def test_get_daily_cardiovascular_age_documents_end_date(self, mock_get): end_date="2024-03-31" ) mock_get.assert_called_once_with( - f"{self.base_url}/v2/usercollection/daily_cardiovascular_age", + f"{self.base_url}/usercollection/daily_cardiovascular_age", headers=self.client.headers, params={"end_date": "2024-03-31"}, ) @@ -2363,7 +2363,7 @@ def test_get_daily_cardiovascular_age_documents_start_and_end_date(self, mock_ge start_date="2024-03-01", end_date="2024-03-31" ) mock_get.assert_called_once_with( - f"{self.base_url}/v2/usercollection/daily_cardiovascular_age", + f"{self.base_url}/usercollection/daily_cardiovascular_age", headers=self.client.headers, params={"start_date": "2024-03-01", "end_date": "2024-03-31"}, ) @@ -2380,7 +2380,7 @@ def test_get_daily_cardiovascular_age_documents_next_token(self, mock_get): next_token="cva_token" ) mock_get.assert_called_once_with( - f"{self.base_url}/v2/usercollection/daily_cardiovascular_age", + f"{self.base_url}/usercollection/daily_cardiovascular_age", headers=self.client.headers, params={"next_token": "cva_token"}, ) @@ -2419,7 +2419,7 @@ def test_get_daily_cardiovascular_age_documents_success(self, mock_get): self.assertEqual(model_item.vascular_age, 30.5) self.assertEqual(response.next_token, "cva_next_token") mock_get.assert_called_with( - f"{self.base_url}/v2/usercollection/daily_cardiovascular_age", + f"{self.base_url}/usercollection/daily_cardiovascular_age", headers=self.client.headers, params={"start_date": "2024-03-20"}, ) @@ -2478,7 +2478,7 @@ def test_get_daily_cardiovascular_age_document_success(self, mock_get): self.assertEqual(response.vascular_age, 32.0) mock_get.assert_called_once_with( - f"{self.base_url}/v2/usercollection/daily_cardiovascular_age/{document_id}", + f"{self.base_url}/usercollection/daily_cardiovascular_age/{document_id}", headers=self.client.headers, params=None, ) @@ -2502,7 +2502,7 @@ def setUp(self): self.client = OuraClient(access_token="test_token") self.base_url = self.client.BASE_URL - self.correct_path_segment = "/v2/usercollection/vO2_max" # Note the casing + self.correct_path_segment = "/usercollection/vO2_max" # Note the casing @patch("requests.get") def test_get_vo2_max_documents_no_params(self, mock_get):