@@ -135,6 +135,13 @@ var BringgSDK = (function () {
135135 log ( 'new shared config ' + JSON . stringify ( updatedConfiguration ) ) ;
136136
137137 var afterCall = new Date ( ) - beforeCall ;
138+
139+ //update relative paths
140+ updatedConfiguration . employee_image = _updateAssetPath ( updatedConfiguration . employee_image ) ;
141+ updatedConfiguration . deliveryPin = _updateAssetPath ( updatedConfiguration . deliveryPin ) ;
142+ updatedConfiguration . destinationPin = _updateAssetPath ( updatedConfiguration . destinationPin ) ;
143+ updatedConfiguration . merchant_logo = _updateAssetPath ( updatedConfiguration . merchant_logo ) ;
144+
138145 configuration = updatedConfiguration ;
139146 configuration . share_uuid = shareUuid ;
140147
@@ -170,26 +177,26 @@ var BringgSDK = (function () {
170177 * closes the socket connection and clear any polling tasks that are currently running.
171178 */
172179 module . disconnect =
173- module . terminateBringg = function ( ) {
174- module . _closeSocketConnection ( ) ;
180+ module . terminateBringg = function ( ) {
181+ module . _closeSocketConnection ( ) ;
175182
176- if ( locationFramesInterval ) {
177- clearInterval ( locationFramesInterval ) ;
178- }
179- if ( etaInterval ) {
180- clearInterval ( etaInterval ) ;
181- }
182- if ( pollingInterval ) {
183- clearInterval ( pollingInterval ) ;
184- }
183+ if ( locationFramesInterval ) {
184+ clearInterval ( locationFramesInterval ) ;
185+ }
186+ if ( etaInterval ) {
187+ clearInterval ( etaInterval ) ;
188+ }
189+ if ( pollingInterval ) {
190+ clearInterval ( pollingInterval ) ;
191+ }
185192
186- // clear only the tracking credentials since we might want to use other configs like rating url later.
187- if ( configuration ) {
188- configuration . share_uuid = null ;
189- configuration . order_uuid = null ;
190- configuration . way_point_id = null ;
191- }
192- } ;
193+ // clear only the tracking credentials since we might want to use other configs like rating url later.
194+ if ( configuration ) {
195+ configuration . share_uuid = null ;
196+ configuration . order_uuid = null ;
197+ configuration . way_point_id = null ;
198+ }
199+ } ;
193200
194201 module . isConnected = function ( ) {
195202 return connected ;
@@ -457,36 +464,36 @@ var BringgSDK = (function () {
457464 var fileName = guid ( ) + '.jpg' ;
458465
459466 if ( configuration && configuration . tipConfiguration && configuration . tipConfiguration . tipSignatureUploadPath
460- && configuration . tipConfiguration . tipCurrency && configuration . tip_token && tipConfiguration . tipUrl )
461- $ . post ( configuration . tipConfiguration . tipSignatureUploadPath , {
462- amount : tip ,
463- signatureImage : fileName ,
464- currency : configuration . tipConfiguration . tipCurrency ,
465- type : blob . type ,
466- tipToken : configuration . tip_token
467- } , function ( urlResponse ) {
468- $ . ajax ( {
469- url : urlResponse . url ,
470- type : 'PUT' ,
471- data : blob ,
472- processData : false ,
473- contentType : blob . type
474- } ) . success ( function ( res ) {
475- $ . post ( configuration . tipConfiguration . tipUrl , {
476- amount : tip ,
477- tipToken : configuration . tip_token ,
478- signatureImage : fileName ,
479- currency : configuration . tipConfiguration . tipCurrency ,
480- taskNoteId : urlResponse . note_id
467+ && configuration . tipConfiguration . tipCurrency && configuration . tip_token && tipConfiguration . tipUrl )
468+ $ . post ( configuration . tipConfiguration . tipSignatureUploadPath , {
469+ amount : tip ,
470+ signatureImage : fileName ,
471+ currency : configuration . tipConfiguration . tipCurrency ,
472+ type : blob . type ,
473+ tipToken : configuration . tip_token
474+ } , function ( urlResponse ) {
475+ $ . ajax ( {
476+ url : urlResponse . url ,
477+ type : 'PUT' ,
478+ data : blob ,
479+ processData : false ,
480+ contentType : blob . type
481481 } ) . success ( function ( res ) {
482+ $ . post ( configuration . tipConfiguration . tipUrl , {
483+ amount : tip ,
484+ tipToken : configuration . tip_token ,
485+ signatureImage : fileName ,
486+ currency : configuration . tipConfiguration . tipCurrency ,
487+ taskNoteId : urlResponse . note_id
488+ } ) . success ( function ( res ) {
482489
483- } ) . fail ( function ( res ) {
490+ } ) . fail ( function ( res ) {
484491
492+ } ) ;
485493 } ) ;
486- } ) ;
487- } ) . fail ( function ( res ) {
494+ } ) . fail ( function ( res ) {
488495
489- } ) ;
496+ } ) ;
490497 } ;
491498
492499 /**
@@ -575,26 +582,26 @@ var BringgSDK = (function () {
575582
576583 function getRealTimeEndPoint ( ) {
577584 return window . MONITOR_END_POINT ?
578- window . MONITOR_END_POINT . indexOf ( '/' , this . length - 1 ) !== - 1 ? window . MONITOR_END_POINT : window . MONITOR_END_POINT + '/'
579- : REAL_TIME_OPTIONS . END_POINT ;
585+ window . MONITOR_END_POINT . indexOf ( '/' , this . length - 1 ) !== - 1 ? window . MONITOR_END_POINT : window . MONITOR_END_POINT + '/'
586+ : REAL_TIME_OPTIONS . END_POINT ;
580587 }
581588
582589 function getWebSocketPort ( ) {
583590 return window . SOCKET_WEBSOCKET_PORT ? window . SOCKET_WEBSOCKET_PORT
584- : isLocal ( ) ? '3030'
585- : REAL_TIME_OPTIONS . SOCKET_WEBSOCKET_PORT ;
591+ : isLocal ( ) ? '3030'
592+ : REAL_TIME_OPTIONS . SOCKET_WEBSOCKET_PORT ;
586593 }
587594
588595 function getXHRPort ( ) {
589596 return window . SOCKET_XHR_PORT ? window . SOCKET_XHR_PORT
590- : isLocal ( ) ? '3030'
591- : REAL_TIME_OPTIONS . SOCKET_XHR_PORT ;
597+ : isLocal ( ) ? '3030'
598+ : REAL_TIME_OPTIONS . SOCKET_XHR_PORT ;
592599 }
593600
594601 function getSecuredSocketSetup ( ) {
595602 return window . SECURED_SOCKETS ? window . SECURED_SOCKETS
596- : isLocal ( ) ? false
597- : REAL_TIME_OPTIONS . SECURED_SOCKETS ;
603+ : isLocal ( ) ? false
604+ : REAL_TIME_OPTIONS . SECURED_SOCKETS ;
598605 }
599606
600607 // ========================================================================
@@ -1140,6 +1147,16 @@ var BringgSDK = (function () {
11401147
11411148 module . _onOrderUpdate = function ( order ) {
11421149 fillConfig ( order ) ;
1150+
1151+ //update relative paths
1152+ if ( order . customer ) {
1153+ order . customer . image = _updateAssetPath ( order . customer . image ) ;
1154+ }
1155+
1156+ if ( order . driver ) {
1157+ order . driver . profile_image = _updateAssetPath ( order . driver . profile_image ) ;
1158+ }
1159+
11431160 if ( ! configuration . order_uuid && order . uuid ) {
11441161 configuration . order_uuid = order . uuid ;
11451162 }
@@ -1390,9 +1407,17 @@ var BringgSDK = (function () {
13901407 head . appendChild ( script ) ;
13911408 }
13921409
1393- return module ;
1394- } ( ) ) ;
1395-
1410+ function _updateAssetPath ( path ) {
1411+ if ( ! path ) {
1412+ return path ;
1413+ }
13961414
1415+ if ( path . indexOf ( 'http' ) === - 1 ) {
1416+ return 'https://app.bringg.com' + path ;
1417+ }
13971418
1419+ return path ;
1420+ }
13981421
1422+ return module ;
1423+ } ( ) ) ;
0 commit comments