Skip to content
This repository has been archived by the owner on Oct 21, 2022. It is now read-only.

Commit

Permalink
add docs for attribute and update attrVal
Browse files Browse the repository at this point in the history
  • Loading branch information
taylordowns2000 committed Dec 18, 2021
1 parent 531419e commit 7ddd4ac
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 6 deletions.
55 changes: 54 additions & 1 deletion ast.json
Expand Up @@ -856,7 +856,7 @@
},
{
"title": "example",
"description": "valByName(tei.attributes, 'first name')"
"description": "attrVal(tei.attributes, 'first name')"
},
{
"title": "function",
Expand Down Expand Up @@ -892,6 +892,59 @@
]
},
"valid": true
},
{
"name": "attribute",
"params": [
"attributeId",
"attributeValue"
],
"docs": {
"description": "Converts an attribute ID and value into a DSHI2 attribute object",
"tags": [
{
"title": "public",
"description": null,
"type": null
},
{
"title": "example",
"description": "attribute('w75KJ2mc4zz', 'Elias')"
},
{
"title": "function",
"description": null,
"name": null
},
{
"title": "param",
"description": "A tracked entity instance (TEI) attribute ID.",
"type": {
"type": "NameExpression",
"name": "string"
},
"name": "attributeId"
},
{
"title": "param",
"description": "The value for that attribute.",
"type": {
"type": "NameExpression",
"name": "string"
},
"name": "attributeValue"
},
{
"title": "returns",
"description": null,
"type": {
"type": "NameExpression",
"name": "object"
}
}
]
},
"valid": true
}
],
"exports": [],
Expand Down
13 changes: 12 additions & 1 deletion lib/Adaptor.js
Expand Up @@ -777,7 +777,7 @@ function del(resourceType, path, data, params, options, callback) {
* Gets an attribute value by its case-insensitive display name
* @public
* @example
* valByName(tei.attributes, 'first name')
* attrVal(tei.attributes, 'first name')
* @function
* @param {Object} tei - A tracked entity instance (TEI) object
* @param {string} attributeName - The 'displayName' to search for in the TEI's attributes
Expand All @@ -790,6 +790,17 @@ function attrVal(tei, attributeName) {

return tei === null || tei === void 0 ? void 0 : (_tei$attributes = tei.attributes) === null || _tei$attributes === void 0 ? void 0 : (_tei$attributes$find = _tei$attributes.find(a => (a === null || a === void 0 ? void 0 : a.displayName.toLowerCase()) == attributeName.toLowerCase())) === null || _tei$attributes$find === void 0 ? void 0 : _tei$attributes$find.value;
}
/**
* Converts an attribute ID and value into a DSHI2 attribute object
* @public
* @example
* attribute('w75KJ2mc4zz', 'Elias')
* @function
* @param {string} attributeId - A tracked entity instance (TEI) attribute ID.
* @param {string} attributeValue - The value for that attribute.
* @returns {object}
*/


function attribute(attributeId, attributeValue) {
return {
Expand Down
17 changes: 13 additions & 4 deletions src/Adaptor.js
Expand Up @@ -546,9 +546,8 @@ export function discover(httpMethod, endpoint) {
if (param.schema['$ref']) {
let schemaRefIndex =
param.schema['$ref'].lastIndexOf('/') + 1;
let schemaRef = param.schema['$ref'].slice(
schemaRefIndex
);
let schemaRef =
param.schema['$ref'].slice(schemaRefIndex);
param.schema = tempData.components.schemas[schemaRef];
}

Expand Down Expand Up @@ -770,7 +769,7 @@ export function del(resourceType, path, data, params, options, callback) {
* Gets an attribute value by its case-insensitive display name
* @public
* @example
* valByName(tei.attributes, 'first name')
* attrVal(tei.attributes, 'first name')
* @function
* @param {Object} tei - A tracked entity instance (TEI) object
* @param {string} attributeName - The 'displayName' to search for in the TEI's attributes
Expand All @@ -782,6 +781,16 @@ export function attrVal(tei, attributeName) {
)?.value;
}

/**
* Converts an attribute ID and value into a DSHI2 attribute object
* @public
* @example
* attribute('w75KJ2mc4zz', 'Elias')
* @function
* @param {string} attributeId - A tracked entity instance (TEI) attribute ID.
* @param {string} attributeValue - The value for that attribute.
* @returns {object}
*/
export function attribute(attributeId, attributeValue) {
return {
attribute: attributeId,
Expand Down

0 comments on commit 7ddd4ac

Please sign in to comment.