Skip to main content

usecase.go

usecase.go - Overview

  1. Overview

This file defines the Usecase interface for managing user and organization preferences. It outlines the methods for retrieving, updating, and listing preferences at both the organization and user levels.

  1. Detailed Documentation

Usecase Interface

The Usecase interface defines the contract for preference management operations.

GetOrgPreference

  • Purpose: Retrieves a specific organization preference.
  • Parameters:
    • ctx (context.Context): The context for the operation.
    • preferenceId (string): The ID of the preference to retrieve.
    • orgId (string): The ID of the organization.
  • Returns:
    • *preferencetypes.GettablePreference: The retrieved preference, or nil if not found.
    • error: An error if the operation fails.

UpdateOrgPreference

  • Purpose: Updates a specific organization preference.
  • Parameters:
    • ctx (context.Context): The context for the operation.
    • preferenceId (string): The ID of the preference to update.
    • preferenceValue (interface<>): The new value for the preference.
    • orgId (string): The ID of the organization.
  • Returns:
    • error: An error if the operation fails.

GetAllOrgPreferences

  • Purpose: Retrieves all preferences for a specific organization.
  • Parameters:
    • ctx (context.Context): The context for the operation.
    • orgId (string): The ID of the organization.
  • Returns:
    • []*preferencetypes.PreferenceWithValue: A slice of preferences with their values.
    • error: An error if the operation fails.

GetUserPreference

  • Purpose: Retrieves a specific user preference.
  • Parameters:
    • ctx (context.Context): The context for the operation.
    • preferenceId (string): The ID of the preference to retrieve.
    • orgId (string): The ID of the organization.
    • userId (string): The ID of the user.
  • Returns:
    • *preferencetypes.GettablePreference: The retrieved preference, or nil if not found.
    • error: An error if the operation fails.

UpdateUserPreference

  • Purpose: Updates a specific user preference.
  • Parameters:
    • ctx (context.Context): Implicit parameter through the interface.
    • preferenceId (string): The ID of the preference to update.
    • preferenceValue (interface<>): The new value for the preference.
    • userId (string): The ID of the user.
  • Returns:
    • error: An error if the operation fails.

GetAllUserPreferences

  • Purpose: Retrieves all preferences for a specific user.
  • Parameters:
    • ctx (context.Context): The context for the operation.
    • orgId (string): The ID of the organization.
    • userId (string): The ID of the user.
  • Returns:
    • []*preferencetypes.PreferenceWithValue: A slice of preferences with their values.
    • error: An error if the operation fails.
  1. Code Examples

None.

  1. Clarity and Accuracy

The documentation is based solely on the code provided.

  1. Markdown & MDX Perfection

No issues found.

  1. Edge Cases To Avoid Breaking MDX:

No issues found.

  1. Getting Started Relevance

Include in Getting Started: NO