Skip to content

Latest commit

 

History

History
440 lines (367 loc) · 10.1 KB

API.md

File metadata and controls

440 lines (367 loc) · 10.1 KB

TMI People API

Agreements

Agreements are forged between users; collectives; and users and collectives. These agreements represent relationships between participants and include:

  • friendship between users
  • invitations to, and member- and moderatorship between users and collectives
  • registration of projects between collectives.
  • any other kind of agreement our community may wish to create.

Agreement schema

TODOC

List Agreements

TODOC

Find Agreements

TODOC

Create Agreement(s)

TODOC

Update Agreement(s)

TODOC

Delete Agreement(s)

TODOC

Agreement types

http://127.0.0.1:3000/agreement

The root endpoint of agreements allows management of types of agreement.



Agreement type schema

Authentication Required
Endpoint http://127.0.0.1:3000/agreement
Request type GET
Content-Type application/json;schema


Expected response

HTTP Status: 200

{
    "data": {
        "$schema": "http://json-schema.org/draft-07/schema#",
        "$id": "http://tmi.mobi/agreement/agreement.schema.json",
        "definitions": {
            "uei": {
                "$ref": "http://tmi.mobi/root.schema.json#/definitions/uei"
            },
            "participantRef": {
                "$ref": "http://tmi.mobi/root.schema.json#/definitions/participantRef"
            }
        },
        "type": "object",
        "title": "string",
        "name": "string",
        "properties": {
            "id": {
                "$ref": "#/definitions/uei"
            },
            "owner": {
                "$ref": "#/definitions/participantRef"
            },
            "schema": {
                "type": "object"
            }
        },
        "required": [
            "name",
            "owner",
            "schema"
        ]
    }
}

JSON schema that defines agreement types.



List agreement types

Authentication Required
Endpoint http://127.0.0.1:3000/agreement
Request type GET
Content-Type application/json


Expected response

{
    "data": [
        {
            "owner": {
                "entityType": "collective",
                "id": 0
            },
            "name": "administrator",
            "schema": {
                "$schema": "http://json-schema.org/draft-07/schema#",
                "$id": "http://tmi.mobi/agreement/administrator/administrator.schema.json",
                "type": "object",
                "title": "Administrator Agreement",
                "allOf": [
                    {
                        "$ref": "http://tmi.mobi/agreement/base.agreement.schema.json"
                    }
                ]
            },
            "id": 0
        },
        {
            "owner": {
                "entityType": "collective",
                "id": 0
            },
            "name": "moderator",
            "schema": {
                "$schema": "http://json-schema.org/draft-07/schema#",
                "$id": "http://tmi.mobi/schemas/agreement/default/moderator.json",
                "type": "object",
                "title": "Moderator Agreement",
                "allOf": [
                    {
                        "$ref": "http://tmi.mobi/agreement/base.agreement.schema.json"
                    }
                ]
            },
            "id": 1
        },
        {
            "owner": {
                "entityType": "collective",
                "id": 0
            },
            "name": "member",
            "schema": {
                "$schema": "http://json-schema.org/draft-07/schema#",
                "$id": "http://tmi.mobi/agreement/default/member.agreement.schema.json",
                "type": "object",
                "title": "Membership Agreement",
                "allOf": [
                    {
                        "$ref": "http://tmi.mobi/agreement/base.agreement.schema.json"
                    }
                ]
            },
            "id": 2
        },
        {
            "owner": {
                "entityType": "collective",
                "id": 0
            },
            "name": "guest",
            "schema": {
                "$schema": "http://json-schema.org/draft-07/schema#",
                "$id": "http://tmi.mobi/schemas/agreement/default/guest.json",
                "type": "object",
                "title": "Guest Agreement",
                "allOf": [
                    {
                        "$ref": "http://tmi.mobi/agreement/base.agreement.schema.json"
                    }
                ]
            },
            "id": 3
        }
    ]
}


Find agreement types

Authentication Required
Endpoint http://127.0.0.1:3000/agreement?property=value&anotherProperty=etc
Request type GET
Content-Type application/json

Where "property" and "anotherProperty" represent properties of the schema type, eg.

http://127.0.0.1:3000/agreement?name=guest


Expected response

{
    "data": [
        {
            "owner": {
                "entityType": "collective",
                "id": 0
            },
            "name": "guest",
            "schema": {
                "$schema": "http://json-schema.org/draft-07/schema#",
                "$id": "http://tmi.mobi/schemas/agreement/default/guest.json",
                "type": "object",
                "title": "Guest Agreement",
                "allOf": [
                    {
                        "$ref": "http://tmi.mobi/agreement/base.agreement.schema.json"
                    }
                ]
            },
            "id": 3
        }
    ]
}


Create agreement type(s)

Authentication Required
Endpoint http://127.0.0.1:3000/agreement
Request type POST
Content-Type application/json
Request body
[
    {
        "owner": {
            "entityType": "collective",
            "id": 0
        },
        "name": "test-agreement",
        "schema": {
            "$schema": "http://json-schema.org/draft-07/schema#",
            "$id": "http://tmi.mobi/schemas/agreement/test-agreement",
            "type": "object",
            "title": "Test Agreement",
            "allOf": [
                {
                    "$ref": "http://tmi.mobi/agreement/base.agreement.schema.json"
                }
            ],
            "properties": {
                "newProp": {
                    "type": "string"
                }
            }
        },
        "id": 4
    }
]

Expected response
{
    "status": "Entities created",
    "code": 201,
    "expose": true,
    "entities": [
        {
            "owner": {
                "entityType": "collective",
                "id": 0
            },
            "name": "test-agreement",
            "schema": {
                "$schema": "http://json-schema.org/draft-07/schema#",
                "$id": "http://tmi.mobi/schemas/agreement/test-agreement",
                "type": "object",
                "title": "Test Agreement",
                "allOf": [
                    {
                        "$ref": "http://tmi.mobi/agreement/base.agreement.schema.json"
                    }
                ],
                "properties": {
                    "newProp": {
                        "type": "string"
                    }
                }
            },
            "id": 4
        }
    ]
}

Creates a new agreement type and enpoint, in this case:

/agreement/test-agreement

that may now be used to create instances of the agreement type "test-agreement", as per the provided name and schema.



Update agreement type(s)

Authentication Required
Endpoint http://127.0.0.1:3000/agreement
Request type PUT
Content-Type application/json
Request body
[
	{
		"owner": {"entityType": "collective", "id": 0},
		"name": "test-agreement",
		"schema": {
			"$schema": "http://json-schema.org/draft-07/schema#",
			"$id": "http://tmi.mobi/schemas/agreement/default/guest.json",

			"type": "object",
			"title": "Test Agreement",

			"allOf": [
				{"$ref": "http://tmi.mobi/agreement/base.agreement.schema.json"}
			],
			"properties": {
				"newProp": "boolean"
			}
		}
	}
]

Expected response
{
    "status": "Success",
    "code": 200,
    "expose": true,
    "entities": [
        {
            "owner": {
                "entityType": "collective",
                "id": 0
            },
            "name": "test-agreement",
            "schema": {
                "$schema": "http://json-schema.org/draft-07/schema#",
                "$id": "http://tmi.mobi/schemas/agreement/test-agreement",
                "type": "object",
                "title": "Test Agreement",
                "allOf": [
                    {
                        "$ref": "http://tmi.mobi/agreement/base.agreement.schema.json"
                    }
                ],
                "properties": {
                    "newProp": {
                        "type": "boolean"
                    }
                }
            },
            "id": 4
        }
    ]
}


Delete agreement type(s)

TODO