aboutsummaryrefslogtreecommitdiff
path: root/src/app/services/rating.service.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/services/rating.service.ts')
-rw-r--r--src/app/services/rating.service.ts20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/app/services/rating.service.ts b/src/app/services/rating.service.ts
index 630a43c..5a86b67 100644
--- a/src/app/services/rating.service.ts
+++ b/src/app/services/rating.service.ts
@@ -14,4 +14,24 @@ import { TokenService } from './token.service';
export class RatingService {
constructor(private _http: HttpClient, private _tokenService: TokenService)
{ }
+
+ createRatingWithSessionStorageRequest(postId: Guid, isLike: boolean): Observable<object> {
+ const userId = this._tokenService.getUserIdFromSessionStorageToken();
+ const token = this._tokenService.getTokenFromSessionStorage();
+
+ return this.createRatingRequest(userId, token, postId, isLike);
+ }
+
+ createRatingRequest(userId: Guid, authToken: string, postId: Guid, isLike: boolean): Observable<object> {
+ const body = {
+ postId: postId.toString(),
+ isLike: isLike
+ };
+ const options = {
+ params: new HttpParams().set('UserId', userId.toString()),
+ headers: new HttpHeaders().set('Authorization', 'Bearer ' + authToken)
+ };
+
+ return this._http.post(AppConstants.API_RATING_URL, body, options);
+ }
}