Accessing the C# SDK object model
Learn about Quickstart and how you can use it to quickly set up and run eSignature REST API code examples.
Instantiating the models
When making a specific eSignature REST API call using the C# SDK, you usually have to include a specific class used for the data sent or returned as part of that API request. The C# classes used to pass data to and from API endpoints are called
models, and all use standard C# properties to get and set values. We will use the
Brand object as an example. The
Brand class can be found in our open-source GitHub repository. Each data member of the class is decorated by a
DataMember attribute and includes the standard triple-slash (XML documentation) descriptive comments that the Visual Studio IntelliSense feature uses to help developers when accessing public libraries.
BrandName is an example of a string that is part of the
Brand class that has both a public getter and a public setter. To set the
BrandName property of a
Brand object, use this code:
To get the value of the
BrandName property, you can simply use the string that it returns:
Most C# SDK models also provide a constructor that enables developers to initialize many of the object’s properties at the same time that it is created. Instead of using the getter and setter methods, you could set property values in the constructor code when you create the object. For example, you could instantiate a new
Brand object and set some of its properties at the same time:
Making API calls
To construct an API call, you need to include both the model and the
accountId of the account making the API call, each time you make a request. That information is not part of the
DocuSignClient object, but is required by the SDK to be able to generate the URL for the specific endpoint.
To create a new brand, for instance, you would instantiate a
Brand object and populate it with initial values as shown above, then add the
accountId to call the API:
Naming conventions
The C# SDK uses the Conventions for Reusable .NET Libraries. All public classes and methods use PascalCase and all parameters use camelCase.
-
The categories in the API Reference are all called
Apisin the C# SDK and can be found in theDocuSign.eSign.Apinamespace. As an example, AccountsApi would be the class you use to make API calls for endpoints in the Accounts Category in the API Reference. -
The resources within each category in the API Reference do not have direct counterparts in the C# SDK. Instead, each API method in each resource corresponds to a C# public method within the class corresponding to the top-level category. The method name is always PascalCase and is a combination of the verb and the proper noun that is being worked upon. For example, for the AccountBrands:update API method, the C# method name within the
AccountsApiclass is UpdateBrand. -
The parameters for each API method are based on the API Reference. Every API call has to specify the
accountIdas its first parameter, required to determine which account is making the API request. The remaining parameters are defined per API call in the documentation and may include optional parameters. Parameter names are always written in camelCase. -
The request and response objects (if they exist; some methods have one or the other) are all defined as objects in the
DocuSign.eSign.Modelnamespace as public classes. These classes are a deserialized version of the JSON that is sent by the REST API. For example, the UpdateBrand method returns an object called Brand, which represents the response of the API call.
Models do not include any methods; they only include properties that have getters and setters. For any array returned by the JSON, the model would include a
List<T> with elements corresponding to that information where
T can be another model or a simple type (typically a string). All models also implement two interfaces:
IEquatable<T> and
IValidatableObject to support comparison as well as cleanup of unused objects.