Promotion.fromJson constructor
Implementation
factory Promotion.fromJson(Map<String, Object?> json) => Promotion(
id: json['id'] as String,
type: TargetType.fromJson(json['type']),
profile: coupon_models.OfferProfile.fromJson(
(json['profile'] as Map).cast<String, Object?>(),
),
schedule: Schedule.fromJson(
(json['schedule'] as Map).cast<String, Object?>()),
activation: Activation.fromJson(
(json['activation'] as Map).cast<String, Object?>(),
),
priority: (json['priority'] as num).toInt(),
status: Status.fromJson(json['status']),
createdAt: decodeDateTime(json['created_at']),
coupon: json['coupon'] == null
? null
: TargetReference.fromJson(
(json['coupon'] as Map).cast<String, Object?>()),
discount: json['discount'] == null
? null
: TargetReference.fromJson(
(json['discount'] as Map).cast<String, Object?>()),
customData: json['custom_data'] == null
? null
: core.CustomData.fromJson(json['custom_data']),
updatedAt: json['updated_at'] == null
? null
: decodeDateTime(json['updated_at']),
firstActivatedAt: json['first_activated_at'] == null
? null
: decodeDateTime(json['first_activated_at']),
activatedAt: json['activated_at'] == null
? null
: decodeDateTime(json['activated_at']),
deactivatedAt: json['deactivated_at'] == null
? null
: decodeDateTime(json['deactivated_at']),
scheduleAdjustments: json['schedule_adjustments'] == null
? null
: (json['schedule_adjustments'] as List)
.map((item) => ScheduleAdjustment.fromJson(
(item as Map).cast<String, Object?>(),
))
.toList(),
archivedAt: json['archived_at'] == null
? null
: decodeDateTime(json['archived_at']),
);