-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Gnanakeethan Balasubramaniam <[email protected]>
- Loading branch information
1 parent
490df02
commit c8b7553
Showing
3 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import {IImpactModelInterface} from '../interfaces'; | ||
|
||
import {CONFIG} from '../../config'; | ||
|
||
import {KeyValuePair} from '../../types/common'; | ||
|
||
const {MODEL_IDS} = CONFIG; | ||
const {TDP} = MODEL_IDS; | ||
|
||
export class TdpFinderModel implements IImpactModelInterface { | ||
authParams: object | undefined = undefined; | ||
staticParams: object | undefined; | ||
name: string | undefined; | ||
|
||
authenticate(authParams: object): void { | ||
this.authParams = authParams; | ||
} | ||
|
||
/** | ||
* Calculate the total emissions for a list of observations. | ||
* | ||
* Each Observation require: | ||
* @param {Object[]} observations | ||
* @param {string} observations[].timestamp RFC3339 timestamp string | ||
*/ | ||
async calculate(observations: object | object[] | undefined): Promise<any[]> { | ||
if (observations === undefined) { | ||
throw new Error('Required Parameters not provided'); | ||
} else if (!Array.isArray(observations)) { | ||
throw new Error('Observations must be an array'); | ||
} | ||
|
||
return observations.map((observation: KeyValuePair) => { | ||
return observation; | ||
}); | ||
} | ||
|
||
async configure( | ||
name: string, | ||
staticParams: object | undefined | ||
): Promise<IImpactModelInterface> { | ||
this.staticParams = staticParams; | ||
this.name = name; | ||
return this; | ||
} | ||
|
||
modelIdentifier(): string { | ||
return TDP; | ||
} | ||
} |