Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cce-unified-config

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cce-unified-config - npm Package Compare versions

Comparing version 0.8.1 to 0.9.0

parse-xml.js

45

index.js
const axios = require('axios')
const parseXmlString = require('./parse-xml')

@@ -76,2 +77,12 @@ class UnifiedConfig {

async get(type, id, q) {
// pass params from input
const params = {q}
try {
return await axios.get(`${this.url}${type.toLowerCase()}/${id}`, body, {auth: this.auth, params})
} catch (e) {
throw e
}
}
async modify(type, body, q) {

@@ -106,15 +117,29 @@ // pass params from input

}
const headers = {
// 'Content-Type'
'Accept': 'application/xml'
}
const options = {
auth: this.auth,
params,
headers
}
try {
let response = await axios.get(this.url + type.toLowerCase(), {auth: this.auth, params})
let totalResults = response.data.pageInfo.totalResults
const response = await axios.get(this.url + type.toLowerCase(), options)
const jsonData = (await parseXmlString(response.data)).results
// console.log('json',jsonData)
let totalResults = jsonData.pageInfo.totalResults
// console.log('totalResults', totalResults)
// console.log('data', response.data[`${type}s`][0][`${type}`])
// console.log('data', jsonData[`${type}s`][0][`${type}`])
// good response?
if (totalResults === 0) {
// console.log('jsonData', jsonData)
if (totalResults === '0') {
// no results
return []
} else if (totalResults === '1') {
// return single result as an array of 1 element
return [jsonData[`${type}s`][`${type}`]]
} else {
// console.log('response.data', response.data)
// 1 or more results
let data = response.data[`${type}s`][0][`${type}`]
// 2 or more results
let data = jsonData[`${type}s`][`${type}`]
// console.log('data', data)

@@ -126,7 +151,7 @@ while (totalResults > params.startIndex + 100) {

// fetch next data set
response = await axios.get(this.url + type.toLowerCase(), {auth: this.auth, params})
response = await axios.get(this.url + type.toLowerCase(), options)
// append data
data = data.concat(response.data[`${type}s`][0][`${type}`])
data = data.concat(jsonData[`${type}s`][`${type}`])
}
// all done, return data array
// all done, return data as an array
return data

@@ -133,0 +158,0 @@ }

{
"name": "cce-unified-config",
"version": "0.8.1",
"version": "0.9.0",
"description": "JavaScript library for Cisco Contact Center Enterprise APIs",

@@ -8,3 +8,3 @@ "main": "index.js",

"start": "node index",
"test": "NODE_TLS_REJECT_UNAUTHORIZED=0 node test"
"test": "NODE_TLS_REJECT_UNAUTHORIZED=0 mocha"
},

@@ -27,4 +27,5 @@ "repository": {

"dependencies": {
"axios": "^0.16.2"
"axios": "^0.16.2",
"xml2js": "^0.4.19"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc