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

Commit

Permalink
add each
Browse files Browse the repository at this point in the history
  • Loading branch information
taylordowns2000 committed Aug 17, 2016
1 parent c3dd757 commit 20a73dc
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 15 deletions.
79 changes: 66 additions & 13 deletions lib/Adaptor.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.lastReferenceValue = exports.dataValue = exports.dataPath = exports.merge = exports.sourceValue = exports.fields = exports.field = undefined;
exports.lastReferenceValue = exports.dataValue = exports.dataPath = exports.each = exports.merge = exports.sourceValue = exports.fields = exports.field = undefined;

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

Expand Down Expand Up @@ -41,6 +41,12 @@ Object.defineProperty(exports, 'merge', {
return _languageCommon.merge;
}
});
Object.defineProperty(exports, 'each', {
enumerable: true,
get: function get() {
return _languageCommon.each;
}
});
Object.defineProperty(exports, 'dataPath', {
enumerable: true,
get: function get() {
Expand Down Expand Up @@ -121,9 +127,16 @@ function event(eventData) {
console.log("Posting event:");
console.log(body);

return (0, _Client.post)({ username: username, password: password, body: body, url: url }).then(function (result) {
return (0, _Client.post)({
username: username,
password: password,
body: body,
url: url
}).then(function (result) {
console.log("Success:", result);
return _extends({}, state, { references: [result].concat(_toConsumableArray(state.references)) });
return _extends({}, state, {
references: [result].concat(_toConsumableArray(state.references))
});
});
};
}
Expand Down Expand Up @@ -154,9 +167,16 @@ function dataValueSet(data) {
console.log("Posting data value set:");
console.log(body);

return (0, _Client.post)({ username: username, password: password, body: body, url: url }).then(function (result) {
return (0, _Client.post)({
username: username,
password: password,
body: body,
url: url
}).then(function (result) {
console.log("Success:", result);
return _extends({}, state, { references: [result].concat(_toConsumableArray(state.references)) });
return _extends({}, state, {
references: [result].concat(_toConsumableArray(state.references))
});
});
};
}
Expand All @@ -173,7 +193,10 @@ function dataValueSet(data) {
* @returns {Operation}
*/
function dataElement(key, value) {
return { "dataElement": key, "value": value };
return {
"dataElement": key,
"value": value
};
}

/**
Expand Down Expand Up @@ -203,9 +226,16 @@ function createTEI(data) {
console.log("Posting tracked entity instance data:");
console.log(body);

return (0, _Client.post)({ username: username, password: password, body: body, url: url }).then(function (result) {
return (0, _Client.post)({
username: username,
password: password,
body: body,
url: url
}).then(function (result) {
console.log("Success:", result);
return _extends({}, state, { references: [result].concat(_toConsumableArray(state.references)) });
return _extends({}, state, {
references: [result].concat(_toConsumableArray(state.references))
});
});
};
}
Expand Down Expand Up @@ -237,14 +267,30 @@ function updateTEI(tei, data) {
console.log('Updating tracked entity instance ' + tei + ' with data:');
console.log(body);

return (0, _Client.put)({ username: username, password: password, body: body, url: url }).then(function (result) {
return (0, _Client.put)({
username: username,
password: password,
body: body,
url: url
}).then(function (result) {
console.log("Success:", result);
return _extends({}, state, { references: [result].concat(_toConsumableArray(state.references)) });
return _extends({}, state, {
references: [result].concat(_toConsumableArray(state.references))
});
});
};
}

// Create and enroll TrackedEntityInstances
// /**
// * Create and enroll TrackedEntityInstances
// * @example
// * execute(
// * createEnrollTEI(te, orgUnit, attributes, enrollments)
// * )(state)
// * @constructor
// * @param {object} enrollmentData - Payload data for new enrollment
// * @returns {Operation}
// */
// export function upsertEnroll(upsertData) {
//
// return state => {
Expand Down Expand Up @@ -293,9 +339,16 @@ function enroll(tei, enrollmentData) {
console.log("Enrolling tracked entity instance with data:");
console.log(body);

return (0, _Client.post)({ username: username, password: password, body: body, url: url }).then(function (result) {
return (0, _Client.post)({
username: username,
password: password,
body: body,
url: url
}).then(function (result) {
console.log("Success:", result);
return _extends({}, state, { references: [result].concat(_toConsumableArray(state.references)) });
return _extends({}, state, {
references: [result].concat(_toConsumableArray(state.references))
});
});
};
}
2 changes: 0 additions & 2 deletions lib/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ function post(_ref) {
if (!!error || !res.ok) {
reject(error);
}

resolve(res);
});
});
Expand All @@ -40,7 +39,6 @@ function put(_ref2) {
if (!!error || !res.ok) {
reject(error);
}

resolve(res);
});
});
Expand Down

0 comments on commit 20a73dc

Please sign in to comment.