PcoPeopleHousehold constructor

PcoPeopleHousehold({
  1. String? id,
  2. String? name,
  3. int? memberCount,
  4. String? primaryContactName,
  5. DateTime? createdAt,
  6. DateTime? updatedAt,
  7. String? avatar,
  8. String? primaryContactId,
  9. Map<String, List<PcoResource>>? withRelationships,
  10. List<PcoResource>? withIncluded,
})

Create a new PcoPeopleHousehold object using this endpoint: https://api.planningcenteronline.com/people/v2/households

NOTES:

  • Creating an instance of a class this way does not save it on the server.
  • Call save() on the object to save it to the server.
  • Only set the id field if you know what you are doing. Save operations will overwrite data when the id is set.
  • Dummy data can be supplied for a required parameter, but if so, .save() should not be called on the object
  • FIELDS USED WHEN CREATING: name, memberCount, avatar, primaryContactId
  • FIELDS USED WHEN UPDATING: name, memberCount, avatar, primaryContactId

Implementation

factory PcoPeopleHousehold(
    {String? id,
    String? name,
    int? memberCount,
    String? primaryContactName,
    DateTime? createdAt,
    DateTime? updatedAt,
    String? avatar,
    String? primaryContactId,
    Map<String, List<PcoResource>>? withRelationships,
    List<PcoResource>? withIncluded}) {
  var obj = PcoPeopleHousehold.empty();
  obj._id = id;
  obj._apiPathOverride =
      'https://api.planningcenteronline.com/people/v2/households';
  if (name != null) obj._attributes['name'] = name;
  if (memberCount != null) obj._attributes['member_count'] = memberCount;
  if (primaryContactName != null)
    obj._attributes['primary_contact_name'] = primaryContactName;
  if (createdAt != null)
    obj._attributes['created_at'] = createdAt.toIso8601String();
  if (updatedAt != null)
    obj._attributes['updated_at'] = updatedAt.toIso8601String();
  if (avatar != null) obj._attributes['avatar'] = avatar;
  if (primaryContactId != null)
    obj._attributes['primary_contact_id'] = primaryContactId;

  if (withRelationships != null) {
    for (var r in withRelationships.entries) {
      obj._relationships[r.key] = r.value;
    }
    obj._hasManualRelationships = true;
  }

  if (withIncluded != null) {
    obj._included.addAll(withIncluded);
    obj._hasManualIncluded = true;
  }

  return obj;
}