diff --git a/api-documentation/README.md b/api-documentation/README.md new file mode 100644 index 0000000..3574e7a --- /dev/null +++ b/api-documentation/README.md @@ -0,0 +1,34 @@ +# REST API Documentation + +The REST API documentation is written in [API Blueprint][2] using [Aglio][1] for rendering the documentation into HTML. + + +## Setup + +Setting up [Aglio][1] is pretty easy, you just have to install [NodeJS][3]/[NPM][4] and then run `npm install -g aglio`. + + +## Development + +For developing on the API you may start the [Aglio][1] server using `aglio -i api-documentation.md -s` and access the server at `http://localhost:3000`. The page is automatically refreshed when files change. + + +## Compiling before Pushing + +Please compile the documentation before pushing your changes using `aglio -i api-documentation.md -o api-documentation.html`. + + +## Documentation + +You can find the specification of [API Blueprint][2] here: [Specification][5] + +To get the most out of [API Blueprint][2], you have to use this [tool][6]. + + + +[1]: https://github.com/danielgtaylor/aglio +[2]: https://apiblueprint.org +[3]: https://nodejs.org +[4]: https://www.npmjs.com +[5]: https://github.com/apiaryio/api-blueprint/blob/master/API%20Blueprint%20Specification.md +[6]: https://www.google.com diff --git a/api-documentation/api-documentation.html b/api-documentation/api-documentation.html new file mode 100644 index 0000000..7ce7f4e --- /dev/null +++ b/api-documentation/api-documentation.html @@ -0,0 +1,1708 @@ +pyBuchaktion Back to top

pyBuchaktion

pyBuchaktion REST API Documentation Version 1.0

+

Data Structures

Classifier Explanation

+

The ‘Classifier’ describes how an attribute has to be applied. The following classifiers are available and can be combined (with some exceptions):

+
    +
  • +

    optional The attribute does not have to exit. Cannot be combined with required.

    +
  • +
  • +

    required The attribute has to exist. Cannot be combined with optional.

    +
  • +
  • +

    secured The attribute may only be read by administrators. Cannot be combined with semi-secured.

    +
  • +
  • +

    semi-secured The attribute may only be read by administrators and users that are strongly coupled to the object. Cannot be combined with secured.

    +
  • +
  • +

    transient The attribute is not stored and is calculated on demand by the server. Therefore it is not required to set this attribute when sending an object to the server.

    +
  • +
+

If neither optional nor required are set either secured or semi-secured have to be set.

+

If either secured or semi-secured have been set, the following rules apply:

+
    +
  • +

    If the user is not permitted to see the attribute it must not be available (really not set, not even null or undefined).

    +
  • +
  • +

    If the user is permitted to see the attribute and neither optional nor required are set it must be available.

    +
  • +
  • +

    If the user is permitted to see the attribute and either optional or required are set, these rules apply.

    +
  • +
+

Account

+ + + + + + + + + + + + + + + + + + + + +
AttributeTypeClassifierDescriptionExample
idnumberrequiredThe ID of the account.1987
+

Basic

+

Date

+

A date encoded in the format YYYY-MM-DD.

+

ISBN-13

+

An ISBN-13 without the dashes.

+

TUCaN-ID

+

A course ID of TUCaN (format: XX-XX-XXXX-XX where X is any alphanumeric character).

+

Book

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AttributeTypeClassifierDescriptionExample
idnumberrequiredThe ID of the book.2444
isbnisbnrequiredThe status of the order.9783836218023
titlestringrequiredThe title of the book.Java ist auch eine Insel
stateenum[string] { AC Accepted, RJ Rejected, PP Proposed, OL Obsolete }The state of the book.AC
authorstringrequiredThe author of the book.Christian Ullenboom
pricenumberThe price of the book.49.90
+

Book

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AttributeTypeClassifierDescriptionExample
idnumberrequiredThe ID of the module.3234
cidtucanidrequiredThe course ID of TUCaN.20-00-0004-iv
namestringrequiredThe name of the course.Functional and Object-oriented Programming Concepts
lastOfferedseasonrequiredThe season this course was last offered.See Season.
literaturearray[book]requiredThe recommened literature of this course.[ See Book. ]
+

Book (Reduced)

+

Like Book, but literature does not exist.

+

Order

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AttributeTypeClassifierDescriptionExample
idnumberrequiredThe ID of the order.5862
statusenum[string] { PD Pending, OD Ordered, RJ Rejected, AR Arrived }semi-securedThe status of the order.AR
hintstringoptionalA hint text including extended information about the status.Enough books available.
bookbookrequiredThe ordered book.See Book.
studentaccountrequiredThe student who has ordered the book.See Account.
timeframetimeframerequiredThe timeframe in which the book order can be changed/cancelled. At the end of the timeframe the order will be processed.See Timeframe.
+

Book

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AttributeTypeClassifierDescriptionExample
idnumberrequiredThe ID of the season.2156
seasonenum[string] { W Winter term, S Summer term }requiredThe season.W
yearstringrequiredThe year of the season.2017
+

Timeframe

+ + + + + + + + + + + + + + + + + + + + + + + + + + +
AttributeTypeClassifierDescriptionExample
fromdaterequiredThe from-date of the timeframe (inclusive).2017-02-01
todaterequiredThe to-date of the timeframe (inclusive).2017-03-01
+

Account

Account Management

Notice: An account is bound to the currently logged in user. Therefore these operations may not return the same data for different users.

+

Retrieve Account
GET/account

Functionality: Retrieves the current account.

+

Security: Requires an authenticated user.

+

Example URI

GET https://www.d120.de/studierende/buchaktion/api/account
Response  200
HideShow
Headers
Content-Type: application/json; charset=utf-8
Body
{
+  "account": {
+    "id": 987
+  }
+}
Schema
{
+  "$schema": "http://json-schema.org/draft-04/schema#",
+  "type": "object",
+  "properties": {
+    "account": {
+      "type": "object",
+      "properties": {
+        "id": {
+          "type": "number",
+          "description": "The ID of the account."
+        }
+      },
+      "required": [
+        "id"
+      ]
+    }
+  },
+  "required": [
+    "account"
+  ]
+}
Response  401
HideShow

Send if: The user is not authenticated.

+
Response  403
HideShow

Send if: The user does not have the required permissions.

+

Modify Account
PATCH/account

Functionality: Changes the given properties of the current account.

+

Security: Requires an authenticated user.

+

Example URI

PATCH https://www.d120.de/studierende/buchaktion/api/account
Request
HideShow
Headers
Content-Type: application/json
Body
{
+  "account": "Hello, world!"
+}
Schema
{
+  "$schema": "http://json-schema.org/draft-04/schema#",
+  "type": "object",
+  "properties": {
+    "account": {
+      "type": "string",
+      "description": "<!-- TODO: To be updated. -->"
+    }
+  },
+  "required": [
+    "account"
+  ]
+}
Response  200
HideShow
Headers
Content-Type: application/json; charset=utf-8
Body
{
+  "account": {
+    "id": 987
+  }
+}
Schema
{
+  "$schema": "http://json-schema.org/draft-04/schema#",
+  "type": "object",
+  "properties": {
+    "account": {
+      "type": "object",
+      "properties": {
+        "id": {
+          "type": "number",
+          "description": "The ID of the account."
+        }
+      },
+      "required": [
+        "id"
+      ]
+    }
+  },
+  "required": [
+    "account"
+  ]
+}
Response  401
HideShow

Send if: The user is not authenticated.

+
Response  403
HideShow

Send if: The user does not have the required permissions.

+
Response  422
HideShow

Send if: The given item cannot be processed (e.g. if it is invalid).

+

Delete Account Data
DELETE/account

Functionality: Deletes the data of the current account.

+

Security: Requires an authenticated user.

+

Example URI

DELETE https://www.d120.de/studierende/buchaktion/api/account
Response  204
HideShow
Headers
Content-Type: application/json; charset=utf-8
Response  401
HideShow

Send if: The user is not authenticated.

+
Response  403
HideShow

Send if: The user does not have the required permissions.

+
Response  422
HideShow

Send if: The given item cannot be processed (e.g. if it is invalid).

+

Retrieve Orders
GET/account/orders{?page,limit,status,orderBy}

Functionality: Retrieves the orders of the current account matching the given criteria.

+

Security: Requires an authenticated user.

+

Example URI

