@chat21/chat21-ionic 3.4.13-rc4 → 3.4.13

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # chat21-ionic ver 3.0
2
2
 
3
+ ### 3.4.13 in PROD
4
+
5
+ ### 3.4.13-rc.5
6
+ - removed: tiledeskToken from tiledesk-service
7
+
3
8
  ### 3.4.13-rc.4
4
9
  - added: management for copilot option in project.profile obj
5
10
  - removed: token in each tiledesk Service method calls and added initialize method for each services
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@chat21/chat21-ionic",
3
3
  "author": "Tiledesk SRL",
4
- "version": "3.4.13-rc4",
4
+ "version": "3.4.13",
5
5
  "license": "MIT License",
6
6
  "homepage": "https://tiledesk.com/",
7
7
  "repository": {
@@ -42,6 +42,8 @@ import { Globals } from './utils/globals';
42
42
  import { GlobalSettingsService } from './services/global-settings/global-settings.service';
43
43
  import { conversationToMessage } from 'src/chat21-core/utils/utils-message';
44
44
  import { ProjectService } from './services/projects/project.service';
45
+ import { ContactsService } from './services/contacts/contacts.service';
46
+ import { TiledeskService } from './services/tiledesk/tiledesk.service';
45
47
 
46
48
  @Component({
47
49
  selector: 'app-root',
@@ -136,7 +138,11 @@ export class AppComponent implements OnInit {
136
138
  public el: ElementRef,
137
139
  public g: Globals,
138
140
  public globalSettingsService: GlobalSettingsService,
139
- public projectService: ProjectService
141
+
142
+ /**TILEDESK SERVICES */
143
+ private tiledeskService: TiledeskService,
144
+ private projectService: ProjectService,
145
+ private contactsService: ContactsService
140
146
  ) {
141
147
 
142
148
  this.saveInStorageNumberOfOpenedChatTab();
@@ -1166,7 +1172,9 @@ export class AppComponent implements OnInit {
1166
1172
  this.chatManager.setTiledeskToken(tiledeskToken);
1167
1173
  this.chatManager.setCurrentUser(currentUser);
1168
1174
 
1175
+ this.tiledeskService.initialize(serverBaseURL)
1169
1176
  this.projectService.initialize(serverBaseURL)
1177
+ this.contactsService.initialize(serverBaseURL)
1170
1178
  // this.chatManager.startApp();
1171
1179
 
1172
1180
  // ----------------------------------------------
@@ -101,9 +101,7 @@ export class CannedResponseComponent implements OnInit {
101
101
  }
102
102
 
103
103
  getProjectIdByConversationWith(strSearch, conversationWith: string) {
104
- const tiledeskToken = this.tiledeskAuthService.getTiledeskToken()
105
-
106
- this.tiledeskService.getProjectIdByConvRecipient(tiledeskToken, conversationWith).subscribe((res) => {
104
+ this.tiledeskService.getProjectIdByConvRecipient(conversationWith).subscribe((res) => {
107
105
  this.logger.log('[CANNED] - loadTagsCanned - GET PROJECTID BY CONV RECIPIENT RES', res)
108
106
  if (res) {
109
107
  const projectId = res.id_project
@@ -204,9 +202,8 @@ export class CannedResponseComponent implements OnInit {
204
202
  onConfirmEditCanned(canned, ev){
205
203
  ev.preventDefault()
206
204
  ev.stopPropagation()
207
- const tiledeskToken = this.tiledeskAuthService.getTiledeskToken()
208
205
  this.logger.log('[CANNED] onConfirmEditCanned ', canned, ev)
209
- this.cannedResponsesService.edit(tiledeskToken, canned.id_project, canned).subscribe(cannedRes=> {
206
+ this.cannedResponsesService.edit(canned.id_project, canned).subscribe(cannedRes=> {
210
207
  canned.disabled = true
211
208
  }, (error) => {
212
209
  this.logger.error('[CANNED] - onConfirmEditCanned - ERROR ', error)
@@ -218,9 +215,8 @@ export class CannedResponseComponent implements OnInit {
218
215
  onDeleteCanned(canned, ev){
219
216
  ev.preventDefault()
220
217
  ev.stopPropagation()
221
- const tiledeskToken = this.tiledeskAuthService.getTiledeskToken()
222
218
  this.logger.log('[CANNED] onDeleteCanned ', canned)
223
- this.cannedResponsesService.delete(tiledeskToken, canned.id_project, canned._id).subscribe(cannedRes=> {
219
+ this.cannedResponsesService.delete(canned.id_project, canned._id).subscribe(cannedRes=> {
224
220
  if(cannedRes.status === 1000){
225
221
  this.tagsCannedFilter.splice(this.tagsCannedFilter.findIndex(el => el._id === canned._id), 1)
226
222
  }
@@ -61,12 +61,12 @@
61
61
  <ion-icon slot="icon-only" name="flash-outline" style="font-size: 24px;"></ion-icon>
62
62
  </ion-button>
63
63
  </div>
64
- <div *ngIf="conversationWith?.startsWith(CHANNEL_TYPE.SUPPORT_GROUP) && tagsCannedCount === 0"
64
+ <div *ngIf="conversationWith?.startsWith(CHANNEL_TYPE.SUPPORT_GROUP) && tagsCannedFilter.length === 0"
65
65
  tooltip="{{translationMap?.get('NO_CANNED_RESPONSES')}}" placement="top"
66
66
  class="no-canned-responses-btn-badge">
67
67
  <ion-icon name="alert-sharp" style="vertical-align: middle;"></ion-icon>
68
68
  </div>
69
- <div *ngIf="conversationWith?.startsWith(CHANNEL_TYPE.SUPPORT_GROUP) && (tagsCannedCount > 0)"
69
+ <div *ngIf="conversationWith?.startsWith(CHANNEL_TYPE.SUPPORT_GROUP) && (tagsCannedFilter.length > 0)"
70
70
  tooltip="{{translationMap?.get('YES_CANNED_RESPONSES')}}" placement="top" class="canned-responses-btn-badge">
71
71
  <ion-icon name="information-sharp" style="vertical-align: middle;"></ion-icon>
72
72
  </div>
@@ -110,9 +110,7 @@ export class InfoContentComponent implements OnInit {
110
110
  }
111
111
 
112
112
  getProjectIdByConversationWith(conversationWith: string) {
113
- const tiledeskToken = this.tiledeskAuthService.getTiledeskToken();
114
-
115
- this.tiledeskService.getProjectIdByConvRecipient(tiledeskToken, conversationWith).subscribe(res => {
113
+ this.tiledeskService.getProjectIdByConvRecipient(conversationWith).subscribe(res => {
116
114
  this.logger.log('[INFO-CONTENT-COMP] - GET PROJECTID BY CONV RECIPIENT RES', res);
117
115
 
118
116
  if (res) {
@@ -11,7 +11,7 @@
11
11
  [(ngModel)]="text"
12
12
  (ionChange)="ionChange($event);"
13
13
  (ionFocus)="ionFocus()"
14
- (keydown.enter)="onKeydown($event, messageString)">
14
+ (keydown.enter)="onKeydown($event)">
15
15
  </ion-textarea>
16
16
  </div>
17
17
  </div>
@@ -72,9 +72,8 @@ export class CopilotPopoverComponent implements OnInit {
72
72
  this.logger.log("[CONVS-DETAIL][MSG-TEXT-AREA] ionFocus event ");
73
73
  }
74
74
 
75
- onKeydown(e: any, text: string) {
75
+ onKeydown(e: any) {
76
76
  this.logger.log("[COPILOT-POPOVER] - returnChangeTextArea - onKeydown in MSG-TEXT-AREA event", e)
77
- this.logger.log("[COPILOT-POPOVER] - returnChangeTextArea - onKeydown in MSG-TEXT-AREA text", text)
78
77
  }
79
78
 
80
79
 
@@ -75,9 +75,7 @@ export class CopilotSuggestionsComponent implements OnInit {
75
75
  }
76
76
 
77
77
  getProjectIdByConversationWith(conversationWith: string) {
78
- const tiledeskToken = this.tiledeskAuthService.getTiledeskToken()
79
-
80
- this.tiledeskService.getProjectIdByConvRecipient(tiledeskToken, conversationWith).subscribe((res) => {
78
+ this.tiledeskService.getProjectIdByConvRecipient(conversationWith).subscribe((res) => {
81
79
  this.logger.log('[COPILOT] - loadTagsCanned - GET PROJECTID BY CONV RECIPIENT RES', res)
82
80
  if (res) {
83
81
  const projectId = res.id_project
@@ -5,7 +5,6 @@ import { Validators, FormBuilder, FormGroup, FormControl } from '@angular/forms'
5
5
  import { TranslateService } from '@ngx-translate/core';
6
6
  import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service';
7
7
  import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance';
8
- import { TiledeskAuthService } from 'src/chat21-core/providers/tiledesk/tiledesk-auth.service';
9
8
  import { TiledeskService } from 'src/app/services/tiledesk/tiledesk.service';
10
9
  import { MenuController } from '@ionic/angular';
11
10
  import { EventsService } from 'src/app/services/events-service';
@@ -28,7 +27,6 @@ export class CreateCannedResponsePage implements OnInit {
28
27
  private logger: LoggerService = LoggerInstance.getInstance();
29
28
 
30
29
  prjctID: string;
31
- tiledeskToken: string;
32
30
  showSpinnerCreateCannedResponse: boolean = false;
33
31
  addWhiteSpaceBefore: boolean;
34
32
  mouseOverBtnAddRecipientNamePlaceholder: boolean = false;
@@ -40,7 +38,6 @@ export class CreateCannedResponsePage implements OnInit {
40
38
  private formBuilder: FormBuilder,
41
39
  private translate: TranslateService,
42
40
  private translateService: CustomTranslateService,
43
- public tiledeskAuthService: TiledeskAuthService,
44
41
  public tiledeskService: TiledeskService,
45
42
  public cannedResponsesService: CannedResponsesService,
46
43
  private menu: MenuController,
@@ -61,9 +58,7 @@ export class CreateCannedResponsePage implements OnInit {
61
58
  // this.getCurrentProjectId();
62
59
  // console.log('[CREATE-CANNED-RES] - conversationWith ', this.conversationWith)
63
60
  console.log('[CREATE-CANNED-RES] - message ', this.message, this.conversationWith)
64
- this.tiledeskToken = this.tiledeskAuthService.getTiledeskToken()
65
- this.logger.log('[CREATE-CANNED-RES] tiledeskToken ', this.tiledeskToken)
66
- this.getCurrentProjectId(this.conversationWith, this.tiledeskToken);
61
+ this.getCurrentProjectId(this.conversationWith);
67
62
 
68
63
 
69
64
  let keys= [
@@ -108,7 +103,7 @@ export class CreateCannedResponsePage implements OnInit {
108
103
  }
109
104
 
110
105
 
111
- getCurrentProjectId(conversation_id, tiledeskToken) {
106
+ getCurrentProjectId(conversation_id) {
112
107
  const conversationWith_segments = conversation_id.split('-')
113
108
  // Removes the last element of the array if is = to the separator
114
109
  if (
@@ -133,14 +128,13 @@ export class CreateCannedResponsePage implements OnInit {
133
128
  this.prjctID = conversationWith_segments[2]
134
129
  this.logger.log('[CREATE-CANNED-RES] - loadTagsCanned projectId ', this.prjctID)
135
130
  } else {
136
- this.getProjectIdByConversationWith(conversation_id, tiledeskToken)
131
+ this.getProjectIdByConversationWith(conversation_id)
137
132
  }
138
133
  }
139
134
 
140
- getProjectIdByConversationWith(conversationWith: string, tiledeskToken: string) {
141
- // const tiledeskToken = this.tiledeskAuthService.getTiledeskToken()
135
+ getProjectIdByConversationWith(conversationWith: string) {
142
136
 
143
- this.tiledeskService.getProjectIdByConvRecipient(tiledeskToken, conversationWith).subscribe((res) => {
137
+ this.tiledeskService.getProjectIdByConvRecipient(conversationWith).subscribe((res) => {
144
138
  this.logger.log('[CREATE-CANNED-RES] - GET PROJECTID BY CONV RECIPIENT RES', res)
145
139
  if (res) {
146
140
  this.prjctID = res.id_project
@@ -23,7 +23,6 @@ export class CreateTicketPage implements OnInit {
23
23
  loadingAssignee: boolean = true;
24
24
  loadingRequesters: boolean = true;
25
25
  prjctID: string;
26
- tiledeskToken: string;
27
26
  selectedRequester: any;
28
27
  storageBucket: string;
29
28
  baseUrl: string;
@@ -66,7 +65,6 @@ export class CreateTicketPage implements OnInit {
66
65
  constructor(
67
66
  public modalController: ModalController,
68
67
  public tiledeskService: TiledeskService,
69
- public tiledeskAuthService: TiledeskAuthService,
70
68
  public appConfigProvider: AppConfigProvider,
71
69
  public events: EventsService
72
70
  ) {}
@@ -85,11 +83,8 @@ export class CreateTicketPage implements OnInit {
85
83
  this.prjctID = storedPrjctObjct.id_project.id
86
84
  this.logger.log('[CREATE-TICKET] this.prjctID ', this.prjctID)
87
85
  }
88
- this.tiledeskToken = this.tiledeskAuthService.getTiledeskToken()
89
- this.logger.log('[CREATE-TICKET] tiledeskToken ', this.tiledeskToken)
90
-
91
- this.getProjectUsersAndContacts(this.prjctID, this.tiledeskToken)
92
- this.getProjectUserBotsAndDepts(this.prjctID, this.tiledeskToken)
86
+ this.getProjectUsersAndContacts(this.prjctID)
87
+ this.getProjectUserBotsAndDepts(this.prjctID)
93
88
  }
94
89
 
95
90
  getUploadEngine() {
@@ -108,16 +103,9 @@ export class CreateTicketPage implements OnInit {
108
103
  // -------------------------------------------------------------------------------------------
109
104
  // Create the array of the project-users and contacts displayed in the combo box "Requester"
110
105
  // -------------------------------------------------------------------------------------------
111
- getProjectUsersAndContacts(projctid: string, tiledesktoken: string) {
112
- const projectUsers = this.tiledeskService.getProjectUsersByProjectId(
113
- projctid,
114
- tiledesktoken,
115
- )
116
- const leads = this.tiledeskService.getAllLeadsActiveWithLimit(
117
- projctid,
118
- tiledesktoken,
119
- 10000,
120
- )
106
+ getProjectUsersAndContacts(projctid: string) {
107
+ const projectUsers = this.tiledeskService.getProjectUsersByProjectId(projctid)
108
+ const leads = this.tiledeskService.getAllLeadsActiveWithLimit(projctid,10000)
121
109
 
122
110
  zip(projectUsers, leads).subscribe(
123
111
  ([_prjctUsers, _leads]) => {
@@ -253,11 +241,11 @@ export class CreateTicketPage implements OnInit {
253
241
  // -------------------------------------------------------------------------------------------------------------------
254
242
  // Create the array of the project-users, the bots and of the departments displayed in the combo box "Select Assignee"
255
243
  // -------------------------------------------------------------------------------------------------------------------
256
- getProjectUserBotsAndDepts(projctid: string, tiledesktoken: string) {
244
+ getProjectUserBotsAndDepts(projctid: string) {
257
245
  // this.loadingAssignee = true;
258
- const projectUsers = this.tiledeskService.getProjectUsersByProjectId( projctid, tiledesktoken)
259
- const bots = this.tiledeskService.getAllBotByProjectId(projctid, tiledesktoken)
260
- const depts = this.tiledeskService.getDeptsByProjectId(projctid, tiledesktoken)
246
+ const projectUsers = this.tiledeskService.getProjectUsersByProjectId( projctid)
247
+ const bots = this.tiledeskService.getAllBotByProjectId(projctid)
248
+ const depts = this.tiledeskService.getDeptsByProjectId(projctid)
261
249
 
262
250
  zip(projectUsers, bots, depts).subscribe(
263
251
  ([_prjctUsers, _bots, _depts]) => {
@@ -361,8 +349,7 @@ export class CreateTicketPage implements OnInit {
361
349
  this.assignee_dept_id,
362
350
  this.assignee_participants_id,
363
351
  this.selectedPriority,
364
- this.prjctID,
365
- this.tiledeskToken
352
+ this.prjctID
366
353
  ).subscribe((newticket: any) => {
367
354
  this.logger.log('[WS-REQUESTS-LIST] create internalRequest - RES ', newticket);
368
355
 
@@ -34,7 +34,6 @@ export class SendEmailModal implements OnInit {
34
34
  public viewCtrl: ModalController,
35
35
  private formBuilder: FormBuilder,
36
36
  private tiledeskService: TiledeskService,
37
- private tiledeskAuthService: TiledeskAuthService,
38
37
  private toastController: ToastController
39
38
  ) { }
40
39
 
@@ -81,8 +80,7 @@ export class SendEmailModal implements OnInit {
81
80
 
82
81
  onSubmit(){
83
82
  this.logger.log('[SEND-EMAIL-MODAL] onSubmit -->',this.emailFormGroup)
84
- const tiledeskToken = this.tiledeskAuthService.getTiledeskToken()
85
- this.tiledeskService.sendEmail(tiledeskToken, this.projectId, this.conversationWith, this.emailFormGroup.value).subscribe((res)=> {
83
+ this.tiledeskService.sendEmail(this.projectId, this.conversationWith, this.emailFormGroup.value).subscribe((res)=> {
86
84
  this.logger.debug('[SEND-EMAIL-MODAL] subscribe to sendEmail API response -->', res)
87
85
  if(res && res.queued){
88
86
  this.viewCtrl.dismiss({form: this.emailFormGroup.value})
@@ -31,11 +31,8 @@ export class ContactsDirectoryPage implements OnInit {
31
31
  private navService: NavProxyService,
32
32
  // private contactsDirectoryService: ContactsDirectoryService,
33
33
  private contactsService: ContactsService,
34
- private appConfigProvider: AppConfigProvider,
35
34
  public events: EventsService
36
- ) {
37
- const serverBaseUrl = this.appConfigProvider.getConfig().apiUrl
38
- this.contactsService.initialize(serverBaseUrl)
35
+ ) {
39
36
  }
40
37
 
41
38
  ngOnInit() {
@@ -544,9 +544,8 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
544
544
  }
545
545
 
546
546
  _getProjectIdByConversationWith(conversationWith: string) {
547
- const tiledeskToken = this.tiledeskAuthService.getTiledeskToken()
548
547
  if (this.channelType !== TYPE_DIRECT && !this.conversationWith.startsWith('group-')) {
549
- this.tiledeskService.getProjectIdByConvRecipient(tiledeskToken, conversationWith).subscribe((res) => {
548
+ this.tiledeskService.getProjectIdByConvRecipient(conversationWith).subscribe((res) => {
550
549
  this.logger.log('[CONVS-DETAIL] - GET PROJECTID BY CONV RECIPIENT RES + projectId', res, res.id_project)
551
550
  if (res) {
552
551
  const projectId = res.id_project
@@ -968,10 +967,9 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
968
967
  getLeadDetail() {
969
968
  const that = this;
970
969
  if (this.channelType !== TYPE_DIRECT && !this.conversationWith.startsWith('group-')) {
971
- const tiledeskToken = this.tiledeskAuthService.getTiledeskToken();
972
970
  const projectId = getProjectIdSelectedConversation(this.conversationWith)
973
971
  this.logger.debug('[CONVS-DETAIL] getLeadDetail - section ', projectId)
974
- this.tiledeskService.getRequest(this.conversationWith, projectId, tiledeskToken).subscribe((request: any) => {
972
+ this.tiledeskService.getRequest(this.conversationWith, projectId).subscribe((request: any) => {
975
973
  that.logger.debug('[CONVS-DETAIL] getLeadDetail - selected REQUEST detail', request)
976
974
  if(request && request.channel){
977
975
  this.conversation.attributes['request_channel'] = request.channel.name
@@ -1037,13 +1035,12 @@ export class ConversationDetailPage implements OnInit, OnDestroy, AfterViewInit
1037
1035
  }
1038
1036
 
1039
1037
  sendEmail(message: string): Observable<boolean> {
1040
- const tiledeskToken = this.tiledeskAuthService.getTiledeskToken();
1041
1038
  const emailFormGroup = {
1042
1039
  subject: this.translationsMap.get('EMAIL.SUBJECT_OFFLINE_MESSAGE'),
1043
1040
  text: message
1044
1041
  }
1045
1042
  let status = new Subject<boolean>();
1046
- this.tiledeskService.sendEmail(tiledeskToken, this.leadInfo.projectId, this.conversationWith, emailFormGroup).subscribe((res) => {
1043
+ this.tiledeskService.sendEmail(this.leadInfo.projectId, this.conversationWith, emailFormGroup).subscribe((res) => {
1047
1044
  this.logger.debug('[SEND-EMAIL-MODAL] subscribe to sendEmail API response -->', res)
1048
1045
  if (res && res.queued) {
1049
1046
  this.presentToast(this.translationsMap.get('EMAIL.SEND_EMAIL_SUCCESS_OFFLINE_MESSAGE'), 'success', '', 2000)
@@ -903,15 +903,11 @@ export class ConversationListPage implements OnInit {
903
903
  // Opens the list of contacts for direct convs
904
904
  // ---------------------------------------------------------
905
905
  openContactsDirectory(event: any) {
906
- const TOKEN = this.tiledeskAuthService.getTiledeskToken()
907
- this.logger.log('[CONVS-LIST-PAGE] openContactsDirectory', TOKEN)
906
+ this.logger.log('[CONVS-LIST-PAGE] openContactsDirectory')
908
907
  if (checkPlatformIsMobile()) {
909
- presentModal(this.modalController, ContactsDirectoryPage, {
910
- token: TOKEN,
911
- isMobile: this.isMobile
912
- })
908
+ presentModal(this.modalController, ContactsDirectoryPage, { isMobile: this.isMobile })
913
909
  } else {
914
- this.navService.push(ContactsDirectoryPage, {})
910
+ this.navService.push(ContactsDirectoryPage, { isMobile: this.isMobile })
915
911
  }
916
912
  }
917
913
 
@@ -1003,9 +999,7 @@ export class ConversationListPage implements OnInit {
1003
999
  let project_id = ''
1004
1000
  if (conversationWith_segments.length === 4) {
1005
1001
  project_id = conversationWith_segments[2]
1006
-
1007
- const tiledeskToken = this.tiledeskAuthService.getTiledeskToken()
1008
- this.archiveSupportGroupConv(tiledeskToken,project_id,conversationId,)
1002
+ this.archiveSupportGroupConv(project_id,conversationId)
1009
1003
  } else {
1010
1004
  this.getProjectIdByConversationWith(conversationId)
1011
1005
  }
@@ -1016,15 +1010,13 @@ export class ConversationListPage implements OnInit {
1016
1010
  }
1017
1011
 
1018
1012
  getProjectIdByConversationWith(conversationId: string) {
1019
- const tiledeskToken = this.tiledeskAuthService.getTiledeskToken()
1020
-
1021
- this.tiledeskService.getProjectIdByConvRecipient(tiledeskToken, conversationId).subscribe((res) => {
1013
+ this.tiledeskService.getProjectIdByConvRecipient(conversationId).subscribe((res) => {
1022
1014
  this.logger.log('[CONVS-LIST-PAGE] - GET PROJECTID BY CONV RECIPIENT RES',res)
1023
1015
 
1024
1016
  if (res) {
1025
1017
  const project_id = res.id_project
1026
1018
  this.logger.log('[INFO-CONTENT-COMP] - GET PROJECTID BY CONV RECIPIENT project_id',project_id)
1027
- this.archiveSupportGroupConv(tiledeskToken,project_id,conversationId)
1019
+ this.archiveSupportGroupConv(project_id,conversationId)
1028
1020
  }
1029
1021
  },(error) => {
1030
1022
  this.logger.error('[CONVS-LIST-PAGE] - GET PROJECTID BY CONV RECIPIENT - ERROR ',error)
@@ -1033,9 +1025,9 @@ export class ConversationListPage implements OnInit {
1033
1025
  })
1034
1026
  }
1035
1027
 
1036
- archiveSupportGroupConv(tiledeskToken, project_id, conversationId) {
1028
+ archiveSupportGroupConv(project_id, conversationId) {
1037
1029
  this.logger.log('[CONVS-LIST-PAGE] - onCloseConversation projectId: ',project_id)
1038
- this.tiledeskService.closeSupportGroup(tiledeskToken, project_id, conversationId).subscribe((res) => {
1030
+ this.tiledeskService.closeSupportGroup(project_id, conversationId).subscribe((res) => {
1039
1031
  this.archiveActionNotAllowed = false
1040
1032
  this.logger.log('[CONVS-LIST-PAGE] - onCloseConversation closeSupportGroup RES',res)
1041
1033
  if(res.status === REQUEST_ARCHIVED)
@@ -3,7 +3,6 @@ import { Validators, FormBuilder, FormGroup, FormControl} from '@angular/forms';
3
3
  import { ModalController } from '@ionic/angular'
4
4
  import { TranslateService } from '@ngx-translate/core';
5
5
  import { TiledeskService } from 'src/app/services/tiledesk/tiledesk.service';
6
- import { TiledeskAuthService } from 'src/chat21-core/providers/tiledesk/tiledesk-auth.service';
7
6
  import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service';
8
7
  import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance';
9
8
  @Component({
@@ -19,7 +18,6 @@ export class CreateRequesterPage implements OnInit {
19
18
  @Input() projectUserAndLeadsArray: any
20
19
 
21
20
  prjctID: string;
22
- tiledeskToken: string;
23
21
  showSpinnerCreateRequester: boolean = false;
24
22
  requester_id: string;
25
23
  logger: LoggerService = LoggerInstance.getInstance();
@@ -28,7 +26,6 @@ export class CreateRequesterPage implements OnInit {
28
26
  public modalController: ModalController,
29
27
  private formBuilder: FormBuilder,
30
28
  public tiledeskService: TiledeskService,
31
- public tiledeskAuthService: TiledeskAuthService,
32
29
  private translate: TranslateService,
33
30
  ) { }
34
31
 
@@ -42,9 +39,7 @@ export class CreateRequesterPage implements OnInit {
42
39
  this.prjctID = storedPrjctObjct.id_project.id
43
40
  this.logger.log('[CREATE-REQUESTER] this.prjctID ', this.prjctID)
44
41
  }
45
- this.tiledeskToken = this.tiledeskAuthService.getTiledeskToken()
46
- this.logger.log('[CREATE-REQUESTER] tiledeskToken ', this.tiledeskToken)
47
-
42
+
48
43
  this.buildForm()
49
44
 
50
45
  }
@@ -84,13 +79,13 @@ export class CreateRequesterPage implements OnInit {
84
79
  this.logger.log('[CREATE-REQUESTER] - CREATE-NEW-USER email ', new_user_email);
85
80
 
86
81
 
87
- this.tiledeskService.createNewProjectUserToGetNewLeadID(this.prjctID, this.tiledeskToken).subscribe(res => {
82
+ this.tiledeskService.createNewProjectUserToGetNewLeadID(this.prjctID).subscribe(res => {
88
83
  this.logger.log('[CREATE-REQUESTER] - CREATE-NEW-USER - CREATE-PROJECT-USER ', res);
89
84
  this.logger.log('[CREATE-REQUESTER] - CREATE-NEW-USER - CREATE-PROJECT-USER UUID ', res.uuid_user);
90
85
  if (res) {
91
86
  if (res.uuid_user) {
92
87
  let new_lead_id = res.uuid_user
93
- this.createNewContact(new_lead_id, new_user_name, new_user_email, this.prjctID, this.tiledeskToken)
88
+ this.createNewContact(new_lead_id, new_user_name, new_user_email, this.prjctID)
94
89
  }
95
90
  }
96
91
  }, error => {
@@ -103,8 +98,8 @@ export class CreateRequesterPage implements OnInit {
103
98
  }
104
99
 
105
100
 
106
- createNewContact(lead_id: string, lead_name: string, lead_email: string, projecId: string, tiledeskToken: string) {
107
- this.tiledeskService.createNewLead(lead_id, lead_name, lead_email, projecId, tiledeskToken ).subscribe(lead => {
101
+ createNewContact(lead_id: string, lead_name: string, lead_email: string, projecId: string) {
102
+ this.tiledeskService.createNewLead(lead_id, lead_name, lead_email, projecId ).subscribe(lead => {
108
103
  this.logger.log('[CREATE-REQUESTER] - CREATE-NEW-USER - CREATE-NEW-LEAD - RES ', lead);
109
104
  this.projectUserAndLeadsArray.push({ id: lead.lead_id, name: lead.fullname, role: 'lead', email: lead_email, requestertype: 'lead', requester_id: lead._id});
110
105
  this.requester_id = lead._id
@@ -75,7 +75,7 @@ export class CannedResponsesService {
75
75
 
76
76
  }
77
77
 
78
- public edit(token: string, projectid: string, canned: any){
78
+ public edit(projectid: string, canned: any){
79
79
  const cannedResponsesURL = this.SERVER_BASE_URL + projectid + "/canned/"+ canned._id;
80
80
  this.logger.log('[CANNED-RESPONSES-SERVICE] editCannedResponses - URL ', cannedResponsesURL);
81
81
 
@@ -97,14 +97,14 @@ export class CannedResponsesService {
97
97
  }))
98
98
  }
99
99
 
100
- public delete(token: string, projectid: string, cannedID: string){
100
+ public delete(projectid: string, cannedID: string){
101
101
  const cannedResponsesURL = this.SERVER_BASE_URL + projectid + "/canned/"+cannedID;
102
102
  this.logger.log('[CANNED-RESPONSES-SERVICE] deleteCannedResponses - URL ', cannedResponsesURL);
103
103
 
104
104
  const httpOptions = {
105
105
  headers: new HttpHeaders({
106
106
  'Content-Type': 'application/json',
107
- Authorization: token
107
+ Authorization: this.tiledeskToken
108
108
  })
109
109
  };
110
110
 
@@ -6,6 +6,7 @@ import { map } from 'rxjs/operators';
6
6
  // Logger
7
7
  import { LoggerService } from 'src/chat21-core/providers/abstract/logger.service';
8
8
  import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance';
9
+ import { AppStorageService } from 'src/chat21-core/providers/abstract/app-storage.service';
9
10
 
10
11
 
11
12
  @Injectable({
@@ -13,38 +14,41 @@ import { LoggerInstance } from 'src/chat21-core/providers/logger/loggerInstance'
13
14
  })
14
15
  export class TiledeskService {
15
16
 
16
- private apiUrl: string;
17
+ // private
18
+ private SERVER_BASE_URL: string;
19
+ private tiledeskToken: string;
20
+
17
21
  private logger: LoggerService = LoggerInstance.getInstance();
18
22
 
19
23
  constructor(
20
24
  public http: HttpClient,
21
- public appConfigProvider: AppConfigProvider
22
- ) {
23
- this.apiUrl = appConfigProvider.getConfig().apiUrl;
24
- // const projectUrl = this.apiUrl + 'projects/'
25
- // console.log('[TILEDESK-SERVICE] projectUrl' ,projectUrl )
25
+ public appStorageService: AppStorageService
26
+ ) {}
27
+
28
+ initialize(serverBaseUrl: string) {
29
+ this.logger.log('[TILEDESK-SERVICE] - initialize serverBaseUrl', serverBaseUrl);
30
+ this.SERVER_BASE_URL = serverBaseUrl;
31
+ this.tiledeskToken = this.appStorageService.getItem('tiledeskToken')
26
32
  }
27
33
 
28
34
 
29
35
  // CLOSE SUPPORT GROUP
30
- public closeSupportGroup(token: string, projectid: string, supportgroupid: string) {
36
+ public closeSupportGroup(projectid: string, supportgroupid: string) {
37
+ const url = this.SERVER_BASE_URL + projectid + '/requests/' + supportgroupid + '/close';
38
+ this.logger.log('[TILEDESK-SERVICE] - closeSupportGroup URL ', url);
39
+
31
40
  const httpOptions = {
32
41
  headers: new HttpHeaders({
33
42
  'Accept': 'application/json',
34
43
  'Content-Type': 'application/json',
35
- Authorization: token
44
+ Authorization: this.tiledeskToken
36
45
  })
37
46
  };
38
47
 
39
48
  const body = {
40
49
  force: true
41
50
  };
42
- // console.log('CLOUD FUNCT CLOSE SUPPORT GROUP REQUEST BODY ', body);
43
- // https://tiledesk-server-pre.herokuapp.com/
44
- // const url = 'https://tiledesk-server-pre.herokuapp.com/' + this.project_id + '/requests/' + group_id + '/close';
45
- const url = this.apiUrl + projectid + '/requests/' + supportgroupid + '/close';
46
51
 
47
- this.logger.log('[TILEDESK-SERVICE] - closeSupportGroup URL ', url);
48
52
  return this.http.put(url, body, httpOptions).pipe(map((res: any) => {
49
53
  this.logger.log('[TILEDESK-SERVICE] - closeSupportGroup - RES ', res);
50
54
  return res
@@ -54,14 +58,14 @@ export class TiledeskService {
54
58
  // ---------------------------------------------
55
59
  // @ GET request by id
56
60
  // ---------------------------------------------
57
- public getRequest(request_id: string, project_id: string, token: string) {
58
- const url = this.apiUrl + project_id + '/requests/'+request_id
61
+ public getRequest(request_id: string, project_id: string) {
62
+ const url = this.SERVER_BASE_URL + project_id + '/requests/'+request_id
59
63
  this.logger.log('[TILEDESK-SERVICE] - CREATE NEW LEAD url ', url);
60
64
 
61
65
  const httpOptions = {
62
66
  headers: new HttpHeaders({
63
67
  'Content-Type': 'application/json',
64
- Authorization: token
68
+ Authorization: this.tiledeskToken
65
69
  })
66
70
  };
67
71
 
@@ -71,15 +75,15 @@ export class TiledeskService {
71
75
  }))
72
76
  }
73
77
 
74
- public getProjectIdByConvRecipient(token: string ,conversationWith: string ) {
75
- const lookupUrl = this.apiUrl + 'requests_util/lookup/id_project/' + conversationWith;
78
+ public getProjectIdByConvRecipient(conversationWith: string ) {
79
+ const lookupUrl = this.SERVER_BASE_URL + 'requests_util/lookup/id_project/' + conversationWith;
76
80
 
77
81
  this.logger.log('[TILEDESK-SERVICE] GET PROJECTID BY CONV RECIPIENT - URL ', lookupUrl);
78
82
 
79
83
  const httpOptions = {
80
84
  headers: new HttpHeaders({
81
85
  'Content-Type': 'application/json',
82
- Authorization: token
86
+ Authorization: this.tiledeskToken
83
87
  })
84
88
  };
85
89
 
@@ -89,14 +93,14 @@ export class TiledeskService {
89
93
  }))
90
94
  }
91
95
 
92
- public getProjectUsersByProjectId(project_id: string, token: string) {
93
- const url = this.apiUrl + project_id + '/project_users/';
96
+ public getProjectUsersByProjectId(project_id: string) {
97
+ const url = this.SERVER_BASE_URL + project_id + '/project_users/';
94
98
  this.logger.log('[TILEDESK-SERVICE] - GET PROJECT-USER URL', url);
95
99
 
96
100
  const httpOptions = {
97
101
  headers: new HttpHeaders({
98
102
  'Content-Type': 'application/json',
99
- Authorization: token
103
+ Authorization: this.tiledeskToken
100
104
  })
101
105
  };
102
106
  return this.http.get(url, httpOptions).pipe(map((res: any) => {
@@ -105,14 +109,14 @@ export class TiledeskService {
105
109
  }))
106
110
  }
107
111
 
108
- public getAllLeadsActiveWithLimit(project_id: string, token: string, limit: number) {
109
- const url = this.apiUrl + project_id + '/leads?limit=' + limit + '&with_fullname=true';
112
+ public getAllLeadsActiveWithLimit(project_id: string, limit: number) {
113
+ const url = this.SERVER_BASE_URL + project_id + '/leads?limit=' + limit + '&with_fullname=true';
110
114
  this.logger.log('[TILEDESK-SERVICE] - GET ALL ACTIVE LEADS (LIMIT 10000) - URL', url);
111
115
 
112
116
  const httpOptions = {
113
117
  headers: new HttpHeaders({
114
118
  'Content-Type': 'application/json',
115
- Authorization: token
119
+ Authorization: this.tiledeskToken
116
120
  })
117
121
  };
118
122
  return this.http.get(url, httpOptions).pipe(map((res: any) => {
@@ -125,13 +129,13 @@ export class TiledeskService {
125
129
  // ---------------------------------------------
126
130
  // @ Create new project user to get new lead ID
127
131
  // ---------------------------------------------
128
- public createNewProjectUserToGetNewLeadID(project_id: string, token: string) {
129
- const url = this.apiUrl + project_id + '/project_users/'
132
+ public createNewProjectUserToGetNewLeadID(project_id: string) {
133
+ const url = this.SERVER_BASE_URL + project_id + '/project_users/'
130
134
  this.logger.log('[TILEDESK-SERVICE] - CREATE NEW PROJECT USER TO GET NEW LEAD ID url ', url);
131
135
  const httpOptions = {
132
136
  headers: new HttpHeaders({
133
137
  'Content-Type': 'application/json',
134
- Authorization: token
138
+ Authorization: this.tiledeskToken
135
139
  })
136
140
  };
137
141
  const body = {};
@@ -144,14 +148,14 @@ export class TiledeskService {
144
148
  // ---------------------------------------------
145
149
  // @ Create new lead
146
150
  // ---------------------------------------------
147
- public createNewLead(leadid: string, fullname: string, leademail: string, project_id: string, token: string) {
148
- const url = this.apiUrl + project_id + '/leads/'
151
+ public createNewLead(leadid: string, fullname: string, leademail: string, project_id: string) {
152
+ const url = this.SERVER_BASE_URL + project_id + '/leads/'
149
153
  this.logger.log('[TILEDESK-SERVICE] - CREATE NEW LEAD url ', url);
150
154
 
151
155
  const httpOptions = {
152
156
  headers: new HttpHeaders({
153
157
  'Content-Type': 'application/json',
154
- Authorization: token
158
+ Authorization: this.tiledeskToken
155
159
  })
156
160
  };
157
161
 
@@ -167,15 +171,14 @@ export class TiledeskService {
167
171
  // -------------------------------------------------------------------------------------
168
172
  // @ Get all bots of the project (with all=true the response return also the identity bot)
169
173
  // -------------------------------------------------------------------------------------
170
- public getAllBotByProjectId(project_id: string, token: string) {
171
-
172
- const url = this.apiUrl + project_id + '/faq_kb?all=true'
174
+ public getAllBotByProjectId(project_id: string) {
175
+ const url = this.SERVER_BASE_URL + project_id + '/faq_kb?all=true'
173
176
  this.logger.log('[TILEDESK-SERVICE] - GET ALL BOTS BY PROJECT ID - URL', url);
174
177
 
175
178
  const httpOptions = {
176
179
  headers: new HttpHeaders({
177
180
  'Content-Type': 'application/json',
178
- Authorization: token
181
+ Authorization: this.tiledeskToken
179
182
  })
180
183
  };
181
184
 
@@ -188,15 +191,14 @@ export class TiledeskService {
188
191
  // -------------------------------------------------------------------------------------
189
192
  // @ Get all DEPTS of the project
190
193
  // -------------------------------------------------------------------------------------
191
- public getDeptsByProjectId(project_id: string, token: string) {
192
-
193
- const url = this.apiUrl + project_id + '/departments/allstatus';
194
+ public getDeptsByProjectId(project_id: string) {
195
+ const url = this.SERVER_BASE_URL + project_id + '/departments/allstatus';
194
196
  this.logger.log('[TILEDESK-SERVICE] - GET DEPTS (ALL STATUS) - URL', url);
195
197
 
196
198
  const httpOptions = {
197
199
  headers: new HttpHeaders({
198
200
  'Content-Type': 'application/json',
199
- Authorization: token
201
+ Authorization: this.tiledeskToken
200
202
  })
201
203
  };
202
204
 
@@ -209,15 +211,14 @@ export class TiledeskService {
209
211
  // -----------------------------------------------------------------------------------------
210
212
  // @ Create ticket
211
213
  // -----------------------------------------------------------------------------------------
212
- public createInternalRequest(requester_id: string, request_id: string, subject: string, message: string, departmentid: string, participantid: string, ticketpriority: string, project_id: string, token: string) {
213
-
214
- const url = this.apiUrl + project_id + '/requests/' + request_id + '/messages'
214
+ public createInternalRequest(requester_id: string, request_id: string, subject: string, message: string, departmentid: string, participantid: string, ticketpriority: string, project_id: string) {
215
+ const url = this.SERVER_BASE_URL + project_id + '/requests/' + request_id + '/messages'
215
216
  this.logger.log('[WS-REQUESTS-SERV] - CREATE INTERNAL REQUEST URL ', url)
216
217
 
217
218
  const httpOptions = {
218
219
  headers: new HttpHeaders({
219
220
  'Content-Type': 'application/json',
220
- Authorization: token
221
+ Authorization: this.tiledeskToken
221
222
  })
222
223
  };
223
224
  // this.logger.log('JOIN FUNCT OPTIONS ', options);
@@ -240,20 +241,20 @@ export class TiledeskService {
240
241
  // -----------------------------------------------------------------------------------------
241
242
  // @ Send Email
242
243
  // -----------------------------------------------------------------------------------------
243
- public sendEmail(token: string, projectid: string, request_id: string, form: { subject: string, text: string}) {
244
+ public sendEmail(projectid: string, request_id: string, form: { subject: string, text: string}) {
245
+ const url = this.SERVER_BASE_URL + projectid + '/requests/' + request_id + '/email/send';
246
+ this.logger.log('[TILEDESK-SERVICE] - sendEmail URL ', url);
244
247
 
245
248
  const httpOptions = {
246
249
  headers: new HttpHeaders({
247
250
  'Accept': 'application/json',
248
251
  'Content-Type': 'application/json',
249
- Authorization: token
252
+ Authorization: this.tiledeskToken
250
253
  })
251
254
  };
252
255
 
253
256
  const body = form;
254
257
 
255
- const url = this.apiUrl + projectid + '/requests/' + request_id + '/email/send';
256
- this.logger.log('[TILEDESK-SERVICE] - sendEmail URL ', url);
257
258
  return this.http.post(url, body, httpOptions).pipe(map((res: any) => {
258
259
  this.logger.log('[TILEDESK-SERVICE] - sendEmail - RES ', res);
259
260
  return res