Class FeatureController
java.lang.Object
com.example.featuretogglelibrary.api.FeatureController
The FeatureController class is responsible for interacting with the backend API
to manage feature toggles for the application.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcreateNewFeatureToggle(FeatureToggleItem featureToggle, GenericCallBack genericCallBack) Sends a request to create a new feature toggle in the backend.voiddeleteAllFeatureToggles(String packageName, GenericCallBack<String> genericCallBack) Deletes all feature toggles for a specific package.voiddeleteFeatureToggle(String packageName, String featureId, GenericCallBack genericCallBack) Sends a request to delete a specific feature toggle from the backend.voidfetchAllActiveFeatures(String packageName, GenericCallBack<List<FeatureToggleItem>> callbackFeatures) Fetches all active feature toggles for the given package.voidfetchAllFeatureToggles(String packageName, GenericCallBack<List<FeatureToggleItem>> callbackFeatures) Fetches all feature toggles for the given package.voidgetActiveFeaturesInRange(String packageName, String startDate, String endDate, GenericCallBack<List<FeatureToggleItem>> callbackFeatures) Retrieves all active feature toggles for a specific package within a specified date range.voidgetFeatureTogglesByDate(String packageName, String date, GenericCallBack<List<FeatureToggleItem>> genericCallBack) Fetches all feature toggles for a specific package that are active on a given date.voidgetFeatureToggleStatistics(String packageName, GenericCallBack genericCallBack) Fetches statistics about feature toggles for a specific package.voidgetRecentFeatureToggles(String packageName, GenericCallBack<List<FeatureToggleItem>> callbackFeatures) Retrieves all feature toggles created in the last 30 days for a specific package.voidupdateFeatureDates(String packageName, String featureId, FeatureToggleItem updatedData, GenericCallBack genericCallBack) Updates the beginning and expiration dates of a specific feature toggle.voidupdateFeatureInfo(String packageName, String featureId, FeatureToggleItem updatedData, GenericCallBack genericCallBack) Updates the name and descriotion of a specific feature toggle for a package.
-
Constructor Details
-
FeatureController
public FeatureController()
-
-
Method Details
-
fetchAllFeatureToggles
public void fetchAllFeatureToggles(String packageName, GenericCallBack<List<FeatureToggleItem>> callbackFeatures) Fetches all feature toggles for the given package.- Parameters:
packageName- The package name to retrieve feature toggles for.callbackFeatures- The callback to handle the result or errors.
-
fetchAllActiveFeatures
public void fetchAllActiveFeatures(String packageName, GenericCallBack<List<FeatureToggleItem>> callbackFeatures) Fetches all active feature toggles for the given package.- Parameters:
packageName- The package name to retrieve active feature toggles for.callbackFeatures- The callback to handle the result or errors.
-
createNewFeatureToggle
public void createNewFeatureToggle(FeatureToggleItem featureToggle, GenericCallBack genericCallBack) Sends a request to create a new feature toggle in the backend.- Parameters:
featureToggle- TheFeatureToggleItemobject containing the details of the new feature toggle to be created.genericCallBack- A callback to handle success or error responses from the server.
-
deleteFeatureToggle
public void deleteFeatureToggle(String packageName, String featureId, GenericCallBack genericCallBack) Sends a request to delete a specific feature toggle from the backend.- Parameters:
packageName- The name of the package to which the feature toggle belongs.featureId- The unique ID of the feature toggle to be deleted.genericCallBack- A callback to handle success or error responses from the server.
-
updateFeatureDates
public void updateFeatureDates(String packageName, String featureId, FeatureToggleItem updatedData, GenericCallBack genericCallBack) Updates the beginning and expiration dates of a specific feature toggle.- Parameters:
packageName- The name of the package to which the feature toggle belongs.featureId- The unique ID of the feature toggle to be updated.updatedData- AFeatureToggleItemobject containing the new beginning and expiration dates.genericCallBack- A callback to handle success or error responses from the server. Example usage:FeatureToggleItem updatedData = new FeatureToggleItem(); updatedData.setBeginning_date("2025-02-01 00:00:00"); updatedData.setExpiration_date("2025-12-31 23:59:59"); featureController.updateFeatureDates( "com.example.myapp", // Replace with the actual package name "814b5dda-c77b-4929-9a40-b683c56adbc6", // Replace with the actual feature ID updatedData, new GenericCallBack<String>() { public void success(String message) { System.out.println("Feature dates updated successfully: " + message); } public void error(String error) { System.err.println("Error updating feature dates: " + error); } } );
-
getRecentFeatureToggles
public void getRecentFeatureToggles(String packageName, GenericCallBack<List<FeatureToggleItem>> callbackFeatures) Retrieves all feature toggles created in the last 30 days for a specific package.- Parameters:
packageName- The name of the package for which recent feature toggles are to be fetched.callbackFeatures- A callback to handle the success or error responses.
-
updateFeatureInfo
public void updateFeatureInfo(String packageName, String featureId, FeatureToggleItem updatedData, GenericCallBack genericCallBack) Updates the name and descriotion of a specific feature toggle for a package.- Parameters:
packageName- The name of the package containing the feature toggle.featureId- The unique identifier of the feature toggle to be updated.updatedData- The updated feature toggle data, including changes to be applied.genericCallBack- A callback to handle the success or error responses.
-
getActiveFeaturesInRange
public void getActiveFeaturesInRange(String packageName, String startDate, String endDate, GenericCallBack<List<FeatureToggleItem>> callbackFeatures) Retrieves all active feature toggles for a specific package within a specified date range.- Parameters:
packageName- The name of the package containing the feature toggles.startDate- The start date of the range in the format "YYYY-MM-DD HH:MM:SS".endDate- The end date of the range in the format "YYYY-MM-DD HH:MM:SS".callbackFeatures- A callback to handle the success or error responses, providing a list of active feature toggles or an error message.
-
getFeatureToggleStatistics
Fetches statistics about feature toggles for a specific package.- Parameters:
packageName- The name of the package for which the statistics are to be retrieved.genericCallBack- A callback to handle the success or error responses. On success, it provides aFeaturesStatisticsobject containing the statistics.
-
getFeatureTogglesByDate
public void getFeatureTogglesByDate(String packageName, String date, GenericCallBack<List<FeatureToggleItem>> genericCallBack) Fetches all feature toggles for a specific package that are active on a given date.- Parameters:
packageName- The name of the package for which feature toggles are to be retrieved.date- The specific date in the format "YYYY-MM-DD", used to filter active toggles.genericCallBack- A callback to handle the success or error responses. On success, it provides a list ofFeatureToggleItemobjects.
-
deleteAllFeatureToggles
Deletes all feature toggles for a specific package.- Parameters:
packageName- The name of the package whose feature toggles are to be deleted.genericCallBack- A callback to handle the result of the operation. On success, it provides a success message as aString.
-