Overview

Read below for a detailed explanation on how to implement certain capabilities of the Resident API.

Pagination

For resources that return an undetermined amount of records, the ability to use paging has been implemented. Any resource with a {page} and {pageSize} parameter can implement paging.

  • The {pageSize} determines the amount of records to pull for a given page.
  • The {page} parameter determines which particular subset records to retrieve given the {pageSize}.
  • If {page} or {pageSize} is 0, all records will be returned.
For example, let's use the violation categories route: GET residentapi/categorytypes/{categoryType}/infocenterquestions?question={question}&privatequestion={privatequestion}&categoryId={categoryId}&sort={sort}&page={page}&pageSize={pageSize}
If the following route is called: GET residentapi/categorytypes/{categoryType}/infocenterquestions?question={question}&privatequestion={privatequestion}&categoryId={categoryId}&sort={sort}&page=2&pageSize=5
The 6th, 7th, 8th, 9th, and 10th category records will be returned.

Other examples:
  • GET residentapi/categorytypes/{categoryType}/infocenterquestions?question={question}&privatequestion={privatequestion}&categoryId={categoryId}&sort={sort}&page=0&pageSize=0 - returns all records, no paging
  • GET residentapi/categorytypes/{categoryType}/infocenterquestions?question={question}&privatequestion={privatequestion}&categoryId={categoryId}&sort={sort} - returns all records, no paging
  • GET residentapi/categorytypes/{categoryType}/infocenterquestions?question={question}&privatequestion={privatequestion}&categoryId={categoryId}&sort={sort}&page=1&pageSize=1 - returns only the very first record
  • GET residentapi/categorytypes/{categoryType}/infocenterquestions?question={question}&privatequestion={privatequestion}&categoryId={categoryId}&sort={sort}&page=5&pageSize=50 - returns the 200th through 250th record


Sorting

Any resource with a sort parameter can implement sorting. Each route allows specific sorting options wich are explained in details in the route's help.

  • The sort parameter take a list of comma separated fields, each with a possible unary negative to imply descending sort order.
  • Unary positive is the default sort direction used, which implies ascending order.
  • Each route that allows sorting defaults to some order which is specified in the route's help.
For example, let's use the work orders get by unitID route: residentapi/units/{unitId:int}/workorders?sort={sort}. If the following route is called: residentapi/units/1/workorders?sort=datecreated (assuming a unitID of 1)
Work orders will be returned sorted in ascending order of Date Created

Other examples:
  • residentapi/units/{unitId:int}/workorders?sort=+datecreated - returns same results as residentapi/units/{unitId:int}/workorders?sort=datecreated
  • residentapi/units/{unitId:int}/workorders?sort=-datecreated - returns work orders sorted in descending order of Date Created
  • residentapi/units/{unitId:int}/workorders?sort=unitdisplayorder,-datecreated - returns work orders sorted in ascending order of Unit Display Order.
    Work orders with same UnitDisplayOrder will be sorted in descending order of Date Created


File Download

To retrieve a physical file (such as an image or PDF), there is a two-step process.

  1. Call the GET method of the desired resource. Each resource that has a physical file will contain a property in their model called PathToFile. When receiving the JSON data, the PathToFile fied will have an encoded path to the desired file.
  2. Call the GetFile resource and pass in the PathToFile value in a query string parameter called filePath. This method will decode the path and retrieve the file from our file system. It will then load it into the response object with the proper content type.
For example, to retrieve the work order photo attached to work order photo ID: 1234, we would need to do the following:
  1. Call the work order photo GET method (api/workorderphotos/1234). The work order photo JSON will be returned with the field PathToFile, which will have a value that looks something like: continental01%5c30%5cWorkOrders%5c2014822162712750_638208377.jpg
  2. Call the GetFile resource with the PathToFile value (api/files?filePath=continental01%5c30%5cWorkOrders%5c2014822162712750_638208377.jpg)
The following is a complete list of routes where the api/files?filePath={filePath} route must be called after retrieving the PathToFile value:
  Documents
  • residentapi/documents/{Id}
  • residentapi/properties/{PropertyId}/documents?documentTypeId={documentTypeId}&documentSubTypeId={documentSubTypeId}&startDate={startDate}&endDate={endDate}&page={page}&pageSize={pageSize}
  Violation Photos [Not Yet Implemented]
  • residentapi/violationphotos/{Id}
  • residentapi/violations/{ViolationId}/violationphotos?page={page}&pageSize={pageSize}
  • residentapi/properties/{PropertyId}/violationphotos?page={page}&pageSize={pageSize}
  • residentapi/units/{UnitId}/violationphotos?page={page}&pageSize={pageSize}
  Violation Letters [Not Yet Implemented]
  • residentapi/violations/{ViolationId}/violationletters?page={page}&pageSize={pageSize}
  • residentapi/properties/{PropertyId}/violationletters?page={page}&pageSize={pageSize}
  Work Orders Photos
  • residentapi/workorderphotos/{Id}
  • residentapi/workorders/{WorkOrderId}/workorderphotos?page={page}&pageSize={pageSize}
  • residentapi/properties/{PropertyId}/workorderphotos?page={page}&pageSize={pageSize}
* Navigate to the list of API Methods for more details on each route


File Upload

To upload a physical file, the following steps must be followed:

  1. The POST resource of the desired module must be called.
    For example, to insert a work order photo, the api/workorderphotos route must be called using http POST.
  2. The content type must be set as multipart/form-data. In the request header, "Content-Type: multipart/form-data" must be present.
  3. The request body must contain all form data.
The illustration below shows an example of each step:

The following is a complete list of routes where a file can be uploaded and the directions above must be applied:
  • Violation Photos: api/violationphotos [Not Yet Implemented]
  • Work Order Photos: api/workorderphotos
* Navigate to the list of API Methods for more details on each route