Skip to content

Account Management

The AccountManager class handles all operations related to account management and settings.

Account Manager Class

notedx_sdk.account.account_manager.AccountManager

AccountManager(client: NoteDxClient)

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: NoteDxClient

Functions

get_account

get_account() -> Dict[str, Any]

Get current account information and settings.

GET /user/account/info
RETURNS DESCRIPTION
Dict[str, Any]

Dict containing:

Dict[str, Any]
  • company_name: Company or organization name
Dict[str, Any]
  • contact_email: Primary contact email
Dict[str, Any]
  • phone_number: Contact phone number
Dict[str, Any]
  • address: Business address
Dict[str, Any]
  • account_status: Current account status ('active', 'inactive', 'cancelled')
Dict[str, Any]
  • created_at: Account creation timestamp (ISO format)
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

Example
account_info = client.account.get_account()
print(f"Account Status: {account_info['account_status']}")

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.

POST /user/account/update
PARAMETER DESCRIPTION
company_name

New company or organization name

TYPE: Optional[str] DEFAULT: None

contact_email

New contact email address

TYPE: Optional[str] DEFAULT: None

phone_number

New contact phone number

TYPE: Optional[str] DEFAULT: None

address

New business address

TYPE: Optional[str] DEFAULT: None

RETURNS DESCRIPTION
Dict[str, Any]

Dict containing:

Dict[str, Any]
  • message: "Account information updated successfully"
Dict[str, Any]
  • updated_fields: List of fields that were updated
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

Example
result = client.account.update_account(
    company_name="New Corp",
    contact_email="contact@newcorp.com"
)
print(f"Updated fields: {result['updated_fields']}")

cancel_account

cancel_account() -> Dict[str, Any]

Cancel the current account.

POST /user/cancel-account

This operation:

  1. Deactivates all live API keys
  2. Updates account status to 'cancelled'
  3. Records cancellation timestamp
  4. Triggers final billing process
RETURNS DESCRIPTION
Dict[str, Any]

Dict containing:

Dict[str, Any]
  • message: "Account cancelled successfully"
Dict[str, Any]
  • user_id: Account identifier
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

Example
result = client.account.cancel_account()
print(f"Account {result['user_id']} cancelled")

reactivate_account

reactivate_account() -> Dict[str, Any]

Reactivate a cancelled account.

POST /user/reactivate-account

This operation:

  1. Verifies account is in 'cancelled' state
  2. Checks for unpaid bills
  3. Sets account status to 'inactive'
  4. Records reactivation timestamp
RETURNS DESCRIPTION
Dict[str, Any]

Dict containing:

Dict[str, Any]
  • message: "Account reactivated successfully"
Dict[str, Any]
  • user_id: Account identifier
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
result = client.account.reactivate_account()
print(f"Account {result['user_id']} reactivated")
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"