PcoServicesBlockout constructor

PcoServicesBlockout({
  1. required String personId,
  2. String? id,
  3. String? description,
  4. String? groupIdentifier,
  5. String? organizationName,
  6. String? reason,
  7. String? repeatFrequency,
  8. String? repeatInterval,
  9. String? repeatPeriod,
  10. String? settings,
  11. String? timeZone,
  12. DateTime? createdAt,
  13. DateTime? updatedAt,
  14. String? repeatUntil,
  15. DateTime? startsAt,
  16. DateTime? endsAt,
  17. bool? isShare,
  18. Map<String, List<PcoResource>>? withRelationships,
  19. List<PcoResource>? withIncluded,
})

Create a new PcoServicesBlockout object using this endpoint: https://api.planningcenteronline.com/services/v2/people/$personId/blockouts

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: reason, repeatFrequency, repeatInterval, repeatPeriod, isShare, repeatUntil, startsAt, endsAt
  • FIELDS USED WHEN UPDATING: reason, repeatFrequency, repeatInterval, repeatPeriod, isShare, repeatUntil, startsAt, endsAt

Implementation

factory PcoServicesBlockout(
    {required String personId,
    String? id,
    String? description,
    String? groupIdentifier,
    String? organizationName,
    String? reason,
    String? repeatFrequency,
    String? repeatInterval,
    String? repeatPeriod,
    String? settings,
    String? timeZone,
    DateTime? createdAt,
    DateTime? updatedAt,
    String? repeatUntil,
    DateTime? startsAt,
    DateTime? endsAt,
    bool? isShare,
    Map<String, List<PcoResource>>? withRelationships,
    List<PcoResource>? withIncluded}) {
  var obj = PcoServicesBlockout.empty();
  obj._id = id;
  obj._apiPathOverride =
      'https://api.planningcenteronline.com/services/v2/people/$personId/blockouts';
  if (description != null) obj._attributes['description'] = description;
  if (groupIdentifier != null)
    obj._attributes['group_identifier'] = groupIdentifier;
  if (organizationName != null)
    obj._attributes['organization_name'] = organizationName;
  if (reason != null) obj._attributes['reason'] = reason;
  if (repeatFrequency != null)
    obj._attributes['repeat_frequency'] = repeatFrequency;
  if (repeatInterval != null)
    obj._attributes['repeat_interval'] = repeatInterval;
  if (repeatPeriod != null) obj._attributes['repeat_period'] = repeatPeriod;
  if (settings != null) obj._attributes['settings'] = settings;
  if (timeZone != null) obj._attributes['time_zone'] = timeZone;
  if (createdAt != null)
    obj._attributes['created_at'] = createdAt.toIso8601String();
  if (updatedAt != null)
    obj._attributes['updated_at'] = updatedAt.toIso8601String();
  if (repeatUntil != null) obj._attributes['repeat_until'] = repeatUntil;
  if (startsAt != null)
    obj._attributes['starts_at'] = startsAt.toIso8601String();
  if (endsAt != null) obj._attributes['ends_at'] = endsAt.toIso8601String();
  if (isShare != null) obj._attributes['share'] = isShare;

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