BucketCampaign.fromJson constructor

BucketCampaign.fromJson(
  1. Map<String, dynamic> json
)

Implementation

BucketCampaign.fromJson(Map<String, dynamic> json) {
  // Set idCampaign
  if (json.keys.contains("id")) {
    idCampaign = json['id'] as String;
  }

  // Set Campaign name
  if (json.keys.contains("name")) {
    campaignName = json['name'] as String;
  }

  // Set type Campaign
  if (json.keys.contains("type")) {
    type = json['type'] as String;
  }

  // Set slug
  if (json.keys.contains("slug")) {
    slug = json['slug'] as String;
  }

  var list = (json['variationGroups'] ?? []) as List<dynamic>;
  variationGroups = list.map((e) {
    return VariationGroup.fromJson(e);
  }).toList();
}