import PassengerAllocationAdapterInterface from './PassengerAllocationAdapterInterface'; import PassengerAllocation from '../entity/PassengerAllocation'; import Customer from '../../Customer/entity/Customer'; import User from '../../User/entity/User'; export default class PassengerAllocationAdapter implements PassengerAllocationAdapterInterface { adapt(json: any, instance: PassengerAllocation): PassengerAllocation { // TODO: Review from new unification. let user = new User(); user.name = json.customer_name; user.email = json.customer_email; instance.user = user; instance.travel_plan_id = json.travel_plan_id; instance.seats = json.concessions_selected.seats; instance.legs = { journey_stop: { pickup: json.legs[0].journey_stop_pickup, dropoff: json.legs[0].journey_stop_dropoff }, }; return instance; } prepare(instance: PassengerAllocation): any { let object = {}; return object; } transformToEntity(json: any): PassengerAllocation { return this.adapt(json, new PassengerAllocation()); } transformToPayload(instance: PassengerAllocation): any { return this.prepare(instance); } }