aboutsummaryrefslogtreecommitdiff
path: root/src/app/services/rating.service.ts
diff options
context:
space:
mode:
authorDanail Dimitrov <danaildimitrov321@gmail.com>2021-03-11 21:57:16 +0200
committerDanail Dimitrov <danaildimitrov321@gmail.com>2021-03-11 21:57:16 +0200
commit051da12e0edd5408c902695fbc45ddd15d7972b1 (patch)
tree8b626c44f135f166e9833aa9fbb5d92adb455193 /src/app/services/rating.service.ts
parentfe4c9eaeac345c63e0c08c43b9dc3185d07716e8 (diff)
downloadDevHive-Angular-051da12e0edd5408c902695fbc45ddd15d7972b1.tar
DevHive-Angular-051da12e0edd5408c902695fbc45ddd15d7972b1.tar.gz
DevHive-Angular-051da12e0edd5408c902695fbc45ddd15d7972b1.zip
added upvote post functionality
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);
+ }
}