trip info model

trip info model
mail@pastecode.io avatar
unknown
dart
2 years ago
8.8 kB
1
Indexable
Never
// To parse this JSON data, do
//
//     final tripHistoryModel = tripHistoryModelFromJson(jsonString);

// ignore_for_file: prefer_null_aware_operators

import 'dart:convert';

TripHistoryModel tripHistoryModelFromJson(String str) => TripHistoryModel.fromJson(json.decode(str));

String tripHistoryModelToJson(TripHistoryModel data) => json.encode(data.toJson());

class TripHistoryModel {
    TripHistoryModel({
        this.beginLocation,
        this.pickedUpLocation,
        this.completeLocation,
        this.id,
        this.temporaryStateId,
        this.beginTime,
        this.completeTime,
        this.customerId,
        this.customerRequest,
        this.deviceId,
        this.driverId,
        this.isCustomerConfirmed,
        this.isCustomerPickedUp,
        this.isTripCompleted,
        this.lastState,
        this.paymentDetails,
        this.pickedUpTime,
        this.pricePaid,
        this.saveTime,
        this.tripInfo,
    });

    Locations beginLocation;
    Locations pickedUpLocation;
    Locations completeLocation;
    String id;
    String temporaryStateId;
    DateTime beginTime;
    DateTime completeTime;
    String customerId;
    CustomerRequest customerRequest;
    String deviceId;
    String driverId;
    bool isCustomerConfirmed;
    bool isCustomerPickedUp;
    bool isTripCompleted;
    int lastState;
    dynamic paymentDetails;
    DateTime pickedUpTime;
    bool pricePaid;
    DateTime saveTime;
    TripInfo tripInfo;

    factory TripHistoryModel.fromJson(Map<String, dynamic> json) => TripHistoryModel(
        beginLocation: json["BeginLocation"] == null ? null : Locations.fromJson(json["BeginLocation"]),
        pickedUpLocation: json["PickedUpLocation"] == null ? null : Locations.fromJson(json["PickedUpLocation"]),
        completeLocation: json["CompleteLocation"] == null ? null : Locations.fromJson(json["CompleteLocation"]),
        id: json["_id"] ?? "",
        temporaryStateId: json["TemporaryStateID"] ?? "",
        beginTime: json["BeginTime"] == null ? null : DateTime.parse(json["BeginTime"]),
        completeTime: json["CompleteTime"] == null ? null : DateTime.parse(json["CompleteTime"]),
        customerId: json["CustomerID"] ?? "",
        customerRequest: json["CustomerRequest"] == null ? null : CustomerRequest.fromJson(json["CustomerRequest"]),
        deviceId: json["DeviceID"] ?? "",
        driverId: json["DriverID"] ?? "",
        isCustomerConfirmed: json["IsCustomerConfirmed"],
        isCustomerPickedUp: json["IsCustomerPickedUp"],
        isTripCompleted: json["IsTripCompleted"],
        lastState: json["LastState"],
        paymentDetails: json["PaymentDetails"],
        pickedUpTime: json["PickedUpTime"] == null ? null : DateTime.parse(json["PickedUpTime"]),
        pricePaid: json["PricePaid"],
        saveTime: json["SaveTime"] == null ? null : DateTime.parse(json["SaveTime"]),
        tripInfo: json["TripInfo"] == null ? null : TripInfo.fromJson(json["TripInfo"]),
    );

    Map<String, dynamic> toJson() => {
        "BeginLocation": beginLocation == null ? null : beginLocation.toJson(),
        "PickedUpLocation": pickedUpLocation == null ? null : pickedUpLocation.toJson(),
        "CompleteLocation": completeLocation == null ? null : completeLocation.toJson(),
        "_id": id,
        "TemporaryStateID": temporaryStateId,
        "BeginTime": beginTime == null ? null : beginTime.toIso8601String(),
        "CompleteTime": completeTime == null ? null : completeTime.toIso8601String(),
        "CustomerID": customerId,
        "CustomerRequest": customerRequest == null ? null : customerRequest.toJson(),
        "DeviceID": deviceId,
        "DriverID": driverId,
        "IsCustomerConfirmed": isCustomerConfirmed,
        "IsCustomerPickedUp": isCustomerPickedUp,
        "IsTripCompleted": isTripCompleted,
        "LastState": lastState,
        "PaymentDetails": paymentDetails,
        "PickedUpTime": pickedUpTime == null ? null : pickedUpTime.toIso8601String(),
        "PricePaid": pricePaid,
        "SaveTime": saveTime == null ? null : saveTime.toIso8601String(),
        "TripInfo": tripInfo == null ? null : tripInfo.toJson(),
    };
}

class Locations {
    Locations({
        this.type,
        this.coordinates,
    });

