Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
ReST API Workflow
// Create an order.
POST /orders
request = {
title: 'TITLE',
description: 'DESCRIPTION'
response = {
id: 'ORDER_ID',
title: 'TITLE',
description: 'DESCRIPTION',
state: 'created',
availableTransitions: [
// Validate an order
request = {
state: 'validated',
validationInfo: {
validatedAt: '2018-01-01',
validatedBy: 'Jesus',
validatedWith: 'Bread&Wine'
state_machine = OrderStateMachine(order)
class StateMachine(object):
def processUpdate(self, data):
state = self._getCurrentState()
return state.processUpdate(data)
class StateCreated(object):
def processUpdate(self, data):
// Checks properties `creationInfo` ...
data = OrderCreatedSerializer().deserialize(
// do stuff
return OrderValidatedSerializer().serialize(self._order)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment