AQSamples Standard Request Response DTO Pattern - AquaticInformatics/aquarius-sdk-net GitHub Wiki
var request = new RequestDTO {Property1 = value1, Property2 = value2};
var response = client.Verb(request);
This is very similar to the AQTS Standard Request/Response DTO Pattern and is the pattern you will find yourself using over and over again as you consume the AQTS APIs:
- Create a request DTO object, setting only the properties you care about
- Invoke the appropriate HTTP Verb (GET/POST/DELETE/etc.)
- Parse the returned response DTO as needed to get your results.
- If an error occurs, a
SamplesApiException
will be thrown. See the AQSamples Error Handling wiki for details
Every REST API follows a Message-Based Web Service pattern. A request DTO (Data Transfer Object) captures all of the request parameters and a corresponding response DTO captures all of the response properties.
The Aquarius.Client
assembly and its dependencies handle all the JSON serialization/deserialization work, as well as all the HTTP request composition housekeeping of URL-encoding and path template substitution. As a result, your client code just deals with DTO objects.
All the public properties of DTOs have default values (0
for numeric data types, null
for strings or object types). If your code does not need to change a default request property, then there is no need to explicitly set it. This often results in very concise, wrist-friendly code.
The Aquarius.Client.dll
assembly includes a request and response DTO service model definition for every operation on every public API endpoint.