mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-06-30 18:15:11 +00:00
[ACS-8037] Add new endpoint to confirm/reject prediction (#9746)
* [ACS-8037] Add new endpoint to confirm/reject prediction * [ACS-8037] Fix prediction api docs
This commit is contained in:
parent
6bdfd83dac
commit
8dc1a9bed0
@ -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);
|
||||
});
|
||||
});
|
||||
|
@ -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<PredictionPaging> {
|
||||
return from(this.predictionsApi.getPredictions(nodeId));
|
||||
}
|
||||
|
||||
/**
|
||||
* Review a prediction
|
||||
*
|
||||
* @param predictionId The identifier of prediction.
|
||||
* @param reviewStatus Review status to apply.
|
||||
* @returns Observable<void>
|
||||
*/
|
||||
reviewPrediction(predictionId: string, reviewStatus: ReviewStatus): Observable<void> {
|
||||
return from(this.predictionsApi.reviewPrediction(predictionId, reviewStatus));
|
||||
}
|
||||
}
|
||||
|
@ -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<void>
|
||||
*/
|
||||
reviewPrediction(predictionId: string, reviewStatus: ReviewStatus): Promise<void> {
|
||||
throwIfNotDefined(predictionId, 'predictionId');
|
||||
throwIfNotDefined(reviewStatus, 'reviewStatus');
|
||||
|
||||
const pathParams = {
|
||||
predictionId,
|
||||
reviewStatus
|
||||
};
|
||||
|
||||
return this.post({
|
||||
path: '/predictions/{predictionId}/review',
|
||||
pathParams,
|
||||
returnType: Promise<void>
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -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.
|
||||
|
||||
<a name="getPredictions"></a>
|
||||
# **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)
|
||||
|
||||
|
||||
<a name="reviewPrediction"></a>
|
||||
# **reviewPrediction**
|
||||
> Promise\<void\> 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\<void\>**
|
||||
|
Loading…
x
Reference in New Issue
Block a user