PcoServicesItem constructor

PcoServicesItem({
  1. required String serviceTypeId,
  2. required String planId,
  3. String? id,
  4. String? title,
  5. int? sequence,
  6. DateTime? createdAt,
  7. DateTime? updatedAt,
  8. int? length,
  9. String? itemType,
  10. String? htmlDetails,
  11. String? servicePosition,
  12. String? description,
  13. String? keyName,
  14. List? customArrangementSequence,
  15. List? customArrangementSequenceShort,
  16. List? customArrangementSequenceFull,
  17. String? arrangementId,
  18. String? keyId,
  19. String? selectedLayoutId,
  20. String? songId,
  21. Map<String, List<PcoResource>>? withRelationships,
  22. List<PcoResource>? withIncluded,
})

Create a new PcoServicesItem object using this endpoint: https://api.planningcenteronline.com/services/v2/service_types/$serviceTypeId/plans/$planId/items

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: arrangementId, customArrangementSequence, description, htmlDetails, keyId, length, selectedLayoutId, servicePosition, songId, title, itemType, sequence
  • FIELDS USED WHEN UPDATING: arrangementId, customArrangementSequence, description, htmlDetails, keyId, length, selectedLayoutId, servicePosition, songId, title

Implementation

factory PcoServicesItem(
    {required String serviceTypeId,
    required String planId,
    String? id,
    String? title,
    int? sequence,
    DateTime? createdAt,
    DateTime? updatedAt,
    int? length,
    String? itemType,
    String? htmlDetails,
    String? servicePosition,
    String? description,
    String? keyName,
    List? customArrangementSequence,
    List? customArrangementSequenceShort,
    List? customArrangementSequenceFull,
    String? arrangementId,
    String? keyId,
    String? selectedLayoutId,
    String? songId,
    Map<String, List<PcoResource>>? withRelationships,
    List<PcoResource>? withIncluded}) {
  var obj = PcoServicesItem.empty();
  obj._id = id;
  obj._apiPathOverride =
      'https://api.planningcenteronline.com/services/v2/service_types/$serviceTypeId/plans/$planId/items';
  if (title != null) obj._attributes['title'] = title;
  if (sequence != null) obj._attributes['sequence'] = sequence;
  if (createdAt != null)
    obj._attributes['created_at'] = createdAt.toIso8601String();
  if (updatedAt != null)
    obj._attributes['updated_at'] = updatedAt.toIso8601String();
  if (length != null) obj._attributes['length'] = length;
  if (itemType != null) obj._attributes['item_type'] = itemType;
  if (htmlDetails != null) obj._attributes['html_details'] = htmlDetails;
  if (servicePosition != null)
    obj._attributes['service_position'] = servicePosition;
  if (description != null) obj._attributes['description'] = description;
  if (keyName != null) obj._attributes['key_name'] = keyName;
  if (customArrangementSequence != null)
    obj._attributes['custom_arrangement_sequence'] =
        customArrangementSequence;
  if (customArrangementSequenceShort != null)
    obj._attributes['custom_arrangement_sequence_short'] =
        customArrangementSequenceShort;
  if (customArrangementSequenceFull != null)
    obj._attributes['custom_arrangement_sequence_full'] =
        customArrangementSequenceFull;
  if (arrangementId != null)
    obj._attributes['arrangement_id'] = arrangementId;
  if (keyId != null) obj._attributes['key_id'] = keyId;
  if (selectedLayoutId != null)
    obj._attributes['selected_layout_id'] = selectedLayoutId;
  if (songId != null) obj._attributes['song_id'] = songId;

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