Skip to content

Instantly share code, notes, and snippets.

@mamund
Created October 26, 2013 22:42
Show Gist options
  • Save mamund/7175429 to your computer and use it in GitHub Desktop.
Save mamund/7175429 to your computer and use it in GitHub Desktop.
Example of expressing "workflow" (non-CRUD) operations in Cj. Note the first ITEM has one possible "workflow" link (approve") while the second ITEM has three possible "workflow" links (upgrade, downgrade, cancellation).
{"collection" :
{
"version" : "1.0",
"href" : "...",
"links" :
[
{"rel" : "home", "href" : "..."},
{"rel" : "profile", "href" : "..."}
],
"items" :
[
{
"href" : "...",
"data" :
[
{"name" : "givenName", "value" : "Rus"},
{"name" : "familyName", "value" : "Data"},
{"name" : "email", "value" : "[email protected]"},
{"name" : "status", "value" : "pending"}
],
"links" :
[
{"rel" : "http://example.org/rels/approve", "href" : "...", "prompt" : "Start credit approval process"}
]
},
{
"href" : "...",
"data" :
[
{"name" : "givenName", "value" : "Sam"},
{"name" : "familyName", "value" : "Iam"},
{"name" : "email", "value" : "[email protected]"},
{"name" : "status", "value" : "approved"}
],
"links" :
[
{"rel" : "http://example.org/rels/upgrade", "href" : "...", "prompt" : "Start credit upgrade process"},
{"rel" : "http://example.org/rels/downgrade", "href" : "...", "prompt" : "Start credit downgrade process"},
{"rel" : "http://example.org/rels/cancellation", "href" : "...", "prompt" : "Start credit cancellation process"}
]
}
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment