Account Management¶
The AccountManager
class handles all operations related to account management and settings.
Account Manager Class¶
notedx_sdk.account.account_manager.AccountManager ¶
Handles account management operations for the NoteDx API.
This class provides methods for:
- Account information retrieval and updates
- Account lifecycle management
Note
Most methods in this class require Firebase authentication (email/password). API key authentication is not supported for account management operations. Account creation is handled by NoteDxClient.create_account().
Example
from notedx_sdk import NoteDxClient
# Initialize with email/password
client = NoteDxClient(
email="user@example.com",
password="your-password"
)
# Get account info
account_info = client.account.get_account()
print(f"Company: {account_info['company_name']}")
# Update account
result = client.account.update_account(
company_name="New Company Name",
contact_email="new@email.com"
)
Initialize the account manager.
PARAMETER | DESCRIPTION |
---|---|
client |
The parent NoteDxClient instance
TYPE:
|
Functions¶
get_account ¶
Get current account information and settings.
RETURNS | DESCRIPTION |
---|---|
Dict[str, Any]
|
Dict containing: |
Dict[str, Any]
|
|
Dict[str, Any]
|
|
Dict[str, Any]
|
|
Dict[str, Any]
|
|
Dict[str, Any]
|
|
Dict[str, Any]
|
|
RAISES | DESCRIPTION |
---|---|
AuthenticationError
|
If Firebase authentication is not available |
AuthorizationError
|
If not authorized to access this data |
NotFoundError
|
If user not found |
NetworkError
|
If connection issues occur |
update_account ¶
update_account(
company_name: Optional[str] = None,
contact_email: Optional[str] = None,
phone_number: Optional[str] = None,
address: Optional[str] = None,
) -> Dict[str, Any]
Update account information and settings.
PARAMETER | DESCRIPTION |
---|---|
company_name |
New company or organization name
TYPE:
|
contact_email |
New contact email address
TYPE:
|
phone_number |
New contact phone number
TYPE:
|
address |
New business address
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Dict[str, Any]
|
Dict containing: |
Dict[str, Any]
|
|
Dict[str, Any]
|
|
RAISES | DESCRIPTION |
---|---|
AuthenticationError
|
If Firebase authentication is not available |
AuthorizationError
|
If not authorized to update account |
BadRequestError
|
If invalid JSON format in request |
InvalidFieldError
|
If no valid fields provided to update |
NetworkError
|
If connection issues occur |
cancel_account ¶
Cancel the current account.
This operation:
- Deactivates all live API keys
- Updates account status to 'cancelled'
- Records cancellation timestamp
- Triggers final billing process
RETURNS | DESCRIPTION |
---|---|
Dict[str, Any]
|
Dict containing: |
Dict[str, Any]
|
|
Dict[str, Any]
|
|
RAISES | DESCRIPTION |
---|---|
AuthenticationError
|
If Firebase authentication is not available |
AuthorizationError
|
If not authorized to cancel |
NotFoundError
|
If user not found |
PaymentRequiredError
|
If outstanding balance exists |
NetworkError
|
If connection issues occur |
reactivate_account ¶
Reactivate a cancelled account.
This operation:
- Verifies account is in 'cancelled' state
- Checks for unpaid bills
- Sets account status to 'inactive'
- Records reactivation timestamp
RETURNS | DESCRIPTION |
---|---|
Dict[str, Any]
|
Dict containing: |
Dict[str, Any]
|
|
Dict[str, Any]
|
|
RAISES | DESCRIPTION |
---|---|
AuthenticationError
|
If Firebase authentication is not available |
AuthorizationError
|
If not authorized to reactivate |
NotFoundError
|
If user not found |
BadRequestError
|
If account is not in cancelled state |
PaymentRequiredError
|
If unpaid bills exist |
NetworkError
|
If connection issues occur |
Example
Note
- Only cancelled accounts can be reactivated
- Account will be set to 'inactive' status
- New API keys must be created after reactivation
- Previous data remains accessible if within retention period
Authentication¶
Note
All account management operations require Firebase authentication (email/password). API key authentication is not supported for these endpoints.
Usage Examples¶
Get Account Information¶
# Initialize with Firebase auth
client = NoteDxClient(
email="user@example.com",
password="your-password"
)
# Get account info
account_info = client.account.get_account()
print(f"Company: {account_info['company_name']}")
print(f"Status: {account_info['account_status']}")
Update Account Settings¶
# Update account information
result = client.account.update_account(
company_name="New Company Name",
contact_email="new@example.com",
phone_number="+1234567890",
address="123 Medical Center Dr"
)
Account Lifecycle Management¶
# Cancel account
result = client.account.cancel_account()
print(f"Account {result['user_id']} cancelled")
# Later, reactivate account
result = client.account.reactivate_account()
print(f"Account {result['user_id']} reactivated")
Error Handling¶
from notedx_sdk.exceptions import (
AuthenticationError,
AuthorizationError,
InvalidFieldError
)
try:
result = client.account.update_account(
contact_email="invalid-email"
)
except AuthenticationError:
print("Firebase authentication required")
except AuthorizationError:
print("Not authorized to update account")
except InvalidFieldError as e:
print(f"Invalid field value: {e}")
REST API Equivalent¶
# Get account info
curl "https://api.notedx.io/v1/user/account/info" \
-H "Authorization: Bearer your-firebase-token"
# Update account
curl -X POST "https://api.notedx.io/v1/user/account/update" \
-H "Authorization: Bearer your-firebase-token" \
-H "Content-Type: application/json" \
-d '{
"company_name": "New Company Name",
"contact_email": "new@example.com"
}'
# Cancel account
curl -X POST "https://api.notedx.io/v1/user/cancel-account" \
-H "Authorization: Bearer your-firebase-token"
# Reactivate account
curl -X POST "https://api.notedx.io/v1/user/reactivate-account" \
-H "Authorization: Bearer your-firebase-token"