-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwsrapi-documentation.htm
86 lines (82 loc) · 4.05 KB
/
wsrapi-documentation.htm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<!DOCTYPE html>
<html ng-app="wsrApiDoc">
<head>
<title>WSR API Overview</title>
<link href="https://netdna.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet">
<style type="text/css">
.tooltip-inner code { background-color: #3f3f3f; color: #dfdfdf; padding: 1pt }
.hl1 { color: #67a472 }
.hl2 { color: #5781da }
.mono { font-family: 'Consolas', monospace }
</style>
<script src="https://code.jquery.com/jquery-2.1.1.min.js" type="text/javascript"></script>
<script src="https://netdna.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.25/angular.min.js"></script>
<script src="wsrapi.js" type="text/javascript"></script>
<script type="text/javascript">
angular.module('wsrApiDoc', [])
.controller('WsrApiDocCtrl', function ($scope) {
var inspectThis = WorldStateRepository.prototype;
var properties = [];
for (var key in inspectThis)
if (typeof inspectThis[key] === 'function')
properties.push(key);
$scope.wsrApiFunctions = properties.sort();
});
</script>
</head>
<body>
<div class="container" ng-controller="WsrApiDocCtrl">
<fieldset>
<legend>Usage</legend>
<p>
Create a new instance of the object pointing at the API URL
(e.g. <code>var api = new WorldStateRepository('http://127.0.0.1:3000/api');</code>).
</p>
<p>
You can then use any of the supported methods (see below); note that a lot of these are inherently
asynchronous, returning a <a href="http://api.jquery.com/Types/#Promise">jQuery Promise</a> instance
instead where you can register callbacks and handle callback data.
</p>
</fieldset>
<fieldset>
<legend>Supported methods</legend>
<p>
This list is generated automatically through programmatic inspection. There may or may not be
documentation for <em>each</em> of these methods, but as a rule of thumb…
</p>
<ul>
<li id="help-for-delete">
<strong>delete</strong> methods delete a single record (using HTTP's DELETE verb).
</li>
<li id="help-for-get">
<strong>get</strong> methods fetch a single record.
If you are looking to fetch <em>all</em> records, use <code>list␣</code> instead.
</li>
<li id="help-for-insert">
<strong>insert</strong> methods insert a new, single record.
</li>
<li id="help-for-list">
<strong>list</strong> methods return an array of objects. They are the equivalent of
<code>SELECT *</code>. If you are looking to fetch <em>one specific</em> record, use <code>get␣</code> instead.
</li>
<li id="help-for-update">
<strong>update</strong> methods return an array of objects. This library does <em>not</em> handle the
HTTP PATCH verb yet, so to perform an update, you would issue <code>get␣</code>, apply changes,
then write back the <em>whole</em> instance with this method.
</li>
</ul>
<p>
These methods follow a simple verb+resource nomenclature — this means that if you want to
<span class="hl1">insert</span> a new <span class="hl2">entity</span> record, you would use the
<span class="hl1 mono">insert</span><span class="hl2 mono">Entity</span> method.
Any methods <em>not</em> listed above are either internal helper methods and/or have documentation in their
JavaScript source code as they are likely not automatically generated but implemented by hand.
</p>
</fieldset>
<ul class="list-unstyled">
<li ng-repeat="c in wsrApiFunctions"><code>{{c}}</code></li>
</ul>
</div>
</body>
</html>