Source code for fatsecret.resources._generated.profile

# AUTO-GENERATED by scripts/oas-sync emit-resource Profile Auth. Do not edit by hand.
"""Resource wrapper for the OAS ``Profile Auth`` tag (generated)."""

from __future__ import annotations

from typing import Any, Optional

from .._base import BaseResource

from ...models._generated.profile_auth import Profile


class ProfileResource(BaseResource):
    """Resource methods for the OAS `Profile Auth` tag (generated)."""

[docs] def create_v1( self, user_id: str, ) -> Optional[Profile]: """Creates a new profile and returns the oauth_token and oauth_secret for the new profile. The token and secret returned by this method are persisted indefinitely and may be used in order to provide profile-specific information storage for users including food and exercise diaries and weight tracking. The response is a newly allocated oauth_token and associated oauth_secret which should be stored and re-used to provide ongoing API services on behalf of a user. The results from this call should be saved and subsequently used to provide ongoing storage to users of your site or service. You are obliged to ensure that the values are held securely and to not disclose any oauth_secret values. You should maintain the relationship between your users and the token and secret values you allocate for them. In addition to creating profiles for your own users, you can also use the full 3-legged OAuth provided by fatsecret.com to attain an access token for a profile that is linked to a user account on fatsecret.com. For more information click here. :param user_id: You can set your own ID for the newly created profile if you do not wish to store the auth_token and auth_secret :return: :class:`Profile` instance, or ``None`` when the response is empty. Notes: profile.create (v1). Premier-only. """ params: dict[str, Any] = {"method": "profile.create"} params["user_id"] = user_id payload = self._client._call(params, method="POST") raw = self._client._unwrap(payload, "profile") if raw is None: return None return Profile.model_validate(raw)
[docs] def get_auth_v1( self, user_id: Optional[str] = None, ) -> Optional[Profile]: """Returns the authentication information for a nominated user. You can also use the full 3-legged OAuth provided by fatsecret.com to attain an access token for a profile that is linked to a user account on fatsecret.com. For more information click here. :param user_id: You can set your own ID for the newly created profile if you do not wish to store the auth_token and auth_secret :return: :class:`Profile` instance, or ``None`` when the response is empty. Notes: profile.get_auth (v1). Premier-only. """ params: dict[str, Any] = {"method": "profile.get_auth"} self._client._set_optional( params, [ ("user_id", user_id), ], ) payload = self._client._call(params) raw = self._client._unwrap(payload, "profile") if raw is None: return None return Profile.model_validate(raw)
[docs] def get_v1( self, ) -> Optional[Profile]: """Returns general status information for a nominated user. :return: :class:`Profile` instance, or ``None`` when the response is empty. Notes: profile.get (v1). Premier-only. """ params: dict[str, Any] = {"method": "profile.get"} payload = self._client._call(params) raw = self._client._unwrap(payload, "profile") if raw is None: return None return Profile.model_validate(raw)
ProfileResource.__module__ = "fatsecret.resources.profile" __all__ = ["ProfileResource"]