PcoServicesAttachment constructor

PcoServicesAttachment({
  1. required String songId,
  2. required String arrangementId,
  3. String? id,
  4. DateTime? createdAt,
  5. String? pageOrder,
  6. DateTime? updatedAt,
  7. String? filename,
  8. int? fileSize,
  9. int? licensesPurchased,
  10. int? licensesRemaining,
  11. int? licensesUsed,
  12. String? contentType,
  13. String? displayName,
  14. String? filetype,
  15. String? linkedUrl,
  16. String? pcoType,
  17. String? remoteLink,
  18. String? thumbnailUrl,
  19. String? url,
  20. bool? isAllowMp3Download,
  21. bool? isWebStreamable,
  22. bool? isDownloadable,
  23. bool? isTransposable,
  24. bool? isStreamable,
  25. bool? isHasPreview,
  26. String? fileUploadIdentifier,
  27. String? attachmentTypeIds,
  28. Map<String, List<PcoResource>>? withRelationships,
  29. List<PcoResource>? withIncluded,
})

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

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: attachmentTypeIds, fileUploadIdentifier, filename, remoteLink, pageOrder
  • FIELDS USED WHEN UPDATING: attachmentTypeIds, fileUploadIdentifier, filename, remoteLink, pageOrder

Implementation

factory PcoServicesAttachment(
    {required String songId,
    required String arrangementId,
    String? id,
    DateTime? createdAt,
    String? pageOrder,
    DateTime? updatedAt,
    String? filename,
    int? fileSize,
    int? licensesPurchased,
    int? licensesRemaining,
    int? licensesUsed,
    String? contentType,
    String? displayName,
    String? filetype,
    String? linkedUrl,
    String? pcoType,
    String? remoteLink,
    String? thumbnailUrl,
    String? url,
    bool? isAllowMp3Download,
    bool? isWebStreamable,
    bool? isDownloadable,
    bool? isTransposable,
    bool? isStreamable,
    bool? isHasPreview,
    String? fileUploadIdentifier,
    String? attachmentTypeIds,
    Map<String, List<PcoResource>>? withRelationships,
    List<PcoResource>? withIncluded}) {
  var obj = PcoServicesAttachment.empty();
  obj._id = id;
  obj._apiPathOverride =
      'https://api.planningcenteronline.com/services/v2/songs/$songId/arrangements/$arrangementId/attachments';
  if (createdAt != null)
    obj._attributes['created_at'] = createdAt.toIso8601String();
  if (pageOrder != null) obj._attributes['page_order'] = pageOrder;
  if (updatedAt != null)
    obj._attributes['updated_at'] = updatedAt.toIso8601String();
  if (filename != null) obj._attributes['filename'] = filename;
  if (fileSize != null) obj._attributes['file_size'] = fileSize;
  if (licensesPurchased != null)
    obj._attributes['licenses_purchased'] = licensesPurchased;
  if (licensesRemaining != null)
    obj._attributes['licenses_remaining'] = licensesRemaining;
  if (licensesUsed != null) obj._attributes['licenses_used'] = licensesUsed;
  if (contentType != null) obj._attributes['content_type'] = contentType;
  if (displayName != null) obj._attributes['display_name'] = displayName;
  if (filetype != null) obj._attributes['filetype'] = filetype;
  if (linkedUrl != null) obj._attributes['linked_url'] = linkedUrl;
  if (pcoType != null) obj._attributes['pco_type'] = pcoType;
  if (remoteLink != null) obj._attributes['remote_link'] = remoteLink;
  if (thumbnailUrl != null) obj._attributes['thumbnail_url'] = thumbnailUrl;
  if (url != null) obj._attributes['url'] = url;
  if (isAllowMp3Download != null)
    obj._attributes['allow_mp3_download'] = isAllowMp3Download;
  if (isWebStreamable != null)
    obj._attributes['web_streamable'] = isWebStreamable;
  if (isDownloadable != null)
    obj._attributes['downloadable'] = isDownloadable;
  if (isTransposable != null)
    obj._attributes['transposable'] = isTransposable;
  if (isStreamable != null) obj._attributes['streamable'] = isStreamable;
  if (isHasPreview != null) obj._attributes['has_preview'] = isHasPreview;
  if (fileUploadIdentifier != null)
    obj._attributes['file_upload_identifier'] = fileUploadIdentifier;
  if (attachmentTypeIds != null)
    obj._attributes['attachment_type_ids'] = attachmentTypeIds;

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