Web API: Chronos - mapto/sprks GitHub Wiki

POST /api/chronos/update

Synchronizes the following data:

  • Upload
    • Elapsed time
    • Policy changes (on monthly syncs only)
  • Download
    • Risks
    • Rankings
    • Prophesies
    • Policies (optional)

Chronos is the mechanism which governs gameplay-related communications between the server and the client. While its primary responsibility is to keep the client and server in sync, because all user inputs (policy changes) will result in new prophesy, such related communications will also piggyback on the same communication channel/API. See the spec for details.

Request

  • initPolicy tells the server to dump the user's policies to the client to populate the client. In other words, setting this to true tells server to send a policy back.
Sample
{
  'date': '2014-02-01',
  'initPolicy': true,
  'policyUpdate': [
    {
      'employee': ['executives', 'road'],
      'location': ['office', 'home'],
      'device': ['phone', 'desktop'],
      'policyDelta': {
       'pwpolicy': {'plen': 12, 'pdict': true},
      'passfaces': {},
       'biometric': {'bdata': 2}
      }
    },
    {
      'employee': ['desk', 'road'],
      'location': ['office', 'public'],
      'device': ['desktop', 'laptop'],
      'policyDelta': {
       'pwpolicy': {'plen': 8
        'psets': 3},
       'passfaces': {'pdata':1},
       'biometric': {}
      }
    }]
}

Response

Sample
{ 
  'date': 'YYYY-MM-DD',
  'policyAccept': true,
  'eventAccept': true,
  'calendar': [
    {
      'date': '2014-01-20',
      'events': [
        {
        'incdt_id': 5,
        'cost': 2000
        }
      ]
    },
    {
      'date': '2014-01-21',
      'events': []
    },
    {
      'date': '2014-02-05',
       'events': [
        {
          'incdt_id': 1,
          'cost': 7000000
        },
        {
          'incdt_id': 4,
          'cost' 5000
        }
      ]
    },
    {
      'date': '2014-02-07',
      'events': [
        {
          'incdt_id': 8,
          'cost' 1000
        }
      ]
    }
  ]
  }
}
{
  'success': False,
  'messages': ['Unauthorized']
}

Sequence diagram of the process of the policy update

policyupdate_sequencediagram