Skip to content
This repository has been archived by the owner on Sep 2, 2020. It is now read-only.

Commit

Permalink
Update systems.md
Browse files Browse the repository at this point in the history
Still to do GET `public`.
  • Loading branch information
SueSmith committed May 22, 2014
1 parent a0eb042 commit a879079
Showing 1 changed file with 104 additions and 28 deletions.
132 changes: 104 additions & 28 deletions docs/systems.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Systems

A system represents the top admin level within BadgeKit - an instance can contain one or more systems, a system can contain one or more issuers and an issuer can contain one or more programs. All BadgeKit API needs to function is one system, which badges will be automatically included in. Badges can optionally be associated with a system, issuer or program.

| NAME | VALUE |
|:---|:---|
| `id` | integer - _id from database entry_ |
| `slug` | string - _used to identify system in API endpoints_ |
| `url` | string |
| `name` | string |
| `email` | string |
| `imageUrl` | string |

This comment has been minimized.

Copy link
@SueSmith

SueSmith May 22, 2014

Author Contributor

Not included description here as it isn't being returned - will check whether this is correct.

| `issuers` | array - _[issuers](issuers.md) in the system (may contain [programs](programs.md))_ |

## `GET /systems`

Retrieves all available systems in the BadgeKit API instance.
Expand Down Expand Up @@ -57,13 +69,25 @@ Content-Type: application/json
}
```

#### Response structure

* systems `[ ]`
* id
* slug
* url
* name
* email
* imageUrl

This comment has been minimized.

Copy link
@SueSmith

SueSmith May 22, 2014

Author Contributor

No description again here.

* [issuers](issuers.md) `[ ]`
* [programs](programs.md) `[ ]`

### Potential errors

*None*

## `GET /systems/<slug>`

Retrieves a specific system.
Retrieves a specific system using its slug.

### Expected request

Expand Down Expand Up @@ -115,6 +139,18 @@ Content-Type: application/json
}
```

#### Response structure

* system
* id
* slug
* url
* name
* email
* imageUrl

This comment has been minimized.

Copy link
@SueSmith

SueSmith May 22, 2014

Author Contributor

No description.

* [issuers](issuers.md) `[ ]`
* [programs](programs.md) `[ ]`

### Potential errors

* **System not found**
Expand All @@ -139,9 +175,6 @@ Creates a new system.

Requests can be sent as `application/json`, `application/x-www-form-urlencoded` or `multipart/form-data`.


<a name="post-parameters"></a>

| Parameters | Required | Description |
|:-----------------------|-----------------|-------------------------|
| **slug** | required | Short, computer-friendly name for the system. Good slugs are lowercase and use dashes instead of spaces, e.g. `city-of-chicago`. Maximum of 50 characters and each system must have a unique slug.
Expand All @@ -156,27 +189,45 @@ Requests can be sent as `application/json`, `application/x-www-form-urlencoded`
```
HTTP/1.1 201 Created
Content-Type: application/json
```

```json
{
"status": "created",
"system": {
"id": 1,
"slug": "system-slug",
"name": "System Name",
"url": "https://example.org/system/",
"email": "system-badges@example.org",
"description": "System Description"

This comment has been minimized.

Copy link
@SueSmith

SueSmith May 22, 2014

Author Contributor

May add back.

"url": "http://systemsite.com",
"email": "admin@systemsite.com",
"imageUrl": "http://systemsite.com/image.jpg",
"issuers": [ ]
}
}
```

#### Response structure

* status
* system
* id
* slug
* name
* url
* email
* imageUrl

This comment has been minimized.

Copy link
@SueSmith

SueSmith May 22, 2014

Author Contributor

No description.

* issuers `[ ]`

### Potential errors

* **Invalid data**

```
```
HTTP/1.1 400 Bad Request
Content-Type: application/json
```

```json
{
"code": "ValidationError",
"message": "Could not validate required fields",
Expand All @@ -189,22 +240,24 @@ Content-Type: application/json
...
]
}
```
```

* **Duplicate entry**

