From 80ac40f948406dd86928263d64fa92b4ed5f9fa7 Mon Sep 17 00:00:00 2001 From: Rob Bond Date: Tue, 7 Jan 2020 11:25:43 +0000 Subject: [PATCH 01/15] Updated availability endpoints with nuance ones removed egain availability endpoints and updated with nuamce ones --- app/assets/javascripts/webchat/library.js | 33 +++++++++++++++++++-- lib/webchat.yaml | 36 +++++++++++------------ 2 files changed, 48 insertions(+), 21 deletions(-) diff --git a/app/assets/javascripts/webchat/library.js b/app/assets/javascripts/webchat/library.js index 1733eb083..df3bcaeee 100644 --- a/app/assets/javascripts/webchat/library.js +++ b/app/assets/javascripts/webchat/library.js @@ -13,7 +13,9 @@ "BUSY", "UNAVAILABLE", "AVAILABLE", - "ERROR" + "ERROR", + "OFFLINE", + "ONLINE" ] var $el = $(options.$el) var openUrl = $el.attr('data-open-url') @@ -48,8 +50,33 @@ } function apiSuccess (result) { - var validState = API_STATES.indexOf(result.response) != -1 - var state = validState ? result.response : "ERROR" + //var validState = API_STATES.indexOf(result.response) != -1 + + + if(result.hasOwnProperty('inHOP')){ + var validState = API_STATES.indexOf(result.status.toUpperCase()) != -1 + var state = validState ? result.status : "ERROR" + if (result.inHOP){ + if(result.availability == "true"){ + if(result.status == "online"){ + state="AVAILABLE" + } + if (result.status == "busy"){ + state="BUSY" + } + if (result.status == "offline"){ + state="UNAVAILABLE" + } + }else{ + state="UNAVAILABLE" + } + }else{ + state = "UNAVAILABLE" + } + }else{ + var validState = API_STATES.indexOf(result.response) != -1 + var state = validState ? result.response : "ERROR" + } advisorStateChange(state) } diff --git a/lib/webchat.yaml b/lib/webchat.yaml index 08162ccee..f3114094b 100644 --- a/lib/webchat.yaml +++ b/lib/webchat.yaml @@ -2,32 +2,32 @@ open_url: https://www.tax.service.gov.uk/csp-partials/open/1027 availability_url: https://www.tax.service.gov.uk/csp-partials/availability/1027 - base_path: /government/organisations/hm-revenue-customs/contact/income-tax-enquiries-for-individuals-pensioners-and-employees - open_url: https://www.tax.service.gov.uk/csp-partials/open/1030 - availability_url: https://www.tax.service.gov.uk/csp-partials/availability/1030 + open_url: https://tax.service.gov.uk/ask-hmrc/webchat/income-tax-enquiries-for-individuals-pensioners-and-employees + availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=PTO-PAYE - base_path: /government/organisations/hm-revenue-customs/contact/vat-online-services-helpdesk - open_url: https://www.tax.service.gov.uk/csp-partials/open/1026 - availability_url: https://www.tax.service.gov.uk/csp-partials/availability/1026 + open_url: https://tax.service.gov.uk/ask-hmrc/webchat/vat-online-services-helpdesk + availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=BTAC-VAT - base_path: /government/organisations/hm-revenue-customs/contact/national-insurance-numbers - open_url: https://www.tax.service.gov.uk/csp-partials/open/1021 - availability_url: https://www.tax.service.gov.uk/csp-partials/availability/1021 + open_url: https://tax.service.gov.uk/ask-hmrc/webchat/national-insurance-numbers + availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=PTO-NI - base_path: /government/organisations/hm-revenue-customs/contact/self-assessment - open_url: https://www.tax.service.gov.uk/csp-partials/open/1004 - availability_url: https://www.tax.service.gov.uk/csp-partials/availability/1004 + open_url: https://tax.service.gov.uk/ask-hmrc/webchat/self-assessment + availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=PTO-SA - base_path: /government/organisations/hm-revenue-customs/contact/tax-credits-enquiries - open_url: https://www.tax.service.gov.uk/csp-partials/open/1016 - availability_url: https://www.tax.service.gov.uk/csp-partials/availability/1016 + open_url: https://tax.service.gov.uk/ask-hmrc/webchat/tax-credits-enquiries + availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=BTAC-TC - base_path: /government/organisations/hm-revenue-customs/contact/vat-enquiries - open_url: https://www.tax.service.gov.uk/csp-partials/open/1028 - availability_url: https://www.tax.service.gov.uk/csp-partials/availability/1028 + open_url: https://tax.service.gov.uk/ask-hmrc/webchat/vat-enquiries + availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=BTAC-VAT - base_path: /government/organisations/hm-revenue-customs/contact/customs-international-trade-and-excise-enquiries - open_url: https://www.tax.service.gov.uk/csp-partials/open/1034 - availability_url: https://www.tax.service.gov.uk/csp-partials/availability/1034 + open_url: https://tax.service.gov.uk/ask-hmrc/webchat/customs-international-trade-and-excise-enquiries + availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=BTAC-EXC - base_path: /government/organisations/hm-revenue-customs/contact/employer-enquiries - open_url: https://www.tax.service.gov.uk/csp-partials/open/1023 - availability_url: https://www.tax.service.gov.uk/csp-partials/availability/1023 + open_url: https://tax.service.gov.uk/ask-hmrc/webchat/employer-enquiries + availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=PTO-EHL&siteID=10006719&businessUnitID=19001214 - base_path: /government/organisations/hm-revenue-customs/contact/online-services-helpdesk - open_url: https://www.tax.service.gov.uk/csp-partials/open/1003 - availability_url: https://www.tax.service.gov.uk/csp-partials/availability/1003 + open_url: https://tax.service.gov.uk/ask-hmrc/webchat/online-services-helpdesk + availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=PTO-OSH - base_path: /government/organisations/hm-revenue-customs/contact/charities-and-community-amateur-sports-clubs-cascs open_url: https://www.tax.service.gov.uk/csp-partials/open/1087 availability_url: https://www.tax.service.gov.uk/csp-partials/availability/1087 From a3fcbac5e1e6bf0ddf5fb4e16bf948dfea682b05 Mon Sep 17 00:00:00 2001 From: Rob Bond Date: Thu, 9 Jan 2020 15:09:36 +0000 Subject: [PATCH 02/15] added open_url_redirect flag to specifie webchat session to open in same browser instance --- lib/webchat.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/webchat.yaml b/lib/webchat.yaml index f3114094b..a9fbfd34a 100644 --- a/lib/webchat.yaml +++ b/lib/webchat.yaml @@ -24,6 +24,7 @@ availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=BTAC-EXC - base_path: /government/organisations/hm-revenue-customs/contact/employer-enquiries open_url: https://tax.service.gov.uk/ask-hmrc/webchat/employer-enquiries + open_url_redirect: true availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=PTO-EHL&siteID=10006719&businessUnitID=19001214 - base_path: /government/organisations/hm-revenue-customs/contact/online-services-helpdesk open_url: https://tax.service.gov.uk/ask-hmrc/webchat/online-services-helpdesk From 700dd3f7531f31273619c317269b6ad7e262dbd3 Mon Sep 17 00:00:00 2001 From: Rob Bond Date: Thu, 9 Jan 2020 15:10:47 +0000 Subject: [PATCH 03/15] updated model to check for open_url_redirect flag --- app/models/webchat.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/webchat.rb b/app/models/webchat.rb index 82234d754..d25f2d3eb 100644 --- a/app/models/webchat.rb +++ b/app/models/webchat.rb @@ -5,13 +5,13 @@ class Webchat validates_presence_of :base_path, :open_url, :availability_url - attr_reader :base_path, :open_url, :availability_url + attr_reader :base_path, :open_url, :availability_url, :open_url_redirect def initialize(attrs) @base_path = attrs["base_path"] if attrs["base_path"].present? @open_url = attrs["open_url"] if attrs["open_url"].present? @availability_url = attrs["availability_url"] if attrs["availability_url"].present? - + @open_url_redirect = attrs.fetch("open_url_redirect", nil) validate! end From 3bb30e0a0d85d52b3b919a407875ef7b9b41fe7d Mon Sep 17 00:00:00 2001 From: Rob Bond Date: Thu, 9 Jan 2020 15:11:59 +0000 Subject: [PATCH 04/15] added open_url_redirect flag as a data attribute to the view --- app/views/shared/_webchat.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/shared/_webchat.html.erb b/app/views/shared/_webchat.html.erb index d92d74f53..f1fe711b1 100644 --- a/app/views/shared/_webchat.html.erb +++ b/app/views/shared/_webchat.html.erb @@ -19,7 +19,7 @@ <% end %> From a8de4128d4e086e9cfeb73b60448c6144c6510e7 Mon Sep 17 00:00:00 2001 From: Rob Bond Date: Thu, 9 Jan 2020 15:13:15 +0000 Subject: [PATCH 05/15] added conditional handling dependant on the open_url redirect flag to open openUrl in same browser or new window --- app/assets/javascripts/webchat/library.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/webchat/library.js b/app/assets/javascripts/webchat/library.js index df3bcaeee..e167614cc 100644 --- a/app/assets/javascripts/webchat/library.js +++ b/app/assets/javascripts/webchat/library.js @@ -34,7 +34,7 @@ function handleOpenChat (evt) { evt.preventDefault() - global.open(openUrl, 'newwin', 'width=366,height=516') + this.dataset.redirect =="true" ? window.location.href = openUrl : global.open(openUrl, 'newwin', 'width=366,height=516') trackEvent('opened') } From 09a065f43a73085ecfe7a46656649573ac8bdd17 Mon Sep 17 00:00:00 2001 From: Rob Bond Date: Thu, 9 Jan 2020 15:29:38 +0000 Subject: [PATCH 06/15] amended yaml to update with latest Nuance queue mappings --- lib/webchat.yaml | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/lib/webchat.yaml b/lib/webchat.yaml index a9fbfd34a..aa01da5ab 100644 --- a/lib/webchat.yaml +++ b/lib/webchat.yaml @@ -1,34 +1,43 @@ - base_path: /government/organisations/hm-revenue-customs/contact/child-benefit - open_url: https://www.tax.service.gov.uk/csp-partials/open/1027 - availability_url: https://www.tax.service.gov.uk/csp-partials/availability/1027 + open_url: https://tax.service.gov.uk/ask-hmrc/webchat/child-benefit + availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=BAC-ChB&siteID=10006719&businessUnitID=19001214 + open_url_redirect: true - base_path: /government/organisations/hm-revenue-customs/contact/income-tax-enquiries-for-individuals-pensioners-and-employees open_url: https://tax.service.gov.uk/ask-hmrc/webchat/income-tax-enquiries-for-individuals-pensioners-and-employees - availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=PTO-PAYE + availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=PTO-PAYE&siteID=10006719&businessUnitID=19001214 + open_url_redirect: true - base_path: /government/organisations/hm-revenue-customs/contact/vat-online-services-helpdesk open_url: https://tax.service.gov.uk/ask-hmrc/webchat/vat-online-services-helpdesk - availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=BTAC-VAT + availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=BTAC-VAT&siteID=10006719&businessUnitID=19001214 + open_url_redirect: true - base_path: /government/organisations/hm-revenue-customs/contact/national-insurance-numbers open_url: https://tax.service.gov.uk/ask-hmrc/webchat/national-insurance-numbers - availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=PTO-NI + availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=PTO-NI&siteID=10006719&businessUnitID=19001214 + open_url_redirect: true - base_path: /government/organisations/hm-revenue-customs/contact/self-assessment open_url: https://tax.service.gov.uk/ask-hmrc/webchat/self-assessment - availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=PTO-SA + availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=PTO-SA&siteID=10006719&businessUnitID=19001214 + open_url_redirect: true - base_path: /government/organisations/hm-revenue-customs/contact/tax-credits-enquiries open_url: https://tax.service.gov.uk/ask-hmrc/webchat/tax-credits-enquiries - availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=BTAC-TC + availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=BTAC-TC&siteID=10006719&businessUnitID=19001214 + open_url_redirect: true - base_path: /government/organisations/hm-revenue-customs/contact/vat-enquiries open_url: https://tax.service.gov.uk/ask-hmrc/webchat/vat-enquiries - availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=BTAC-VAT + availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=BTAC-VAT&siteID=10006719&businessUnitID=19001214 + open_url_redirect: true - base_path: /government/organisations/hm-revenue-customs/contact/customs-international-trade-and-excise-enquiries open_url: https://tax.service.gov.uk/ask-hmrc/webchat/customs-international-trade-and-excise-enquiries - availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=BTAC-EXC + availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=BTAC-EXC&siteID=10006719&businessUnitID=19001214 + open_url_redirect: true - base_path: /government/organisations/hm-revenue-customs/contact/employer-enquiries open_url: https://tax.service.gov.uk/ask-hmrc/webchat/employer-enquiries - open_url_redirect: true availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=PTO-EHL&siteID=10006719&businessUnitID=19001214 + open_url_redirect: true - base_path: /government/organisations/hm-revenue-customs/contact/online-services-helpdesk open_url: https://tax.service.gov.uk/ask-hmrc/webchat/online-services-helpdesk - availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=PTO-OSH + availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=PTO-OSH&siteID=10006719&businessUnitID=19001214 + open_url_redirect: true - base_path: /government/organisations/hm-revenue-customs/contact/charities-and-community-amateur-sports-clubs-cascs open_url: https://www.tax.service.gov.uk/csp-partials/open/1087 availability_url: https://www.tax.service.gov.uk/csp-partials/availability/1087 From e82cd8279e13a0a0ec410f0db00b317d38c41fe3 Mon Sep 17 00:00:00 2001 From: Rob Bond Date: Thu, 16 Jan 2020 15:58:21 +0000 Subject: [PATCH 07/15] updated the correct ids for the nuance web queues --- app/assets/javascripts/webchat/library.js | 1 + lib/webchat.yaml | 37 +++++++---------------- 2 files changed, 12 insertions(+), 26 deletions(-) diff --git a/app/assets/javascripts/webchat/library.js b/app/assets/javascripts/webchat/library.js index e167614cc..dd3810e26 100644 --- a/app/assets/javascripts/webchat/library.js +++ b/app/assets/javascripts/webchat/library.js @@ -42,6 +42,7 @@ var ajaxConfig = { url: availabilityUrl, type: 'GET', + dataType: "jsonp", timeout: AJAX_TIMEOUT, success: apiSuccess, error: apiError diff --git a/lib/webchat.yaml b/lib/webchat.yaml index aa01da5ab..9d73805eb 100644 --- a/lib/webchat.yaml +++ b/lib/webchat.yaml @@ -1,55 +1,40 @@ - base_path: /government/organisations/hm-revenue-customs/contact/child-benefit open_url: https://tax.service.gov.uk/ask-hmrc/webchat/child-benefit - availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=BAC-ChB&siteID=10006719&businessUnitID=19001214 + availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=10006859&siteID=10006719&businessUnitID=19001235 open_url_redirect: true - base_path: /government/organisations/hm-revenue-customs/contact/income-tax-enquiries-for-individuals-pensioners-and-employees open_url: https://tax.service.gov.uk/ask-hmrc/webchat/income-tax-enquiries-for-individuals-pensioners-and-employees - availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=PTO-PAYE&siteID=10006719&businessUnitID=19001214 + availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=10006852&siteID=10006719&businessUnitID=19001235 open_url_redirect: true - base_path: /government/organisations/hm-revenue-customs/contact/vat-online-services-helpdesk open_url: https://tax.service.gov.uk/ask-hmrc/webchat/vat-online-services-helpdesk - availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=BTAC-VAT&siteID=10006719&businessUnitID=19001214 + availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=10006860&siteID=10006719&businessUnitID=19001235 open_url_redirect: true - base_path: /government/organisations/hm-revenue-customs/contact/national-insurance-numbers open_url: https://tax.service.gov.uk/ask-hmrc/webchat/national-insurance-numbers - availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=PTO-NI&siteID=10006719&businessUnitID=19001214 + availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=10006855&siteID=10006719&businessUnitID=19001235 open_url_redirect: true - base_path: /government/organisations/hm-revenue-customs/contact/self-assessment open_url: https://tax.service.gov.uk/ask-hmrc/webchat/self-assessment - availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=PTO-SA&siteID=10006719&businessUnitID=19001214 + availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=10006851&siteID=10006719&businessUnitID=19001235 open_url_redirect: true - base_path: /government/organisations/hm-revenue-customs/contact/tax-credits-enquiries open_url: https://tax.service.gov.uk/ask-hmrc/webchat/tax-credits-enquiries - availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=BTAC-TC&siteID=10006719&businessUnitID=19001214 + availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=10006858&siteID=10006719&businessUnitID=19001235 open_url_redirect: true - base_path: /government/organisations/hm-revenue-customs/contact/vat-enquiries open_url: https://tax.service.gov.uk/ask-hmrc/webchat/vat-enquiries - availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=BTAC-VAT&siteID=10006719&businessUnitID=19001214 + availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=10006860&siteID=10006719&businessUnitID=19001235 open_url_redirect: true - base_path: /government/organisations/hm-revenue-customs/contact/customs-international-trade-and-excise-enquiries open_url: https://tax.service.gov.uk/ask-hmrc/webchat/customs-international-trade-and-excise-enquiries - availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=BTAC-EXC&siteID=10006719&businessUnitID=19001214 + availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=10006861&siteID=10006719&businessUnitID=19001235 open_url_redirect: true - base_path: /government/organisations/hm-revenue-customs/contact/employer-enquiries open_url: https://tax.service.gov.uk/ask-hmrc/webchat/employer-enquiries - availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=PTO-EHL&siteID=10006719&businessUnitID=19001214 + availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=10006854&siteID=10006719&businessUnitID=19001235 open_url_redirect: true - base_path: /government/organisations/hm-revenue-customs/contact/online-services-helpdesk open_url: https://tax.service.gov.uk/ask-hmrc/webchat/online-services-helpdesk - availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=PTO-OSH&siteID=10006719&businessUnitID=19001214 - open_url_redirect: true -- base_path: /government/organisations/hm-revenue-customs/contact/charities-and-community-amateur-sports-clubs-cascs - open_url: https://www.tax.service.gov.uk/csp-partials/open/1087 - availability_url: https://www.tax.service.gov.uk/csp-partials/availability/1087 -- base_path: /government/organisations/hm-revenue-customs/contact/enquiries-from-employers-with-expatriate-employees - open_url: https://www.tax.service.gov.uk/csp-partials/open/1089 - availability_url: https://www.tax.service.gov.uk/csp-partials/availability/1089 -- base_path: /government/organisations/hm-revenue-customs/contact/share-schemes-for-employees - open_url: https://www.tax.service.gov.uk/csp-partials/open/1088 - availability_url: https://www.tax.service.gov.uk/csp-partials/availability/1088 -- base_path: /government/organisations/hm-revenue-customs/contact/non-uk-expatriate-employees-expats - open_url: https://www.tax.service.gov.uk/csp-partials/open/1089 - availability_url: https://www.tax.service.gov.uk/csp-partials/availability/1089 -- base_path: /government/organisations/hm-revenue-customs/contact/non-resident-landlords - open_url: https://www.tax.service.gov.uk/csp-partials/open/1086 - availability_url: https://www.tax.service.gov.uk/csp-partials/availability/1086 + availability_url: https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=10006856&siteID=10006719&businessUnitID=19001235 + open_url_redirect: true From 341fa33b04d686e2de69cbe718b3497fb92d1a2c Mon Sep 17 00:00:00 2001 From: Rob Bond Date: Fri, 17 Jan 2020 07:21:13 +0000 Subject: [PATCH 08/15] adjusted condition for out of business hours response --- app/assets/javascripts/webchat/library.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/webchat/library.js b/app/assets/javascripts/webchat/library.js index dd3810e26..9e3495109 100644 --- a/app/assets/javascripts/webchat/library.js +++ b/app/assets/javascripts/webchat/library.js @@ -57,7 +57,7 @@ if(result.hasOwnProperty('inHOP')){ var validState = API_STATES.indexOf(result.status.toUpperCase()) != -1 var state = validState ? result.status : "ERROR" - if (result.inHOP){ + if (result.inHOP == "true"){ if(result.availability == "true"){ if(result.status == "online"){ state="AVAILABLE" From 4b1899e9accd3637e6b637ca28c243878c8a268f Mon Sep 17 00:00:00 2001 From: Rob Bond Date: Tue, 21 Jan 2020 09:15:14 +0000 Subject: [PATCH 09/15] added request payload type attribute - default is jsonp for HMRC/Nuance --- app/assets/javascripts/webchat/library.js | 3 ++- app/models/webchat.rb | 3 ++- app/views/shared/_webchat.html.erb | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/webchat/library.js b/app/assets/javascripts/webchat/library.js index 9e3495109..f365e111e 100644 --- a/app/assets/javascripts/webchat/library.js +++ b/app/assets/javascripts/webchat/library.js @@ -24,6 +24,7 @@ var webchatStateClass = 'js-webchat-advisers-' var intervalID = null var lastRecordedState = null + var response_datatype = $el.attr('data-redirect') function init () { if (!availabilityUrl || !openUrl) throw 'urls for webchat not defined' @@ -42,7 +43,7 @@ var ajaxConfig = { url: availabilityUrl, type: 'GET', - dataType: "jsonp", + dataType: response_datatype, timeout: AJAX_TIMEOUT, success: apiSuccess, error: apiError diff --git a/app/models/webchat.rb b/app/models/webchat.rb index d25f2d3eb..b3ebecd32 100644 --- a/app/models/webchat.rb +++ b/app/models/webchat.rb @@ -5,13 +5,14 @@ class Webchat validates_presence_of :base_path, :open_url, :availability_url - attr_reader :base_path, :open_url, :availability_url, :open_url_redirect + attr_reader :base_path, :open_url, :availability_url, :open_url_redirect, :availability_payload_format def initialize(attrs) @base_path = attrs["base_path"] if attrs["base_path"].present? @open_url = attrs["open_url"] if attrs["open_url"].present? @availability_url = attrs["availability_url"] if attrs["availability_url"].present? @open_url_redirect = attrs.fetch("open_url_redirect", nil) + @availability_payload_format = attrs.fetch("availability_payload_format", nil) validate! end diff --git a/app/views/shared/_webchat.html.erb b/app/views/shared/_webchat.html.erb index f1fe711b1..74a4a3fdf 100644 --- a/app/views/shared/_webchat.html.erb +++ b/app/views/shared/_webchat.html.erb @@ -4,6 +4,7 @@ <% if webchat_unavailable? %> <%= unavailability_message %> From f1f4eb7aef355756ef4197f368c831c9f9a382a4 Mon Sep 17 00:00:00 2001 From: Rob Bond Date: Tue, 21 Jan 2020 12:24:07 +0000 Subject: [PATCH 10/15] updated test for new availability urls --- spec/javascripts/webchat.spec.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/javascripts/webchat.spec.js b/spec/javascripts/webchat.spec.js index 73d5bfba1..436cf4324 100644 --- a/spec/javascripts/webchat.spec.js +++ b/spec/javascripts/webchat.spec.js @@ -8,9 +8,9 @@ describe('Webchat', function () { // Stub analytics. GOVUK.analytics = GOVUK.analytics || {} GOVUK.analytics.trackEvent = function () {} - var CHILD_BENEFIT_API_URL = 'https://www.tax.service.gov.uk/csp-partials/open/' + - 1027 - var INSERTION_HOOK = '
' + + var CHILD_BENEFIT_API_URL = 'https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=10006859&siteID=10006719&businessUnitID=19001235' + + var INSERTION_HOOK = '
' + '
Error
' + '' + '' + @@ -68,7 +68,7 @@ describe('Webchat', function () { mount() expect( $.ajax - ).toHaveBeenCalledWith({ url: CHILD_BENEFIT_API_URL, type: 'GET', timeout: jasmine.any(Number), success: jasmine.any(Function), error: jasmine.any(Function) }) + ).toHaveBeenCalledWith({ url: CHILD_BENEFIT_API_URL, type: 'GET', dataType: "jsonp" ,timeout: jasmine.any(Number), success: jasmine.any(Function), error: jasmine.any(Function) }) }) it('should inform user whether advisors are available', function () { From e53800e01bfcf9c250c945e86478341a44d48187 Mon Sep 17 00:00:00 2001 From: Rob Bond Date: Tue, 21 Jan 2020 12:32:29 +0000 Subject: [PATCH 11/15] updated test for present webchat --- test/presenters/contact_presenter_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/presenters/contact_presenter_test.rb b/test/presenters/contact_presenter_test.rb index 67ef8c498..319847a49 100644 --- a/test/presenters/contact_presenter_test.rb +++ b/test/presenters/contact_presenter_test.rb @@ -88,8 +88,8 @@ def schema_name schema = schema_item("contact_with_webchat") presented = present_example(schema) assert_equal true, presented.show_webchat? - assert_equal presented.webchat.availability_url, "https://www.tax.service.gov.uk/csp-partials/availability/1030" - assert_equal presented.webchat.open_url, "https://www.tax.service.gov.uk/csp-partials/open/1030" + assert_equal presented.webchat.availability_url, "https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=10006852&siteID=10006719&businessUnitID=19001235" + assert_equal presented.webchat.open_url, "https://tax.service.gov.uk/ask-hmrc/webchat/child-benefit" end end end From 7fd9939ca03d973589bfded04bcc43e792f46416 Mon Sep 17 00:00:00 2001 From: Rob Bond Date: Tue, 21 Jan 2020 12:55:41 +0000 Subject: [PATCH 12/15] adjusted test --- test/presenters/contact_presenter_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/presenters/contact_presenter_test.rb b/test/presenters/contact_presenter_test.rb index 319847a49..60b1a804c 100644 --- a/test/presenters/contact_presenter_test.rb +++ b/test/presenters/contact_presenter_test.rb @@ -89,7 +89,7 @@ def schema_name presented = present_example(schema) assert_equal true, presented.show_webchat? assert_equal presented.webchat.availability_url, "https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=10006852&siteID=10006719&businessUnitID=19001235" - assert_equal presented.webchat.open_url, "https://tax.service.gov.uk/ask-hmrc/webchat/child-benefit" + # assert_equal presented.webchat.open_url, "https://tax.service.gov.uk/ask-hmrc/webchat/child-benefit" end end end From 8e105bebdb02cf5ad59962e7d3f0bf10b7a1a0e7 Mon Sep 17 00:00:00 2001 From: Rob Bond Date: Tue, 21 Jan 2020 16:53:40 +0000 Subject: [PATCH 13/15] updated as per comments --- app/assets/javascripts/webchat/library.js | 34 +++++++++++------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/app/assets/javascripts/webchat/library.js b/app/assets/javascripts/webchat/library.js index f365e111e..2adca0f4b 100644 --- a/app/assets/javascripts/webchat/library.js +++ b/app/assets/javascripts/webchat/library.js @@ -52,33 +52,31 @@ } function apiSuccess (result) { - //var validState = API_STATES.indexOf(result.response) != -1 - if(result.hasOwnProperty('inHOP')){ var validState = API_STATES.indexOf(result.status.toUpperCase()) != -1 var state = validState ? result.status : "ERROR" if (result.inHOP == "true"){ - if(result.availability == "true"){ - if(result.status == "online"){ - state="AVAILABLE" - } - if (result.status == "busy"){ - state="BUSY" - } - if (result.status == "offline"){ - state="UNAVAILABLE" - } - }else{ - state="UNAVAILABLE" - } + if(result.availability == "true"){ + if(result.status == "online"){ + state="AVAILABLE" + } + if (result.status == "busy"){ + state="BUSY" + } + if (result.status == "offline"){ + state="UNAVAILABLE" + } }else{ - state = "UNAVAILABLE" + state="UNAVAILABLE" } }else{ - var validState = API_STATES.indexOf(result.response) != -1 - var state = validState ? result.response : "ERROR" + state = "UNAVAILABLE" } + }else{ + var validState = API_STATES.indexOf(result.response) != -1 + var state = validState ? result.response : "ERROR" + } advisorStateChange(state) } From 6be8da6013e22a0f070c6b696c627ddc4ec032ff Mon Sep 17 00:00:00 2001 From: Rob Bond Date: Tue, 21 Jan 2020 17:07:26 +0000 Subject: [PATCH 14/15] fixed test to assert correct value instead of commenting out --- test/presenters/contact_presenter_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/presenters/contact_presenter_test.rb b/test/presenters/contact_presenter_test.rb index 60b1a804c..d51e71401 100644 --- a/test/presenters/contact_presenter_test.rb +++ b/test/presenters/contact_presenter_test.rb @@ -89,7 +89,7 @@ def schema_name presented = present_example(schema) assert_equal true, presented.show_webchat? assert_equal presented.webchat.availability_url, "https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=10006852&siteID=10006719&businessUnitID=19001235" - # assert_equal presented.webchat.open_url, "https://tax.service.gov.uk/ask-hmrc/webchat/child-benefit" + assert_equal presented.webchat.open_url, "https://tax.service.gov.uk/ask-hmrc/webchat/income-tax-enquiries-for-individuals-pensioners-and-employees" end end end From cddc735574bfc7f5de6476b699a90ecf7121aa27 Mon Sep 17 00:00:00 2001 From: Rob Bond Date: Tue, 21 Jan 2020 17:16:08 +0000 Subject: [PATCH 15/15] fixed lint error --- test/presenters/contact_presenter_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/presenters/contact_presenter_test.rb b/test/presenters/contact_presenter_test.rb index d51e71401..2afb391ac 100644 --- a/test/presenters/contact_presenter_test.rb +++ b/test/presenters/contact_presenter_test.rb @@ -89,7 +89,7 @@ def schema_name presented = present_example(schema) assert_equal true, presented.show_webchat? assert_equal presented.webchat.availability_url, "https://hmrc-uk.digital.nuance.com/tagserver/launch/agentAvailability?agentGroupID=10006852&siteID=10006719&businessUnitID=19001235" - assert_equal presented.webchat.open_url, "https://tax.service.gov.uk/ask-hmrc/webchat/income-tax-enquiries-for-individuals-pensioners-and-employees" + assert_equal presented.webchat.open_url, "https://tax.service.gov.uk/ask-hmrc/webchat/income-tax-enquiries-for-individuals-pensioners-and-employees" end end end