Class RestApi
public class RestApi : IRestApi
- Inheritance
-
RestApi
- Implements
- Inherited Members
Constructors
RestApi(Credentials)
Initializes a new instance of the RestApi class.
public RestApi(Credentials credentials)
Parameters
credentialsCredentialsThe Credentials.
RestApi(string, string?, string?, string, string?, int, HttpMessageHandler?)
Initializes a new instance of the RestApi class.
public RestApi(string userName, string? password, string? sessionId, string database, string? server = null, int timeout = 300000, HttpMessageHandler? handler = null)
Parameters
userNamestringThe user name to use for authentication.
passwordstringThe password to use for authentication. Note: password OR sessionId are required. Both can be supplied.
sessionIdstringThe session ID if user is already authenticated. Note: password OR sessionId are required. Both can be supplied. If only session ID is supplied the API cannot re-authenticate.
databasestringThe name of the database the user belongs to.
serverstringThe server federation name. Default: my.geotab.com. Note: this should NOT be a specific server (my3.geotab.com) databases can be moved to different servers to maximize performance without warning.
timeoutintThe timeout for the requests in milliseconds (Default 300000).
handlerHttpMessageHandlerThe HttpMessageHandler to be used with the HttpClient request. The HttpMessageHandler provides additional control over see cref="HttpClient"/> request. The API object will not dispose of this object.
Properties
Database
Gets or sets the specific database on the server to which the API call is being made.
public string Database { get; set; }
Property Value
LoginResult
Gets or sets the result of the login request.
public LoginResult? LoginResult { get; set; }
Property Value
Password
Sets the user's password.
public string Password { set; }
Property Value
Server
Gets or sets the name of the server that the API call is being made to.
public string Server { get; set; }
Property Value
SessionId
Gets or sets the token generated from the authentication call which can be used to make the API call instead of the password.
public string? SessionId { get; set; }
Property Value
Timeout
Gets or sets the timeout for the requests in milliseconds.
public int Timeout { get; set; }
Property Value
UserName
Gets or sets the username (typically an email address) that identifies the user being authenticated.
public string UserName { get; set; }
Property Value
Methods
AuthenticateAsync(CancellationToken)
Authenticate the user in an async call.
public Task AuthenticateAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenThe CancellationToken.
Returns
- Task
A Task which is a result of calling AuthenticateImplAsync.
Clone()
Creates a new object that is a copy of the current instance.
public object Clone()
Returns
- object
A new object that is a copy of this instance.
GetAsync(string, CancellationToken)
Make a GET http request.
public Task<HttpResponseMessage> GetAsync(string url, CancellationToken cancellationToken = default)
Parameters
urlstringThe url for the REST api.
cancellationTokenCancellationTokenThe CancellationToken.
Returns
- Task<HttpResponseMessage>
The HttpResponseMessage which is the result of the api call.