Show / Hide Table of Contents

Class EthosClient

Base HTTP client to interact with Ellucian Ethos API. This class is mostly used internally by the SDK to interact with the Ethos Integration API to retrieve objects via HTTP(S). It lightly wraps the library for simplicity.

Inheritance
System.Object
EthosClient
EthosErrorsClient
EthosMessagesClient
EthosProxyClient
EthosConfigurationClient
Namespace: Ellucian.Ethos.Integration.Client
Assembly: Ellucian.Ethos.Integration.dll
Syntax
public class EthosClient : object

Constructors

EthosClient(String, HttpClient)

Constructor called by subclasses of this class.

Declaration
public EthosClient(string apiKey, HttpClient client)
Parameters
Type Name Description
System.String apiKey

An api key .

HttpClient client

A .

Fields

expirationMinutes

Default token expiration time.

Declaration
int expirationMinutes
Field Value
Type Description
System.Int32

Properties

ApiKey

A api key.

Declaration
string ApiKey { }
Property Value
Type Description
System.String

AutoRefresh

Gets/Sets the automatic refresh behavior for access tokens.

Declaration
public bool AutoRefresh { get; set; }
Property Value
Type Description
System.Boolean

EthosResponseBuilder

Declaration
protected EthosResponseBuilder EthosResponseBuilder { get; }
Property Value
Type Description
EthosResponseBuilder

Used to build an EthosResponse from the given HttpResponse in the responseHandler of each call made.

ExpirationMinutes

Gets/Sets the number of minutes that a new access token will be valid.

Declaration
public int ExpirationMinutes { get; set; }
Property Value
Type Description
System.Int32

HttpProtocolClientBuilder

Declaration
protected IHttpProtocolClientBuilder HttpProtocolClientBuilder { get; }
Property Value
Type Description
IHttpProtocolClientBuilder

The Http client builder which builds an used for making secure calls to the Ethos Integration API.

Region

Supported region.

Declaration
public SupportedRegions Region { get; set; }
Property Value
Type Description
SupportedRegions

Token

Declaration
AccessToken Token { }
Property Value
Type Description
AccessToken

AccessToken used when making calls through the SDK to the Ethos Integration APIs. This is specified by the subclasses of this class.

Methods

AddAccessTokenAuthHeaderAsync(Dictionary<String, String>)

Gets an access token and add it authorization key to the header.

Declaration
async Task AddAccessTokenAuthHeaderAsync(Dictionary<string, string> headers)
Parameters
Type Name Description
Dictionary<System.String, System.String> headers
Returns
Type Description
Task

A

AttachHeaders(HttpClient, Dictionary<String, String>)

Attaches headers to a request.

Declaration
void AttachHeaders(HttpClient request, Dictionary<string, string> headers)
Parameters
Type Name Description
HttpClient request

The request being made.

Dictionary<System.String, System.String> headers

A map of headers to attach to the request.

DeleteAsync(Dictionary<String, String>, String)

Send an HTTP or HTTPS DELETE request to a given URL.

Declaration
public async Task DeleteAsync(Dictionary<string, string> headers, string url)
Parameters
Type Name Description
Dictionary<System.String, System.String> headers

A dictionary containing HTTP headers. Usually this will contain the authorization header at minimum.

System.String url

URL to post to.

Returns
Type Description
Task

GetAccessTokenAsync()

Gets an access token. If this client does not currently have an access token, it will make a call to the Ethos Integration /auth endpoint to get one.Additionally, if autoRefresh is set to true, this will check to see if the current token is expired and, if so, get a new one.

Declaration
public async Task<AccessToken> GetAccessTokenAsync()
Returns
Type Description
Task<AccessToken>

An access token

GetAsync(Dictionary<String, String>, String)

Make an HTTP GET request with the given headers. This will return the result as a string so any conversion to JSON or other results will need to be done on the caller. Also note that HTTP status codes that throw errors will come back as an exception.

Declaration
public async Task<EthosResponse> GetAsync(Dictionary<string, string> headers, string url)
Parameters
Type Name Description
Dictionary<System.String, System.String> headers

headers attached to the request. typically would include authentication.

System.String url

URL to make the request to.

Returns
Type Description
Task<EthosResponse>

The result of the request as a string.

GetAsync(String)

Convenience method to make an HTTP call without headers.

Declaration
public Task<EthosResponse> GetAsync(string url)
Parameters
Type Name Description
System.String url

The URL to GET.

Returns
Type Description
Task<EthosResponse>

The response as an EthosRespone containing response headers, response body (content) and the HTTP status code.

GetHttpClient()

Returns the HttpClient built by the httpProtocolClientBuilder. Used primarily by this class.

Declaration
HttpClient GetHttpClient()
Returns
Type Description
HttpClient

The HttpClient used to make Http calls.

GetNewTokenAsync()

Gets a new access token.

Declaration
async Task<AccessToken> GetNewTokenAsync()
Returns
Type Description
Task<AccessToken>

An access token

GetStringAsync(Dictionary<String, String>, String)

Make an HTTP GET request with no headers. This will return the result as a string so any conversion to JSON or other results will need to be done on the caller. Also note that HTTP status codes that throw errors will come back as an exception.

Declaration
public async Task<string> GetStringAsync(Dictionary<string, string> headers, string url)
Parameters
Type Name Description
Dictionary<System.String, System.String> headers

headers attached to the request. typically would include authentication.

System.String url

URL to make the request to.

Returns
Type Description
Task<System.String>

The result of the request as a string.

HeadAsync(String)

Make an HTTP HEAD request against the given URL. This will return an EthosResponse object containing the response headers.Note that the HTTP status codes that throw errors will come back as an exception via the responseHandler

Declaration
public async Task<EthosResponse> HeadAsync(string url)
Parameters
Type Name Description
System.String url

The Request URL.

Returns
Type Description
Task<EthosResponse>

The response as an Ethos Response containing headers and HTTP status code.

PostAsync(Dictionary<String, String>, String, String)

Post to the Ethos Integration REST API to get objects back to translate to the SDK model.

Declaration
public async Task<EthosResponse> PostAsync(Dictionary<string, string> headers, string url, string body = "")
Parameters
Type Name Description
Dictionary<System.String, System.String> headers

A dictionary containing HTTP headers. Usually this will contained the authorization header at minimum.

System.String url

URL to post to.

System.String body

The JSON body to post to the URL endpoint.

Returns
Type Description
Task<EthosResponse>

A EthosResponse.

PutAsync(Dictionary<String, String>, String, String)

Send a PUT request to the Ethos Integration REST API to get objects back to translate to the SDK model.

Declaration
public async Task<EthosResponse> PutAsync(Dictionary<string, string> headers, string url, string body = "")
Parameters
Type Name Description
Dictionary<System.String, System.String> headers

A dictionary containing HTTP headers. Usually this will contained the authorization header at minimum.

System.String url

URL to PUT to.

System.String body

The JSON body to PUT to the URL endpoint.

Returns
Type Description
Task<EthosResponse>

A EthosResponse.

ResponseHandlerAsync(HttpResponseMessage)

The responseHandler used for each request made. Either supplies an EthosResponse, or throws an HttpResponseException if the HttpStatus code is not a successful code.

Declaration
protected async Task<EthosResponse> ResponseHandlerAsync(HttpResponseMessage response)
Parameters
Type Name Description
HttpResponseMessage response
Returns
Type Description
Task<EthosResponse>

A of EthosResponse.

In This Article
Back to top Generated by DocFX