{"mock":"https://private-anon-519b3bbac9-eventhuboulu.apiary-mock.com/","production":"http://polls.apiblueprint.org/","proxy":"https://private-anon-519b3bbac9-eventhuboulu.apiary-proxy.com/"}
   FORMAT: 1A
HOST: http://polls.apiblueprint.org/
# Event
This API is serve basic information about events as well as allow users to create and join events. 
The API serves JSON data extended by the Mason hypermedia format. 
## Link Relations
### get-users
### get-user
### add-user
### edit-user
### delete-user
### get-events
### get-event
### add-event
### edit-event
### delete-event
## Users [/users]
### List All Users [GET]
**Relation:** all-users
List all users in the database
+ Response 200 (application/json)
    + Headers 
    
            Accept: application/vnd.mason+json
            
    + Body        
            {
                [
                    "@namespaces": {
                            "mumeta": {
                                "name": "/eventmeta/link-relations#"
                            }
                        },
                    "@controls": {
                            "self": {
                                "href": "/api/users/"
                            },
                            "mumeta:events-all": {
                                "href": "/api/events/",
                                "title": "All events"
                            },
                        }
                    },
                    "items": [
                        {
                            "id": "0",
                            "name": "Bangju",
                            "picture": 2048,
                            "location": "Oulu",
                            "@controls": {
                            "self": {
                                "href": "/api/users/0/"
                                },
                            "edit": {
                                "href": "/api/users/0/",
                                "method":"PUT"
                                },
                            "delete": {
                                "href": "/api/users/0/",
                                "method":"DELETE"
                                },
                        }, {
                            "id": "1",
                            "name": "Hao",
                            "picture": 2048,
                            "location": "Helsinki",
                            "@controls": {
                            "self": {
                                "href": "/api/users/1/"
                                },
                            "edit": {
                                "href": "/api/users/1/",
                                "method":"PUT"
                                },
                            "delete": {
                                "href": "/api/users/1/",
                                "method":"DELETE"
                                },
                        }, {
                            "id": "2",
                            "name": "Nechir",
                            "picture": 2048,
                            "location": "Espoo",
                            "@controls": {
                            "self": {
                                "href": "/api/users/2/"
                                },
                            "edit": {
                                "href": "/api/users/2/",
                                "method":"PUT"
                                },
                            "delete": {
                                "href": "/api/users/2/",
                                "method":"DELETE"
                                },                            
                        }
                    ]
                ]
            }
            
+ Response 201 ()
    + Headers
            Location: /users/0
+ Response 415 (application/vnd.mason+json)
    
    + Body
            {
                "resource_url": "/api/users/0/",
                "@error": {
                "@message": "Unsupported media type",
                "@messages": [
                  "Use JSON"
                ]
                },
                "@controls": {
                "profile": {
                  "href": "/users/error-user/"
                }
                }
            }
## Events [/events]
### List All Events [GET]
**Relation:** all-events
List all events in the database
+ Response 200 (application/json)
    + Headers 
    
            Accept: application/vnd.mason+json
            
    + Body        
            {
                [
                    "@namespaces": {
                            "mumeta": {
                                "name": "/eventmeta/link-relations#"
                            }
                        },
                    "@controls": {
                            "self": {
                                "href": "/api/events/"
                            },
                            "mumeta:events-all": {
                                "href": "/api/users/",
                                "title": "All users"
                            },
                        }
                    },
                    "items": [
                        {
                            "name": "Music Meeting",
                            "place": "Oulu",
                            "description": "Play Guitar",
                            "time":"tomorrow",
                            "creator":"Nechir",
                            "@controls": {
                            "self": {
                                "href": "/api/events/0/"
                                },
                            "edit": {
                                "href": "/api/events/0/",
                                "method":"PUT"
                                },
                            "delete": {
                                "href": "/api/events/0/",
                                "method":"DELETE"
                                },                                 
                        }, {
                            "name": "Football",
                            "place": "Oulu",
                            "description": "Indoor football",
                            "time":"tomorrow",
                            "creator":"Bangju",
                            "@controls": {
                            "self": {
                                "href": "/api/events/1/"
                                },
                            "edit": {
                                "href": "/api/events/0/",
                                "method":"PUT"
                                },
                            "delete": {
                                "href": "/api/events/0/",
                                "method":"DELETE"
                                },                                 
                        }
                    ]
                ]
            }
+ Response 201 ()
    + Headers
            Location: /events/0
## User Item [/users/user]
### User Information[GET]
**Relation:** get-user
Get user's information
+ Response 200 (application/json)
        [
            "@namespaces": {
                    "mumeta": {
                        "name": "/eventmeta/link-relations#"
                    }
                },
            "@controls": {
                    "self": {
                        "href": "/api/users/"
                    },
                    "mumeta:events-all": {
                        "href": "/api/events/",
                        "title": "All events"
                    },
                }
            },
            "id": "1",
            "name": "Bangju",
            "picture": 2048,
            "location": "Oulu",
            "loginuser": 
                {
                    "username": "GoJamie",
                    "password": "c0ab660dacd6cb3772ef955ecf3ed619"
                },
            "@controls": {
                    "self": {
                        "href": "/api/users/0/"
                        },
                    "author": {
                        "href": "/api/users/0/"
                        },
                    "mumeta:events-by": {
                        "href": "/api/users/0/events"
                        },
                    "collection": {
                        "href": "/api/users/"
                        },
            "edit": {
                "href": "/api/users/0/",
                "title": "Edit this user",
                "encoding": "json",
                "method": "PUT",
                "schema": {
                    "type": "object",
                    "properties": {
                        "id": {
                            "description": "User's id",
                            "type": "integer"
                        },
                        "username": {
                            "description": "Username",
                            "type": "string"
                        },
                        "picture": {
                            "description": "User's picture",
                            "type": "string"
                        },
                        "location": {
                            "description": "User's location",
                            "type": "string"
                        },
                        "password": {
                            "description": "User's password",
                            "type": "string"
                        }
                    },
                    "required": ["id", "username"]
                }
            },
            "mumeta:delete": {
                "href": "/api/users/0/",
                "title": "Delete this user",
                "method": "DELETE"
            }            
        ]
### Add User to User Collection[POST]
+ Request (application/json)
    + Headers
        
            Accept: application/vnd.mason+json
    
    + Body
            {
                "name": "Bangju",
                "picture": 2048,
                "location": "Oulu",
                "loginuser": 
                    {
                        "username": "GoJamie",
                        "password": "bangju"
                    }
            }
            
+ Response 200 (application/json)
        [
            "user": [
                {
                    "name": "Bangju",
                    "picture": 2048,
                    "location": "Oulu",
                    "loginuser": 
                        {
                            "username": "GoJamie",
                            "password": "c0ab660dacd6cb3772ef955ecf3ed619"
                        }
                }
            ]
        ]
+ Response 201 ()
    
    + Headers
            Location: /users/0
+ Response 415 (application/vnd.mason+json)
    The client sent a request with the wrong content type or the request body was not valid JSON.
    
    + Body
            {
                "resource_url": "/api/users/0/",
                "@error": {
                "@message": "Unsupported media type",
                "@messages": [
                  "Use JSON"
                ]
                },
                "@controls": {
                "profile": {
                  "href": "/users/error-user/"
                }
                }
            }
### Edit User Information[PUT]
+ Request (application/json)
    + Headers
        
            Accept: application/vnd.mason+json
    
    + Body
            {
                "name": "Bangju",
                "picture": 2048,
                "location": "Oulu",
                "loginuser": 
                    {
                        "username": "GGoJamie",
                        "password": "bangju"
                    }
            }
+ Response 200 (application/json)
        [
            "user": [
                {
                    "id": "1",
                    "name": "Bangju Wang",
                    "picture": 2048,
                    "location": "Oulu",
                    "events": [
                        {
                            "name": "Music Meeting",
                            "place": "Oulu",
                            "description": "Play Guitar",
                            "time":"tomorrow",
                            "creator":"Nechir"
                        }, {
                            "name": "Football",
                            "place": "Oulu",
                            "description": "Indoor football",
                            "time":"tomorrow",
                            "creator":"Bangju"
                        }
                    ],
                    "loginuser": 
                        {
                            "username": "GoJamie",
                            "password": "c0ab660dacd6cb3772ef955ecf3ed619"
                        }
                }
            ]
        ]
+ Response 400 (application/vnd.mason+json)
    The user is trying to edit with invalid value.
    
    + Body
            {
                "resource_url": "/api/users/0/",
                "@error": {
                "@message": "Unsupported media type",
                "@messages": [
                  "Use JSON"
                ]
                },
                "@controls": {
                "user": {
                  "href": "/users/error-user/"
                }
                }
            }
### Delete User[DELETE]
+ Request (application/json)
    + Headers
        
            Accept: application/vnd.mason+json
    
    + Body
            {
                "id": "1"
            }
+ Response 200 (application/json)
        [
            "user": [
                {
                    "id": "1"
                }
            ]
        ]
+ Response 404 (application/vnd.mason+json)
    The user is trying to edit with invalid value.
    
    + Body
            {
                "resource_url": "/api/users/0/",
                "@error": {
                "@message": "User not found",
                "@messages": [
                  null
                ]
                },
                "@controls": {
                "profile": {
                  "href": "/profiles/error/"
                }
            }
## Event by User [/eventbyuser]
### Add Event[POST]
+ Request (application/json)
    + Headers
        
            Accept: application/vnd.mason+json
    
    + Body
            {
                "name": "Music Meeting",
                "place": "Oulu",
                "description": "Play Guitar",
                "time":"tomorrow",
                "creator":"Bangju",
                "events-by": [
                    {
                        "id": "1",
                        "name": "Bangju Wang",
                        "picture": 2048,
                        "location": "Oulu",
                    }
                ]
            }
+ Response 200 (application/json)
        [
            "event": [
                {
                    "name": "Music Meeting",
                    "place": "Oulu",
                    "description": "Play Guitar",
                    "time":"tomorrow",
                    "creator":"Bangju",
                    "events-by": [
                        {
                            "id": "1",
                            "name": "Bangju Wang",
                            "picture": 2048,
                            "location": "Oulu",
                        }
                    ]
                }
            ]
        ]
+ Response 201 ()
    + Headers
            Location: /events/0
+ Response 415 (application/vnd.mason+json)
    
    + Body
            {
                "resource_url": "/api/events/0/",
                "@error": {
                "@message": "Unsupported media type",
                "@messages": [
                  "Use JSON"
                ]
                },
                "@controls": {
                "event": {
                  "href": "/events/error-event/"
                }
                }
            }
### Edit Event[PUT]
+ Request (application/json)
    + Headers
        
            Accept: application/vnd.mason+json
    
    + Body
            {
                "event": [
                    {
                        "event_id": "1",
                        "name": "Music Meeting",
                        "place": "Oulu",
                        "description": "Play Guitar",
                        "time":"tomorrow",
                        "creator":"Nechir",
                        "creator_id":"3"
                    }
                ]
            }
+ Response 200 (application/json)
        [
            "event": [
                {
                    "event_id": "1",
                    "name": "Music Meeting",
                    "place": "Oulu",
                    "description": "Play Drums",
                    "time":"tomorrow",
                    "creator":"Nechir",
                    "creator_id":"3"
                }
            ]
        ]
+ Response 400 (application/vnd.mason+json)
    The user is trying to edit with invalid value.
    
    + Body
            {
                "resource_url": "/api/events/0/",
                "@error": {
                "@message": "Unsupported media type",
                "@messages": [
                  "Use JSON"
                ]
                },
                "@controls": {
                "event": {
                  "href": "/events/error-event/"
                }
                }
            }
### Delete Event[DELETE]
+ Request (application/json)
    + Headers
        
            Accept: application/vnd.mason+json
    
    + Body
            {
                "id": "1"
            }
+ Response 200 (application/json)
        [
            "event": [
                {
                    "id": "1"
                }
            ]
        ]
+ Response 404 (application/vnd.mason+json)
    The user is trying to edit with invalid value.
    
    + Body
            {
                "resource_url": "/api/events/0/",
                "@error": {
                "@message": "Event not found",
                "@messages": [
                  null
                ]
                },
                "@controls": {
                "event": {
                  "href": "/events/error-event/"
                }
            }
## Events by User [/eventsbyuser]
### Get Events by User[GET]
**Relation:** all-events
List all events a user has attended in the database
+ Request (application/json)
    + Headers
        
            Accept: application/vnd.mason+json
    
    + Body
            {
                "id": "1"
            }
+ Response 200 (application/json)
    + Headers 
    
            Accept: application/vnd.mason+json
            
    + Body        
            {
                [
                    "@namespaces": {
                            "mumeta": {
                                "name": "/eventmeta/link-relations#"
                            }
                        },
                    "@controls": {
                            "self": {
                                "href": "/api/users/1/events"
                            },
                            "mumeta:user": {
                                "href": "/api/users/1",
                                "title": "User's info"
                            },
                        }
                    },
                    "items": [
                        {
                            "name": "Music Meeting",
                            "place": "Oulu",
                            "description": "Play Guitar",
                            "time":"tomorrow",
                            "creator":"Nechir",
                            "@controls": {
                            "self": {
                                "href": "/api/events/0/"
                                },
                            "edit": {
                                "href": "/api/events/0/",
                                "method":"PUT"
                                },
                            "delete": {
                                "href": "/api/events/0/",
                                "method":"DELETE"
                                },
                        }, {
                            "name": "Football",
                            "place": "Oulu",
                            "description": "Indoor football",
                            "time":"tomorrow",
                            "creator":"Bangju",
                            "@controls": {
                            "self": {
                                "href": "/api/events/1/"
                                }, 
                            "edit": {
                                "href": "/api/events/1/",
                                "method":"PUT"
                                },
                            "delete": {
                                "href": "/api/events/1/",
                                "method":"DELETE"
                                },
                        }
                    ]
                ]
            }
+ Response 201 ()
    + Headers
            Location: /events/0
## Users by Event [/usersbyevent]
### Get User Collection by Event[GET]
+ Request (application/json)
    + Headers
        
            Accept: application/vnd.mason+json
    
    + Body
            {
                "id": "1"
            }
+ Response 200 (application/json)
        [
            "event": [
                {
                    "event_id": "1",
                    "users": [
                        {
                            "name": "Bangju",
                            "picture": 2048,
                            "location": "Oulu"
                        }, {
                            "name": "Hao",
                            "picture": 2048,
                            "location": "Helsinki"
                        }, {
                            "name": "Nechir",
                            "picture": 2048,
                            "location": "Espoo"
                        }
                    ]
                }
            ]
        ]
## Join Event by User [/joinevent]
### Join Event by User[POST]
+ Request (application/json)
    + Headers
        
            Accept: application/vnd.mason+json
    
    + Body
            {
                "user-id": "0",
                "event-id": "1",
            }
+ Response 200 (application/json)
        [
            "event": [
                {
                    "event_id": "1",
                    "users": [
                        {
                            "name": "Bangju",
                            "id": "0"
                        }, {
                            "name": "Hao",
                            "id": "1"
                        }, {
                            "name": "Nechir",
                            "id": "2"
                        }
                    ]
                }
            ]
        ]
### Delete User from Event[DELETE]
+ Request (application/json)
    + Headers
        
            Accept: application/vnd.mason+json
    
    + Body
            {
                "user-id": "0",
                "event-id": "1",
            }
+ Response 200 (application/json)
        [
            "event": [
                {
                    "event_id": "1",
                    "users": [
                        {
                            "name": "Hao",
                            "id": "1"
                        }, {
                            "name": "Nechir",
                            "id": "2"
                        }
                    ]
                }
            ]
        ]
## Event Item [/eventitem]
### Event Information[GET]
**Relation:** get-user
Get user's information
+ Response 200 (application/json)
        [
            "@namespaces": {
                    "mumeta": {
                        "name": "/eventmeta/link-relations#"
                    }
                },
            "@controls": {
                    "self": {
                        "href": "/api/users/"
                    },
                    "mumeta:events-all": {
                        "href": "/api/events/",
                        "title": "All events"
                    },
                }
            },
            "event_id": "1",
            "name": "Music Meeting",
            "place": "Oulu",
            "description": "Play Guitar",
            "time":"tomorrow",
            "creator":"Nechir",
            "creator_id":"3",
            "@controls": {
                    "self": {
                        "href": "/api/users/0/"
                        },
                    "author": {
                        "href": "/api/users/0/"
                        },
                    "mumeta:events-by": {
                        "href": "/api/users/0/events"
                        },
                    "collection": {
                        "href": "/api/events/"
                        },
            "edit": {
                "href": "/api/events/0/",
                "title": "Edit this event",
                "encoding": "json",
                "method": "PUT",
                "schema": {
                    "type": "object",
                    "properties": {
                        "event_id": {
                            "description": "Event's id",
                            "type": "integer"
                        },
                        "name": {
                            "description": "name",
                            "type": "string"
                        },
                        "place": {
                            "description": "Place",
                            "type": "string"
                        },
                        "description": {
                            "description": "Description",
                            "type": "string"
                        },
                        "time": {
                            "description": "Time",
                            "type": "string"
                        }
                    },
                    "required": ["event_id", "name"]
                }
            },
            "mumeta:delete": {
                "href": "/api/events/0/",
                "title": "Delete this event",
                "method": "DELETE"
            }            
        ]
        ]