aboutsummaryrefslogtreecommitdiff
path: root/src/app/services/profile-picture.service.ts
diff options
context:
space:
mode:
authorKamen Mladenov <kamen.d.mladenov@protonmail.com>2021-04-09 19:55:59 +0300
committerGitHub <noreply@github.com>2021-04-09 19:55:59 +0300
commitf849e37ccdd6fd48f83119a3b3b65cdd8b765dc3 (patch)
tree83b88a773bb7dc053bb3aced35bce302264ec925 /src/app/services/profile-picture.service.ts
parentbcd88af53b1a920d728ec98b45daa9ac2e2c0917 (diff)
parentc13889759d70687de6833c505221c203f65fedb8 (diff)
downloadDevHive-Angular-0.2.tar
DevHive-Angular-0.2.tar.gz
DevHive-Angular-0.2.zip
Merge pull request #7 from Team-Kaleidoscope/devHEADv0.2main
Second Stage: Complete
Diffstat (limited to 'src/app/services/profile-picture.service.ts')
-rw-r--r--src/app/services/profile-picture.service.ts32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/app/services/profile-picture.service.ts b/src/app/services/profile-picture.service.ts
new file mode 100644
index 0000000..8b9d0a3
--- /dev/null
+++ b/src/app/services/profile-picture.service.ts
@@ -0,0 +1,32 @@
+import { HttpClient, HttpHeaders, HttpParams } from '@angular/common/http';
+import { Injectable } from '@angular/core';
+import { Guid } from 'guid-typescript';
+import { Observable } from 'rxjs';
+import { AppConstants } from '../app-constants.module';
+import { TokenService } from './token.service';
+
+@Injectable({
+ providedIn: 'root'
+})
+export class ProfilePictureService {
+ constructor(private _http: HttpClient, private _tokenService: TokenService)
+ { }
+
+ putPictureWithSessionStorageRequest(newPicture: File): Observable<object> {
+ const userId = this._tokenService.getUserIdFromSessionStorageToken();
+ const token = this._tokenService.getTokenFromSessionStorage();
+
+ return this.putRatingRequest(userId, token, newPicture);
+ }
+
+ putRatingRequest(userId: Guid, authToken: string, newPicture: File): Observable<object> {
+ const options = {
+ params: new HttpParams().set('UserId', userId.toString()),
+ headers: new HttpHeaders().set('Authorization', 'Bearer ' + authToken)
+ };
+ const form = new FormData();
+ form.append('picture', newPicture);
+
+ return this._http.put(AppConstants.API_PROFILE_PICTURE_URL, form, options);
+ }
+}