diff --git a/README.md b/README.md index efd201f..568e23c 100644 --- a/README.md +++ b/README.md @@ -29,9 +29,9 @@ The following parameters can be set in config files or in env variables: - TOKEN_CACHE_TIME: The token cache time - SLEEP_TIME: The pause time between two create operations, default value: 1000 ms - UBAHN_API_URL: The ubahn api url, default value: 'https://api.topcoder-dev.com/v5' -- MEMBERS_API_URL: The topcoder member api url, default value: 'https://api.topcoder-dev.com/v5/members' +- MEMBERS_API_URL: The topcoder member api url, default value: 'https://api.topcoder-dev.com/v5/members'. Not in use anymore. Retained for any future use - ATTRIBUTE_GROUP_NAME: The attribute group name -- SKILL_PROVIDER_NAME: The skill provider name +- SKILL_PROVIDER_NAME: The skill provider name. Not in use anymore. Retained for any future use - ORGANIZATION_NAME: The organization name There is a `/health` endpoint that checks for the health of the app. This sets up an expressjs server and listens on the environment variable `PORT`. It's not part of the configuration file and needs to be passed as an environment variable diff --git a/VERIFICATION.md b/VERIFICATION.md index 47793ad..975e232 100644 --- a/VERIFICATION.md +++ b/VERIFICATION.md @@ -19,7 +19,9 @@ "credential":{"activationCode":"FOOBAR2","resetToken":null,"hasPassword":false}, "profiles":null, "status":"A", - "country":null, + "country":{ + "isoAlpha3Code": "IND" + }, "regSource":"null", "utmSource":"null", "utmMedium":"null", @@ -44,5 +46,5 @@ docker exec -it identity-data-processor_kafka /opt/kafka/bin/kafka-console-produ `{"recipients":[],"notificationType":"useractivation"}` 3. Watch the app console, It will show error message. 4. write message: - `{"topic":"identity.notification.create","originator":"u-bahn-api","timestamp":"2019-07-08T00:00:00.000Z","mime-type":"application/json","payload":{"id":"90064000","modifiedBy":null,"modifiedAt":"2021-01-05T14:01:40.336Z","createdBy":null,"createdAt":"2021-01-05T14:01:40.336Z","handle":"theuserhandle","email":"foo@bar.com","firstName":"theuserfirstname","lastName":"theuserlastname","credential":{"activationCode":"FOOBAR2","resetToken":null,"hasPassword":false},"profiles":null,"status":"A","country":null,"regSource":"null","utmSource":"null","utmMedium":"null","utmCampaign":"null","roles":null,"ssoLogin":false,"active":true,"profile":null,"emailActive":true}}` + `{"topic":"identity.notification.create","originator":"u-bahn-api","timestamp":"2019-07-08T00:00:00.000Z","mime-type":"application/json","payload":{"id":"90064000","modifiedBy":null,"modifiedAt":"2021-01-05T14:01:40.336Z","createdBy":null,"createdAt":"2021-01-05T14:01:40.336Z","handle":"theuserhandle","email":"foo@bar.com","firstName":"theuserfirstname","lastName":"theuserlastname","credential":{"activationCode":"FOOBAR2","resetToken":null,"hasPassword":false},"profiles":null,"status":"A","country":{"isoAlpha3Code":"IND"},"regSource":"null","utmSource":"null","utmMedium":"null","utmCampaign":"null","roles":null,"ssoLogin":false,"active":true,"profile":null,"emailActive":true}}` 5. Watch the app console, It will show message successfully handled. diff --git a/src/common/helper.js b/src/common/helper.js index 9804493..fb9fe62 100644 --- a/src/common/helper.js +++ b/src/common/helper.js @@ -53,6 +53,7 @@ async function getUbahnToken () { /** * Function to get M2M token * (U-Bahn APIs only) + * * Unused for now. Retained for any future use * @returns {Promise} */ async function getTopcoderToken () { @@ -96,6 +97,7 @@ async function getAttributes (token) { /** * Get all skills + * * Unused for now. Retained for any future use * @param {String} token * @returns a map (name -> id) */ @@ -108,6 +110,7 @@ async function getSkillProviderId (token) { /** * Get the skillId + * * Unused for now. Retained for any future use * @param {String} skillProviderId * @param {String} name * @param {String} token @@ -121,6 +124,7 @@ async function getSkillId (skillProviderId, name, token) { /** * Returns the member location for the member handle + * * Unused for now. Retained for any future use * @param {String} handle The member handle */ async function getMemberLocation (handle, token) { @@ -131,6 +135,7 @@ async function getMemberLocation (handle, token) { /** * Returns the member's skills + * * Unused for now. Retained for any future use * @param {String} handle The member's handle */ async function getMemberSkills (handle, token) { @@ -185,6 +190,7 @@ async function createExternalProfile (userId, body, token) { /** * Create user skill + * * Unused for now. Retained for any future use * @param {String} userId * @param {String} skillId * @param {String} metricValue diff --git a/src/services/ProcessorService.js b/src/services/ProcessorService.js index f3d5616..109f582 100644 --- a/src/services/ProcessorService.js +++ b/src/services/ProcessorService.js @@ -13,12 +13,9 @@ const helper = require('../common/helper') */ async function processCreate (message) { const ubahnToken = await helper.getUbahnToken() - const topcoderToken = await helper.getTopcoderToken() const organizationId = await helper.getOrganizationId(ubahnToken) const attributes = await helper.getAttributes(ubahnToken) - const skillProviderId = await helper.getSkillProviderId(ubahnToken) - const location = await helper.getMemberLocation(message.payload.handle, topcoderToken) - const userSkills = await helper.getMemberSkills(message.payload.handle, topcoderToken) + const location = message.payload.country.isoAlpha3Code const userId = await helper.createUser(_.pick(message.payload, 'handle', 'firstName', 'lastName'), ubahnToken) logger.info(`user: ${message.payload.handle} created`) @@ -37,16 +34,6 @@ async function processCreate (message) { helper.sleep() await helper.createUserAttribute(userId, _.get(attributes, 'location'), location, ubahnToken) logger.info('user attribute: location created') - for (const userSkill of userSkills) { - helper.sleep() - const skillId = await helper.getSkillId(skillProviderId, userSkill.name, ubahnToken) - if (skillId) { - await helper.createUserSkill(userId, skillId, userSkill.score, ubahnToken) - logger.info(`user skill: ${userSkill.name}:${userSkill.score} created`) - } else { - throw Error(`Cannot find skill with name ${userSkill.name} and skill provider id ${skillProviderId} in u-bahn`) - } - } } processCreate.schema = { @@ -59,7 +46,10 @@ processCreate.schema = { id: Joi.string().required(), handle: Joi.string().required(), firstName: Joi.string().required(), - lastName: Joi.string().required() + lastName: Joi.string().required(), + country: Joi.object().keys({ + isoAlpha3Code: Joi.string().required() + }).required().unknown(true) }).required().unknown(true) }).required().unknown(true) }