Show / Hide Table of Contents

Class EthosResponseConverter

Converter class extending the EthosResponseBuilder, the primary purpose of which is to handle manipulation of the response body content for paging calculations, such as trimming the response body content for a given offset or number of rows.Also converts an EthosResponse to format.

Inheritance
System.Object
EthosResponseBuilder
EthosResponseConverter
Inherited Members
EthosResponseBuilder.BuildEthosResponseAsync(HttpResponseMessage)
Namespace: Ellucian.Ethos.Integration.Client
Assembly: Ellucian.Ethos.Integration.dll
Syntax
public class EthosResponseConverter : EthosResponseBuilder

Methods

CopyHeaders(EthosResponse)

Returns a copy of the headers map from the given EthosResponse. Uses the HeadersMap in the EthosResponseBuilder class to copy headers into the returned headers map.

Declaration
HttpResponseHeaders CopyHeaders(EthosResponse sourceResponse)
Parameters
Type Name Description
EthosResponse sourceResponse
Returns
Type Description
HttpResponseHeaders

Returns Http Response Header values.

ParamsValid(EthosResponse, Int32)

Validates whether the given params are valid. If the given sourceResponse is not null, and contains content that is not null or empty, and if the positiveParam( which is intended to be either the offset or numRows ) is not less than 0 (positive), then returns true. Otherwise returns false.

Declaration
bool ParamsValid(EthosResponse sourceResponse, int positiveParam)
Parameters
Type Name Description
EthosResponse sourceResponse

The EthosResponse to validate the content for.

System.Int32 positiveParam

Should be either the offset or numRows as called from other methods.

Returns
Type Description
System.Boolean

False if the given sourceResponse is null, or contains null or empty content, or if the positive param is less than 0, true otherwise.

ToCNList(EthosResponse)

Converts the given ethosResponse to a list of ChangeNotification object.

Declaration
public IEnumerable<ChangeNotification> ToCNList(EthosResponse ethosResponse)
Parameters
Type Name Description
EthosResponse ethosResponse

The EthosResponse to convert containing content for the ChangeNotifications.

Returns
Type Description
IEnumerable<ChangeNotification>

A list of ChangeNotifications from the content of the given ethosResponse, or null if the ethosResponse is null or it's content is null or blank.

ToContentString(EthosResponse)

Returns the content body of the given EthosResponse, or null if the EthosResponse is null.

Declaration
public string ToContentString(EthosResponse ethosResponse)
Parameters
Type Name Description
EthosResponse ethosResponse

The EthosResponse to get the content body from.

Returns
Type Description
System.String

The content body of the given EthosResponse.

ToEthosErrorList(EthosResponse)

Converts an ethosResponse to a list of EthosError objects. The given ethosResponse.getContent() should contain an entire page of errors as an errors array in JSON format.

Declaration
public IEnumerable<EthosError> ToEthosErrorList(EthosResponse ethosResponse)
Parameters
Type Name Description
EthosResponse ethosResponse

The EthosResponse to convert containing content for a page of EthosErrors.

Returns
Type Description
IEnumerable<EthosError>

An IEnumerable of EthosErrors from the content of the given ethosResponse, or an empty list if the ethosResponse is null or it's content is null or blank.

ToJArray(EthosResponse)

Returns a representation of the content body of the given EthosResponse.

Declaration
public JArray ToJArray(EthosResponse ethosResponse)
Parameters
Type Name Description
EthosResponse ethosResponse

The given EthosResponse to convert to a .

Returns
Type Description
JArray

A containing the content body of the given EthosResponse

ToJArray(IEnumerable<EthosResponse>)

Converts the given list of EthosResponse objects into a , where each item in the array is a single resource. This combines all the pages of data from each response object into a top-level array of resources. It is expected that the EthosResponse objects have a content in a JSON array format. If the response is not a JSON array, an exception will be thrown while trying to deserialize it.

Declaration
public JArray ToJArray(IEnumerable<EthosResponse> ethosResponseList)
Parameters
Type Name Description
IEnumerable<EthosResponse> ethosResponseList

The list of EthosResponse objects to convert to a .

Returns
Type Description
JArray

a where each item in the array is a single resource, or an empty list if the given ethosResponseList is null.

ToJArrayList(IEnumerable<EthosResponse>)

Converts the given list of EthosResponse objects into a list of , where each in the list contains the content body of the givenEthosResponse in the ethosResponseList. The expectation is that each EthosResponse in the given list contains a page of resources, and therefore each JArray in the returned list contains that same page of resources as a JArray.

Declaration
public IEnumerable<JArray> ToJArrayList(IEnumerable<EthosResponse> ethosResponseList)
Parameters
Type Name Description
IEnumerable<EthosResponse> ethosResponseList

The list of EthosResponse objects to convert to a list of

Returns
Type Description
IEnumerable<JArray>

A list of where each in the list contains a page of resources from the corresponding EthosResponse object in the ethosResponseList, or an empty list if the given ethosResponseList is null.

ToJObjectSingle(EthosResponse)

Returns a representation of the content body of the given EthosResponse.

Declaration
public JObject ToJObjectSingle(EthosResponse ethosResponse)
Parameters
Type Name Description
EthosResponse ethosResponse

The given EthosResponse to convert to a .

Returns
Type Description
JObject

A containing the content body of the given EthosResponse

