| 
									
										
										
										
											2018-07-31 01:44:45 -06:00
										 |  |  | <!DOCTYPE html> | 
					
						
							|  |  |  | <html> | 
					
						
							| 
									
										
										
										
											2018-08-02 11:28:05 -06:00
										 |  |  |   <head><title>API Docs</title></head> | 
					
						
							| 
									
										
										
										
											2018-07-31 01:44:45 -06:00
										 |  |  |   <body> | 
					
						
							| 
									
										
										
										
											2018-08-02 11:28:05 -06:00
										 |  |  |     <h1>Sample Chat - API Docs</h1> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <h2>Login</h2> | 
					
						
							|  |  |  |     <ul> | 
					
						
							|  |  |  |     <li> | 
					
						
							|  |  |  |     <h3>POST /api/sessions | 
					
						
							|  |  |  |     <br> | 
					
						
							| 
									
										
										
										
											2018-08-02 11:33:47 -06:00
										 |  |  |     <code>{"sub":"<strong><em><email></em></strong>"}</code> | 
					
						
							| 
									
										
										
										
											2018-08-02 11:28:05 -06:00
										 |  |  |     </h3> | 
					
						
							| 
									
										
										
										
											2018-07-31 01:44:45 -06:00
										 |  |  |     <pre><code># Ask for an auth code (swap sub) | 
					
						
							| 
									
										
										
										
											2018-08-02 11:28:05 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-01 19:13:10 -06:00
										 |  |  | curl -X POST http://localhost:4080/api/sessions \ | 
					
						
							| 
									
										
										
										
											2018-07-31 01:44:45 -06:00
										 |  |  |   -H 'Content-Type: application/json; charset=utf-8' \ | 
					
						
							| 
									
										
										
										
											2018-08-02 02:13:56 -06:00
										 |  |  |   -d '{"sub":"<strong><em>jon@example.com</em></strong>"}' | 
					
						
							| 
									
										
										
										
											2018-08-02 11:28:05 -06:00
										 |  |  |     </code></pre> | 
					
						
							|  |  |  |     </li> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <li> | 
					
						
							| 
									
										
										
										
											2018-08-02 11:33:47 -06:00
										 |  |  |     <h3>POST /api/sessions/<strong><em><id></em></strong> | 
					
						
							| 
									
										
										
										
											2018-08-02 11:28:05 -06:00
										 |  |  |     <br> | 
					
						
							| 
									
										
										
										
											2018-08-02 11:33:47 -06:00
										 |  |  |     <code>{"otp":"<strong><em><auth-code></em></strong>"}</code> | 
					
						
							| 
									
										
										
										
											2018-08-02 11:28:05 -06:00
										 |  |  |     </h3> | 
					
						
							|  |  |  |     <pre><code># Validate auth code (swap session id, sub, and otp) | 
					
						
							| 
									
										
										
										
											2018-07-31 01:44:45 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-02 02:13:56 -06:00
										 |  |  | curl -X POST http://localhost:4080/api/sessions/<strong><em>xyz</em></strong> \ | 
					
						
							| 
									
										
										
										
											2018-07-31 01:44:45 -06:00
										 |  |  |   -H 'Content-Type: application/json; charset=utf-8' \ | 
					
						
							| 
									
										
										
										
											2018-08-02 02:13:56 -06:00
										 |  |  |   -d '{"otp":"<strong><em>secret123</em></strong>"}' | 
					
						
							| 
									
										
										
										
											2018-08-02 11:28:05 -06:00
										 |  |  |     </code></pre> | 
					
						
							|  |  |  |     </li> | 
					
						
							|  |  |  |     </ul> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <h2>Messages</h2> | 
					
						
							|  |  |  |     <ul> | 
					
						
							|  |  |  |     <li> | 
					
						
							|  |  |  |     <h3>POST /api/rooms/general | 
					
						
							|  |  |  |     <br> | 
					
						
							| 
									
										
										
										
											2018-08-02 11:33:47 -06:00
										 |  |  |     <code>Authorization: Bearer <strong><em><api-token></em></strong> | 
					
						
							|  |  |  |     <br>{"message":"<strong><em><msg></em></strong>"}</code> | 
					
						
							| 
									
										
										
										
											2018-08-02 11:28:05 -06:00
										 |  |  |     </h3> | 
					
						
							|  |  |  |     <pre><code># Post a message (swap api-token) | 
					
						
							| 
									
										
										
										
											2018-07-31 01:44:45 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-01 19:13:10 -06:00
										 |  |  | curl -X POST http://localhost:4080/api/rooms/general \ | 
					
						
							| 
									
										
										
										
											2018-08-02 02:13:56 -06:00
										 |  |  |   -H 'Authorization: Bearer <strong><em>api-token</em></strong>' \ | 
					
						
							| 
									
										
										
										
											2018-07-31 01:44:45 -06:00
										 |  |  |   -H 'Content-Type: application/json; charset=utf-8' \ | 
					
						
							| 
									
										
										
										
											2018-08-02 02:13:56 -06:00
										 |  |  |   -d '{"message":"Hello, World!"}' | 
					
						
							| 
									
										
										
										
											2018-08-02 11:28:05 -06:00
										 |  |  |     </code></pre> | 
					
						
							|  |  |  |     </li> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <li> | 
					
						
							|  |  |  |     <h3>GET /api/rooms/general | 
					
						
							|  |  |  |     <br> | 
					
						
							| 
									
										
										
										
											2018-08-02 11:33:47 -06:00
										 |  |  |     <code>Authorization: Bearer <strong><em><api-token></em></strong></code> | 
					
						
							| 
									
										
										
										
											2018-08-02 11:28:05 -06:00
										 |  |  |     </h3> | 
					
						
							|  |  |  |     <pre><code># Get a room's messages (swap api-token, since unix-epoch) | 
					
						
							| 
									
										
										
										
											2018-07-31 01:44:45 -06:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-02 11:28:05 -06:00
										 |  |  | curl http://localhost:4080/api/rooms/general \ | 
					
						
							| 
									
										
										
										
											2018-08-02 02:13:56 -06:00
										 |  |  |   -H 'Authorization: Bearer <strong><em>api-token</em></strong>' | 
					
						
							| 
									
										
										
										
											2018-07-31 01:44:45 -06:00
										 |  |  |     </code></pre> | 
					
						
							| 
									
										
										
										
											2018-08-02 11:28:05 -06:00
										 |  |  |     </li> | 
					
						
							|  |  |  |     </ul> | 
					
						
							| 
									
										
										
										
											2018-07-31 01:44:45 -06:00
										 |  |  |   </body> | 
					
						
							|  |  |  | </html> |