Since this round of 2.0 PRs is probably our last chance for breaking changes in a while, it would be nice if we could standardize all of the action verbs we're using across resources. Right now, after the PRs:
// templates, relay webhooks, recipient lists, and sending domains
{resource}.all() // get collection
{resource}.find() // get one by id
{resource}.create() // create one
{resource}.update() // update one by id
{resource}.delete() // delete one by id
// webhooks
webhooks.all() // get collection
webhooks.describe() // get one by id
webhooks.create() // create one
webhooks.update() // update one by id
webhooks.delete() // delete one by id
// suppression
suppressionList.search() // get collection (can filter by criteria)
suppressionList.getEntry() // get one by id
suppressionList.upsert() // create, or update one by id
suppressionList.deleteEntry() // delete one by id
I think all and maybe find come from ActiveRecord, but even AR has find_by and you can find by any column criteria you want, assuming a relational db backend. I don't think describe fits at all, and looking at everything as a whole now, I don't think suppression needs to be different.
The main difference in suppression's search is that it can filter by criteria, but at some point we will most likely be adding pagination to all of our API endpoints, which means you'll be specifying criteria in all no matter what, so the word "all" makes a little less sense.
Here's what I propose across the board. Happy to hear reasons why this won't work, needs improvement, etc.
{resource}.list() // get collection (can filter by criteria where applicable)
{resource}.get(id) // get one by id
{resource}.create() // create one
{resource}.update(id) // update one by id
{resource}.upsert([id]) // replaces both create and update, where applicable
{resource}.delete(id) // delete one by id
{resource}.{custom}() // resource-specific action, e.g. getBatchStatus
UPDATE: Per comment discussion, removed bc aliases, added required params. Optional params like options and callback not specified here.
Side note: If we go this way I am of course happy to help with the conversion, examples, docs, tests, etc.
Since this round of 2.0 PRs is probably our last chance for breaking changes in a while, it would be nice if we could standardize all of the action verbs we're using across resources. Right now, after the PRs:
I think
alland maybefindcome from ActiveRecord, but even AR hasfind_byand you can find by any column criteria you want, assuming a relational db backend. I don't thinkdescribefits at all, and looking at everything as a whole now, I don't think suppression needs to be different.The main difference in suppression's
searchis that it can filter by criteria, but at some point we will most likely be adding pagination to all of our API endpoints, which means you'll be specifying criteria inallno matter what, so the word "all" makes a little less sense.Here's what I propose across the board. Happy to hear reasons why this won't work, needs improvement, etc.
UPDATE: Per comment discussion, removed bc aliases, added required params. Optional params like
optionsandcallbacknot specified here.Side note: If we go this way I am of course happy to help with the conversion, examples, docs, tests, etc.