Office
Allows accessing and manipulation of offices.
GET /v1/office/{id}
Provides information about an office.
Params
-
{id}- Required. Integer ID of office. -
token- Required. Parameter or cookie of user token.
Responses
- Code: 200
Content:
{ "id":1, "name":"National Coordinator", "email":"nc@mindseyesociety.org", "type":"Primary", "roles":[ "user_read_private", "user_update", "..." ], "parents":[], "children":[ { "id":3, "name":"Regional Coordinator", "type":"Primary" }, { "id":9, "name":"aRC Membership", "type":"Assistant" } ], "orgUnit":{ "id":1, "name":"United States", "code":"US", "type":"Nation" }, "user":{ "id":2, "membershipNumber":"US2016010002", "firstName":"Test", "lastName":"NC", "nickname":null, "fullName":"Test NC", "membershipType":"Full", "membershipExpiration":"2020-01-01T00:00:00.000Z" } } - Code: 404
Content:{ status: 404, message: 'Office not found' }
POST /v1/office/
Creates a primary national office. Requires admin role.
Params
token- Required. Parameter or cookie of user token.
Body
-
name- Name of office. -
email- Optional. The office email. -
roles- Array of roles. -
userID- Optional. User to assign new office to.
Responses
-
Code: 200
Content: The office JSON. SeeGET office/{id}, above. -
No body data provided.
Code: 400
Content:{ status: 400, message: 'No data provided' } -
Invalid body data provided.
Code: 400
Content:{ status: 400, message: 'Invalid data provided: [errors]' }
GET /v1/office/me
Provides an array of the current user offices.
Params
token- Required. Parameter or cookie of user token.
Responses
- Code: 200
Content:
[ { "id":7, "name":"DC", "email":null, "type":"Primary", "parentOfficeID":null, "parentPath":"1.3.7", "parentOrgID":3, "userID":8, "roles":[ "Array of roles" ] } ]
GET /v1/office/roles
Provides a human-readable list of roles.
Responses
- Code: 200
Content:{ user_read_private: 'Read private user data', [...] }
PUT /v1/office/{id}
Updates data for a given office.
Params
-
id- Required. ID of office to change. -
token- Required. Parameter or cookie of user token. Needsoffice_updaterole over office.
Body
-
name- Name of office. -
email- The office email. -
roles- Array of roles.
Responses
-
Code: 200
Content: The modified JSON. SeeGET office/{id}, above. -
No body data provided.
Code: 400
Content:{ status: 400, message: 'No data provided' } -
Invalid body data provided.
Code: 400
Content:{ status: 400, message: 'Invalid data provided: [errors]' }
PUT /v1/office/{id}/assign/{user}
Assigns an office to a given user, or vacates an office. Holder of office can use this to resign.
Params
-
{id}- Required. ID of office to assign. -
{user}- Required. ID of user to be assigned, or zero to vacate. -
token- Required. Parameter or cookie of user token. Needsoffice_assignrole over office.
Responses
-
Code: 200
Content:{ success: true } -
Code: 404
Content:{ status: 404, message: 'Office not found' } -
Code: 404
Content:{ status: 404, message: 'User not found' } -
User is already in this office.
Code: 500
Content:{ status: 500, message: 'User already officer' } -
Office is already vacant.
Code: 500
Content:{ status: 500, message: 'Office already vacant' }
POST /v1/office/{id}/assistant
Creates an assistant office for a given primary one.
Params
-
{id}- Required. ID of parent office. -
token- Required. Parameter or cookie of user token. Needsoffice_create_assistantsrole over office, oroffice_create_own_assistantsfor self.
Body
-
name- Required. Name of office. -
email- The office email. -
roles- Array of roles.
Responses
-
Code: 200
Content: The modified JSON. SeeGET office/{id}, above. -
No body data provided.
Code: 400
Content:{ status: 400, message: 'No data provided' } -
Parent office doesn’t exist.
Code: 404
Content:{ status: 404, message: 'Parent office not found' } -
Invalid body data provided.
Code: 400
Content:{ status: 400, message: 'Invalid data provided: [errors]' }
DELETE /v1/office/{id}/assistant
Deletes an assistant office.
Params
-
{id}- Required. ID of assistant office to delete. -
token- Required. Parameter or cookie of user token. Needsoffice_create_assistantsrole over office, oroffice_create_own_assistantsfor self.
Responses
-
Code: 200
Content:{ success: true } -
Code: 404
Content:{ status: 404, message: 'Office not found' } -
Office is a primary one.
Code: 400
Content:{ status: 400, message: 'Office is not an assistant' }
GET /v1/office/verify/orgunit/{unit}
Internal endpoint only. Verifies the user has a given role over an org unit.
Params
-
{unit}- Required. ID of org unit to check. -
roles- Required. Comma separated list of roles to verify. -
token- Required. Parameter or cookie of user token.
Responses
-
Code: 200
Content:{ success: true, offices: [Array of offices] } -
Code: 400
Content:{ status: 400, message: 'Missing required "roles" param' } -
All other permission errors.
Code: 403
Content:{ status: 403, message: {mixed} }
GET /v1/office/verify/user/{user}
Internal endpoint only. Verifies the user has a given role over a user.
Params
-
{user}- Required. ID of user to check. -
roles- Required. Comma separated list of roles to verify. -
token- Required. Parameter or cookie of user token.
Responses
-
Code: 200
Content:{ success: true, offices: [Array of offices] } -
Code: 400
Content:{ status: 400, message: 'Missing required "roles" param' } -
All other permission errors.
Code: 403
Content:{ status: 403, message: {mixed} }
GET /v1/office/verify/office/{office}
Internal endpoint only. Verifies the user has a given role over an office.
Params
-
{office}- Required. ID of office to check. -
roles- Required. Comma separated list of roles to verify. -
token- Required. Parameter or cookie of user token.
Responses
-
Code: 200
Content:{ success: true, offices: [Array of offices] } -
Code: 400
Content:{ status: 400, message: 'Missing required "roles" param' } -
All other permission errors.
Code: 403
Content:{ status: 403, message: {mixed} }