PcoResource class abstract

follows the implementation of a JSON:API resource object

Implementations should override static members pcoApplication, typeString, apiVersion as well as all the field mapping constants.

Implementations should override the getters createAllowed, updateAllowed, and defaultAttributes.

Implementations should also have a static typeEndpoint and override itemEndpoint

Implementers

Constructors

PcoResource(String pcoApplication, String resourceType)
PcoResource.fromJson(String pcoApplication, String resourceType, Map<String, dynamic> data, {List<Map<String, dynamic>>? withIncluded})

Properties

api PlanningCenter
planning center resources must be tied to an api
no setter
apiEndpoint String
no setter
apiPath String?
PcoResources include their own path as a link object but this might be null if we haven't created/fetched the object yet Child classes should redefine this getter to allow for manual path overrides
no setter
apiVersion String
child classes can override these getters which will allow methods in this class to see static variables from child classes
no setter
attributes ReadOnlyMapView<String, dynamic>
contains the underlying attributes returned by the api and allows a user to access arbitrary data in the attributes by actual api name
no setter
canCreate bool
no setter
canDestroy bool
no setter
canUpdate bool
no setter
createAllowed List<String>
no setter
createdAt DateTime
no setter
createPathTemplate String
no setter
defaultPathTemplate String
no setter
fetched bool
indicate whether an item is full or partial
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
id String?
no setter
included List<PcoResource>
contains included items parsed into objects
no setter
contains the links data returned by the api if present
no setter
needsSave bool
no setter
pcoApplication String
latefinal
relationships ReadOnlyMapView<String, List<PcoResource>>
contains relationships parsed into objects even though the api sends relationship objects as Maps or Lists we always put them into lists for consistency
no setter
resourceType String
all planning center resources must have a type
latefinal
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
slug String
no setter
updateAllowed List<String>
no setter
updatedAt DateTime
no setter

Methods

coerceDouble(dynamic a) double
coerceInt(dynamic a) int
delete() Future<PlanningCenterApiResponse<PlanningCenterApiData>>
filteredAttributes(List<String> allowedKeys) Map<String, dynamic>
fromJson(Map<String, dynamic> data, {List<Map<String, dynamic>>? withIncluded}) → dynamic
Takes a full JSON:API Response Object (the contents of a "data" field) will clear and update id, apiPath, attributes and _relationships
handleIncludes(List<Map<String, dynamic>> included) → void
This function populates the relationships with typed resource objects based on the data in the included map of the json.
handleItem(Map<String, dynamic> data) PcoResource?
handleRelationships(Map<String, dynamic> items, [List<Map<String, dynamic>> included = const []]) Map<String, List<PcoResource>>
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
save({Map<String, PcoResource>? withRelated, List<PcoResource>? withIncluded}) Future<PlanningCenterApiResponse<PlanningCenterApiData>>
Many Planning Center endpoints allow or require additional relationships and/or included items to be sent with a create/update operation. Since these cannot always be determined by the automatic code generation, they may be included as arguments to the save operation.
toCreateResource() Map<String, dynamic>
create the attributes Map for this object without the id field using only the attributes allowed in create (post) operations
toDataMap({Map<String, PcoResource>? withRelated, List<PcoResource>? withIncluded}) Map<String, dynamic>
create a json-api Map for this object automatically selecting create or update based on the existence of the id field. Will result in something like this:
toIdResource() Map<String, dynamic>
returns the simplest representation of this resource with only the type and the id:
toJson({dynamic includeAttributes = true, dynamic includeRelationships = false}) Map<String, dynamic>
Some api requests only want the type and id of an object. In those cases, set includeAttributes to false or call toIdResource instead.
toString() String
A string representation of this object.
override
toUpdateResource() Map<String, dynamic>
create the attributes Map for this object using only the attributes allowed in update (patch) operations

Operators

operator ==(Object other) bool
The equality operator.
inherited

Constants

kApiVersion → const String
kCreatedAt → const String
kCreatePathTemplate → const String
kDefaultPathTemplate → const String
kPcoApplication → const String
implementations should duplicate/override these
kTypeString → const String
kUpdatedAt → const String