```
```
HTTP/1.1 409 Conflict
Content-Type: application/json
```

```json
{
"code": "ResourceConflict",
"error": system with that `slug` already exists",
"details": {
"slug": "system-slug",
"name": "System Name",
"url": "https://example.org/system/",
"email": "system-badges@example.org",
"url": "http://systemsite.com",
"email": "admin@systemsite.com",
"description": "System Description"
}
}
Expand All @@ -218,22 +271,35 @@ Updates an existing system.

Requests can be sent as `application/json`, `application/x-www-form-urlencoded` or `multipart/form-data`.

<a href="#post-parameters">See above for parameters.</a> You only have to pass in the fields you are updating. Any fields that are not represented will be left unchanged.
| Parameters | Required | Description |
|:-----------------------|-----------------|-------------------------|
| **slug** | required | Short, computer-friendly name for the system. Good slugs are lowercase and use dashes instead of spaces, e.g. `city-of-chicago`. Maximum of 50 characters and each system must have a unique slug.
| **name** | required | Name of the system. Maximum of 255 characters.
| **url** | required | URL for the system. Must be fully qualified, e.g. https://www.example.org, **NOT** just www.example.org.
| **description** | optional | A short, human-friendly description of the system. Maximum of 255 characters
| **email** | optional | Email address associated with the badge administrator of the system.
| **image** | optional | Image for the system. Should be either multipart data or a URL.

You only have to pass in the fields you are updating. Any fields that are not represented will be left unchanged.

### Expected response

```
HTTP/1.1 200 OK
Content-Type: application/json
```
```json
{
"status": "updated",
"system": {
"id": 1,
"slug": "system-slug",
"name": Updated System Name",
"url": "https://example.org/system/",
"email": "system-badges@example.org",
"description": "Updated System Description"

This comment has been minimized.

Copy link
@SueSmith

SueSmith May 22, 2014

Author Contributor

As above.

"name": "System Name",
"url": "http://systemsite.com",
"email": "admin@systemsite.com",
"imageUrl": "http://systemsite.com/image.jpg",
"issuers": [ ]
}
}
```
Expand All @@ -242,10 +308,12 @@ Content-Type: application/json

* **Invalid data**

```
```
HTTP/1.1 400 Bad Request
Content-Type: application/json
```

```json
{
"code": "ValidationError",
"message": "Could not validate required fields",
Expand All @@ -258,26 +326,28 @@ Content-Type: application/json
...
]
}
```
```

* **Duplicate entry**

```
```
HTTP/1.1 409 Conflict
Content-Type: application/json
```

```json
{
"code": "ResourceConflict",
"error": "system with that `slug` already exists",
"details": {
"slug": "system-slug",
"name": "System Name",
"url": "https://example.org/system/",
"email": "system-badges@example.org",
"url": "http://systemsite.com",
"email": "admin@systemsite.com",
"description": "System Description"
}
}
```
```

## `DELETE /systems/<slug>`

Expand All @@ -294,15 +364,19 @@ DELETE /systems/<slug> HTTP/1.1
```
HTTP/1.1 200 OK
Content-Type: application/json
```

```json
{
"status": "deleted",
"system": {
"id": 1,
"slug": "system-slug",
"name": "System Name",
"url": "https://example.org/system/",
"email": "system-badges@example.org",
"description": "System Description"

This comment has been minimized.

Copy link
@SueSmith

SueSmith May 22, 2014

Author Contributor

As above.

"url": "http://systemsite.com",
"email": "admin@systemsite.com",
"imageUrl": "http://systemsite.com/image.jpg",
"issuers": [ ]
}
}
```
Expand All @@ -311,15 +385,17 @@ Content-Type: application/json

* **System not found**

```
```
HTTP/1.1 404 Not Found
Content-Type: application/json
```

```json
{
"code": "ResourceNotFound",
"message": "Could not find system with slug `<attempted slug>`"
}
```
```

## `GET /public/systems/<slug>`

This comment has been minimized.

Copy link
@SueSmith

SueSmith May 22, 2014

Author Contributor

Need to check what this is for - if it shouldn't be in the docs remove it here and in api-endpoints.md.


Expand Down

0 comments on commit a879079

Please sign in to comment.