Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
@planningcenter/api-client
Advanced tools
A Planning Center JavaScript API client that will make you smile
@planningcenter/api-client
Install the package:
yarn add @planningcenter/api-client
transformResponse
takes an JSON API spec-adhering response and returns a lovely, transformed object or collection.
For example:
transformResponse({
"data": {
"type": "Person",
"id": "123",
"attributes": {
"first_name": "Marvin",
"last_name": "Gaye"
},
"relationships": {
"top_song": {
"data": {
"type": "Song",
"id": "456"
}
},
"instruments": {
"data": [{
"type": "Instrument",
"id": "789"
}]
}
},
"links": { ... }
},
"included": [
{
"type": "Instrument",
"id": "789",
"attributes": {
"name": "Piano"
}
}
],
"meta": {
"parent": {
"id": "1",
"type": "Organization"
}
}
})
Will return a transformed object:
{
data: {
// string IDs are parsed into integers
id: 123,
type: "Person",
// all keys are camel-cased
firstName: "Marvin",
lastName: "Gaye",
// belongs to relationships are given a singular foreign key property
topSongId: 456,
topSongType: "Song",
// relationships not also `included` are given a property with a null value
topSong: null,
// has many relationships are given a plural foreign key property
instrumentIds: [789],
// included records are gathered via relationships & placed in a collection:
instruments: [
{ id: 789, type: "Instrument", name: "Piano" },
],
links: {}
},
// response meta is available in case you need it
meta: { parent: { id: "1", type: "Organization" } }
}
transformRequestData
takes an object with request parameters and transforms to a more api friendly format.
For example:
transformRequestData({
fields: { Song: ["title", "arrangements"], Arrangement: ["name"] },
include: "arrangements",
where: { title: "I Like Bugs" },
})
Will return a transformed object:
{
"fields[Song]": "title,arrangements",
"fields[Arrangement]": "name",
include: "arrangements",
per_page: 100,
"where[title]": "I Like Bugs",
}
Request methods are exposed on instances of Client
.
import { Client } from "@planningcenter/api-client"
// You may choose to instantiate clients as needed, or export a singleton for use across multiple call-sites
const client = new Client({ app: "services", version: "2018-11-01" })
Note:
fields
are requiredmeta
attributes are discarded when walking pagination with walk: true
client.get({
url: '/plans',
data: {
where: { title: 'Plan Title' },
include: ['series'],
order: 'created_at',
fields: { Plan: 'dates,series,title', Series: 'title,artwork_for_dashboard' },
}
})
Fields are recommended, it will warn in dev if you do not pass them
client.post({
url: '/series',
data: {
fields: { Series: 'title,artwork_for_dashboard' },
data: {
type: 'Series',
attributes: { name: 'New Series Name' },
relationships: {
plan: {
data: { type: 'Plan', id }
}
}
}
}
})
Fields are recommended, it will warn in dev if you do not pass them
client.patch({
url: `/series/${seriesId}`,
data: {
fields: { Series: 'title,artwork_for_dashboard' },
data: { type: 'Series', attributes: { name: 'New Series Name' }
}
})
same as what you would expect
client.delete({ url: `/series/${seriesId}` })
FAQs
A Planning Center JavaScript API client that will make you smile
The npm package @planningcenter/api-client receives a total of 589 weekly downloads. As such, @planningcenter/api-client popularity was classified as not popular.
We found that @planningcenter/api-client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.