PcoGroupsMembership constructor

PcoGroupsMembership({
  1. required String groupId,
  2. String? id,
  3. String? accountCenterIdentifier,
  4. String? avatarUrl,
  5. String? colorIdentifier,
  6. String? emailAddress,
  7. String? firstName,
  8. DateTime? joinedAt,
  9. String? lastName,
  10. String? phoneNumber,
  11. String? role,
  12. String? personId,
  13. Map<String, List<PcoResource>>? withRelationships,
  14. List<PcoResource>? withIncluded,
})

Create a new PcoGroupsMembership object using this endpoint: https://api.planningcenteronline.com/groups/v2/groups/$groupId/memberships

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: personId, role, joinedAt
  • FIELDS USED WHEN UPDATING: role, joinedAt

Implementation

factory PcoGroupsMembership(
    {required String groupId,
    String? id,
    String? accountCenterIdentifier,
    String? avatarUrl,
    String? colorIdentifier,
    String? emailAddress,
    String? firstName,
    DateTime? joinedAt,
    String? lastName,
    String? phoneNumber,
    String? role,
    String? personId,
    Map<String, List<PcoResource>>? withRelationships,
    List<PcoResource>? withIncluded}) {
  var obj = PcoGroupsMembership.empty();
  obj._id = id;
  obj._apiPathOverride =
      'https://api.planningcenteronline.com/groups/v2/groups/$groupId/memberships';
  if (accountCenterIdentifier != null)
    obj._attributes['account_center_identifier'] = accountCenterIdentifier;
  if (avatarUrl != null) obj._attributes['avatar_url'] = avatarUrl;
  if (colorIdentifier != null)
    obj._attributes['color_identifier'] = colorIdentifier;
  if (emailAddress != null) obj._attributes['email_address'] = emailAddress;
  if (firstName != null) obj._attributes['first_name'] = firstName;
  if (joinedAt != null)
    obj._attributes['joined_at'] = joinedAt.toIso8601String();
  if (lastName != null) obj._attributes['last_name'] = lastName;
  if (phoneNumber != null) obj._attributes['phone_number'] = phoneNumber;
  if (role != null) obj._attributes['role'] = role;
  if (personId != null) obj._attributes['person_id'] = personId;

  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;
}