import 'dart:core';

    // https://www.codegrepper.com/code-examples/dart/dart+create+json+array

    class CallPut
    {
        static const String Call = "C";
        static const String Put = "P";
        static const String None = "-";
    }

    class TickerResponse
    {
        int tickerTime;
        String prodCode;
        double price;
        int qty;
        int dealSrc;
        String hitSide;
        String buySideBroker;
        String sellSideBroker;

        TickerResponse({
            this.tickerTime, 
            this.prodCode,
            this.price,
            this.qty,
            this.dealSrc,
            this.hitSide,
            this.buySideBroker,
            this.sellSideBroker,
        });

        factory TickerResponse.fromJson(Map<String, dynamic> json) {
            return TickerResponse(
                tickerTime: json['tickerTime'],
                prodCode: json['prodCode'],
                price: json['price'],
                qty: json['qty'],
                dealSrc: json['dealSrc'],
                hitSide: json['hitSide'],
                buySideBroker: json['buySideBroker'],
                sellSideBroker: json['sellSideBroker'],                                                               
            );
        }

        Map<String, dynamic> toJson() => {
          'tickerTime': tickerTime,
          'prodCode': prodCode,
          'price': price,
          'qty': qty,
          'dealSrc': dealSrc,
          'hitSide': hitSide,
          'buySideBroker': buySideBroker,
          'sellSideBroker': sellSideBroker,                                                            
        };        
    }

    class BuySell
    {
        static const String Buy = "B";
        static const String Sell = "S";
    }

    class PriceResponse
    {
        String prodCode;
        String productName;
        int productType;    // 1=Futures, 2=Options, 3=Spreads
        int contractSize;
        int expiryDate;
        String instrumentCode;
        String currency;
        double strike;
        String callPut;
        String underlying;

        List<double> bidPrice = [0, 0, 0, 0, 0];        
        List<int> bidQty = [0, 0, 0, 0, 0];

        List<double> askPrice = [0, 0, 0, 0, 0];        
        List<int> askQty = [0, 0, 0, 0, 0];

        List<double> lastPrice = [0, 0, 0, 0, 0];        
        List<int> lastQty = [0, 0, 0, 0, 0];        

        int openInterest;
        double turnoverAmount;
        int turnoverVolume;
        double reserved1;
        double reserved2;
        double equilibriumPrice;
        double open;
        double high;
        double low;
        double previousClose;
        double previousCloseDate;
        double notUsed;
        double tradeStateNo;

        int lotSize;
        int tickSize;
        int updateTime;

        PriceResponse({
            this.prodCode, 
            this.productName,
            this.productType,
            this.contractSize,
            this.expiryDate,
            this.instrumentCode,
            this.currency,
            this.strike,
            this.callPut,
            this.underlying,

            this.bidPrice, 
            this.bidQty,
            this.askPrice,
            this.askQty,
            this.lastPrice,
            this.lastQty,

            this.openInterest, 
            this.turnoverAmount,
            this.turnoverVolume,
            this.reserved1,
            this.reserved2,
            this.equilibriumPrice,
            this.open,
            this.high,
            this.low,
            this.previousClose,            
            this.previousCloseDate, 
            this.notUsed,
            this.tradeStateNo,

            this.lotSize,
            this.tickSize,
            this.updateTime,
        });

        factory PriceResponse.fromJson(Map<String, dynamic> json) {
            return PriceResponse(
                prodCode: json['prodCode'],
                productName: json['productName'],
                productType: json['productType'],
                contractSize: json['contractSize'],
                expiryDate: json['expiryDate'],
                instrumentCode: json['instrumentCode'],
                currency: json['currency'],
                strike: json['strike'],   
                callPut: json['callPut'],
                underlying: json['underlying'],

                bidPrice: List<double>.from(json["bidPrice"].map((x) => x)),
                bidQty: List<int>.from(json["bidQty"].map((x) => x)),
                askPrice: List<double>.from(json["askPrice"].map((x) => x)),
                askQty: List<int>.from(json["askQty"].map((x) => x)),
                lastPrice: List<double>.from(json["lastPrice"].map((x) => x)),
                lastQty: List<int>.from(json["lastQty"].map((x) => x)),  

                openInterest: json['openInterest'],
                turnoverAmount: json['turnoverAmount'],
                turnoverVolume: json['turnoverVolume'],
                reserved1: json['reserved1'],
                reserved2: json['reserved2'],
                equilibriumPrice: json['equilibriumPrice'],
                open: json['open'],
                high: json['high'],   
                low: json['low'],
                previousClose: json['previousClose'],        
                previousCloseDate: json['previousCloseDate'],
                notUsed: json['notUsed'],
                tradeStateNo: json['tradeStateNo'],

                lotSize: json['lotSize'],
                tickSize: json['tickSize'],
                updateTime: json['updateTime'],                                                                                                        
            );
        } 

        Map<String, dynamic> toJson() => {
          'prodCode': prodCode,
          'productName': productName,
          'productType': productType,
          'contractSize': contractSize,
          'expiryDate': expiryDate,
          'instrumentCode': instrumentCode,
          'currency': currency,
          'strike': strike,   
          'callPut': callPut,
          'underlying': underlying,

          'bidPrice': List<dynamic>.from(bidPrice.map((x) => x)),
          'bidQty': List<dynamic>.from(bidQty.map((x) => x)),
          'askPrice': List<dynamic>.from(askPrice.map((x) => x)),
          'askQty': List<dynamic>.from(askQty.map((x) => x)),
          'lastPrice': List<dynamic>.from(lastPrice.map((x) => x)),
          'lastQty': List<dynamic>.from(lastQty.map((x) => x)),    

          'openInterest': openInterest,
          'turnoverAmount': turnoverAmount,
          'turnoverVolume': turnoverVolume,
          'reserved1': reserved1,
          'reserved2': reserved2,
          'equilibriumPrice': equilibriumPrice,
          'open': open,
          'high': high,   
          'low': low,
          'previousClose': previousClose,  
          'previousCloseDate': previousCloseDate,
          'notUsed': notUsed,
          'tradeStateNo': tradeStateNo,
          
          'lotSize': lotSize,
          'tickSize': tickSize,
          'updateTime': updateTime,                                                                                  
        };                 
    }