DocuSign CSharp Docs
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Properties | List of all members
DocuSign.eSign.Client.DocuSignClient Class Reference

DocuSignClient is mainly responsible for facilitating HTTP calls to the DocuSign APIs. More...

Inheritance diagram for DocuSign.eSign.Client.DocuSignClient:
DocuSign.eSign.Client.ApiClient

Public Member Functions

virtual void InterceptRequest (DocuSignRequest request)
 Allows for extending request processing for DocuSignClient generated code. More...
 
virtual void InterceptResponse (DocuSignRequest request, DocuSignResponse response)
 Allows for extending response processing for DocuSignClient generated code. More...
 
 DocuSignClient ()
 Initializes a new instance of DocuSignClient with default with default base path (https://www.docusign.net/restapi). More...
 
 DocuSignClient (Configuration configuration)
 Initializes a new instance of DocuSignClient using the provided configuration with the default base path (https://www.docusign.net/restapi). More...
 
 DocuSignClient (String apiBase, IWebProxy proxy=null)
 Initializes a new instance of DocuSignClient configured with the provided API base path and optional IWebProxy object More...
 
 DocuSignClient (String apiBase, String oAuthBase, IWebProxy proxy=null)
 Initializes a new instance of DocuSignClient with the provided API base path, OAuth base path, and optional IWebProxy object More...
 
 DocuSignClient (string apiBase, HttpClient apiClient)
 Initializes a new instance of DocuSignClient with the provided API base path and pre-configured HttpClient object More...
 
 DocuSignClient (string apiBase, IHttpClient client)
 Initializes a new instance of DocuSignClient with the provided API base path and pre-configured IHttpClient object More...
 
String GetBasePath ()
 
DocuSignRequest PrepareOAuthRequest (string oAuthBasePath, string path, HttpMethod method, List< KeyValuePair< string, string >> headerParams=null, List< KeyValuePair< string, string >> formParams=null)
 
DocuSignRequest PrepareRequest (string path, HttpMethod method, List< KeyValuePair< string, string >> queryParams=null, object postBody=null, List< KeyValuePair< string, string >> headerParams=null, List< KeyValuePair< string, string >> formParams=null, List< KeyValuePair< string, string >> pathParams=null, List< FileParameter > fileParams=null, string contentType=null, string contentDisposition=null)
 
DocuSignResponse CallApi (DocuSignRequest request)
 
async Task< DocuSignResponseCallApiAsync (DocuSignRequest request)
 
string EscapeString (string str)
 Escape string (url-encoded). More...
 
FileParameter ParameterToFile (string name, Stream stream)
 Create FileParameter based on Stream. More...
 
string ParameterToString (object obj)
 If parameter is DateTime, output in a formatted string (default ISO 8601), customizable with Configuration.DateTime. If parameter is a list, join the list with ",". Otherwise just return the string. More...
 
object Deserialize (DocuSignResponse response, Type type)
 Deserialize the JSON string into a proper object. More...
 
String Serialize (object obj, string contentType="application/json")
 Serialize an input (model) into JSON string More...
 
String SelectHeaderContentType (String[] contentTypes)
 Select the Content-Type header's value from the given content-type array: if JSON exists in the given array, use it; otherwise use the first one defined in 'consumes' More...
 
String SelectHeaderAccept (String[] accepts)
 Select the Accept header's value from the given accepts array: if JSON exists in the given array, use it; otherwise use all of them (joining into a string) More...
 
Uri GetAuthorizationUri (string clientId, List< string > scopes, string redirectUri, string responseType, string state=null)
 Helper method to configure the OAuth accessCode/implicit flow parameters More...
 
void SetBasePath (string basePath)
 Use this method to Set Base Path More...
 
void SetOAuthBasePath (string oauthBaseUri=null)
 Use this method to set custom OAuth Base Path. More...
 
OAuth.OAuthToken GenerateAccessToken (string clientId, string clientSecret, string code)
 GenerateAccessToken will exchange the authorization code for an access token and refresh tokens. More...
 
OAuth.UserInfo GetUserInfo (string accessToken)
 Get User Info method takes the accessToken to retrieve User Account Data. More...
 
OAuth.OAuthToken RequestJWTUserToken (string clientId, string userId, string oauthBasePath, Stream privateKeyStream, int expiresInHours, List< string > scopes=null)
 Request JWT User Token Configures the current instance of ApiClient with a fresh OAuth JWT access token from DocuSign More...
 
OAuth.OAuthToken RequestJWTUserToken (string clientId, string userId, string oauthBasePath, byte[] privateKeyBytes, int expiresInHours, List< string > scopes=null)
 Request JWT User Token Configures the current instance of ApiClient with a fresh OAuth JWT access token from DocuSign More...
 
OAuth.OAuthToken RequestJWTApplicationToken (string clientId, string oauthBasePath, byte[] privateKeyBytes, int expiresInHours, List< string > scopes=null)
 RESERVED FOR PARTNERS Request JWT Application Token More...
 

Static Public Member Functions

static String SerializeCsvToString (object obj)
 SerializeCsvToString - Interim method to Serialize the Request Object to CSV format More...
 
static String SerializeCsvToString< T > (List< T > obj)
 SerializeCsvToString - Interim method to Serialize the Request Object to CSV format More...
 
static string Base64Encode (string text)
 Encode string in base64 format. More...
 
static dynamic ConvertType (dynamic source, Type dest)
 Dynamically cast the object into target type. Ref: http://stackoverflow.com/questions/4925718/c-dynamic-runtime-cast More...
 
static byte [] ReadAsBytes (Stream input)
 Convert stream to byte array Credit/Ref: http://stackoverflow.com/a/221941/677735 More...
 
static string UrlEncode (string input)
 URL encode a string Credit/Ref: https://github.com/restsharp/RestSharp/blob/master/RestSharp/Extensions/StringExtensions.cs#L50 More...
 
static string SanitizeFilename (string filename)
 Sanitize filename by removing the path More...
 

Public Attributes

const string Production_REST_BasePath = "https://www.docusign.net/restapi"
 
const string Demo_REST_BasePath = "https://demo.docusign.net/restapi"
 
const string Stage_REST_BasePath = "https://stage.docusign.net/restapi"
 

Protected Member Functions

string BuildQueryString (string clientId, string scopes, string redirectUri, string responseType, string state)
 Builds a QueryString with the given parameters More...
 
string GetOAuthBasePath ()
 GetOAuthBasePath sets the basePath for the user account. More...
 

Static Protected Member Functions

static IHttpClient buildDefaultHttpClient (int timeout=Configuration.DefaultTimeoutValue, IWebProxy proxy=null)
 
static RSA CreateRSAKeyFromPem (string key)
 Creates an RSA Key from the given PEM key. More...
 

Protected Attributes

string basePath = Production_REST_BasePath
 
Uri baseUri => Uri.TryCreate(basePath, UriKind.Absolute, out Uri uri) ? uri : new Uri(Production_REST_BasePath)
 
string oAuthBasePath = OAuth.Production_OAuth_BasePath
 
string oAuthBasePathWithScheme => $"https://{oAuthBasePath}/"
 
Uri oAuthBaseUri => Uri.TryCreate(oAuthBasePathWithScheme, UriKind.Absolute, out Uri uri) ? uri : new Uri(OAuth.Production_OAuth_BasePath)
 
JsonSerializerSettings serializerSettings
 

Properties

Configuration Configuration [get, set]
 Gets or sets the Configuration. More...
 
IHttpClient RestClient [get, set]
 Gets or sets the RestClient. More...
 
IWebProxy Proxy .*[/\\](.*)$" [get, set]
 Gets or sets the Proxy of ApiClient. Default to null More...
 

Detailed Description

DocuSignClient is mainly responsible for facilitating HTTP calls to the DocuSign APIs.

Constructor & Destructor Documentation

◆ DocuSignClient() [1/6]

DocuSign.eSign.Client.DocuSignClient.DocuSignClient ( )
inline

Initializes a new instance of DocuSignClient with default with default base path (https://www.docusign.net/restapi).

◆ DocuSignClient() [2/6]

DocuSign.eSign.Client.DocuSignClient.DocuSignClient ( Configuration  configuration)
inline

Initializes a new instance of DocuSignClient using the provided configuration with the default base path (https://www.docusign.net/restapi).

Parameters
configurationProvided pre-populated Configuration object

◆ DocuSignClient() [3/6]

DocuSign.eSign.Client.DocuSignClient.DocuSignClient ( String  apiBase,
IWebProxy  proxy = null 
)
inline

Initializes a new instance of DocuSignClient configured with the provided API base path and optional IWebProxy object

Parameters
apiBaseThe API base path
proxyAn optional IWebProxy instance
Exceptions
ArgumentExceptionThwon when apiBase is null or empty

◆ DocuSignClient() [4/6]

DocuSign.eSign.Client.DocuSignClient.DocuSignClient ( String  apiBase,
String  oAuthBase,
IWebProxy  proxy = null 
)
inline

Initializes a new instance of DocuSignClient with the provided API base path, OAuth base path, and optional IWebProxy object

Parameters
apiBaseThe API base path
oAuthBaseThe oAuth base path
proxyAn optional IWebProxy instance
Exceptions
ArgumentExceptionThrown when apiBase or oAuthBase are null or empty

◆ DocuSignClient() [5/6]

DocuSign.eSign.Client.DocuSignClient.DocuSignClient ( string  apiBase,
HttpClient  apiClient 
)
inline

Initializes a new instance of DocuSignClient with the provided API base path and pre-configured HttpClient object

Parameters
apiBaseThe API base path
apiClientAn instance of an HttpClient object

◆ DocuSignClient() [6/6]

DocuSign.eSign.Client.DocuSignClient.DocuSignClient ( string  apiBase,
IHttpClient  client 
)
inline

Initializes a new instance of DocuSignClient with the provided API base path and pre-configured IHttpClient object

Parameters
apiBase
client

Member Function Documentation

◆ Base64Encode()

static string DocuSign.eSign.Client.DocuSignClient.Base64Encode ( string  text)
inlinestatic

Encode string in base64 format.

Parameters
textString to be encoded.
Returns
Encoded string.

◆ BuildQueryString()

string DocuSign.eSign.Client.DocuSignClient.BuildQueryString ( string  clientId,
string  scopes,
string  redirectUri,
string  responseType,
string  state 
)
inlineprotected

Builds a QueryString with the given parameters

Parameters
clientId
scopes
redirectUri
responseType
state
Returns
Formatted Query String

◆ ConvertType()

static dynamic DocuSign.eSign.Client.DocuSignClient.ConvertType ( dynamic  source,
Type  dest 
)
inlinestatic

Dynamically cast the object into target type. Ref: http://stackoverflow.com/questions/4925718/c-dynamic-runtime-cast

Parameters
sourceObject to be casted
destTarget type
Returns
Casted object

◆ CreateRSAKeyFromPem()

static RSA DocuSign.eSign.Client.DocuSignClient.CreateRSAKeyFromPem ( string  key)
inlinestaticprotected

Creates an RSA Key from the given PEM key.

Parameters
key
Returns
RSACryptoServiceProvider using the "key"

◆ Deserialize()

object DocuSign.eSign.Client.DocuSignClient.Deserialize ( DocuSignResponse  response,
Type  type 
)
inline

Deserialize the JSON string into a proper object.

Parameters
responseThe HTTP response.
typeObject type.
Returns
Object representation of the JSON string.

◆ EscapeString()

string DocuSign.eSign.Client.DocuSignClient.EscapeString ( string  str)
inline

Escape string (url-encoded).

Parameters
strString to be escaped.
Returns
Escaped string.

◆ GenerateAccessToken()

OAuth.OAuthToken DocuSign.eSign.Client.DocuSignClient.GenerateAccessToken ( string  clientId,
string  clientSecret,
string  code 
)
inline

GenerateAccessToken will exchange the authorization code for an access token and refresh tokens.

Parameters
clientIdOAuth2 client ID: Identifies the client making the request.
clientSecretthe secret key you generated when you set up the integration in DocuSign Admin console.
codeThe authorization code that you received from the GetAuthorizationUri callback.
Returns
OAuth.OAuthToken object. ApiException if the HTTP call status is different than 2xx. IOException if there is a problem while parsing the reponse object.

◆ GetAuthorizationUri()

Uri DocuSign.eSign.Client.DocuSignClient.GetAuthorizationUri ( string  clientId,
List< string >  scopes,
string  redirectUri,
string  responseType,
string  state = null 
)
inline

Helper method to configure the OAuth accessCode/implicit flow parameters

Parameters
clientIdOAuth2 client ID: Identifies the client making the request.
scopesthe list of requested scopes. Client applications may be scoped to a limited set of system access.
redirectUrithis determines where to deliver the response containing the authorization code or access token.
responseTypedetermines the response type of the authorization request.
Note: these response types are mutually exclusive for a client application. A public/native client application may only request a response type of "token"; a private/trusted client application may only request a response type of "code".
stateAllows for arbitrary state that may be useful to your application. The value in this parameter will be round-tripped along with the response so you can make sure it didn't change.
Returns

◆ GetOAuthBasePath()

string DocuSign.eSign.Client.DocuSignClient.GetOAuthBasePath ( )
inlineprotected

GetOAuthBasePath sets the basePath for the user account.

Returns
If the current base path is demo then it sets the demo account as the basePath, else it sets the Production account as the basePath.

◆ GetUserInfo()

OAuth.UserInfo DocuSign.eSign.Client.DocuSignClient.GetUserInfo ( string  accessToken)
inline

Get User Info method takes the accessToken to retrieve User Account Data.

Parameters
accessToken
Returns
The User Info model.

◆ InterceptRequest()

virtual void DocuSign.eSign.Client.DocuSignClient.InterceptRequest ( DocuSignRequest  request)
inlinevirtual

Allows for extending request processing for DocuSignClient generated code.

Parameters
requestThe IHttpClient request object

◆ InterceptResponse()

virtual void DocuSign.eSign.Client.DocuSignClient.InterceptResponse ( DocuSignRequest  request,
DocuSignResponse  response 
)
inlinevirtual

Allows for extending response processing for DocuSignClient generated code.

Parameters
requestThe DocuSignRequest request object
responseThe DocuSignResponse response object

◆ ParameterToFile()

FileParameter DocuSign.eSign.Client.DocuSignClient.ParameterToFile ( string  name,
Stream  stream 
)
inline

Create FileParameter based on Stream.

Parameters
nameParameter name.
streamInput stream.
Returns
FileParameter.

◆ ParameterToString()

string DocuSign.eSign.Client.DocuSignClient.ParameterToString ( object  obj)
inline

If parameter is DateTime, output in a formatted string (default ISO 8601), customizable with Configuration.DateTime. If parameter is a list, join the list with ",". Otherwise just return the string.

Parameters
objThe parameter (header, path, query, form).
Returns
Formatted string.

◆ ReadAsBytes()

static byte [] DocuSign.eSign.Client.DocuSignClient.ReadAsBytes ( Stream  input)
inlinestatic

Convert stream to byte array Credit/Ref: http://stackoverflow.com/a/221941/677735

Parameters
inputInput stream to be converted
Returns
Byte array

◆ RequestJWTApplicationToken()

OAuth.OAuthToken DocuSign.eSign.Client.DocuSignClient.RequestJWTApplicationToken ( string  clientId,
string  oauthBasePath,
byte []  privateKeyBytes,
int  expiresInHours,
List< string >  scopes = null 
)
inline

RESERVED FOR PARTNERS Request JWT Application Token

Parameters
clientIdDocuSign OAuth Client Id(AKA Integrator Key)
oauthBasePathDocuSign OAuth base path OAuth.Demo_OAuth_BasePath OAuth.Production_OAuth_BasePath OAuth.Stage_OAuth_BasePath
See also
GetOAuthBasePath(), SetOAuthBasePath(string)
privateKeyBytesThe byte contents of the RSA private key
expiresInHoursNumber of hours remaining before the JWT assertion is considered as invalid
scopesOptional. The list of requested scopes may include (but not limited to) You can also pass any advanced scope. OAuth.Scope_SIGNATURE OAuth.Scope_IMPERSONATION OAuth.Scope_EXTENDED
Returns
The JWT application token

◆ RequestJWTUserToken() [1/2]

OAuth.OAuthToken DocuSign.eSign.Client.DocuSignClient.RequestJWTUserToken ( string  clientId,
string  userId,
string  oauthBasePath,
Stream  privateKeyStream,
int  expiresInHours,
List< string >  scopes = null 
)
inline

Request JWT User Token Configures the current instance of ApiClient with a fresh OAuth JWT access token from DocuSign

Parameters
clientIdDocuSign OAuth Client Id(AKA Integrator Key)
userIdDocuSign user Id to be impersonated(This is a UUID)
oauthBasePathDocuSign OAuth base path OAuth.Demo_OAuth_BasePath OAuth.Production_OAuth_BasePath OAuth.Stage_OAuth_BasePath
See also
GetOAuthBasePath(), SetOAuthBasePath(string)
privateKeyStreamThe Stream of the RSA private key
expiresInHoursNumber of hours remaining before the JWT assertion is considered as invalid
scopesOptional. The list of requested scopes may include (but not limited to) OAuth.Scope_SIGNATURE OAuth.Scope_IMPERSONATION OAuth.Scope_EXTENDED
Returns
The JWT user token

◆ RequestJWTUserToken() [2/2]

OAuth.OAuthToken DocuSign.eSign.Client.DocuSignClient.RequestJWTUserToken ( string  clientId,
string  userId,
string  oauthBasePath,
byte []  privateKeyBytes,
int  expiresInHours,
List< string >  scopes = null 
)
inline

Request JWT User Token Configures the current instance of ApiClient with a fresh OAuth JWT access token from DocuSign

Parameters
clientIdDocuSign OAuth Client Id(AKA Integrator Key)
userIdDocuSign user Id to be impersonated(This is a UUID)
oauthBasePathDocuSign OAuth base path OAuth.Demo_OAuth_BasePath OAuth.Production_OAuth_BasePath OAuth.Stage_OAuth_BasePath
See also
GetOAuthBasePath(), SetOAuthBasePath(string)
privateKeyBytesThe byte contents of the RSA private key
expiresInHoursNumber of hours remaining before the JWT assertion is considered as invalid
scopesOptional. The list of requested scopes may include (but not limited to) You can also pass any advanced scope. OAuth.Scope_SIGNATURE OAuth.Scope_IMPERSONATION OAuth.Scope_EXTENDED
Returns
The JWT user token

◆ SanitizeFilename()

static string DocuSign.eSign.Client.DocuSignClient.SanitizeFilename ( string  filename)
inlinestatic

Sanitize filename by removing the path

Parameters
filenameFilename
Returns
Filename

◆ SelectHeaderAccept()

String DocuSign.eSign.Client.DocuSignClient.SelectHeaderAccept ( String []  accepts)
inline

Select the Accept header's value from the given accepts array: if JSON exists in the given array, use it; otherwise use all of them (joining into a string)

Parameters
acceptsThe accepts array to select from.
Returns
The Accept header to use.

◆ SelectHeaderContentType()

String DocuSign.eSign.Client.DocuSignClient.SelectHeaderContentType ( String []  contentTypes)
inline

Select the Content-Type header's value from the given content-type array: if JSON exists in the given array, use it; otherwise use the first one defined in 'consumes'

Parameters
contentTypesThe Content-Type array to select from.
Returns
The Content-Type header to use.

◆ Serialize()

String DocuSign.eSign.Client.DocuSignClient.Serialize ( object  obj,
string  contentType = "application/json" 
)
inline

Serialize an input (model) into JSON string

Parameters
objObject.
contentType
Returns
JSON string.

◆ SerializeCsvToString()

static String DocuSign.eSign.Client.DocuSignClient.SerializeCsvToString ( object  obj)
inlinestatic

SerializeCsvToString - Interim method to Serialize the Request Object to CSV format

Parameters
obj
Returns

◆ SerializeCsvToString< T >()

static String DocuSign.eSign.Client.DocuSignClient.SerializeCsvToString< T > ( List< T >  obj)
inlinestatic

SerializeCsvToString - Interim method to Serialize the Request Object to CSV format

Template Parameters
T
Parameters
obj
Returns
Type Constraints
T :class 

◆ SetBasePath()

void DocuSign.eSign.Client.DocuSignClient.SetBasePath ( string  basePath)
inline

Use this method to Set Base Path

Parameters
basePath

◆ SetOAuthBasePath()

void DocuSign.eSign.Client.DocuSignClient.SetOAuthBasePath ( string  oauthBaseUri = null)
inline

Use this method to set custom OAuth Base Path.

Parameters
oauthBaseUriOptional custom base path value. If not provided we will derive it according to the ApiClient basePath value.

◆ UrlEncode()

static string DocuSign.eSign.Client.DocuSignClient.UrlEncode ( string  input)
inlinestatic

URL encode a string Credit/Ref: https://github.com/restsharp/RestSharp/blob/master/RestSharp/Extensions/StringExtensions.cs#L50

Parameters
inputString to be URL encoded
Returns
Byte array

Member Data Documentation

◆ serializerSettings

JsonSerializerSettings DocuSign.eSign.Client.DocuSignClient.serializerSettings
protected
Initial value:
= new JsonSerializerSettings
{
ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor
}

Property Documentation

◆ Configuration

Configuration DocuSign.eSign.Client.DocuSignClient.Configuration
getset

Gets or sets the Configuration.

An instance of the Configuration.

◆ Proxy

IWebProxy DocuSign.eSign.Client.DocuSignClient.Proxy .*[/\\](.*)$"
getset

Gets or sets the Proxy of ApiClient. Default to null

Timeout.

◆ RestClient

IHttpClient DocuSign.eSign.Client.DocuSignClient.RestClient
getset

Gets or sets the RestClient.

An instance of the RestClient


The documentation for this class was generated from the following file: