@@ -17,10 +17,8 @@ class ApiClient {
1717    this . databaseId  =  databaseId ; 
1818    this . publicToken  =  publicToken ; 
1919    this . options  =  options  ||  { } ; 
20-     this . baseUri  =  this . _getBaseUri ( ) ; 
20+     this . baseUri  =  this . getBaseUri ( ) ; 
2121    this . useHttps  =  'useHttps'  in  this . options  ? this . options . useHttps  : true ; 
22-     this . async  =  'async'  in  this . options  ? this . options . async  : true ; 
23-     this . future_v6_fetch  =  'future_v6_fetch'  in  this . options  ? this . options . future_v6_fetch  : false ; 
2422  } 
2523
2624  _getRegionalBaseUri ( region )  { 
@@ -40,7 +38,7 @@ class ApiClient {
4038    return  uri ; 
4139  } 
4240
43-   _getBaseUri ( )  { 
41+   getBaseUri ( )  { 
4442    let  baseUri  =  this . options . baseUri ; 
4543    if  ( this . options . region )  { 
4644      if  ( baseUri )  { 
@@ -57,22 +55,16 @@ class ApiClient {
5755   * @param  {Object } callback - Optional callback (send returns Promise if omitted) 
5856   */ 
5957  send ( request ,  callback )  { 
60-     if  ( this . future_v6_fetch )  { 
61-       if  ( ! ( typeof  globalThis  ===  'undefined'  ? window . Promise  : globalThis . Promise ) )  { 
62-         throw  new  Error ( 'future_v6_fetch requires Promises to be available.' ) ; 
63-       } 
64-       if  ( ! this . async )  { 
65-         throw  new  Error ( 'future_v6_fetch cannot be used with synchronous requests.' ) ; 
66-       } 
67-       if  ( callback  ===  undefined )  { 
68-         return  this . _sendFetch ( request ) ; 
69-       }  else  { 
70-         return  this . _sendFetch ( request ) 
71-           . then ( ( result )  =>  callback ( null ,  result ) ) 
72-           . catch ( callback ) ; 
73-       } 
58+     if  ( ! ( typeof  globalThis  ===  'undefined'  ? window . Promise  : globalThis . Promise ) )  { 
59+       throw  new  Error ( 'Recombee API Client requires Promises to be available.' ) ; 
60+     } 
61+     if  ( callback  ===  undefined )  { 
62+       return  this . _sendFetch ( request ) ; 
63+     }  else  { 
64+       return  this . _sendFetch ( request ) 
65+         . then ( ( result )  =>  callback ( null ,  result ) ) 
66+         . catch ( callback ) ; 
7467    } 
75-     return  this . _sendXhr ( request ,  callback ) ; 
7668  } 
7769
7870  async  _sendFetch ( request )  { 
@@ -102,42 +94,6 @@ class ApiClient {
10294    } 
10395  } 
10496
105-   _sendXhr ( request ,  callback )  { 
106-     const  Promise  =  typeof  globalThis  ===  'undefined'  ? window . Promise  : globalThis . Promise ; 
107-     if  ( callback  ===  undefined  &&  Promise )  { 
108-       const  sendXhr  =  this . _sendXhr . bind ( this ) ; 
109-       return  new  Promise ( function  ( resolve ,  reject )  { 
110-         sendXhr ( request ,  function  ( err ,  result )  { 
111-           return  err  ? reject ( err )  : resolve ( result ) ; 
112-         } ) ; 
113-       } ) ; 
114-     } 
115- 
116-     const  url  =  this . _getUrl ( request ) ; 
117-     const  xmlhttp  =  new  XMLHttpRequest ( ) ; 
118-     xmlhttp . open ( 'POST' ,  url ,  this . async ) ; 
119-     xmlhttp . setRequestHeader ( 'Accept' ,  'application/json' ) ; 
120-     xmlhttp . setRequestHeader ( 'Content-Type' ,  'application/json' ) ; 
121- 
122-     if  ( this . async )  xmlhttp . timeout  =  request . timeout ; 
123- 
124-     xmlhttp . onreadystatechange  =  function  ( )  { 
125-       if  ( this . readyState  ==  4  &&  this . responseText )  { 
126-         if  ( this . status  ==  200 )  { 
127-           if  ( callback )  return  callback ( null ,  JSON . parse ( this . responseText ) ) ; 
128-         }  else  { 
129-           if  ( callback ) 
130-             return  callback ( new  api_errors . ResponseError ( request ,  this . status ,  this . responseText ) ) ; 
131-         } 
132-       } 
133-     } ; 
134-     xmlhttp . ontimeout  =  function  ( )  { 
135-       if  ( callback )  return  callback ( new  api_errors . TimeoutError ( request ) ) ; 
136-     } ; 
137- 
138-     xmlhttp . send ( JSON . stringify ( request . bodyParameters ( ) ) ) ; 
139-   } 
140- 
14197  _getUrl ( request )  { 
14298    const  signedUrl  =  this . _signUrl ( request . path ) ; 
14399    const  url  = 
0 commit comments