GET https://www.d120.de/studierende/buchaktion/api/account/orders?page=1&limit=10&status=OD&orderBy=status
URI Parameters
HideShow
page
number (optional) Example: 1

pagination - The page to return. Defaults to 1.

+
limit
number (optional) Example: 10

pagination - The number of items per page. Defaults to 10.

+
status
string (optional) Example: OD

A comma-separated list of states to filter for.

+
    +
  • +

    PD Pending

    +
  • +
  • +

    OD Ordered

    +
  • +
  • +

    RJ Rejected

    +
  • +
  • +

    AR Arrived

    +
  • +
+
orderBy
string (optional) Example: status

The field to order by. Defaults to no specific order.

+
    +
  • +

    status Order by the status.

    +
  • +
  • +

    timeframe Order by the timeframe.

    +
  • +
+
Response  200
HideShow
Headers
Content-Type: application/json; charset=utf-8
Body
{
+  "orders": [
+    {
+      "id": 5862,
+      "status": "AR",
+      "hint": "Enough books available.",
+      "book": {
+        "id": 2444,
+        "isbn": "9783836218023",
+        "title": "Java ist auch eine Insel",
+        "state": "AC",
+        "author": "Christian Ullenboom",
+        "price": 49.9
+      },
+      "student": {
+        "id": 987
+      },
+      "timeframe": {
+        "from": "2017-02-01",
+        "to": "2017-03-01"
+      }
+    }
+  ],
+  "total": 10
+}
Schema
{
+  "$schema": "http://json-schema.org/draft-04/schema#",
+  "type": "object",
+  "properties": {
+    "orders": {
+      "type": "array"
+    },
+    "total": {
+      "type": "number"
+    }
+  },
+  "required": [
+    "orders",
+    "total"
+  ]
+}
Response  400
HideShow

Send if: Wrong parameters where sent from the user.

+
Response  401
HideShow

Send if: The user is not authenticated.

+
Response  403
HideShow

Send if: The user does not have the required permissions.

+

Books

Multiple Books

Retrieve Books
GET/books{?page,limit,isbn,title,state,author,orderBy}

Functionality: Retrieves all books matching the given criteria.

+

Example URI

GET https://www.d120.de/studierende/buchaktion/api/books?page=1&limit=10&isbn=9783836218023&title=java&state=AC&author=ullenboom&orderBy=author
URI Parameters
HideShow
page
number (optional) Example: 1

pagination - The page to return. Defaults to 1.

+
limit
number (optional) Example: 10

pagination - The number of items per page. Defaults to 10.

+
isbn
isbn (optional) Example: 9783836218023

A comma-separated list of ISBNs to filter for.

+
title
string (optional) Example: java

The title to filter for. Represents a case-insensitive text search.

+
state
string (optional) Example: AC

A comma-separated list of states to filter for.

+

Choices: AC RJ PP OL

author
string (optional) Example: ullenboom

The author to filter for. Represents a case-insensitive text search.

+
orderBy
string (optional) Example: author

The field to order by. Defaults to no specific order.

+
    +
  • +

    isbn Order by the ISBN.

    +
  • +
  • +

    title Order by the title.

    +
  • +
  • +

    state Order by the state.

    +
  • +
  • +

    author Order by the author.

    +
  • +
+
Response  200
HideShow
Headers
Content-Type: application/json; charset=utf-8
Body
{
+  "books": [
+    {
+      "id": 2444,
+      "isbn": "9783836218023",
+      "title": "Java ist auch eine Insel",
+      "state": "AC",
+      "author": "Christian Ullenboom",
+      "price": 49.9
+    }
+  ],
+  "total": 10
+}
Schema
{
+  "$schema": "http://json-schema.org/draft-04/schema#",
+  "type": "object",
+  "properties": {
+    "books": {
+      "type": "array"
+    },
+    "total": {
+      "type": "number"
+    }
+  },
+  "required": [
+    "books",
+    "total"
+  ]
+}
Response  400
HideShow

Send if: Wrong parameters where sent from the user.

+

Propose Book
PUT/books

Functionality: Proposes a new book that has to be approved by an administrator. If this endpoint.

+

Security: Requires an authenticated user.

+

Example URI

PUT https://www.d120.de/studierende/buchaktion/api/books
Request  Create by ISBN
HideShow
Headers
Content-Type: application/json
Body
{
+  "book": {
+    "isbn": "9783836218023"
+  }
+}
Schema
{
+  "$schema": "http://json-schema.org/draft-04/schema#",
+  "type": "object",
+  "properties": {
+    "book": {
+      "type": "object",
+      "properties": {
+        "isbn": {
+          "type": "string"
+        }
+      }
+    }
+  },
+  "required": [
+    "book"
+  ]
+}
Request  Create by Author/Title
HideShow
Headers
Content-Type: application/json
Body
{
+  "book": {
+    "title": "Java ist auch eine Insel",
+    "author": "Christian Ullenboom"
+  }
+}
Schema
{
+  "$schema": "http://json-schema.org/draft-04/schema#",
+  "type": "object",
+  "properties": {
+    "book": {
+      "type": "object",
+      "properties": {
+        "title": {
+          "type": "string"
+        },
+        "author": {
+          "type": "string"
+        }
+      }
+    }
+  },
+  "required": [
+    "book"
+  ]
+}
Response  201
HideShow

Send if: The book was created an accepted (this is only possible if the proposal was sent by an administrator).

+
Headers
Content-Type: application/json; charset=utf-8
Body
{
+  "book": {
+    "id": 2444,
+    "isbn": "9783836218023",
+    "title": "Java ist auch eine Insel",
+    "state": "AC",
+    "author": "Christian Ullenboom",
+    "price": 49.9
+  }
+}
Schema
{
+  "$schema": "http://json-schema.org/draft-04/schema#",
+  "type": "object",
+  "properties": {
+    "book": {
+      "type": "object",
+      "properties": {
+        "id": {
+          "type": "number",
+          "description": "The ID of the book."
+        },
+        "isbn": {
+          "type": "string",
+          "description": "The ISBN of the book."
+        },
+        "title": {
+          "type": "string",
+          "description": "The title of the book."
+        },
+        "state": {
+          "type": "string",
+          "enum": [
+            "AC",
+            "RJ",
+            "PP",
+            "OL"
+          ],
+          "description": "secured - The state of the book."
+        },
+        "author": {
+          "type": "string",
+          "description": "The author of the book."
+        },
+        "price": {
+          "type": "number",
+          "description": "secured - The price of the book."
+        }
+      },
+      "required": [
+        "id",
+        "isbn",
+        "title",
+        "author"
+      ]
+    }
+  },
+  "required": [
+    "book"
+  ]
+}
Response  202
HideShow

Send if: The book was created and is waiting for approval.

+
Headers
Content-Type: application/json; charset=utf-8
Body
{
+  "book": {
+    "id": 2444,
+    "isbn": "9783836218023",
+    "title": "Java ist auch eine Insel",
+    "state": "AC",
+    "author": "Christian Ullenboom",
+    "price": 49.9
+  }
+}
Schema
{
+  "$schema": "http://json-schema.org/draft-04/schema#",
+  "type": "object",
+  "properties": {
+    "book": {
+      "type": "object",
+      "properties": {
+        "id": {
+          "type": "number",
+          "description": "The ID of the book."
+        },
+        "isbn": {
+          "type": "string",
+          "description": "The ISBN of the book."
+        },
+        "title": {
+          "type": "string",
+          "description": "The title of the book."
+        },
+        "state": {
+          "type": "string",
+          "enum": [
+            "AC",
+            "RJ",
+            "PP",
+            "OL"
+          ],
+          "description": "secured - The state of the book."
+        },
+        "author": {
+          "type": "string",
+          "description": "The author of the book."
+        },
+        "price": {
+          "type": "number",
+          "description": "secured - The price of the book."
+        }
+      },
+      "required": [
+        "id",
+        "isbn",
+        "title",
+        "author"
+      ]
+    }
+  },
+  "required": [
+    "book"
+  ]
+}
Response  401
HideShow

Send if: The user is not authenticated.

+
Response  403
HideShow

Send if: The user does not have the required permissions.

+
Response  404
HideShow

Send if: The specified book was not found.

+
Response  409
HideShow

Send if: The book already exists.

+
Response  422
HideShow

Send if: The given item cannot be processed (e.g. if it is invalid).

