content controller - SWEZenith/Living-History-API GitHub Wiki

Create Content

Request:

POST /api/v1/contents/ HTTP/1.1

Accept: application/json
Content-Type: application/json

{
  "contentType": "Image",
  "title": "Bebek was not so crowded",
  "description": "https://goo.gl/XQxhTt",
  "tags": ["Bebek", "2015", "Seaside"],
  "date": "2017-10-28",
  "location": {
    "longitude": -83.6945691,
    "latitude": 42.25475478
  },
  "creator": "http://example.net/api/v1/users/yasemin"
}

Restrictions:

  • contentType is Enum: TEXT("TextualBody"), IMAGE("Image")
  • date format will be ISO-8601 without time
  • unique id will be created when saving - UUID is recommended

Response:

HTTP/1.1 201 CREATED

{
  "id": "4c088c96-bcb0-11e7-abc4-cec278b6b50a",
  "contentType": "Image",
  "title": "Bebek was not so crowded",
  "description": "https://goo.gl/XQxhTt",
  "tags": ["Bebek", "2015", "Seaside"],
  "date": "2017-10-28",
  "location": {
    "longitude": -83.6945691,
    "latitude": 42.25475478
  },
  "creator": "http://example.net/api/v1/users/yasemin"
}

Retrieve All Contents

Request:

GET /api/v1/contents/ HTTP/1.1

Accept: application/json
Content-Type: application/json

Response:

HTTP/1.1 200 OK

[{
	"id": "4c088c96-bcb0-11e7-abc4-cec278b6b50a",
	"contentType": "Image",
	"title": "Bebek was not so crowded",
	"description": "https://goo.gl/XQxhTt",
	"tags": ["Bebek", "2015", "Seaside"],
	"date": "2017-10-28",
	"location": {
		"longitude": -83.6945691,
		"latitude": 42.25475478
		},
        "creator": "http://example.net/api/v1/users/yasemin"
	},
{
	"id": "4c0891dc-bcb0-11e7-abc4-cec278b6b50a",
	"contentType": "Text",
	"title": "Nuremberg Trials",
	"description": "Nuremberg has a long and complex history. It was here that the Nazi rallies were held and where the Nuremberg Laws denying German citizenship for Jewish people were passed. After World War 2, the Nuremberg Trials were held. The city has a dreadful burden of history to bear, but it bears it honestly and well. Some of the most important World War 2 sites and museums are located here:",
	"tags": ["Nuremberg", "ww2"],
	"date": "1945-01-01",
	"location": {
		"longitude": -83.6945691,
		"latitude": 42.25475478
	},
        "creator": "http://example.net/api/v1/users/yasemin"
}
]

Retrieve Content by ID

Request:

GET /api/v1/contents/{id} HTTP/1.1

Accept: application/json
Content-Type: application/json

Response:

HTTP/1.1 200 OK

{
	"id": "4c088c96-bcb0-11e7-abc4-cec278b6b50a",
	"contentType": "Image",
	"title": "Bebek was not so crowded",
	"description": "https://goo.gl/XQxhTt",
	"tags": ["Bebek", "2015", "Seaside"],
	"date": "2017-10-28",
	"location": {
		"longitude": -83.6945691,
		"latitude": 42.25475478
		},
        "creator": "http://example.net/api/v1/users/yasemin"
}

Retrieve Content by Query

Request:

GET /api/v1/contents?tags=Bebek,olddays&creator=yasemin&title=bebek&description&&.......... ???? HTTP/1.1

Accept: application/json
Content-Type: application/json

Notes:

  • case insensitive search
  • advanced search criteria should met, search by creator is for porfolio page
  • will be discussed

Response:

HTTP/1.1 200 OK

[{
	"id": "4c088c96-bcb0-11e7-abc4-cec278b6b50a",
	"contentType": "Image",
	"title": "Bebek was not so crowded",
	"description": "https://goo.gl/XQxhTt",
	"tags": ["Bebek", "2015", "Seaside"],
	"date": "2017-10-28",
	"location": {
		"longitude": -83.6945691,
		"latitude": 42.25475478
		},
        "creator": "http://example.net/api/v1/users/yasemin"

},
{
	"id": "4c088c96-bcb0-11e7-abc4-cec278b6b501",
	"contentType": "Text",
	"title": "We used to have an ice cream",
	"description": "Nowadays Kadikoy is better",
	"tags": ["Bebek", "Kadikoy", "icecream", "olddays","2015"],
	"date": "2017-09-14",
	"location": {
		"longitude": -83.6945691,
		"latitude": 42.25475478
		},
        "creator": "http://example.net/api/v1/users/yasemin"

}
]