    String type;
    List<double> coordinates;

    factory Locations.fromJson(Map<String, dynamic> json) => Locations(
        type: json["type"] ?? "",
        coordinates: json["coordinates"] == null ? null : List<double>.from(json["coordinates"].map((x) => x.toDouble())),
    );

    Map<String, dynamic> toJson() => {
        "type": type,
        "coordinates": coordinates == null ? null : List<dynamic>.from(coordinates.map((x) => x)),
    };
}

class CustomerRequest {
    CustomerRequest({
        this.beginLat,
        this.beginLng,
        this.endLat,
        this.endLng,
        this.userId,
        this.beginCity,
        this.endCity,
        this.routeIndex,
        this.payMethods,
        this.id,
    });

    double beginLat;
    double beginLng;
    double endLat;
    double endLng;
    String userId;
    String beginCity;
    String endCity;
    int routeIndex;
    int payMethods;
    String id;

    factory CustomerRequest.fromJson(Map<String, dynamic> json) => CustomerRequest(
        beginLat: json["BeginLat"] == null ? null : json["BeginLat"].toDouble(),
        beginLng: json["BeginLng"] == null ? null : json["BeginLng"].toDouble(),
        endLat: json["EndLat"] == null ? null : json["EndLat"].toDouble(),
        endLng: json["EndLng"] == null ? null : json["EndLng"].toDouble(),
        userId: json["UserID"] ?? "",
        beginCity: json["BeginCity"] ?? "",
        endCity: json["EndCity"] ?? "",
        routeIndex: json["RouteIndex"],
        payMethods: json["PayMethods"],
        id: json["_id"] ?? "",
    );

    Map<String, dynamic> toJson() => {
        "BeginLat": beginLat,
        "BeginLng": beginLng,
        "EndLat": endLat,
        "EndLng": endLng,
        "UserID": userId,
        "BeginCity": beginCity,
        "EndCity": endCity,
        "RouteIndex": routeIndex,
        "PayMethods": payMethods,
        "_id": id,
    };
}

class TripInfo {
    TripInfo({
        this.id,
        this.isUserExist,
        this.username,
        this.saveTime,
        this.tripId,
        this.rentedTripFare,
        this.rentedTripDistance,
        this.rentedTripTariff,
        this.rentedTripExtras,
        this.startOfRentedTrip,
        this.endOfRentedTrip,
        this.startLocationLatitude,
        this.startLocationLongitude,
        this.endLocationLatitude,
        this.endLocationLongitude,
    });

    dynamic id;
    bool isUserExist;
    String username;
    int saveTime;
    String tripId;
    int rentedTripFare;
    int rentedTripDistance;
    int rentedTripTariff;
    int rentedTripExtras;
    int startOfRentedTrip;
    int endOfRentedTrip;
    double startLocationLatitude;
    double startLocationLongitude;
    double endLocationLatitude;
    double endLocationLongitude;

    factory TripInfo.fromJson(Map<String, dynamic> json) => TripInfo(
        id: json["_id"],
        isUserExist: json["IsUserExist"],
        username: json["Username"] ?? "",
        saveTime: json["SaveTime"],
        tripId: json["TripID"] ?? "",
        rentedTripFare: json["RentedTripFare"],
        rentedTripDistance: json["RentedTripDistance"],
        rentedTripTariff: json["RentedTripTariff"],
        rentedTripExtras: json["RentedTripExtras"],
        startOfRentedTrip: json["StartOfRentedTrip"],
        endOfRentedTrip: json["EndOfRentedTrip"],
        startLocationLatitude: json["StartLocationLatitude"] == null ? null : json["StartLocationLatitude"].toDouble(),
        startLocationLongitude: json["StartLocationLongitude"] == null ? null : json["StartLocationLongitude"].toDouble(),
        endLocationLatitude: json["EndLocationLatitude"] == null ? null : json["EndLocationLatitude"].toDouble(),
        endLocationLongitude: json["EndLocationLongitude"] == null ? null : json["EndLocationLongitude"].toDouble(),
    );

    Map<String, dynamic> toJson() => {
        "_id": id,
        "IsUserExist": isUserExist,
        "Username": username,
        "SaveTime": saveTime,
        "TripID": tripId,
        "RentedTripFare": rentedTripFare,
        "RentedTripDistance": rentedTripDistance,
        "RentedTripTariff": rentedTripTariff,
        "RentedTripExtras": rentedTripExtras,
        "StartOfRentedTrip": startOfRentedTrip,
        "EndOfRentedTrip": endOfRentedTrip,
        "StartLocationLatitude": startLocationLatitude,
        "StartLocationLongitude": startLocationLongitude,
        "EndLocationLatitude": endLocationLatitude,
        "EndLocationLongitude": endLocationLongitude,
    };
}