+

Specific Book

Retrieve Book
GET/books/{bookId}

Functionality: Retrieves the specified book.

+

Example URI

GET https://www.d120.de/studierende/buchaktion/api/books/2444
URI Parameters
HideShow
bookId
number (required) Example: 2444

The ID of the book.

+
Response  200
HideShow
Headers
Content-Type: application/json; charset=utf-8
Body
{
+  "book": {
+    "id": 2444,
+    "isbn": "9783836218023",
+    "title": "Java ist auch eine Insel",
+    "state": "AC",
+    "author": "Christian Ullenboom",
+    "price": 49.9
+  }
+}
Schema
{
+  "$schema": "http://json-schema.org/draft-04/schema#",
+  "type": "object",
+  "properties": {
+    "book": {
+      "type": "object",
+      "properties": {
+        "id": {
+          "type": "number",
+          "description": "The ID of the book."
+        },
+        "isbn": {
+          "type": "string",
+          "description": "The ISBN of the book."
+        },
+        "title": {
+          "type": "string",
+          "description": "The title of the book."
+        },
+        "state": {
+          "type": "string",
+          "enum": [
+            "AC",
+            "RJ",
+            "PP",
+            "OL"
+          ],
+          "description": "secured - The state of the book."
+        },
+        "author": {
+          "type": "string",
+          "description": "The author of the book."
+        },
+        "price": {
+          "type": "number",
+          "description": "secured - The price of the book."
+        }
+      },
+      "required": [
+        "id",
+        "isbn",
+        "title",
+        "author"
+      ]
+    }
+  },
+  "required": [
+    "book"
+  ]
+}
Response  404
HideShow

Send if: The specified book was not found

+

Modify Book
PATCH/books/{bookId}

Functionality: Changes the given properties of the specified book.

+

Security: Requires an authenticated user with the role admin.

+

Example URI

PATCH https://www.d120.de/studierende/buchaktion/api/books/2444
URI Parameters
HideShow
bookId
number (required) Example: 2444

The ID of the book.

+
Request
HideShow
Headers
Content-Type: application/json
Body
{
+  "isbn": "9783836218023",
+  "title": "Java ist auch eine Insel",
+  "state": "AC",
+  "author": "Christian Ullenboom",
+  "price": 49.9
+}
Schema
{
+  "$schema": "http://json-schema.org/draft-04/schema#",
+  "type": "object",
+  "properties": {
+    "isbn": {
+      "type": "string"
+    },
+    "title": {
+      "type": "string"
+    },
+    "state": {
+      "type": "string",
+      "enum": [
+        "AC",
+        "RJ",
+        "PP",
+        "OL"
+      ]
+    },
+    "author": {
+      "type": "string"
+    },
+    "price": {
+      "type": "number"
+    }
+  }
+}
Response  200
HideShow
Headers
Content-Type: application/json; charset=utf-8
Body
{
+  "book": {
+    "id": 2444,
+    "isbn": "9783836218023",
+    "title": "Java ist auch eine Insel",
+    "state": "AC",
+    "author": "Christian Ullenboom",
+    "price": 49.9
+  }
+}
Schema
{
+  "$schema": "http://json-schema.org/draft-04/schema#",
+  "type": "object",
+  "properties": {
+    "book": {
+      "type": "object",
+      "properties": {
+        "id": {
+          "type": "number",
+          "description": "The ID of the book."
+        },
+        "isbn": {
+          "type": "string",
+          "description": "The ISBN of the book."
+        },
+        "title": {
+          "type": "string",
+          "description": "The title of the book."
+        },
+        "state": {
+          "type": "string",
+          "enum": [
+            "AC",
+            "RJ",
+            "PP",
+            "OL"
+          ],
+          "description": "secured - The state of the book."
+        },
+        "author": {
+          "type": "string",
+          "description": "The author of the book."
+        },
+        "price": {
+          "type": "number",
+          "description": "secured - The price of the book."
+        }
+      },
+      "required": [
+        "id",
+        "isbn",
+        "title",
+        "author"
+      ]
+    }
+  },
+  "required": [
+    "book"
+  ]
+}
Response  401
HideShow

Send if: The user is not authenticated.

+
Response  403
HideShow

Send if: The user does not have the required permissions.

+
Response  404
HideShow

Send if: The specified book was not found

+
Response  422
HideShow

Send if: The given item cannot be processed (e.g. if it is invalid).

+

Delete Book
DELETE/books/{bookId}

Functionality: Deletes the specified book.

+

Security: Requires an authenticated user with the role admin.

+

Example URI

DELETE https://www.d120.de/studierende/buchaktion/api/books/2444
URI Parameters
HideShow
bookId
number (required) Example: 2444

The ID of the book.

+
Response  204
HideShow
Headers
Content-Type: application/json; charset=utf-8
Response  401
HideShow

Send if: The user is not authenticated.

+
Response  403
HideShow

Send if: The user does not have the required permissions.

+
Response  404
HideShow

Send if: The specified book was not found

+
Response  422
HideShow

Send if: The given item cannot be processed (e.g. if it is invalid).

+

Modules

Multiple Modules

Retrieve Modules
GET/modules{?page,limit,cid,name}

Functionality: Retrieves all modules matching the given criteria.

+

Example URI

GET https://www.d120.de/studierende/buchaktion/api/modules?page=1&limit=10&cid=20-00-0004-iv&name=programming
URI Parameters
HideShow
page
number (optional) Example: 1

pagination - The page to return. Defaults to 1.

+
limit
number (optional) Example: 10

pagination - The number of items per page. Defaults to 10.

+
cid
tucanid (optional) Example: 20-00-0004-iv

A comma-separated list of TUCaN course IDs to filter for.

+
name
string (optional) Example: programming

The course name to filter for. Represents a case-insensitive text search.

+
Response  200
HideShow
Headers
Content-Type: application/json; charset=utf-8
Body
{
+  "modules": [
+    {
+      "id": 3234,
+      "cid": "20-00-0004-iv",
+      "name": "Functional and Object-oriented Programming Concepts",
+      "lastOffered": {
+        "id": 2156,
+        "season": "W",
+        "year": "2017"
+      }
+    }
+  ],
+  "total": 0
+}
Schema
{
+  "$schema": "http://json-schema.org/draft-04/schema#",
+  "type": "object",
+  "properties": {
+    "modules": {
+      "type": "array"
+    },
+    "total": {
+      "type": "number"
+    }
+  },
+  "required": [
+    "modules",
+    "total"
+  ]
+}
Response  400
HideShow

Send if: Wrong parameters where sent from the user.

+

Create Module
PUT/modules

Functionality: Creates a new module.

+

Security: Requires an authenticated user with the role admin.

+

Example URI

