Model DTO

Automated API uses different data transfer objects for each of the operations that can be performed. The most basic of these will the the one returned by a simple Get By Id call, or as a collection in a get call with no id specified.

Specified By Id

The generated ModelDTO Consider a generated service for a generic object called Model with the properties StringProp1, IntProp2, DateTimeProp3, and an assumed Id (Automated Appends a GUID Id by convention).

The pseudo code might be written for that intended model thusly.

Class Model
    public guid ModelId
    public string StringProp1
    public int IntProp2
    public datetime DateTimeProp3

Automated API will generate a ModelDTO of the following shape.

{
    "ModelId":"{expected guid}",
    "StringProp1":"this is a string",
    "IntProp2":"123",
    "DateTimeProp3":"2019-09-11 1200:00.0000"
}

This represents a ‘Model’ returned with a Get by ID or what would be returned from a creation call, which is designed such that the response would confirm correct input to the service.

Collections

The GET generic call without an id specified will return a collection.

In this case the generated service will automatically apply paging and uses the maximum page size of 25. What is returned will include two things.

  1. the collection of “Models” that the api is built on
  2. a pagination model which includes the details of the current page, next page, previous page and other information to help you make subsequent calls if necessary.

The response to the collection call will take the form:

{
    "models": [
        {
            "ModelId":"{expected guid for model 1}",
            "StringProp1":"this is a string",
            "IntProp2":"123",
            "DateTimeProp3":"2019-09-11 1200:00.0000"
        },
        {
            "ModelId":"{expected guid for model 2}",
            "StringProp1":"this is a second string",
            "IntProp2":"234",
            "DateTimeProp3":"2019-09-09 1200:00.0000"
        },
        {
            "ModelId":"{expected guid for model 3}",
            "StringProp1":"this is a third string",
            "IntProp2":"345",
            "DateTimeProp3":"2019-09-10 1200:00.0000"
        }
    ],
    "paginationMetadata": {
        "totalCount": 3,
        "pageSize": 25,
        "currentPage": 1,
        "totalPages": 1,
        "previousPageLink": "{url to previous page if available (or null)}",
        "nextPageLink": "{url to next page if available (or null)}"
    }
}