File tree Expand file tree Collapse file tree 2 files changed +8
-11
lines changed
__test__/extensions/message-handlers
src/extensions/message-handlers/ngpvan-optout Expand file tree Collapse file tree 2 files changed +8
-11
lines changed Original file line number Diff line number Diff line change @@ -21,8 +21,8 @@ describe("extensions.message-handlers.ngpvan-optout", () => {
2121
2222 contact = {
2323 message_status : "needsMessage" ,
24- customFields : '{"vanid": 12345}' ,
25- cell : "( 123) -456-7891"
24+ custom_fields : '{"vanid": 12345}' ,
25+ cell : "123-456-7891"
2626 } ;
2727
2828 organization = {
@@ -39,11 +39,11 @@ describe("extensions.message-handlers.ngpvan-optout", () => {
3939 "inputTypeId" : 11 , // API input
4040 "phone" : {
4141 "dialingPrefix" : "1" ,
42- "phoneNumber" : "1234567891 " ,
42+ "phoneNumber" : "123-456-7891 " ,
4343 "smsOptInStatus" : "O" // opt out status
4444 }
4545 } ,
46- "resultCodeId" : 205
46+ "resultCodeId" : 130
4747 } ;
4848
4949 jest . spyOn ( Config , "getConfig" ) . mockReturnValue ( undefined ) ;
@@ -102,7 +102,7 @@ describe("extensions.message-handlers.ngpvan-optout", () => {
102102 beforeEach ( async ( ) => {
103103 contact = {
104104 ...contact ,
105- customFields : '{}'
105+ custom_fields : '{}'
106106 } ;
107107 } ) ;
108108
Original file line number Diff line number Diff line change @@ -47,28 +47,25 @@ export const postMessageSave = async ({
4747 // we don't want to call that function every time if a vanid
4848 // was never provided in the first place. Example: CSV
4949 try {
50- customField = JSON . parse ( contact . customFields ) ;
50+ customField = JSON . parse ( contact . custom_fields ) ;
5151 vanId = customField . VanID || customField . vanid ;
5252 if ( ! vanId ) return { }
5353 } catch ( exception ) {
5454 console . log ( "message-handlers | ngpvan-optout ERROR" , exception ) ;
5555 return { } ;
5656 }
5757
58- // Testing shows that "-" , "(", and ")" break this request
59- const cell = contact . cell . replace ( / \D / g, '' )
60-
6158 // https://docs.ngpvan.com/reference/peoplevanidcanvassresponses
6259 const body = {
6360 "canvassContext" : {
6461 "inputTypeId" : 11 , // API input
6562 "phone" : {
6663 "dialingPrefix" : "1" ,
67- "phoneNumber" : cell ,
64+ "phoneNumber" : contact . cell ,
6865 "smsOptInStatus" : "O" // opt out status
6966 }
7067 } ,
71- "resultCodeId" : 205
68+ "resultCodeId" : 130 // Do Not Text result code
7269 } ;
7370
7471 return Van . postCanvassResponse ( contact , organization , body )
You can’t perform that action at this time.
0 commit comments