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
Install the package:
yarn install @planning-center/api-client
Expose your config on window
(for now):
window.PCO_API_CLIENT_DEFAULT_APP = "services"
window.PCO_API_CLIENT_DEFAULT_VERSION = "2018-11-01"
window.PCO_API_CLIENT_ENV = "<%= Rails.env %>"
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:
{
// 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" },
],
// response metadata is preserved in case you need it
responseMeta: { parent: { id: "1", type: "Organization" } },
links: {}
}
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",
}
GET
There are a few things to be aware of with get
s:
walk: false
responseMeta
responseMeta
example:
get({
url: '/plans',
data: {
where: { title: 'Plan Title' },
include: ['series'],
order: 'created_at',
fields: { Plan: 'dates,series,title', Series: 'title,artwork_for_dashboard' },
}
})
POST
Fields are recommended, it will warn in dev if you do not pass them
example:
post({
url: '/series',
data: {
fields: { Series: 'title,artwork_for_dashboard' },
data: {
type: 'Series',
attributes: { name: 'New Series Name' },
relationships: {
plan: {
data: { type: 'Plan', id }
}
}
}
}
})
PATCH
Fields are recommended, it will warn in dev if you do not pass them
example:
patch({
url: `/series/${seriesId}`,
data: {
fields: { Series: 'title,artwork_for_dashboard' },
data: { type: 'Series', attributes: { name: 'New Series Name' }
}
})
DESTROY
same as what you would expect
example:
destroy({ 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.