import { StateCreate, StateRequest } from '@/models' import { StateResponse } from '@/models/api/StateResponse' import { State } from '@/models/State' import { MapFunction } from '@/services/Mapper' export const mapStateResponseToState: MapFunction = function(source) { return { id: source.id, type: this.map('ServerStateType', source.type, 'StateType'), kind: 'state', message: source.message, stateDetails: this.map('StateDetailsResponse', source.state_details, 'StateDetails'), data: source.data, timestamp: this.map('string', source.timestamp, 'Date'), name: source.name, } } export const mapStateToStateResponse: MapFunction = function(source) { return { id: source.id, type: this.map('StateType', source.type, 'ServerStateType'), message: source.message, state_details: this.map('StateDetails', source.stateDetails, 'StateDetailsResponse'), data: source.data, timestamp: this.map('Date', source.timestamp, 'string'), name: source.name, } } export const mapStateCreateToStateRequest: MapFunction = function(source) { return { type: this.map('StateType', source.type, 'ServerStateType'), message: source.message, state_details: source.stateDetails ? this.map('StateDetailsCreate', source.stateDetails, 'StateDetailsRequest') : {}, data: source.data, timestamp: this.map('Date', source.timestamp, 'string'), name: source.name, } }