Create.fromJson constructor
Implementation
factory Create.fromJson(
Map<String, dynamic> json,
) {
return Create(
accountReference: json['account_reference'] as String?,
accountType: AccountType.fromJson(json['account_type'] as String),
affiliate: json['affiliate'] != null
? Affiliate.fromJson(json['affiliate'] as Map<String, dynamic>)
: null,
billingAddress:
Address.fromJson(json['billing_address'] as Map<String, dynamic>),
billingOptions: json['billing_options'] != null
? BillingOptions.fromJson(
json['billing_options'] as Map<String, dynamic>)
: null,
brandCode: json['brand_code'] != null
? BrandCode.fromJson(json['brand_code'] as String)
: null,
business: json['business'] != null
? Business.fromJson(json['business'] as Map<String, dynamic>)
: null,
deposit: json['deposit'] != null
? Deposit.fromJson(json['deposit'] as Map<String, dynamic>)
: null,
electricityMeterPoints: (json['electricity_meter_points']
as List<dynamic>?)
?.map(
(e) => ElectricityMeterPoint.fromJson(e as Map<String, dynamic>))
.toList(),
gasMeterPoints: (json['gas_meter_points'] as List<dynamic>?)
?.map((e) => GasMeterPoint.fromJson(e as Map<String, dynamic>))
.toList(),
isChangeOfTenancy: json['is_change_of_tenancy'] as bool,
metadata: (json['metadata'] as List<dynamic>?)
?.map((e) => Metadata.fromJson(e as Map<String, dynamic>))
.toList(),
payment: json['payment'] != null
? Payment.fromJson(json['payment'] as Map<String, dynamic>)
: null,
preferredSsd: json['preferred_ssd']?.isNotEmpty == true
? DateTime.parse(json['preferred_ssd'] as String)
: null,
previousBillingAddress: json['previous_billing_address'] != null
? Address.fromJson(
json['previous_billing_address'] as Map<String, dynamic>,
)
: null,
promoRewardCode: json['promo_reward_code'] as String?,
quoteCode: json['quote_code'] as String?,
quoteRequestCode: json['quote_request_code'] as String?,
reference: json['reference'] as String,
referralCode: json['referral_code'] as String?,
requiresPostalComms: json['requires_postal_comms'] as bool?,
salesChannel: json['sales_channel'] != null
? SalesChannel.fromJson(json['sales_channel'] as String)
: null,
salesSubchannel: json['sales_subchannel'] as String?,
signupRewardCode: json['signup_reward_code'] as String?,
smartMeterInterest: json['smart_meter_interest'] != null
? SmartMeterInterest.fromJson(
json['smart_meter_interest'] as String,
)
: null,
smartMeterReadPermission: json['smart_meter_read_permission'] != null
? SmartMeterReadPermission.fromJson(
json['smart_meter_read_permission'] as String,
)
: null,
smartOnboardingProductType: json['smart_onboarding_product_type'] != null
? SmartOnboardingProductType.fromJson(
json['smart_onboarding_product_type'] as String,
)
: null,
soldAt: json['sold_at']?.isNotEmpty == true
? DateTime.parse(json['sold_at'] as String)
: null,
source: AccountSource.fromJson(json['source'] as String),
users: (json['users'] as List<dynamic>)
.map((e) => User.fromJson(e as Map<String, dynamic>))
.toList(),
);
}