import Vehicle from '../entity/Vehicle'; import VehicleAdapterInterface from './VehicleAdapterInterface'; export default class VehicleAdapter implements VehicleAdapterInterface { adapt(json: any, instance: Vehicle): Vehicle { instance.number_of_seats = json.number_of_seats; instance.reg_number = json.reg_number; return instance; } prepare(instance: Vehicle): object { let object = { number_of_seats: instance.number_of_seats, driver_name: instance.driver_name, driver_contact_number: instance.driver_contact_number, }; return object; } transformToEntity(json: any): Vehicle { return this.adapt(json, new Vehicle()); } transformToPayload(instance: Vehicle): any { return this.prepare(instance); } }