PcoServicesKey constructor

PcoServicesKey({
  1. required String songId,
  2. required String arrangementId,
  3. String? id,
  4. DateTime? createdAt,
  5. DateTime? updatedAt,
  6. String? name,
  7. String? alternateKeys,
  8. String? endingKey,
  9. String? startingKey,
  10. bool? isStartingMinor,
  11. bool? isEndingMinor,
  12. Map<String, List<PcoResource>>? withRelationships,
  13. List<PcoResource>? withIncluded,
})

Create a new PcoServicesKey object using this endpoint: https://api.planningcenteronline.com/services/v2/songs/$songId/arrangements/$arrangementId/keys

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: alternateKeys, endingKey, name, startingKey
  • FIELDS USED WHEN UPDATING: alternateKeys, endingKey, name, startingKey

Implementation

factory PcoServicesKey(
    {required String songId,
    required String arrangementId,
    String? id,
    DateTime? createdAt,
    DateTime? updatedAt,
    String? name,
    String? alternateKeys,
    String? endingKey,
    String? startingKey,
    bool? isStartingMinor,
    bool? isEndingMinor,
    Map<String, List<PcoResource>>? withRelationships,
    List<PcoResource>? withIncluded}) {
  var obj = PcoServicesKey.empty();
  obj._id = id;
  obj._apiPathOverride =
      'https://api.planningcenteronline.com/services/v2/songs/$songId/arrangements/$arrangementId/keys';
  if (createdAt != null)
    obj._attributes['created_at'] = createdAt.toIso8601String();
  if (updatedAt != null)
    obj._attributes['updated_at'] = updatedAt.toIso8601String();
  if (name != null) obj._attributes['name'] = name;
  if (alternateKeys != null)
    obj._attributes['alternate_keys'] = alternateKeys;
  if (endingKey != null) obj._attributes['ending_key'] = endingKey;
  if (startingKey != null) obj._attributes['starting_key'] = startingKey;
  if (isStartingMinor != null)
    obj._attributes['starting_minor'] = isStartingMinor;
  if (isEndingMinor != null) obj._attributes['ending_minor'] = isEndingMinor;

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