@solidpepper/solidpepper-service 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -99,7 +99,13 @@ class SettingsService {
99
99
  year: '2019',
100
100
  };
101
101
  }
102
+ setToken(token) {
103
+ this.customToken = token;
104
+ }
102
105
  getToken() {
106
+ if (this.customToken) {
107
+ return this.customToken;
108
+ }
103
109
  if (this.tokenGetter) {
104
110
  return this.tokenGetter();
105
111
  }
@@ -132,11 +138,14 @@ class SettingsService {
132
138
  getHeaders() {
133
139
  let token = this.getToken();
134
140
  let language = this.getLanguage();
135
- this.headers = {
136
- Authorization: 'Bearer ' + token,
141
+ let headersObj = {
137
142
  'Content-Type': 'application/json',
138
143
  'Accept-Language': language,
139
144
  };
145
+ if (token && token !== 'undefined' && token !== 'null') {
146
+ headersObj['Authorization'] = 'Bearer ' + token;
147
+ }
148
+ this.headers = headersObj;
140
149
  return this.headers;
141
150
  }
142
151
  getPrimoTexto(name) {
@@ -9909,6 +9918,45 @@ class Document {
9909
9918
  }
9910
9919
  }
9911
9920
 
9921
+ class DocumentCommentService {
9922
+ constructor(http, settingsService) {
9923
+ this.http = http;
9924
+ this.settingsService = settingsService;
9925
+ }
9926
+ getAliasQuery() {
9927
+ const alias = this.settingsService.getSettings('alias') || this.settingsService.getAppSetting('alias');
9928
+ return alias ? `?alias=${alias}` : '';
9929
+ }
9930
+ getComments(documentGuid) {
9931
+ const headers = this.settingsService.getHeaders();
9932
+ const apiUrl = this.settingsService.getSettings('apiUrl');
9933
+ return this.http.get(`${apiUrl}dam/documents/${documentGuid}/comments${this.getAliasQuery()}`, { headers });
9934
+ }
9935
+ addComment(comment) {
9936
+ const headers = this.settingsService.getHeaders();
9937
+ const apiUrl = this.settingsService.getSettings('apiUrl');
9938
+ return this.http.post(`${apiUrl}dam/documents/comments${this.getAliasQuery()}`, comment, { headers });
9939
+ }
9940
+ deleteComment(commentGuid) {
9941
+ const headers = this.settingsService.getHeaders();
9942
+ const apiUrl = this.settingsService.getSettings('apiUrl');
9943
+ return this.http.delete(`${apiUrl}dam/documents/comments/${commentGuid}${this.getAliasQuery()}`, { headers });
9944
+ }
9945
+ updateComment(commentGuid, updates) {
9946
+ const headers = this.settingsService.getHeaders();
9947
+ const apiUrl = this.settingsService.getSettings('apiUrl');
9948
+ return this.http.put(`${apiUrl}dam/documents/comments/${commentGuid}${this.getAliasQuery()}`, updates, { headers });
9949
+ }
9950
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: DocumentCommentService, deps: [{ token: i1.HttpClient }, { token: SettingsService }], target: i0.ɵɵFactoryTarget.Injectable }); }
9951
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: DocumentCommentService, providedIn: 'root' }); }
9952
+ }
9953
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.12", ngImport: i0, type: DocumentCommentService, decorators: [{
9954
+ type: Injectable,
9955
+ args: [{
9956
+ providedIn: 'root'
9957
+ }]
9958
+ }], ctorParameters: () => [{ type: i1.HttpClient }, { type: SettingsService }] });
9959
+
9912
9960
  class StripeService {
9913
9961
  constructor(http, _settingsService) {
9914
9962
  this.http = http;
@@ -9959,5 +10007,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.12", ngImpo
9959
10007
  * Generated bundle index. Do not edit.
9960
10008
  */
9961
10009
 
9962
- export { AccountsService, AttributesService, AuthService, CategoriesService, CompaniesService, CompanyService, CompletenessService, DEFAULT_PUBLICATION_STR, DEFAULT_TEMPLATEGUID, DamAssetsProfilesService, DamAssetsSelectionsService, DamAssetsService, Document, DocumentsService, EasypiechartDirective, ExportsService, FrameworkagreementsService, GenerationService, LocaleNumberPipe, LoginService, MasksService, MediaSelectionService, MenuService, NotificationServiceService, PricesTaxService, ProductSheetsService, Publication, PublicationBreak, PublicationData, PublicationDataType, PublicationPage, PublicationTemplate, PublicationsService, PublicationsTemplatesService, RightsService, SOLIDPEPPER_API_URL, SOLIDPEPPER_TOKEN_GETTER, SearchService, SettingsService, SidebarRightService, SkusService, StatusService, StripeService, SuppliersService, TeamsService, Template, TemplatesService, ThumbnailService, TimeElapsedPipe, TranslateService, TranslatorService, UsersService, ViewsService, WorkflowsDesksService, WorkflowsHistoricalService, websocketService };
10010
+ export { AccountsService, AttributesService, AuthService, CategoriesService, CompaniesService, CompanyService, CompletenessService, DEFAULT_PUBLICATION_STR, DEFAULT_TEMPLATEGUID, DamAssetsProfilesService, DamAssetsSelectionsService, DamAssetsService, Document, DocumentCommentService, DocumentsService, EasypiechartDirective, ExportsService, FrameworkagreementsService, GenerationService, LocaleNumberPipe, LoginService, MasksService, MediaSelectionService, MenuService, NotificationServiceService, PricesTaxService, ProductSheetsService, Publication, PublicationBreak, PublicationData, PublicationDataType, PublicationPage, PublicationTemplate, PublicationsService, PublicationsTemplatesService, RightsService, SOLIDPEPPER_API_URL, SOLIDPEPPER_TOKEN_GETTER, SearchService, SettingsService, SidebarRightService, SkusService, StatusService, StripeService, SuppliersService, TeamsService, Template, TemplatesService, ThumbnailService, TimeElapsedPipe, TranslateService, TranslatorService, UsersService, ViewsService, WorkflowsDesksService, WorkflowsHistoricalService, websocketService };
9963
10011
  //# sourceMappingURL=solidpepper-solidpepper-service.mjs.map