PUT https://www.d120.de/studierende/buchaktion/api/modules
Request
HideShow
Headers
Content-Type: application/json
Body
{
+  "module": {
+    "cid": "20-00-0004-iv",
+    "name": "Functional and Object-oriented Programming Concepts",
+    "lastOffered": {
+      "id": 2156,
+      "season": "W",
+      "year": "2017"
+    },
+    "literature": []
+  }
+}
Schema
{
+  "$schema": "http://json-schema.org/draft-04/schema#",
+  "type": "object",
+  "properties": {
+    "module": {
+      "type": "object",
+      "properties": {
+        "cid": {
+          "type": "string"
+        },
+        "name": {
+          "type": "string"
+        },
+        "lastOffered": {
+          "type": "object",
+          "properties": {
+            "id": {
+              "type": "number",
+              "description": "The ID of the season."
+            },
+            "season": {
+              "type": "string",
+              "enum": [
+                "W",
+                "S"
+              ],
+              "description": "The season."
+            },
+            "year": {
+              "type": "string",
+              "description": "The year of the season."
+            }
+          },
+          "required": [
+            "id",
+            "season",
+            "year"
+          ]
+        },
+        "literature": {
+          "type": "array",
+          "description": "The IDs of the proposed books."
+        }
+      },
+      "required": [
+        "cid",
+        "name",
+        "lastOffered"
+      ]
+    }
+  },
+  "required": [
+    "module"
+  ]
+}
Response  201
HideShow
Headers
Content-Type: application/json; charset=utf-8
Body
{
+  "module": {
+    "id": 3234,
+    "cid": "20-00-0004-iv",
+    "name": "Functional and Object-oriented Programming Concepts",
+    "lastOffered": {
+      "id": 2156,
+      "season": "W",
+      "year": "2017"
+    },
+    "literature": [
+      {
+        "id": 2444,
+        "isbn": "9783836218023",
+        "title": "Java ist auch eine Insel",
+        "state": "AC",
+        "author": "Christian Ullenboom",
+        "price": 49.9
+      }
+    ]
+  }
+}
Schema
{
+  "$schema": "http://json-schema.org/draft-04/schema#",
+  "type": "object",
+  "properties": {
+    "module": {
+      "type": "object",
+      "properties": {
+        "id": {
+          "type": "number",
+          "description": "The ID of the module."
+        },
+        "cid": {
+          "type": "string",
+          "description": "The course ID of TUCaN."
+        },
+        "name": {
+          "type": "string",
+          "description": "The name of the course."
+        },
+        "lastOffered": {
+          "type": "object",
+          "properties": {
+            "id": {
+              "type": "number",
+              "description": "The ID of the season."
+            },
+            "season": {
+              "type": "string",
+              "enum": [
+                "W",
+                "S"
+              ],
+              "description": "The season."
+            },
+            "year": {
+              "type": "string",
+              "description": "The year of the season."
+            }
+          },
+          "required": [
+            "id",
+            "season",
+            "year"
+          ],
+          "description": "The season this course was last offered."
+        },
+        "literature": {
+          "type": "array",
+          "description": "The recommened literature of this course."
+        }
+      },
+      "required": [
+        "id",
+        "cid",
+        "name",
+        "lastOffered",
+        "literature"
+      ]
+    }
+  },
+  "required": [
+    "module"
+  ]
+}
Response  401
HideShow

Send if: The user is not authenticated.

+
Response  403
HideShow

Send if: The user does not have the required permissions.

+
Response  422
HideShow

Send if: The given item cannot be processed (e.g. if it is invalid).

+

Specific Moudle

Retrieve Module
GET/modules/{moduleId}

Functionality: Retrieves the specified module.

+

Example URI

GET https://www.d120.de/studierende/buchaktion/api/modules/3234
URI Parameters
HideShow
moduleId
number (required) Example: 3234

The ID of the module.

+
Response  200
HideShow
Headers
Content-Type: application/json; charset=utf-8
Body
{
+  "module": {
+    "id": 3234,
+    "cid": "20-00-0004-iv",
+    "name": "Functional and Object-oriented Programming Concepts",
+    "lastOffered": {
+      "id": 2156,
+      "season": "W",
+      "year": "2017"
+    },
+    "literature": [
+      {
+        "id": 2444,
+        "isbn": "9783836218023",
+        "title": "Java ist auch eine Insel",
+        "state": "AC",
+        "author": "Christian Ullenboom",
+        "price": 49.9
+      }
+    ]
+  }
+}
Schema
{
+  "$schema": "http://json-schema.org/draft-04/schema#",
+  "type": "object",
+  "properties": {
+    "module": {
+      "type": "object",
+      "properties": {
+        "id": {
+          "type": "number",
+          "description": "The ID of the module."
+        },
+        "cid": {
+          "type": "string",
+          "description": "The course ID of TUCaN."
+        },
+        "name": {
+          "type": "string",
+          "description": "The name of the course."
+        },
+        "lastOffered": {
+          "type": "object",
+          "properties": {
+            "id": {
+              "type": "number",
+              "description": "The ID of the season."
+            },
+            "season": {
+              "type": "string",
+              "enum": [
+                "W",
+                "S"
+              ],
+              "description": "The season."
+            },
+            "year": {
+              "type": "string",
+              "description": "The year of the season."
+            }
+          },
+          "required": [
+            "id",
+            "season",
+            "year"
+          ],
+          "description": "The season this course was last offered."
+        },
+        "literature": {
+          "type": "array",
+          "description": "The recommened literature of this course."
+        }
+      },
+      "required": [
+        "id",
+        "cid",
+        "name",
+        "lastOffered",
+        "literature"
+      ]
+    }
+  },
+  "required": [
+    "module"
+  ]
+}
Response  404
HideShow

Send if: The specified module was not found.

+

Modify Module
PATCH/modules/{moduleId}

Functionality: Changes the given properties of the specified module.

+

Security: Requires an authenticated user with the role admin.

+

Example URI

PATCH https://www.d120.de/studierende/buchaktion/api/modules/3234
URI Parameters
HideShow
moduleId
number (required) Example: 3234

The ID of the module.

+
Request
HideShow
Headers
Content-Type: application/json
Body
{
+  "module": {
+    "cid": "20-00-0004-iv",
+    "name": "Functional and Object-oriented Programming Concepts",
+    "lastOffered": {
+      "id": 2156,
+      "season": "W",
+      "year": "2017"
+    },
+    "literature": []
+  }
+}
Schema
{
+  "$schema": "http://json-schema.org/draft-04/schema#",
+  "type": "object",
+  "properties": {
+    "module": {
+      "type": "object",
+      "properties": {
+        "cid": {
+          "type": "string"
+        },
+        "name": {
+          "type": "string"
+        },
+        "lastOffered": {
+          "type": "object",
+          "properties": {
+            "id": {
+              "type": "number",
+              "description": "The ID of the season."
+            },
+            "season": {
+              "type": "string",
+              "enum": [
+                "W",
+                "S"
+              ],
+              "description": "The season."
+            },
+            "year": {
+              "type": "string",
+              "description": "The year of the season."
+            }
+          },
+          "required": [
+            "id",
+            "season",
+            "year"
+          ]
+        },
+        "literature": {
+          "type": "array",
+          "description": "The IDs of the proposed books."
+        }
+      }
+    }
+  },
+  "required": [
+    "module"
+  ]
+}
Response  200
HideShow
Headers
Content-Type: application/json; charset=utf-8
Body
{
+  "module": {
+    "id": 3234,
+    "cid": "20-00-0004-iv",
+    "name": "Functional and Object-oriented Programming Concepts",
+    "lastOffered": {
+      "id": 2156,
+      "season": "W",
+      "year": "2017"
+    },
+    "literature": [
+      {
+        "id": 2444,
+        "isbn": "9783836218023",
+        "title": "Java ist auch eine Insel",
+        "state": "AC",
+        "author": "Christian Ullenboom",
+        "price": 49.9
+      }
+    ]
+  }
+}
Schema
{
+  "$schema": "http://json-schema.org/draft-04/schema#",
+  "type": "object",
+  "properties": {
+    "module": {
+      "type": "object",
+      "properties": {
+        "id": {
+          "type": "number",
+          "description": "The ID of the module."
+        },
+        "cid": {
+          "type": "string",
+          "description": "The course ID of TUCaN."
+        },
+        "name": {
+          "type": "string",
+          "description": "The name of the course."
+        },
+        "lastOffered": {
+          "type": "object",
+          "properties": {
+            "id": {
+              "type": "number",
+              "description": "The ID of the season."
+            },
+            "season": {
+              "type": "string",
+              "enum": [
+                "W",
+                "S"
+              ],
+              "description": "The season."
+            },
+            "year": {
+              "type": "string",
+              "description": "The year of the season."
+            }
+          },
+          "required": [
+            "id",
+            "season",
+            "year"
+          ],
+          "description": "The season this course was last offered."
+        },
+        "literature": {
+          "type": "array",
+          "description": "The recommened literature of this course."
+        }
+      },
+      "required": [
+        "id",
+        "cid",
+        "name",
+        "lastOffered",
+        "literature"
+      ]
+    }
+  },
+  "required": [
+    "module"
+  ]
+}
Response  401
HideShow

Send if: The user is not authenticated.

+
Response  403
HideShow

Send if: The user does not have the required permissions.

+
Response  404
HideShow

Send if: The specified module was not found.

+
Response  422
HideShow

Send if: The given item cannot be processed (e.g. if it is invalid).

+

Delete Module
DELETE/modules/{moduleId}

Functionality: Deletes the specified module.

+

Security: Requires an authenticated user with the role admin.

+

Example URI

DELETE https://www.d120.de/studierende/buchaktion/api/modules/3234
URI Parameters
HideShow
moduleId
number (required) Example: 3234

The ID of the module.

+
Response  204
HideShow
Headers
Content-Type: application/json; charset=utf-8
Response  401
HideShow

Send if: The user is not authenticated.

