diff --git a/lib/content-services/src/lib/prediction/services/prediction.service.spec.ts b/lib/content-services/src/lib/prediction/services/prediction.service.spec.ts index 0cd9707e74..8e88c50393 100644 --- a/lib/content-services/src/lib/prediction/services/prediction.service.spec.ts +++ b/lib/content-services/src/lib/prediction/services/prediction.service.spec.ts @@ -18,7 +18,7 @@ import { PredictionService } from './prediction.service'; import { TestBed } from '@angular/core/testing'; import { ContentTestingModule } from '../../testing/content.testing.module'; -import { Prediction, PredictionEntry, PredictionPaging, PredictionPagingList } from '@alfresco/js-api'; +import { Prediction, PredictionEntry, PredictionPaging, PredictionPagingList, ReviewStatus } from '@alfresco/js-api'; describe('PredictionService', () => { let service: PredictionService; @@ -44,4 +44,11 @@ describe('PredictionService', () => { service.getPredictions('test id'); expect(service.predictionsApi.getPredictions).toHaveBeenCalledWith('test id'); }); + + it('should call reviewPrediction on PredictionsApi with predictionId and reviewStatus', () => { + spyOn(service.predictionsApi, 'reviewPrediction').and.returnValue(Promise.resolve()); + + service.reviewPrediction('test id', ReviewStatus.CONFIRMED); + expect(service.predictionsApi.reviewPrediction).toHaveBeenCalledWith('test id', ReviewStatus.CONFIRMED); + }); }); diff --git a/lib/content-services/src/lib/prediction/services/prediction.service.ts b/lib/content-services/src/lib/prediction/services/prediction.service.ts index 7900927d2c..020749f819 100644 --- a/lib/content-services/src/lib/prediction/services/prediction.service.ts +++ b/lib/content-services/src/lib/prediction/services/prediction.service.ts @@ -17,7 +17,7 @@ import { Injectable } from '@angular/core'; import { AlfrescoApiService } from '@alfresco/adf-core'; -import { PredictionsApi, PredictionPaging } from '@alfresco/js-api'; +import { PredictionsApi, PredictionPaging, ReviewStatus } from '@alfresco/js-api'; import { from, Observable } from 'rxjs'; @Injectable({ providedIn: 'root' }) @@ -40,4 +40,15 @@ export class PredictionService { getPredictions(nodeId: string): Observable { return from(this.predictionsApi.getPredictions(nodeId)); } + + /** + * Review a prediction + * + * @param predictionId The identifier of prediction. + * @param reviewStatus Review status to apply. + * @returns Observable + */ + reviewPrediction(predictionId: string, reviewStatus: ReviewStatus): Observable { + return from(this.predictionsApi.reviewPrediction(predictionId, reviewStatus)); + } } diff --git a/lib/js-api/src/api/hxi-connector-api/api/predictions.api.ts b/lib/js-api/src/api/hxi-connector-api/api/predictions.api.ts index 1f57dfdf56..eb97b1a25f 100644 --- a/lib/js-api/src/api/hxi-connector-api/api/predictions.api.ts +++ b/lib/js-api/src/api/hxi-connector-api/api/predictions.api.ts @@ -17,7 +17,7 @@ import { BaseApi } from './base.api'; import { throwIfNotDefined } from '../../../assert'; -import { PredictionPaging } from '../model'; +import { PredictionPaging, ReviewStatus } from '../model'; export class PredictionsApi extends BaseApi { /** @@ -39,4 +39,27 @@ export class PredictionsApi extends BaseApi { returnType: PredictionPaging }); } + + /** + * Confirm or reject a prediction + * + * @param predictionId The identifier of a prediction. + * @param reviewStatus New status to apply for prediction. Can be either 'confirmed' or 'rejected'. + * @returns Promise + */ + reviewPrediction(predictionId: string, reviewStatus: ReviewStatus): Promise { + throwIfNotDefined(predictionId, 'predictionId'); + throwIfNotDefined(reviewStatus, 'reviewStatus'); + + const pathParams = { + predictionId, + reviewStatus + }; + + return this.post({ + path: '/predictions/{predictionId}/review', + pathParams, + returnType: Promise + }); + } } diff --git a/lib/js-api/src/api/hxi-connector-api/docs/PredictionsApi.md b/lib/js-api/src/api/hxi-connector-api/docs/PredictionsApi.md index f4ce759cd2..c7a2ee8ad8 100644 --- a/lib/js-api/src/api/hxi-connector-api/docs/PredictionsApi.md +++ b/lib/js-api/src/api/hxi-connector-api/docs/PredictionsApi.md @@ -5,6 +5,7 @@ All URIs are relative to *https://localhost/alfresco/api/-default-/private/hxi/v Method | HTTP request | Description ------------- | ------------- | ------------- [**getPredictions**](PredictionsApi.md#getPredictions) | **GET** /nodes/{nodeId}/predictions | Get predictions for node. +[**reviewPrediction**](PredictionsApi.md#reviewPrediction) | **POST** /predictions/{predictionId}/review | Reject or confirm prediction. # **getPredictions** @@ -16,8 +17,26 @@ Get predictions for a node. Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **nodeId** | **string**| The identifier of a node. | + **nodeId** | **string** | The identifier of a node. | ### Return type [**PredictionPaging**](PredictionPaging.md) + + + +# **reviewPrediction** +> Promise\ reviewPrediction(predictionId, reviewStatus) + +Confirm or reject a prediction. + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **predictionId** | **string** | The identifier of a prediction. | + **reviewStatus** | **ReviewStatus** | Review status for prediction. Can be confirmed or rejected. | + +### Return type + +**Promise\**