Metric.ts•7.78 kB
/* tslint:disable */
/* eslint-disable */
/**
* Squad API
* API for managing Squad resources
*
* The version of the OpenAPI document: 4.0.0
* Contact: help@meetsquad.ai
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import { mapValues } from '../runtime.js';
import type { MetricTimeseriesPointOutput } from './MetricTimeseriesPointOutput.js';
import {
MetricTimeseriesPointOutputFromJSON,
MetricTimeseriesPointOutputFromJSONTyped,
MetricTimeseriesPointOutputToJSON,
MetricTimeseriesPointOutputToJSONTyped,
} from './MetricTimeseriesPointOutput.js';
/**
* Metric data representing a measurable KPI result
* @export
* @interface Metric
*/
export interface Metric {
/**
* Unique identifier for the metric
* @type {string}
* @memberof Metric
*/
id: string;
/**
* Display name for the metric
* @type {string}
* @memberof Metric
*/
title: string;
/**
* Detailed description of the metric
* @type {string}
* @memberof Metric
*/
description?: string;
/**
* Unit of measurement for the metric
* @type {string}
* @memberof Metric
*/
unit?: string;
/**
* Category/type of the metric
* @type {string}
* @memberof Metric
*/
type?: MetricTypeEnum;
/**
* Comparison operator for the target
* @type {string}
* @memberof Metric
*/
targetOperator?: MetricTargetOperatorEnum;
/**
* Target value to achieve
* @type {number}
* @memberof Metric
*/
targetValue?: number;
/**
* Direction of improvement (up = higher is better, down = lower is better)
* @type {string}
* @memberof Metric
*/
targetDirection?: MetricTargetDirectionEnum;
/**
* Current value of the metric
* @type {number}
* @memberof Metric
*/
currentValue?: number;
/**
* Previous value of the metric for comparison
* @type {number}
* @memberof Metric
*/
previousValue?: number;
/**
* Type of period for metric comparison
* @type {string}
* @memberof Metric
*/
periodType?: MetricPeriodTypeEnum;
/**
* Specific period value for metric comparison
* @type {string}
* @memberof Metric
*/
periodValue?: MetricPeriodValueEnum;
/**
* UserId of the Owner/responsible person for this metric
* @type {string}
* @memberof Metric
*/
ownerId: string;
/**
* Historical values for trend analysis
* @type {Array<MetricTimeseriesPointOutput>}
* @memberof Metric
*/
timeseries?: Array<MetricTimeseriesPointOutput>;
/**
* Timestamp of when the metric was created
* @type {Date}
* @memberof Metric
*/
createdAt: Date;
/**
* Timestamp of when the metric was last updated
* @type {Date}
* @memberof Metric
*/
updatedAt: Date;
/**
* Related outcomes that use this metric
* @type {Array<any>}
* @memberof Metric
*/
relatedOutcomes?: Array<any>;
}
/**
* @export
*/
export const MetricTypeEnum = {
Engagement: 'engagement',
Conversion: 'conversion',
Revenue: 'revenue',
Nps: 'nps',
Csat: 'csat',
Ces: 'ces',
Ratio: 'ratio',
Custom: 'custom'
} as const;
export type MetricTypeEnum = typeof MetricTypeEnum[keyof typeof MetricTypeEnum];
/**
* @export
*/
export const MetricTargetOperatorEnum = {
GreaterThan: 'greater_than',
LessThan: 'less_than',
EqualTo: 'equal_to'
} as const;
export type MetricTargetOperatorEnum = typeof MetricTargetOperatorEnum[keyof typeof MetricTargetOperatorEnum];
/**
* @export
*/
export const MetricTargetDirectionEnum = {
Up: 'up',
Down: 'down'
} as const;
export type MetricTargetDirectionEnum = typeof MetricTargetDirectionEnum[keyof typeof MetricTargetDirectionEnum];
/**
* @export
*/
export const MetricPeriodTypeEnum = {
Rolling: 'rolling',
Calendar: 'calendar'
} as const;
export type MetricPeriodTypeEnum = typeof MetricPeriodTypeEnum[keyof typeof MetricPeriodTypeEnum];
/**
* @export
*/
export const MetricPeriodValueEnum = {
Day: 'day',
Week: 'week',
Month: 'month',
Quarter: 'quarter',
Year: 'year',
_7Day: '7-day',
_30Day: '30-day',
_90Day: '90-day'
} as const;
export type MetricPeriodValueEnum = typeof MetricPeriodValueEnum[keyof typeof MetricPeriodValueEnum];
/**
* Check if a given object implements the Metric interface.
*/
export function instanceOfMetric(value: object): value is Metric {
if (!('id' in value) || value['id'] === undefined) return false;
if (!('title' in value) || value['title'] === undefined) return false;
if (!('ownerId' in value) || value['ownerId'] === undefined) return false;
if (!('createdAt' in value) || value['createdAt'] === undefined) return false;
if (!('updatedAt' in value) || value['updatedAt'] === undefined) return false;
return true;
}
export function MetricFromJSON(json: any): Metric {
return MetricFromJSONTyped(json, false);
}
export function MetricFromJSONTyped(json: any, ignoreDiscriminator: boolean): Metric {
if (json == null) {
return json;
}
return {
'id': json['id'],
'title': json['title'],
'description': json['description'] == null ? undefined : json['description'],
'unit': json['unit'] == null ? undefined : json['unit'],
'type': json['type'] == null ? undefined : json['type'],
'targetOperator': json['targetOperator'] == null ? undefined : json['targetOperator'],
'targetValue': json['targetValue'] == null ? undefined : json['targetValue'],
'targetDirection': json['targetDirection'] == null ? undefined : json['targetDirection'],
'currentValue': json['currentValue'] == null ? undefined : json['currentValue'],
'previousValue': json['previousValue'] == null ? undefined : json['previousValue'],
'periodType': json['periodType'] == null ? undefined : json['periodType'],
'periodValue': json['periodValue'] == null ? undefined : json['periodValue'],
'ownerId': json['ownerId'],
'timeseries': json['timeseries'] == null ? undefined : ((json['timeseries'] as Array<any>).map(MetricTimeseriesPointOutputFromJSON)),
'createdAt': (new Date(json['createdAt'])),
'updatedAt': (new Date(json['updatedAt'])),
'relatedOutcomes': json['relatedOutcomes'] == null ? undefined : json['relatedOutcomes'],
};
}
export function MetricToJSON(json: any): Metric {
return MetricToJSONTyped(json, false);
}
export function MetricToJSONTyped(value?: Metric | null, ignoreDiscriminator: boolean = false): any {
if (value == null) {
return value;
}
return {
'id': value['id'],
'title': value['title'],
'description': value['description'],
'unit': value['unit'],
'type': value['type'],
'targetOperator': value['targetOperator'],
'targetValue': value['targetValue'],
'targetDirection': value['targetDirection'],
'currentValue': value['currentValue'],
'previousValue': value['previousValue'],
'periodType': value['periodType'],
'periodValue': value['periodValue'],
'ownerId': value['ownerId'],
'timeseries': value['timeseries'] == null ? undefined : ((value['timeseries'] as Array<any>).map(MetricTimeseriesPointOutputToJSON)),
'createdAt': ((value['createdAt']).toISOString()),
'updatedAt': ((value['updatedAt']).toISOString()),
'relatedOutcomes': value['relatedOutcomes'],
};
}