+
Response  403
HideShow

Send if: The user does not have the required permissions.

+
Response  404
HideShow

Send if: The specified module was not found.

+
Response  422
HideShow

Send if: The given item cannot be processed (e.g. if it is invalid).

+

Orders

Multiple Orders

Retrieve Orders
GET/orders{?page,limit,userId,status,orderBy}

Functionality: Retrieves all orders that are visible to the current user (that is, only the orders of the logged in user or all orders if the logged in user as the role admin).

+

Security: Requires an authenticated user.

+

Example URI

GET https://www.d120.de/studierende/buchaktion/api/orders?page=1&limit=10&userId=1987&status=OD&orderBy=status
URI Parameters
HideShow
page
number (optional) Example: 1

pagination - The page to return. Defaults to 1.

+
limit
number (optional) Example: 10

pagination - The number of items per page. Defaults to 10.

+
userId
number (optional) Example: 1987

A comma-separated list of user IDs to filter for. This property does not have any functionality if the current user does not have the role admin.

+
status
string (optional) Example: OD

A comma-separated list of states to filter for.

+

Choices: PD OD RJ AR

orderBy
string (optional) Example: status

The field to order by. Defaults to no specific order.

+
    +
  • +

    status Order by the status.

    +
  • +
  • +

    timeframe Order by the timeframe.

    +
  • +
+
Response  200
HideShow
Headers
Content-Type: application/json; charset=utf-8
Body
{
+  "orders": [
+    {
+      "id": 5862,
+      "status": "AR",
+      "hint": "Enough books available.",
+      "book": {
+        "id": 2444,
+        "isbn": "9783836218023",
+        "title": "Java ist auch eine Insel",
+        "state": "AC",
+        "author": "Christian Ullenboom",
+        "price": 49.9
+      },
+      "student": {
+        "id": 987
+      },
+      "timeframe": {
+        "from": "2017-02-01",
+        "to": "2017-03-01"
+      }
+    }
+  ],
+  "total": 10
+}
Schema
{
+  "$schema": "http://json-schema.org/draft-04/schema#",
+  "type": "object",
+  "properties": {
+    "orders": {
+      "type": "array"
+    },
+    "total": {
+      "type": "number"
+    }
+  },
+  "required": [
+    "orders",
+    "total"
+  ]
+}
Response  400
HideShow

Send if: Wrong parameters where sent from the user.

+
Response  401
HideShow

Send if: The user is not authenticated.

+
Response  403
HideShow

Send if: The user does not have the required permissions.

+

Specific Order

Modify Order
PATCH/orders/{orderId}

Functionality: Changes the given properties of the specified order.

+

Security: Requires an authenticated user with the role admin.

+

Example URI

PATCH https://www.d120.de/studierende/buchaktion/api/orders/5862
URI Parameters
HideShow
orderId
number (required) Example: 5862

The ID of the order.

+
Request
HideShow
Headers
Content-Type: application/json
Body
{
+  "order": {
+    "status": "PD",
+    "hint": "Enough books available."
+  }
+}
Schema
{
+  "$schema": "http://json-schema.org/draft-04/schema#",
+  "type": "object",
+  "properties": {
+    "order": {
+      "type": "object",
+      "properties": {
+        "status": {
+          "type": "string",
+          "enum": [
+            "PD",
+            "OD",
+            "RJ",
+            "AR"
+          ]
+        },
+        "hint": {
+          "type": "string"
+        }
+      }
+    }
+  },
+  "required": [
+    "order"
+  ]
+}
Response  200
HideShow
Headers
Content-Type: application/json; charset=utf-8
Body
{
+  "order": {
+    "id": 5862,
+    "status": "AR",
+    "hint": "Enough books available.",
+    "book": {
+      "id": 2444,
+      "isbn": "9783836218023",
+      "title": "Java ist auch eine Insel",
+      "state": "AC",
+      "author": "Christian Ullenboom",
+      "price": 49.9
+    },
+    "student": {
+      "id": 987
+    },
+    "timeframe": {
+      "from": "2017-02-01",
+      "to": "2017-03-01"
+    }
+  }
+}
Schema
{
+  "$schema": "http://json-schema.org/draft-04/schema#",
+  "type": "object",
+  "properties": {
+    "order": {
+      "type": "object",
+      "properties": {
+        "id": {
+          "type": "number",
+          "description": "The ID of the order."
+        },
+        "status": {
+          "type": "string",
+          "enum": [
+            "PD",
+            "OD",
+            "RJ",
+            "AR"
+          ],
+          "description": "semi-secured - The status of the order."
+        },
+        "hint": {
+          "type": "string",
+          "description": "A hint text including extended information about the status."
+        },
+        "book": {
+          "type": "object",
+          "properties": {
+            "id": {
+              "type": "number",
+              "description": "The ID of the book."
+            },
+            "isbn": {
+              "type": "string",
+              "description": "The ISBN of the book."
+            },
+            "title": {
+              "type": "string",
+              "description": "The title of the book."
+            },
+            "state": {
+              "type": "string",
+              "enum": [
+                "AC",
+                "RJ",
+                "PP",
+                "OL"
+              ],
+              "description": "secured - The state of the book."
+            },
+            "author": {
+              "type": "string",
+              "description": "The author of the book."
+            },
+            "price": {
+              "type": "number",
+              "description": "secured - The price of the book."
+            }
+          },
+          "required": [
+            "id",
+            "isbn",
+            "title",
+            "author"
+          ],
+          "description": "The ordered book."
+        },
+        "student": {
+          "type": "object",
+          "properties": {
+            "id": {
+              "type": "number",
+              "description": "The ID of the account."
+            }
+          },
+          "required": [
+            "id"
+          ],
+          "description": "The student who has ordered the book."
+        },
+        "timeframe": {
+          "type": "object",
+          "properties": {
+            "from": {
+              "type": "string",
+              "description": "The from-date of the timeframe (inclusive)."
+            },
+            "to": {
+              "type": "string",
+              "description": "The to-date of the timeframe (inclusive)."
+            }
+          },
+          "required": [
+            "from",
+            "to"
+          ],
+          "description": "The timeframe in which the book order can be changed/cancelled. At the end of the timeframe the order will be processed."
+        }
+      },
+      "required": [
+        "id",
+        "book",
+        "student",
+        "timeframe"
+      ]
+    }
+  },
+  "required": [
+    "order"
+  ]
+}
Response  401
HideShow

Send if: The user is not authenticated.

+
Response  403
HideShow

Send if: The user does not have the required permissions.

+
Response  404
HideShow

Send if: The specified order was not found.

+
Response  422
HideShow

Send if: The given item cannot be processed (e.g. if it is invalid).

+

Delete Order
DELETE/orders/{orderId}

Functionality: Deletes the specified order.

+

Security: Requires an authenticated user with the role admin or the user who has created the order.

+

Example URI

DELETE https://www.d120.de/studierende/buchaktion/api/orders/5862
URI Parameters
HideShow
orderId
number (required) Example: 5862

The ID of the order.

+
Response  204
HideShow
Headers
Content-Type: application/json; charset=utf-8
Response  401
HideShow

Send if: The user is not authenticated.

+
Response  403
HideShow

Send if: The user does not have the required permissions.

+
Response  404
HideShow

Send if: The specified order was not found.

+

Generated by aglio on 25 Jan 2017

