-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmarkFileRead.js
More file actions
60 lines (52 loc) · 1.57 KB
/
Copy pathmarkFileRead.js
File metadata and controls
60 lines (52 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
'use strict'
const yargs = require('yargs/yargs')
const {hideBin} = require('yargs/helpers')
const AWS = require('aws-sdk')
const {idpCredentials} = require('./idpStuff')
const {APIClient} = require('./clientVars.js')
const axios = require('axios')
AWS.config.region = 'us-east-1'
const argv = yargs(hideBin(process.argv))
.option('messageId', {
alias: 'm',
describe: 'The ID of the inbox record to be marked as read',
})
.demandOption('messageId')
.argv
async function refresh() {
let access_token
try {
access_token = await idpCredentials()
console.log('Retrieving STEVE external API client access token')
} catch (e) {
console.log('Failed to retrieve STEVE external API client access token', e)
}
return access_token
}
async function main() {
const {seaBaseUrl} = APIClient
const messageId = argv.messageId
const url = `${seaBaseUrl}/inbound/read/${messageId}`
const token = await refresh()
const options = {
url: url,
method: 'patch',
headers: {
'Authorization': `Bearer ${token}`
}
}
axios(options)
.then((response) => {
console.log(`Successfully marked inbox record as read`)
})
.catch((error) => {
console.log(`Failed to mark inbox record as read`)
console.log({
error: error,
message: error.response.data.message,
status: error.response.status,
statusText: error.response.statusText
})
})
}
main()