import 'dart:convert';

class ApplePayResponse {
  PaymentMethod paymentMethod;
  dynamic billingContact;
  dynamic shippingMethod;
  dynamic shippingContact;
  Token token;

  ApplePayResponse(
      {this.paymentMethod,
        this.billingContact,
        this.shippingMethod,
        this.shippingContact,
        this.token});

  ApplePayResponse.fromJson(Map<String, dynamic> jsonValue) {
    paymentMethod = jsonValue['paymentMethod'] != null
        ? new PaymentMethod.fromJson(jsonValue['paymentMethod'])
        : null;
    // billingContact = json['billingContact'] != null ? json['billingContact'] : "";
    // shippingMethod = json['shippingMethod'] != null ? json['shippingMethod'] : "";
    // shippingContact = json['shippingContact'] != null ? json['shippingContact'] : "";
    token = jsonValue['token'] != null ? new Token.fromJson(json.decode(jsonValue['token'])) : null;
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    if (this.paymentMethod != null) {
      data['paymentMethod'] = this.paymentMethod.toJson();
    }
    data['billingContact'] = this.billingContact;
    data['shippingMethod'] = this.shippingMethod;
    data['shippingContact'] = this.shippingContact;
    if (this.token != null) {
      data['token'] = this.token.toJson();
    }
    return data;
  }
}

class PaymentMethod {
  dynamic network;
  dynamic displayName;
  dynamic type;

  PaymentMethod({this.network, this.displayName, this.type});

  PaymentMethod.fromJson(Map<String, dynamic> json) {
    network = json['network'];
    displayName = json['displayName'];
    type = json['type'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['network'] = this.network;
    data['displayName'] = this.displayName;
    data['type'] = this.type;
    return data;
  }
}

class Token {
  String version;
  String data;
  String signature;
  Header header;

  Token({this.version, this.data, this.signature, this.header});

  Token.fromJson(Map<String, dynamic> json) {
    version = json['version'];
    data = json['data'];
    signature = json['signature'];
    header =
    json['header'] != null ? new Header.fromJson(json['header']) : null;
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['version'] = this.version;
    data['data'] = this.data;
    data['signature'] = this.signature;
    if (this.header != null) {
      data['header'] = this.header.toJson();
    }
    return data;
  }
}

class Header {
  String ephemeralPublicKey;
  String publicKeyHash;
  String transactionId;

  Header({this.ephemeralPublicKey, this.publicKeyHash, this.transactionId});

  Header.fromJson(Map<String, dynamic> json) {
    ephemeralPublicKey = json['ephemeralPublicKey'];
    publicKeyHash = json['publicKeyHash'];
    transactionId = json['transactionId'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['ephemeralPublicKey'] = this.ephemeralPublicKey;
    data['publicKeyHash'] = this.publicKeyHash;
    data['transactionId'] = this.transactionId;
    return data;
  }
}
