-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.raml
419 lines (413 loc) · 12.4 KB
/
api.raml
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
#%RAML 0.8
title: GeoRenting
baseUri: https://georenting.herokuapp.com/{version}
version: v1
protocols: [HTTPS]
schemas:
- Fence: !include schema/fence.json
securitySchemes:
- x-jean-auth:
type: x-Jean-Auth
description: Some requests require authentication. Jean-Auth uses a JSON Web Token in a Header to prove the Identity of the user.
describedBy:
headers:
Authorization:
description: |
Used to send a valid Jean-Auth Token.
type: string
responses:
401:
description: |
Bad or expired token. Reauthenticate the user.
403:
description: |
Things are going bad for you. Reauthenticating won't help here.
documentation:
- title: Home
content: |
Welcome to the GeoRenting API. This is WIP. Please use me gently.
- title: Auth
content: |
The GeoRenting API uses JSON Web Tokens for authentication. You will get
one through the Sign In API Call. You need a Google Account Token to login.
Authenticated API calls require the token you get after login to be sent in a
Authorization header.
- title: GCM
content: |
The API will leverage Google Butt Messaging to notify the user of specific events.
<img src="art/comm.jpg" style="width: 700px" />
/application:
/upgrades:
get:
description: Gives you information about the currently possible Upgrade Levels of GeoFences.
responses:
200:
description: Returns the Information about Upgrade Levels. Radius in Meters, Max TTL in Seconds.
body:
application/json:
example: |
{
"min_radius": 100,
"max_radius": 400,
"radius": [
100, 150, 200, 250, 300, 350, 400
],
"rent": [
1, 1.5, 2, 2.5, 3, 3.5, 4
],
max_ttl: 604800,
min_ttl: 10
}
/users:
get:
queryParameters:
name:
description: Filter the users by name.
/refreshToken:
post:
description: Refreshes a Session for a given user. Requires an existing session Token.
body:
application/json:
example: |
{
"token": "asdasdasd.asdasd98asd987.asd89a7"
}
responses:
200:
description: Returns the JWT Token.
body:
application/json:
example: |
{
"token": "asdaisdansd.asdiu088ur98uasd.oaisd982"
"user": UserObject
}
403:
description: You sent an invalid JWT token.
/auth:
post:
description: Authenticate the User. Requires a Google OAuth Token.
body:
application/json:
example: |
{
"google_token": "AAAJJJDDDDEEEE"
}
responses:
200:
description: Returns the JWT token.
body:
application/json:
example: |
{
"token": "asdaisdansd.asdiu088ur98uasd.oaisd982"
"user": UserObject
}
403:
description: You sent an invalid Google OAuth token.
delete:
securedBy: [x-jean-auth]
description: Delete the session.
body:
application/json:
example: |
{
"token": "asdasdasd.asdpiajsdohuds9f8asdf.asdiasjdo"
}
responses:
200:
body:
application/json:
example: |
{}
/me:
get:
description: Returns information about the currently signed in User.
securedBy: [x-jean-auth]
responses:
200:
description: Returns the JWT token.
body:
application/json:
example: |
UserObject
403:
description: You sent an invalid Google OAuth token.
/cash:
get:
description: Returns information about the CashFlow of the user in the last 7 days and all time.
securedBy: [x-jean-auth]
responses:
200:
body:
application/json:
example: |
{
"earnings_rent_7d": 100.0,
"expenses_rent_7d": 10.0,
"expenses_geofence_7d": 100.0,
"earnings_rent_all": 10000.0,
"expenses_rent_all": 2342090.0,
"expenses_geofence_all": 3909090.0
}
403:
description: The user is not authorized to access this.
/history:
get:
description: Returns the Activity stream of the User.
securedBy: [x-jean-auth]
responses:
200:
body:
application/json:
example: |
[{
'verb': 'ownFenceVisited',
'date': 2255555555
'data': {
'visitor': 'Ulf',
'fence': 'Pedas Castle',
'rent': 200
}
}, {
'verb': 'foreignFenceVisited',
'date': 2255555557
'data': {
'owner': 'Friedhelm',
'fence': 'Friedhelms Area',
'rent': 10
}
}]
403:
description: The user is not authorized to access this.
/gcm:
post:
description: Add a GCM ID.
securedBy: [x-jean-auth]
body:
application/json:
example: |
{
"gcm_id": "42ua0sd8n"
}
delete:
description: Remove a GCM ID.
securedBy: [x-jean-auth]
body:
application/json:
example: |
{
"gcm_id": "42ua0sd8n"
}
responses:
200:
body:
application/json:
example: |
{}
403:
description: The user is not authorized to do this.
401:
description: The specified GCM ID could not be deleted.
/scores:
/heatmap:
get:
description: Returns data for generating a HeatMap of score values.
responses:
200:
body:
application/json:
example: |
[{
lat: 54.01,
lon: 8.2,
score: 2
}, {
lat: 42.1,
lon: 1.3,
score: 10
}]
/fences:
get:
description: Get Fences by user or around a center location. Returns more Information if the fence is owned by the current user.
queryParameters:
user:
type: string
description: Get all Fences owned by the specified User ID.
required: false
latitude:
type: number
description: Get Fences near the specified center location. Requires longitude and radius.
longitude:
type: number
description: Get Fences near the specified center location. Requires latitude and radius.
radius:
type: integer
description: Get Fences near the specified center location. Requires latitude and longitude.
excludeOwn:
type: boolean
description: Exclude GeoFences owned by the current user from the search. Requires Authorization, otherwise will be ignored.
responses:
200:
body:
application/json:
schema: Fence
example: |
[
{
"id": 42
"center_lon": 54.42,
"center_lat": 8.5,
"name": "Ulfs Castle",
"radius": 200,
"total_visitors": 23,
"total_earnings": 55.31,
"cost": 500.32,
"dies_at": 14588879,
"rent_multiplier": 1.5
},
{
"id": 45
"center_lon": 51.42,
"center_lat": 4.5,
"name": "Pedas House",
"radius": 100,
"total_visitors": 23,
"total_earnings": 55.31,
"cost": 500.32,
"dies_at": 14588879,
"rent_multiplier": 1.5
}
]
post:
description: Create the GeoFence. TTL has to be smaller than MaxTLL, RentMultiplier and Radius have to be valid Values from GET /application/upgrades.
securedBy: [x-jean-auth]
body:
application/json:
schema: Fence
example: |
{
"center_lon": 54.42,
"center_lat": 8.5,
"ttl": 1024,
"rent_multiplier": 1.5,
"radius": 150
"name": "Ulfs Castle"
}
responses:
200:
body:
application/json:
schema: Fence
example: |
{
"id": "42",
"center_lon": 54.42,
"center_lat": 8.5,
"name": "Ulfs Castle",
"dies_at": 14588879,
"rent_multiplier": 1.5,
"radius": 150
}
402:
description: The user does not have enough GeoCoins.
400:
description: The GeoFence is overlapping with another GeoFence in its radius.
417:
description: Upgrade Values not valid.
/estimateCost:
post:
description: Returns a price estimate for creating a GeoFence at the given location. TTL has to be smaller than MaxTLL, RentMultiplier and Radius have to be valid Values from GET /application/upgrades.
securedBy: [x-jean-auth]
body:
application/json:
schema: Fence
example: |
{
"center_lon": 54.42,
"center_lat": 8.5,
"ttl": 1024,
"rent_multiplier": 1.5,
"radius": 150
}
responses:
200:
body:
application/json:
schema: CostEstimate
example: |
{
"cost": 100,
"can_afford": true
}
400:
description: The GeoFence is overlapping with another GeoFence in its radius.
417:
description: Upgrade Values not valid.
/{fenceId}:
get:
description: Get information about the GeoFence.
responses:
200:
body:
application/json:
schema: Fence
example: |
{
"id": "42",
"center_lon": 54.42,
"center_lat": 8.5,
"name": "Ulfs Castle",
"radius": 200
}
404:
description: Not found.
put:
description: Update the GeoFence. Requires the user to be the owner of it.
securedBy: [x-jean-auth]
responses:
200:
body:
application/json:
schema: Fence
example: |
{
"id": "42",
"center_lon": 54.42,
"center_lat": 8.5,
"name": "Ulfs Castle",
"radius": 100
}
404:
description: Not Found.
403:
description: The current user is not authorized to update that fence.
body:
application/json:
schema: Fence
example: |
{
"id": "42",
"center_lon": 54.42,
"center_lat": 8.5,
"name": "Ulfs Castle"
}
delete:
description: Delete the GeoFence. Requires the user to be the owner of it.
securedBy: [x-jean-auth]
responses:
200:
body:
application/json:
example: |
{}
404:
description: Not Found.
403:
description: The current user is not authorized to delete the fence.
/visit:
post:
securedBy: [x-jean-auth]
description: |
This method will visit a GeoFence. The visitor and the owner will be notified
via GCM.