Class FeatureToggle

java.lang.Object
com.example.featuretogglelibrary.FeatureToggle

public class FeatureToggle extends Object
The FeatureToggle class provides utility methods to interact with feature toggle APIs. It allows applications to manage and fetch feature toggles dynamically.
  • Constructor Details

    • FeatureToggle

      public FeatureToggle()
  • Method Details

    • getActiveFeatures

      public static void getActiveFeatures(Context context, FeatureToggle.Callback_Data<List<FeatureToggleItem>> callback)
      Fetches all active feature toggles for the package.
      Parameters:
      context - The Android context, used to get the package name.
      callback - The callback to handle the list of active feature toggles or errors.
    • getAllFeatures

      public static void getAllFeatures(Context context, FeatureToggle.Callback_Data<List<FeatureToggleItem>> callback)
      Fetch all feature toggles for the current application, including inactive ones.
      Parameters:
      context - The Android context, used to retrieve the package name.
      callback - The callback to handle the list of all feature toggles or errors.
    • createFeatureToggle

      public static void createFeatureToggle(Context context, FeatureToggleItem featureToggle, FeatureToggle.Callback_Data<String> callback)
      Create a new feature toggle.
      Parameters:
      context - The Android context, used to retrieve the package name.
      featureToggle - The feature toggle object containing the details to be created.
      callback - The callback to handle the result of the operation or errors.
    • deleteFeatureToggle

      public static void deleteFeatureToggle(Context context, String featureId, FeatureToggle.Callback_Data<String> callback)
      Deletes a specific feature toggle for the sepcified package.
      Parameters:
      context - The Android context, used to get the package name.
      featureId - The ID of the feature toggle to delete.
      callback - The callback to handle success or error responses.
    • updateFeatureDates

      public static void updateFeatureDates(Context context, String featureId, FeatureToggleItem updatedData, FeatureToggle.Callback_Data<String> callback)
      Updates the beginning and expiration dates of a specific feature toggle.
      Parameters:
      context - The Android context, used to retrieve the package name.
      featureId - The unique ID of the feature toggle to update.
      updatedData - An instance of FeatureToggleItem containing the updated dates.
      callback - The callback to handle the result of the operation or errors.
    • getRecentFeatureToggles

      public static void getRecentFeatureToggles(Context context, FeatureToggle.Callback_Data<List<FeatureToggleItem>> callback)
      fetch all feature toggles created in the last 30 days for a specific package.
      Parameters:
      context - The Android context, used to get the package name.
      callback - The callback to handle the list of recent feature toggles or errors.
    • updateFeatureInfo

      public static void updateFeatureInfo(Context context, String featureId, FeatureToggleItem updatedData, FeatureToggle.Callback_Data<String> callback)
      Update the name or description of a feature toggle
      Parameters:
      context - The Android context, used to get the package name.
      featureId - The ID of the feature toggle to update.
      updatedData - The updated information for the feature toggle.
      callback - The callback to handle the success or error responses.
    • getActiveFeaturesInRange

      public static void getActiveFeaturesInRange(Context context, String startDate, String endDate, FeatureToggle.Callback_Data<List<FeatureToggleItem>> callback)
      Fetch all active feature toggles for the current app within a specific date range.
      Parameters:
      context - The Android context, used to get the package name.
      startDate - The start date of the range (format: YYYY-MM-DD).
      endDate - The end date of the range (format: YYYY-MM-DD).
      callback - The callback to handle success or error responses.
    • getFeatureToggleStatistics

      public static void getFeatureToggleStatistics(Context context, FeatureToggle.Callback_Data<FeaturesStatistics> callback)
      Fetch feature toggle statistics for the current app.
      Parameters:
      context - The Android context, used to get the package name.
      callback - The callback to handle success or error responses. Example usage:
       FeatureToggle.getFeatureToggleStatistics(context,
           new FeatureToggle.Callback_Data<FeaturesStatistics>() {
               public void onSuccess(FeaturesStatistics data) {
                   // Handle the successful response
                   Log.d("FeatureToggle", "Total Features: " + data.getTotalFeatures());
                   Log.d("FeatureToggle", "Active Features: " + data.getActiveFeatures());
               }
      
               public void onError(String errorMessage) {
                   // Handle the error response
                   Log.e("FeatureToggle", "Error fetching statistics: " + errorMessage);
               }
           }
       );
       
    • getFeatureTogglesByDate

      public static void getFeatureTogglesByDate(Context context, String date, FeatureToggle.Callback_Data<List<FeatureToggleItem>> callback)
      Fetch all feature toggles active on a specific date for the specified package.
      Parameters:
      context - The Android context, used to get the package name.
      date - The date for which feature toggles are to be fetched, in format YYYY-MM-DD.
      callback - The callback to handle the data or errors.
    • deleteAllFeatureToggles

      public static void deleteAllFeatureToggles(Context context, FeatureToggle.Callback_Data<String> callback)
      Delete all feature toggles for the current app.
      Parameters:
      context - The Android context, used to get the package name.
      callback - The callback to handle success or error responses.