Skip to content

Commit

Permalink
Merge pull request #150 from rdkcentral/FIRECERT-2148
Browse files Browse the repository at this point in the history
FIRECERT-2148: Implementation ticket for 1.2.0 - In-App User interests' behavioral scenarios
  • Loading branch information
Abhishk123 authored Jun 28, 2024
2 parents fb9ad36 + 3532898 commit 5490206
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
9 changes: 8 additions & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export default class App extends Base {
process.env.REPORTINGID = reportingId;
process.env.STANDALONE = standalone;
process.env.STANDALONE_PREFIX = standalonePrefix;
process.env.REGISTERPROVIDER = true;

// Set the pubSub URL if present
process.env.PUB_SUB_URL = new URLSearchParams(window.location.search).get('pubSubUrl');
Expand Down Expand Up @@ -209,7 +210,9 @@ export default class App extends Base {
Keyboard.provide('xrn:firebolt:capability:input:keyboard', new KeyboardProviderDelegater(this));
PinChallenge.provide('xrn:firebolt:capability:usergrant:pinchallenge', new PinChallengeProviderDelegater(this));
} else {
Discovery.provide('xrn:firebolt:capability:discovery:interest', new UserInterestDelegater(this));
if (process.env.REGISTERPROVIDER) {
Discovery.provide('xrn:firebolt:capability:discovery:interest', new UserInterestDelegater(this));
}
}
} catch (err) {
logger.error('Could not set up providers' + err, 'LoadedState');
Expand Down Expand Up @@ -414,6 +417,10 @@ export default class App extends Base {
logger.error('No Mac Address Found in Parameter Initialization response...', 'getParameterInitializationValues');
}

if (query.params.hasOwnProperty(CONSTANTS.REGISTERPROVIDER)) {
process.env.REGISTERPROVIDER = query.params.registerprovider;
}

// Set the pubSub URL if present
if (query.params.pubSubUrl) {
process.env.PUB_SUB_URL = query.params.pubSubUrl;
Expand Down
1 change: 1 addition & 0 deletions src/constant.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ export const CONSTANTS = {
WRONG_RESPONSE_MESSAGE_FORMAT: 'Unexpected error format encountered in the response',
EXCLUDED_METHODS_FOR_SDK: [],
EXCLUDED_METHODS_FOR_TRANSPORT: [],
REGISTERPROVIDER: 'registerprovider',
defaultSDKs: [
{
name: 'Core',
Expand Down
18 changes: 12 additions & 6 deletions src/providers/UserInterestProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,18 @@
export default class UserIntrestProvider {
userInterest() {
try {
const USERINTERESTDATA = require('../source/userInterest.json');
if (USERINTERESTDATA.hasOwnProperty(process.env.userInterestKey)) {
const data = USERINTERESTDATA[process.env.userInterestKey];
return Promise.resolve(data);
} else {
return Promise.resolve(null);
if (process.env.userInterestError == null || process.env.userInterestError.toLowerCase() != 'timeout') {
if (process.env.userInterestError && process.env.userInterestError.toLowerCase() == 'error') {
return Promise.reject({ code: 1000, message: 'Custom error from provider' });
} else {
const USERINTERESTDATA = require('../source/userInterest.json');
if (USERINTERESTDATA.hasOwnProperty(process.env.userInterestKey)) {
const data = USERINTERESTDATA[process.env.userInterestKey];
return Promise.resolve(data);
} else {
return Promise.resolve(null);
}
}
}
} catch (err) {
logger.error('Error in userInterest provider: ', err.message);
Expand Down
1 change: 1 addition & 0 deletions src/pubsub/handlers/setApiResponseHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export default class SetApiResponseHandler extends BaseHandler {
setResponseUserInterestChallenge(message) {
const userInterestData = message.params.apiResponse.attributes[0];
process.env.userInterestKey = userInterestData.userInterestKey;
process.env.userInterestError = userInterestData.userInterestError;
const reportIdString = JSON.stringify({ report: 'Received UserInterest apiResponse parameters' });
return reportIdString;
}
Expand Down

0 comments on commit 5490206

Please sign in to comment.