ToPagedStringList(IEnumerable<EthosResponse>)

Converts the given list of EthosResponse objects into a list of , where each in the list is the content body of the given EthosResponse in the ethosResponseList. The expectation is that each EthosResponse in the given list contains a page of resources, and therefore each string in the returned list contains that same page of resources as a string.

Declaration
public IEnumerable<string> ToPagedStringList(IEnumerable<EthosResponse> ethosResponseList)
Parameters
Type Name Description
IEnumerable<EthosResponse> ethosResponseList

The list of EthosResponse objects to convert to a list of (s).

Returns
Type Description
IEnumerable<System.String>

a list of where each in the list contains a page of resources from the corresponding EthosResponse object in the ethosResponseList, or an empty list if the given ethosResponseList is null.

ToSingleEthosError(EthosResponse)

Converts an EthosResponse to an EthosError object. The given ethosResponse.Content should contain data for only a single error, and not an entire page of errors.

Declaration
public EthosError ToSingleEthosError(EthosResponse ethosResponse)
Parameters
Type Name Description
EthosResponse ethosResponse

An EthosError from the content of the given ethosResponse, or null if the ethosResponse is null or its content is null or blank.

Returns
Type Description
EthosError

EthosError with error content.

ToStringList(IEnumerable<EthosResponse>)

Converts the given list of EthosResponse objects into a list of , where each in the list is a single resource. This combines all the pages of data from each response object into a top-level list of resources. It is expected that the EthosResponse objects have a content in a JSON array format. If the response is not a JSON array, an exception will be thrown while trying to deserialize it.

Declaration
public IEnumerable<string> ToStringList(IEnumerable<EthosResponse> ethosResponseList)
Parameters
Type Name Description
IEnumerable<EthosResponse> ethosResponseList

The list of EthosResponse objects to convert to a list of (s).

Returns
Type Description
IEnumerable<System.String>

a list of where each in the list is a single resource, or an empty list if the given ethosResponseList is null.

TrimContentForNumRows(EthosResponse, Int32)

Takes the given EthosResponse and trims it's content for the given number of rows.
For example, if the given content contains 10 rows, and numRows is 7, the returned EthosResponse content will contain rows 0 through 6 (for a total of 7) of the sourceResponse content. The returned EthosResponse will also contain the headers and Http status code from the given sourceResponse.

Declaration
public EthosResponse TrimContentForNumRows(EthosResponse sourceResponse, int numRows)
Parameters
Type Name Description
EthosResponse sourceResponse

The EthosResponse to trim content for.

System.Int32 numRows

The number of rows to trim the content for.

Returns
Type Description
EthosResponse

An EthosResponse containing the same content as the sourceResponse, minus the rows in thesourceResponse which occur after numRows - 1. The returned EthosResponse will also contain the headers and Http status code from the givensourceResponse. If the sourceResponse is null, if thesourceResponse content is null or empty, or if the numRows is negative, the original sourceResponse will be returned unchanged.

TrimContentFromOffset(EthosResponse, Int32)

Takes the given EthosResponse and trims it's content from the given offset. For example, if the given content contains 10 rows, and the offset is 3, the returned EthosResponse content will contain rows 3 through the end of the sourceResponse content. The returned EthosResponse will also contain the headers and Http status code from the given sourceResponse.

Declaration
public EthosResponse TrimContentFromOffset(EthosResponse sourceResponse, int offset)
Parameters
Type Name Description
EthosResponse sourceResponse

The EthosResponse to trim content for.

System.Int32 offset

The offset (row num) from which to begin trimming content.

Returns
Type Description
EthosResponse

An EthosResponse containing the same content as the sourceResponse, minus the rows in thesourceResponse which occurred before the given offset. The returned EthosResponse will also contain the headers and Http status code from the givensourceResponse. If the sourceResponse is null, if thesourceResponse content is null or empty, or if the offset is negative, the original sourceResponse will be returned unchanged.

TrimContentFromOffsetForNumRows(EthosResponse, Int32, Int32)

Takes the given EthosResponse and trims it's content from the given offset for the given number of rows. For example, if the given content contains 10 rows, the offset is 3, and numRows is 7, the returnedEthosResponse content will contain rows 3 through 6 (for a total of 4) of thesourceResponse content. The returned EthosResponse will also contain the headers and Http status code from the given sourceResponse.

Declaration
public EthosResponse TrimContentFromOffsetForNumRows(EthosResponse sourceResponse, int offset, int numRows)
Parameters
Type Name Description
EthosResponse sourceResponse

The EthosResponse to trim content for.

System.Int32 offset

The offset (row num) from which to begin trimming content.

System.Int32 numRows

The number of rows to trim the content for.

Returns
Type Description
EthosResponse

An EthosResponse containing the same content as the sourceResponse, minus the rows in the sourceResponse which occur before the offset and after numRows - 1. The returned EthosResponse will also contain the headers and Http status code from the given sourceResponse. If the sourceResponse is null, if the sourceResponse content is null or empty, or if the offset is negative, the original sourceResponse will be returned unchanged. If the offset is positive but the numRows is negative, then the EthosResponse will contain the same content as the sourceResponse, minus the rows in the sourceResponse which occur before the offset, just as what TrimContentFromOffset(EthosResponse, Int32) returns.

In This Article
Back to top Generated by DocFX