@@ -4,15 +4,16 @@ const axios = require('axios');
4
4
const querystring = require ( 'querystring' )
5
5
6
6
/**
7
- * Minimal Scanii API client in javascript (@see https://docs.scanii.com/v2.1/resources.html )
7
+ * Minimal Scanii API client in javascript (@see https://docs.scanii.com)
8
8
*/
9
9
class ScaniiClient {
10
- constructor ( key , secret , endpoint = "api.scanii.com" , maxAttempts , maxAttemptDelay ) {
10
+ constructor ( key , secret , endpoint = "api.scanii.com" , maxAttempts = 3 , maxAttemptDelay = 1000 ) {
11
11
this . key = key ;
12
12
this . secret = secret ;
13
13
this . maxAttempts = maxAttempts ;
14
14
this . maxAttemptDelay = maxAttemptDelay ;
15
15
this . userAgent = `scanii-lambda/v${ VERSION } ` ;
16
+
16
17
this . client = axios . create ( {
17
18
auth : {
18
19
username : key , password : secret
@@ -26,7 +27,7 @@ class ScaniiClient {
26
27
}
27
28
28
29
/**
29
- * Makes a fetch call to scanii @ see <a href="http ://docs.scanii.com/v2.1/resources.html#files">http://docs.scanii.com/v2.1/resources.html#files</a>
30
+ * Makes a fetch call to scanii, see https ://uvasoftware.github.io/openapi/v22/#/Files/processFileFetch
30
31
* @param location (URL) of the content to be processed
31
32
* @param callback callback location (URL) to be notified and receive the result
32
33
* @param metadata optional metadata to be added to this file
@@ -50,7 +51,7 @@ class ScaniiClient {
50
51
}
51
52
52
53
return await this . _retry ( async ( ) => {
53
- const response = await this . client . post ( '/v2.1 /files/fetch' , querystring . stringify ( data ) , { headers : { 'content-type' : 'application/x-www-form-urlencoded' } } ) ;
54
+ const response = await this . client . post ( '/v2.2 /files/fetch' , querystring . stringify ( data ) , { headers : { 'content-type' : 'application/x-www-form-urlencoded' } } ) ;
54
55
assert . ok ( response . status === 202 , `Invalid response from server, with HTTP code: ${ response . status } ` ) ;
55
56
console . log ( `submit successful with id: ${ response . data . id } ` ) ;
56
57
return ( { id : response . data . id , location : response . headers . location } ) ;
@@ -59,13 +60,13 @@ class ScaniiClient {
59
60
60
61
// noinspection JSUnusedGlobalSymbols
61
62
/**
62
- * Fetches the results of a previously processed file @see <a href="http ://docs.scanii.com/v2.1/resources.html#files">http://docs.scanii.com/v2.1/resources.html#files</a>
63
+ * Fetches the results of a previously processed file @see https ://uvasoftware.github.io/openapi/v22/#/Files/retrieveFile
63
64
* @param id of the content/file to be retrieved
64
65
* @returns {Promise<*> }
65
66
*/
66
67
async retrieve ( id ) {
67
68
return await this . _retry ( async ( ) => {
68
- const response = await this . client . get ( `/v2.1 /files/fetch/${ id } ` ) ;
69
+ const response = await this . client . get ( `/v2.2 /files/fetch/${ id } ` ) ;
69
70
assert . ok ( response . status === 200 , `Invalid response from server, with HTTP code: ${ response . status } ` ) ;
70
71
let result = JSON . parse ( response . data ) ;
71
72
console . log ( `retrieve successful with id: ${ result . id } ` ) ;
0 commit comments