Skip to content

Parties API

amplifi edited this page Jun 29, 2017 · 1 revision

This document outlines the API design for organization project parties. Follows spatial units and organizations API docs.

API endpoints

List all parties for a project.

Request

GET /organizations/{organization-slug}/projects/{project-slug}/parties
Accept: application/json
Content-Type: application/json
Authorization: Token 1398dojk9sd8jf9hsd89hd

Successful response

HTTP/1.1 200 OK
Content-Type: application/json
[
    {
        "id": "0asjij9asjd8jh8ghashgd7",
        "name": "Barnabas Mughongo",
        "type": "IN",
        "organization": "Cadasta",
        "country": "Uganda"
        "description: "",
        "archived": false,
        "contacts": [ // following http://microformats.org/wiki/h-card
            {
                "type": ["hcard"],
                "properties": {
                    "name": ["Barnabas Mughongo"],
                    "email": ["mailto:[email protected]"]
                }
            }
        ],
        "attributes": [
            "depends on party type"
        ]
        "relationships":[],
        "tenure_relationships": [],
    },
    ...
]

Search

Providing a query for parameter search will return a list of parties where name, relationship or related parties match the provided query.

GET /organizations/{organization-slug}/projects/{project-slug}/parties/?search=Mughongo
Accept: application/json
Content-Type: application/json
Authorization: Token 1398dojk9sd8jf9hsd89hd

Filter by type

Providing a query for parameter type will return a list of parties that match the given party type.

GET /organizations/{organization-slug}/projects/{project-slug}/parties/?type=IN
Accept: application/json
Content-Type: application/json
Authorization: Token 1398dojk9sd8jf9hsd89hd

Ordering

Orders the response according to name.

GET /organizations/{organization-slug}/projects/{project-slug}/parties/?ordering=name

For descending ordering add add a dash to the ordering attribute

GET /organizations/{organization-slug}/projects/{project-slug}/parties/?ordering=-name

Errors

When the request content contains invalid data

HTTP/1.1 400 Bad request
Content-Type: application/json

{
  "name": "This field is required"
}

When the request is not signed with a auth token

HTTP/1.1 401 Unauthorized
Content-Type: application/json

{
  "error": "Please sign in."
}

Create a new party for a project.

Request

The request Content-Type must be multipart/formdata to allow uploading files together with other form data.

POST /organizations/{organization-slug}/projects/{project-slug}/parties/
Content-Type: multipart/formdata
Authorization: Token 1398dojk9sd8jf9hsd89hd
---separator---
Content-Disposition: form-data; name="name"

Barnabas Mughongo
---separator---
Content-Disposition: form-data; name="project"

Mapping property rights in Uganda
---separator---

---separator---
Content-Disposition: form-data; name="type"

IN
Content-Disposition: form-data; name="contacts"

{}
---separator---
Content-Disposition: form-data; name="attributes"

{}
---separator---
Content-Disposition: form-data; name="relationships"

[]
---separator---

Successful response

HTTP/1.1 201 Created
Content-Type: application/json

[
    {
        "id": "0asjij9asjd8jh8ghashgd7",
        "name": "Barnabas Mughongo",
        "type": "Individual",
        "organization": "",
        "country": "Uganda"
        "description: "",
        "archived": false,
        "contacts": [],
        "attributes": [
            "depends on party type"
        ]
        "relationships":[],
        "tenure_relationships": [],
    },
    ...
]

Get a single party

Request

GET /organizations/{organization-slug}/projects/{project-slug}/parties/0asjij9asjd8jh8ghashgd7
Accept: application/json
Content-Type: application/json
Authorization: Token 1398dojk9sd8jf9hsd89hd

Successful response

{
        "id": "0asjij9asjd8jh8ghashgd7",
        "name": "Barnabas Mughongo",
        "type": "Individual",
        "organization": "",
        "country": "Uganda"
        "description: "",
        "archived": false,
        "contacts": [],
        "attributes": [
            "depends on party type"
        ]
        "relationships":[],
        "tenure_relationships": [],
    }

Update a single party

Request

The request Content-Type must be multipart/formdata to allow uploading files together with other form data.

PATCH /organizations/{organization-slug}/projects/{project-slug}/parties/0asjij9asjd8jh8ghashgd7
Content-Type: multipart/formdata
Authorization: Token 1398dojk9sd8jf9hsd89hd
---separator---
Content-Disposition: form-data; name="name"

Barnabas Mughongo
---separator---
Content-Disposition: form-data; name="project"

Mapping property rights in Uganda
---separator---

---separator---
Content-Disposition: form-data; name="type"

IN
Content-Disposition: form-data; name="contacts"

[
  {
     "type": ["hcard"],
     "properties": {
           "name": ["Barnabas Mughongo"],
           "email": ["mailto:[email protected]"]
      }
  }
]
---separator---
Content-Disposition: form-data; name="attributes"

{
    "gender": "Male",
    "dob": "1980-02-11",
    "notes": "Brother to Solomon Mughongo"
}
---separator---
Content-Disposition: form-data; name="relationships"

[]
---separator---

Successful response

HTTP/1.1 200 Ok
Content-Type: application/json

[
    {
        "id": "0asjij9asjd8jh8ghashgd7",
        "name": "Barnabas Mughongo",
        "type": "IN",
        "organization": "",
        "country": "Uganda"
        "description: "",
        "archived": false,
        "contacts": [
            {
               "type": ["hcard"],
               "properties": {
                    "name": ["Barnabas Mughongo"],
                    "email": ["mailto:[email protected]"]
                }
            }
        ],
        "attributes": {
                "gender": "Male",
                "dob": "1980-02-11",
                "notes": "Brother to Solomon Mughongo"
        },
        "relationships":[],
        "tenure_relationships": [],
    },
    ...
]

Get all relationships for a single party

Clone this wiki locally