\ No newline at end of file diff --git a/api-documentation/api-documentation.md b/api-documentation/api-documentation.md new file mode 100644 index 0000000..a769008 --- /dev/null +++ b/api-documentation/api-documentation.md @@ -0,0 +1,9 @@ +FORMAT: 1A +HOST: https://www.d120.de/studierende/buchaktion/api + +# pyBuchaktion + +pyBuchaktion REST API Documentation Version 1.0 + + + diff --git a/api-documentation/datastructures/account.md b/api-documentation/datastructures/account.md new file mode 100644 index 0000000..a0438a2 --- /dev/null +++ b/api-documentation/datastructures/account.md @@ -0,0 +1,7 @@ +## Account + + + +| Attribute | Type | Classifier | Description | Example | +|-----------|--------|------------|------------------------|---------| +| id | number | required | The ID of the account. | `1987` | diff --git a/api-documentation/datastructures/basic.md b/api-documentation/datastructures/basic.md new file mode 100644 index 0000000..e6fc3e5 --- /dev/null +++ b/api-documentation/datastructures/basic.md @@ -0,0 +1,10 @@ +## Basic + +### Date +A date encoded in the format `YYYY-MM-DD`. + +### ISBN-13 +An ISBN-13 without the dashes. + +### TUCaN-ID +A course ID of TUCaN (format: `XX-XX-XXXX-XX` where `X` is any alphanumeric character). diff --git a/api-documentation/datastructures/book.md b/api-documentation/datastructures/book.md new file mode 100644 index 0000000..867cf26 --- /dev/null +++ b/api-documentation/datastructures/book.md @@ -0,0 +1,10 @@ +## Book + +| Attribute | Type | Classifier | Description | Example | +|-----------|-----------------------------------------------------------------------------|------------|--------------------------|----------------------------| +| id | number | required | The ID of the book. | `2444` | +| isbn | isbn | required | The status of the order. | `9783836218023` | +| title | string | required | The title of the book. | `Java ist auch eine Insel` | +| state | enum[string] { `AC` Accepted, `RJ` Rejected, `PP` Proposed, `OL` Obsolete } | | The state of the book. | `AC` | +| author | string | required | The author of the book. | `Christian Ullenboom` | +| price | number | | The price of the book. | `49.90` | diff --git a/api-documentation/datastructures/datastructures.md b/api-documentation/datastructures/datastructures.md new file mode 100644 index 0000000..a32fcb1 --- /dev/null +++ b/api-documentation/datastructures/datastructures.md @@ -0,0 +1,89 @@ +# Data Structures + +## date (string) YYYY-MM-DD +## isbn (string) ISBN-13 +## tucanid (string) XX-XX-XXXX-XX + + +## account (object) ++ id: `0987` (required, number) - The ID of the account. + +## book (object) ++ id: `2444` (required, number) - The ID of the book. ++ isbn: `9783836218023` (required, isbn) - The ISBN of the book. ++ title: `Java ist auch eine Insel` (required, string) - The title of the book. ++ state: `AC` (enum[string]) - secured - The state of the book. + + Members + + `AC` - Accepted + + `RJ` - Rejected + + `PP` - Proposed + + `OL` - Obsolete ++ author: `Christian Ullenboom` (required, string) - The author of the book. ++ price: `49.90` (number) - secured - The price of the book. + +## order (object) ++ id: `5862` (required, number) - The ID of the order. ++ status: `AR` (enum[string]) - semi-secured - The status of the order. + + Members + + `PD` - Pending + + `OD` - Ordered + + `RJ` - Rejected + + `AR` - Arrived ++ hint: `Enough books available.` (optional, string) - A hint text including extended information about the status. ++ book (required, book) - The ordered book. ++ student (required, account) - The student who has ordered the book. ++ timeframe (required, timeframe) - The timeframe in which the book order can be changed/cancelled. At the end of the timeframe the order will be processed. + +## module (object) ++ id: `3234` (required, number) - The ID of the module. ++ cid: `20-00-0004-iv` (required, tucanid) - The course ID of TUCaN. ++ name: `Functional and Object-oriented Programming Concepts` (required, string) - The name of the course. ++ lastOffered (required, season) - The season this course was last offered. ++ literature (required, array[book]) - The recommened literature of this course. + +## modulereduced (object) ++ id: `3234` (required, number) - The ID of the module. ++ cid: `20-00-0004-iv` (required, tucanid) - The course ID of TUCaN. ++ name: `Functional and Object-oriented Programming Concepts` (required, string) - The name of the course. ++ lastOffered (required, season) - The season this course was last offered. + + +## season (object) ++ id: `2156` (required, number) - The ID of the season. ++ season: `W` (required, enum[string]) - The season. + + Members + + `W` - Winter term + + `S` - Summer term ++ year: `2017` (required, string) - The year of the season. + +## timeframe (object) ++ from: `2017-02-01` (required, date) - The from-date of the timeframe (inclusive). ++ to: `2017-03-01` (required, date) - The to-date of the timeframe (inclusive). + + + +# Group Data Structures + +## Classifier Explanation + +The 'Classifier' describes how an attribute has to be applied. The following classifiers are available and can be combined (with some exceptions): +- `optional` The attribute does not have to exit. Cannot be combined with `required`. +- `required` The attribute has to exist. Cannot be combined with `optional`. +- `secured` The attribute may only be read by administrators. Cannot be combined with `semi-secured`. +- `semi-secured` The attribute may only be read by administrators and users that are strongly coupled to the object. Cannot be combined with `secured`. +- `transient` The attribute is not stored and is calculated on demand by the server. Therefore it is not required to set this attribute when sending an object to the server. + +If neither `optional` nor `required` are set either `secured` or `semi-secured` have to be set. + +If either `secured` or `semi-secured` have been set, the following rules apply: +- If the user is not permitted to see the attribute it must not be available (really not set, not even `null` or `undefined`). +- If the user is permitted to see the attribute and neither `optional` nor `required` are set it must be available. +- If the user is permitted to see the attribute and either `optional` or `required` are set, these rules apply. + + + + + + + + diff --git a/api-documentation/datastructures/module.md b/api-documentation/datastructures/module.md new file mode 100644 index 0000000..8405eff --- /dev/null +++ b/api-documentation/datastructures/module.md @@ -0,0 +1,15 @@ +## Book + +| Attribute | Type | Classifier | Description | Example | +|-------------|-------------|------------|-------------------------------------------|-------------------------------------------------------| +| id | number | required | The ID of the module. | `3234` | +| cid | tucanid | required | The course ID of TUCaN. | `20-00-0004-iv` | +| name | string | required | The name of the course. | `Functional and Object-oriented Programming Concepts` | +| lastOffered | season | required | The season this course was last offered. | See `Season`. | +| literature | array[book] | required | The recommened literature of this course. | \[ See `Book`. \] | + + + +## Book (Reduced) + +Like `Book`, but `literature` does not exist. diff --git a/api-documentation/datastructures/order.md b/api-documentation/datastructures/order.md new file mode 100644 index 0000000..7d16e71 --- /dev/null +++ b/api-documentation/datastructures/order.md @@ -0,0 +1,10 @@ +## Order + +| Attribute | Type | Classifier | Description | Example | +|-----------|--------------------------------------------------------------------------|--------------|--------------------------------------------------------------------------------------------------------------------------|---------------------------| +| id | number | required | The ID of the order. | `5862` | +| status | enum[string] { `PD` Pending, `OD` Ordered, `RJ` Rejected, `AR` Arrived } | semi-secured | The status of the order. | `AR` | +| hint | string | optional | A hint text including extended information about the status. | `Enough books available.` | +| book | book | required | The ordered book. | See `Book`. | +| student | account | required | The student who has ordered the book. | See `Account`. | +| timeframe | timeframe | required | The timeframe in which the book order can be changed/cancelled. At the end of the timeframe the order will be processed. | See `Timeframe`. | diff --git a/api-documentation/datastructures/season.md b/api-documentation/datastructures/season.md new file mode 100644 index 0000000..9ab286c --- /dev/null +++ b/api-documentation/datastructures/season.md @@ -0,0 +1,7 @@ +## Book + +| Attribute | Type | Classifier | Description | Example | +|-----------|---------------------------------------------------|------------|-------------------------|---------| +| id | number | required | The ID of the season. | `2156` | +| season | enum[string] { `W` Winter term, `S` Summer term } | required | The season. | `W` | +| year | string | required | The year of the season. | `2017` | diff --git a/api-documentation/datastructures/timeframe.md b/api-documentation/datastructures/timeframe.md new file mode 100644 index 0000000..47e1616 --- /dev/null +++ b/api-documentation/datastructures/timeframe.md @@ -0,0 +1,6 @@ +## Timeframe + +| Attribute | Type | Classifier | Description | Example | +|-----------|------|------------|---------------------------------------------|--------------| +| from | date | required | The from-date of the timeframe (inclusive). | `2017-02-01` | +| to | date | required | The to-date of the timeframe (inclusive). | `2017-03-01` | diff --git a/api-documentation/routes/account.md b/api-documentation/routes/account.md new file mode 100644 index 0000000..a874edf --- /dev/null +++ b/api-documentation/routes/account.md @@ -0,0 +1,166 @@ +# Group Account + + + + +## Account Management [/account] + +**Notice:** An account is bound to the currently logged in user. Therefore these operations may not return the same data for different users. + + + +### Retrieve Account [GET /account] + +**Functionality:** Retrieves the current account. + +**Security:** Requires an authenticated user. + + ++ Response 200 (application/json; charset=utf-8) + + + Attributes + + account (required, account) + + + Body + + ++ Response 401 + + **Send if:** The user is not authenticated. + + + Body + + ++ Response 403 + + **Send if:** The user does not have the required permissions. + + + Body + + + +### Modify Account [PATCH /account] + +**Functionality:** Changes the given properties of the current account. + +**Security:** Requires an authenticated user. + + ++ Request (application/json) + + Attributes + + account (required) + + + ++ Response 200 (application/json; charset=utf-8) + + + Attributes + + account (required, account) + + + Body + + ++ Response 401 + + **Send if:** The user is not authenticated. + + + Body + + ++ Response 403 + + **Send if:** The user does not have the required permissions. + + + Body + + ++ Response 422 + + **Send if:** The given item cannot be processed (e.g. if it is invalid). + + + Body + + + +### Delete Account Data [DELETE /account] + +**Functionality:** Deletes the data of the current account. + +**Security:** Requires an authenticated user. + + ++ Response 204 (application/json; charset=utf-8) + + + Body + + ++ Response 401 + + **Send if:** The user is not authenticated. + + + Body + + ++ Response 403 + + **Send if:** The user does not have the required permissions. + + + Body + + ++ Response 422 + + **Send if:** The given item cannot be processed (e.g. if it is invalid). + + + Body + + + +### Retrieve Orders [GET /account/orders{?page,limit,status,orderBy}] + +**Functionality:** Retrieves the orders of the current account matching the given criteria. + +**Security:** Requires an authenticated user. + + ++ Parameters + + page: `1` (optional, number) - pagination - The page to return. Defaults to `1`. + + limit: `10` (optional, number) - pagination - The number of items per page. Defaults to `10`. + + status: `OD` (optional, enum[string]) - A comma-separated list of states to filter for. + + `PD` Pending + + `OD` Ordered + + `RJ` Rejected + + `AR` Arrived + + orderBy: `status` (optional, enum[string]) - The field to order by. Defaults to no specific order. + + `status` Order by the status. + + `timeframe` Order by the timeframe. + + ++ Response 200 (application/json; charset=utf-8) + + + Attributes + + orders (required, array[order]) + + total: `10` (required, number) + + + Body + + ++ Response 400 + + **Send if:** Wrong parameters where sent from the user. + + + Body + + ++ Response 401 + + **Send if:** The user is not authenticated. + + + Body + + ++ Response 403 + + **Send if:** The user does not have the required permissions. + + + Body diff --git a/api-documentation/routes/books.md b/api-documentation/routes/books.md new file mode 100644 index 0000000..126e0bd --- /dev/null +++ b/api-documentation/routes/books.md @@ -0,0 +1,263 @@ +# Group Books + + + + +## Multiple Books [/books] + + + +### Retrieve Books [GET /books{?page,limit,isbn,title,state,author,orderBy}] + +**Functionality:** Retrieves all books matching the given criteria. + + ++ Parameters + + page: `1` (optional, number) - pagination - The page to return. Defaults to `1`. + + limit: `10` (optional, number) - pagination - The number of items per page. Defaults to `10`. + + isbn: `9783836218023` (optional, isbn) - A comma-separated list of ISBNs to filter for. + + title: `java` (optional, string) - The title to filter for. Represents a case-insensitive text search. + + state: `AC` (optional, enum[string]) - A comma-separated list of states to filter for. + + Members + + `AC` - Accepted + + `RJ` - Rejected + + `PP` - Proposed + + `OL` - Obsolete + + author: `ullenboom` (optional, string) - The author to filter for. Represents a case-insensitive text search. + + orderBy: `author` (optional, enum[string]) - The field to order by. Defaults to no specific order. + + `isbn` Order by the ISBN. + + `title` Order by the title. + + `state` Order by the state. + + `author` Order by the author. + + ++ Response 200 (application/json; charset=utf-8) + + + Attributes + + books (required, array[book]) + + total: `10` (required, number) + + + Body + + ++ Response 400 + + **Send if:** Wrong parameters where sent from the user. + + + Body + + + +### Propose Book [PUT /books] + +**Functionality:** Proposes a new book that has to be approved by an administrator. If this endpoint. + +**Security:** Requires an authenticated user. + + ++ Request Create by ISBN (application/json) + + Attributes + + book (required) + + isbn: `9783836218023` (optional, isbn) + + ++ Request Create by Author/Title (application/json) + + Attributes + + book (required) + + title: `Java ist auch eine Insel` (optional, string) + + author: `Christian Ullenboom` (optional, string) + + ++ Response 201 (application/json; charset=utf-8) + + **Send if:** The book was created an accepted (this is only possible if the proposal was sent by an administrator). + + + Attributes + + book (required, book) + + + Body + + ++ Response 202 (application/json; charset=utf-8) + + **Send if:** The book was created and is waiting for approval. + + + Attributes + + book (required, book) + + + Body + + ++ Response 401 + + **Send if:** The user is not authenticated. + + + Body + + ++ Response 403 + + **Send if:** The user does not have the required permissions. + + + Body + + ++ Response 404 + + **Send if:** The specified book was not found. + + + Body + + ++ Response 409 + + **Send if:** The book already exists. + + + Body + + ++ Response 422 + + **Send if:** The given item cannot be processed (e.g. if it is invalid). + + + Body + + + + +## Specific Book [/books/{bookId}] + ++ Parameters + + bookId: `2444` (required, number) - The ID of the book. + + + +### Retrieve Book [GET /books/{bookId}] + +**Functionality:** Retrieves the specified book. + + ++ Parameters + + bookId: `2444` (required, number) - The ID of the book. + + ++ Response 200 (application/json; charset=utf-8) + + + Attributes + + book (required, book) + + + Body + + ++ Response 404 + + **Send if:** The specified book was not found + + + Body + + + +### Modify Book [PATCH /books/{bookId}] + +**Functionality:** Changes the given properties of the specified book. + +**Security:** Requires an authenticated user with the role `admin`. + + ++ Parameters + + bookId: `2444` (required, number) - The ID of the book. + + ++ Request (application/json) + + Attributes + + isbn: `9783836218023` (optional, isbn) + + title: `Java ist auch eine Insel` (optional, string) + + state: `AC` (optional, enum[string]) + + Members + + `AC` - Accepted + + `RJ` - Rejected + + `PP` - Proposed + + `OL` - Obsolete + + author: `Christian Ullenboom` (optional, string) + + price: `49.90` (optional, number) + + ++ Response 200 (application/json; charset=utf-8) + + + Attributes + + book (required, book) + + + Body + + ++ Response 401 + + **Send if:** The user is not authenticated. + + + Body + + ++ Response 403 + + **Send if:** The user does not have the required permissions. + + + Body + + ++ Response 404 + + **Send if:** The specified book was not found + + + Body + + ++ Response 422 + + **Send if:** The given item cannot be processed (e.g. if it is invalid). + + + Body + + + +### Delete Book [DELETE /books/{bookId}] + +**Functionality:** Deletes the specified book. + +**Security:** Requires an authenticated user with the role `admin`. + + ++ Parameters + + bookId: `2444` (required, number) - The ID of the book. + + ++ Response 204 (application/json; charset=utf-8) + + + Body + + ++ Response 401 + + **Send if:** The user is not authenticated. + + + Body + + ++ Response 403 + + **Send if:** The user does not have the required permissions. + + + Body + + ++ Response 404 + + **Send if:** The specified book was not found + + + Body + + ++ Response 422 + + **Send if:** The given item cannot be processed (e.g. if it is invalid). + + + Body diff --git a/api-documentation/routes/modules.md b/api-documentation/routes/modules.md new file mode 100644 index 0000000..c40bbec --- /dev/null +++ b/api-documentation/routes/modules.md @@ -0,0 +1,216 @@ +# Group Modules + + + + +## Multiple Modules [/modules] + + + +### Retrieve Modules [GET /modules{?page,limit,cid,name}] + +**Functionality:** Retrieves all modules matching the given criteria. + + ++ Parameters + + page: `1` (optional, number) - pagination - The page to return. Defaults to `1`. + + limit: `10` (optional, number) - pagination - The number of items per page. Defaults to `10`. + + cid: `20-00-0004-iv` (optional, tucanid) - A comma-separated list of TUCaN course IDs to filter for. + + name: `programming` (optional, string) - The course name to filter for. Represents a case-insensitive text search. + + ++ Response 200 (application/json; charset=utf-8) + + + Attributes + + modules (required, array[modulereduced]) + + total (required, number) + + + Body + + ++ Response 400 + + **Send if:** Wrong parameters where sent from the user. + + + Body + + + +### Create Module [PUT /modules] + +**Functionality:** Creates a new module. + +**Security:** Requires an authenticated user with the role `admin`. + + ++ Request (application/json) + + Attributes + + module (required) + + cid: `20-00-0004-iv` (required, tucanid) + + name: `Functional and Object-oriented Programming Concepts` (required, string) + + lastOffered (required, season) + + literature (optional, array[string]) - The IDs of the proposed books. + + ++ Response 201 (application/json; charset=utf-8) + + + Attributes + + module (required, module) + + + Body + + ++ Response 401 + + **Send if:** The user is not authenticated. + + + Body + + ++ Response 403 + + **Send if:** The user does not have the required permissions. + + + Body + + ++ Response 422 + + **Send if:** The given item cannot be processed (e.g. if it is invalid). + + + Body + + + + +## Specific Moudle [/modules/{moduleId}] + ++ Parameters + + moduleId: `3234` (required, number) - The ID of the module. + + + +### Retrieve Module [GET /modules/{moduleId}] + +**Functionality:** Retrieves the specified module. + + ++ Parameters + + moduleId: `3234` (required, number) - The ID of the module. + + ++ Response 200 (application/json; charset=utf-8) + + + Attributes + + module (required, module) + + + Body + + ++ Response 404 + + **Send if:** The specified module was not found. + + + Body + + + +### Modify Module [PATCH /modules/{moduleId}] + +**Functionality:** Changes the given properties of the specified module. + +**Security:** Requires an authenticated user with the role `admin`. + + ++ Parameters + + moduleId: `3234` (required, number) - The ID of the module. + + ++ Request (application/json) + + Attributes + + module (required) + + cid: `20-00-0004-iv` (optional, tucanid) + + name: `Functional and Object-oriented Programming Concepts` (optional, string) + + lastOffered (optional, season) + + literature (optional, array[string]) - The IDs of the proposed books. + + ++ Response 200 (application/json; charset=utf-8) + + + Attributes + + module (required, module) + + + Body + + ++ Response 401 + + **Send if:** The user is not authenticated. + + + Body + + ++ Response 403 + + **Send if:** The user does not have the required permissions. + + + Body + + ++ Response 404 + + **Send if:** The specified module was not found. + + + Body + + ++ Response 422 + + **Send if:** The given item cannot be processed (e.g. if it is invalid). + + + Body + + + +### Delete Module [DELETE /modules/{moduleId}] + +**Functionality:** Deletes the specified module. + +**Security:** Requires an authenticated user with the role `admin`. + + ++ Parameters + + moduleId: `3234` (required, number) - The ID of the module. + + ++ Response 204 (application/json; charset=utf-8) + + + Body + + ++ Response 401 + + **Send if:** The user is not authenticated. + + + Body + + ++ Response 403 + + **Send if:** The user does not have the required permissions. + + + Body + + ++ Response 404 + + **Send if:** The specified module was not found. + + + Body + + ++ Response 422 + + **Send if:** The given item cannot be processed (e.g. if it is invalid). + + + Body diff --git a/api-documentation/routes/orders.md b/api-documentation/routes/orders.md new file mode 100644 index 0000000..58fe342 --- /dev/null +++ b/api-documentation/routes/orders.md @@ -0,0 +1,165 @@ +# Group Orders + + + + +## Multiple Orders [/orders] + + + +### Retrieve Orders [GET /orders{?page,limit,userId,status,orderBy}] + +**Functionality:** Retrieves all orders that are visible to the current user (that is, only the orders of the logged in user or all orders if the logged in user as the role `admin`). + +**Security:** Requires an authenticated user. + + ++ Parameters + + page: `1` (optional, number) - pagination - The page to return. Defaults to `1`. + + limit: `10` (optional, number) - pagination - The number of items per page. Defaults to `10`. + + userId: `1987` (optional, number) - A comma-separated list of user IDs to filter for. This property does not have any functionality if the current user does not have the role `admin`. + + status: `OD` (optional, enum[string]) - A comma-separated list of states to filter for. + + Members + + `PD` - Pending + + `OD` - Ordered + + `RJ` - Rejected + + `AR` - Arrived + + orderBy: `status` (optional, enum[string]) - The field to order by. Defaults to no specific order. + + `status` Order by the status. + + `timeframe` Order by the timeframe. + + ++ Response 200 (application/json; charset=utf-8) + + + Attributes + + orders (required, array[order]) + + total: `10` (required, number) + + + Body + + ++ Response 400 + + **Send if:** Wrong parameters where sent from the user. + + + Body + + ++ Response 401 + + **Send if:** The user is not authenticated. + + + Body + + ++ Response 403 + + **Send if:** The user does not have the required permissions. + + + Body + + + + +## Specific Order [/orders/{orderId}] + ++ Parameters + + orderId: `5862` (required, number) - The ID of the order. + + + +### Modify Order [PATCH /orders/{orderId}] + +**Functionality:** Changes the given properties of the specified order. + +**Security:** Requires an authenticated user with the role `admin`. + + ++ Parameters + + orderId: `5862` (required, number) - The ID of the order. + + ++ Request (application/json) + + Attributes + + order (required) + + status: `OD` (optional, enum[string]) + + Members + + `PD` - Pending + + `OD` - Ordered + + `RJ` - Rejected + + `AR` - Arrived + + hint: `Enough books available.` (optional, string) + + ++ Response 200 (application/json; charset=utf-8) + + + Attributes + + order (required, order) + + + Body + + ++ Response 401 + + **Send if:** The user is not authenticated. + + + Body + + ++ Response 403 + + **Send if:** The user does not have the required permissions. + + + Body + + ++ Response 404 + + **Send if:** The specified order was not found. + + + Body + + ++ Response 422 + + **Send if:** The given item cannot be processed (e.g. if it is invalid). + + + Body + + + +### Delete Order [DELETE /orders/{orderId}] + +**Functionality:** Deletes the specified order. + +**Security:** Requires an authenticated user with the role `admin` or the user who has created the order. + + ++ Parameters + + orderId: `5862` (required, number) - The ID of the order. + + ++ Response 204 (application/json; charset=utf-8) + + + Body + + ++ Response 401 + + **Send if:** The user is not authenticated. + + + Body + + ++ Response 403 + + **Send if:** The user does not have the required permissions. + + + Body + + ++ Response 404 + + **Send if:** The specified order was not found. + + + Body diff --git a/api-documentation/routes/routes.md b/api-documentation/routes/routes.md new file mode 100644 index 0000000..fc32ce1 --- /dev/null +++ b/api-documentation/routes/routes.md @@ -0,0 +1,4 @@ + + + + diff --git a/api-documentation/routes/sample.md b/api-documentation/routes/sample.md new file mode 100644 index 0000000..fd32bf9 --- /dev/null +++ b/api-documentation/routes/sample.md @@ -0,0 +1,70 @@ +# Group GROUP + + + + +## SECTION [PATH] + + + +### OPERATION_TITLE [METHOD PATH] + +**Functionality:** N/A + +**Notice:** N/A + +**Security:** Requires an authenticated user. +**Security:** Requires an authenticated user with the role `admin`. + + ++ Parameters + + PARAMETER: `EXAMPLE` (optional,required, TYPE) - DESCRIPTION + + ++ Request (application/json) + + Attributes + + ATTRIBUTE (optional,required, TYPE) + + ++ Response CODE (application/json; charset=utf-8) + + **Send if:** SEND_IF + + + Attributes + + ATTRIBUTE (optional,required, TYPE) + + + Body + + ++ Response 400 + + **Send if:** Wrong parameters where sent from the user. + + + Body + + ++ Response 401 + + **Send if:** The user is not authenticated. + + + Body + + ++ Response 403 + + **Send if:** The user does not have the required permissions. + + + Body + + ++ Response 422 + + **Send if:** The given item cannot be processed (e.g. if it is invalid). + + + Body + + + +### next operation +## next section +# next group