Show / Hide Table of Contents

Class PayrollHttpClient

Http client for the Payroll Engine API

Inheritance
object
PayrollHttpClient
Implements
IDisposable
Inherited Members
object.GetType()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: PayrollEngine.Client
Assembly: PayrollEngine.Client.Core.dll
Syntax
public sealed class PayrollHttpClient : IDisposable
Remarks

This class is not thread-safe. Do not share instances across threads or modify headers (API key, tenant authorization) concurrently.

Constructors

PayrollHttpClient(HttpClient, Version)

New instance of the payroll http client with a custom http client

Declaration
public PayrollHttpClient(HttpClient httpClient, Version version = null)
Parameters
Type Name Description
HttpClient httpClient

The HTTP client

Version version

The request version

PayrollHttpClient(HttpClientHandler, PayrollHttpConfiguration, Version)

New instance of the payroll http client with a custom http configuration

Declaration
public PayrollHttpClient(HttpClientHandler httpClientHandler, PayrollHttpConfiguration configuration, Version version = null)
Parameters
Type Name Description
HttpClientHandler httpClientHandler

The http client handler

PayrollHttpConfiguration configuration

The HTTP configuration

Version version

The request version

PayrollHttpClient(HttpClientHandler, string, int, Version)

New instance of the payroll http client with unknown server certificate, timeout is 100 seconds. See https://docs.microsoft.com/en-us/dotnet/api/system.net.http.httpclient.timeout

Declaration
public PayrollHttpClient(HttpClientHandler httpClientHandler, string baseUrl, int port = 0, Version version = null)
Parameters
Type Name Description
HttpClientHandler httpClientHandler

The http client handler

string baseUrl

The Uri the request is sent to

int port

The backend port

Version version

The request version

PayrollHttpClient(HttpClientHandler, string, TimeSpan, int, Version)

New instance of the payroll http client with unknown server certificate and request timeout

Declaration
public PayrollHttpClient(HttpClientHandler httpClientHandler, string baseUrl, TimeSpan requestTimeout, int port = 0, Version version = null)
Parameters
Type Name Description
HttpClientHandler httpClientHandler

The http client handler

string baseUrl

The Uri the request is sent to

TimeSpan requestTimeout

The request timeout

int port

The backend port

Version version

The request version

Properties

Address

The http address

Declaration
public string Address { get; }
Property Value
Type Description
string

Methods

DeleteAsync(string)

Delete backend collection

Declaration
public Task DeleteAsync(string requestUri)
Parameters
Type Name Description
string requestUri

The Uri the request is sent to

Returns
Type Description
Task

DeleteAsync(string, int)

Delete backend resource

Declaration
public Task DeleteAsync(string requestUri, int id)
Parameters
Type Name Description
string requestUri

The Uri the request is sent to

int id

The object id

Returns
Type Description
Task

DeleteAttributeAsync(string)

Delete resource attribute

Declaration
public Task DeleteAttributeAsync(string requestUri)
Parameters
Type Name Description
string requestUri

The Uri the request is sent to

Returns
Type Description
Task

Dispose()

Dispose http client

Declaration
public void Dispose()

GetAsync(string)

Get backend resource response

Declaration
public Task<HttpResponseMessage> GetAsync(string requestUri)
Parameters
Type Name Description
string requestUri

The Uri the request is sent to

Returns
Type Description
Task<HttpResponseMessage>

The http response message

GetAsync(string, StringContent)

Get backend resource response with string content

Declaration
public Task<HttpResponseMessage> GetAsync(string requestUri, StringContent content)
Parameters
Type Name Description
string requestUri

The Uri the request is sent to

StringContent content

The request content

Returns
Type Description
Task<HttpResponseMessage>

The http response message

GetAsync<T>(string)

Get backend resource

Declaration
public Task<T> GetAsync<T>(string requestUri)
Parameters
Type Name Description
string requestUri

The Uri the request is sent to

Returns
Type Description
Task<T>

The backend resource

Type Parameters
Name Description
T

The object type

GetAsync<T>(string, object)

Get backend resource with request content

Declaration
public Task<T> GetAsync<T>(string requestUri, object content)
Parameters
Type Name Description
string requestUri

The Uri the request is sent to

object content

The request content

Returns
Type Description
Task<T>

The backend resource

Type Parameters
Name Description
T

The object type

GetAttributeAsync(string)

Get resource attribute

Declaration
public Task<string> GetAttributeAsync(string requestUri)
Parameters
Type Name Description
string requestUri

The Uri the request is sent to

Returns
Type Description
Task<string>

The attribute value

GetCollectionAsync<T>(string)

Get collection of backend resource

Declaration
public Task<List<T>> GetCollectionAsync<T>(string requestUri) where T : class
Parameters
Type Name Description
string requestUri

The Uri the request is sent to

Returns
Type Description
Task<List<T>>

A collection of backend resources

Type Parameters
Name Description
T

The object type

GetCollectionAsync<T>(string, object)

Get collection of backend resource with request content

Declaration
public Task<List<T>> GetCollectionAsync<T>(string requestUri, object content) where T : class
Parameters
Type Name Description
string requestUri

The Uri the request is sent to

object content

The request content

Returns
Type Description
Task<List<T>>

A collection of backend resources

Type Parameters
Name Description
T

The object type

GetLogName(string, string)

Get the log name

Declaration
public static string GetLogName(string methodName, string requestUri)
Parameters
Type Name Description
string methodName

The method name

string requestUri

The request uri

Returns
Type Description
string

The log name

GetRecordIdAsync(HttpResponseMessage)

Get record id from the response (last uri segment)

Declaration
public static Task<int> GetRecordIdAsync(HttpResponseMessage response)
Parameters
Type Name Description
HttpResponseMessage response

The http response message

Returns
Type Description
Task<int>

The new record id

GetSingleAsync<T>(string)

Get single resource from a collection

Declaration
public Task<T> GetSingleAsync<T>(string requestUri) where T : class
Parameters
Type Name Description
string requestUri

The Uri the request is sent to

Returns
Type Description
Task<T>

First collection resource, null on empty collections

Type Parameters
Name Description
T

The object type

GetTenantAuthorization()

Get the tenant authorization

Declaration
public string GetTenantAuthorization()
Returns
Type Description
string

HasApiKey()

Test for api key

Declaration
public bool HasApiKey()
Returns
Type Description
bool

HasTenantAuthorization()

Test for tenant authorization

Declaration
public bool HasTenantAuthorization()
Returns
Type Description
bool

IsConnectionAvailableAsync(string)

Test for the client internet connection

Declaration
public Task<bool> IsConnectionAvailableAsync(string address)
Parameters
Type Name Description
string address

The address to test

Returns
Type Description
Task<bool>

True if internet connection is available

PostAsync(string, StringContent)

Post resource to backend

Declaration
public Task<HttpResponseMessage> PostAsync(string requestUri, StringContent content)
Parameters
Type Name Description
string requestUri

The Uri the request is sent to

StringContent content

The resource content

Returns
Type Description
Task<HttpResponseMessage>

The http response message

PostAsync(string, object)

Post resource to backend

Declaration
public Task PostAsync(string requestUri, object content)
Parameters
Type Name Description
string requestUri

The Uri the request is sent to

object content

The resource content

Returns
Type Description
Task

PostAsync<T>(string)

Post resource to backend

Declaration
public Task<T> PostAsync<T>(string requestUri)
Parameters
Type Name Description
string requestUri

The Uri the request is sent to

Returns
Type Description
Task<T>

The backend resource

Type Parameters
Name Description
T

PostAsync<T>(string, T)

Post resource to backend

Declaration
public Task<T> PostAsync<T>(string requestUri, T content) where T : class
Parameters
Type Name Description
string requestUri

The Uri the request is sent to

T content

The resource content

Returns
Type Description
Task<T>

The backend resource

Type Parameters
Name Description
T

PostAsync<TIn, TOut>(string, TIn)

Post resource to backend

Declaration
public Task<TOut> PostAsync<TIn, TOut>(string requestUri, TIn content)
Parameters
Type Name Description
string requestUri

The Uri the request is sent to

TIn content

The resource content

Returns
Type Description
Task<TOut>

The backend resource

Type Parameters
Name Description
TIn
TOut

PostAttributeAsync(string, string)

Post resource attribute value

Declaration
public Task<string> PostAttributeAsync(string requestUri, string attributeValue)
Parameters
Type Name Description
string requestUri

The Uri the request is sent to

string attributeValue

Value of the attribute

Returns
Type Description
Task<string>

PutAsync(string, StringContent)

Put resource to backend

Declaration
public Task PutAsync(string requestUri, StringContent content)
Parameters
Type Name Description
string requestUri

The Uri the request is sent to

StringContent content

The resource content

Returns
Type Description
Task

PutAsync(string, string)

Put resource to backend

Declaration
public Task PutAsync(string requestUri, string content = null)
Parameters
Type Name Description
string requestUri

The Uri the request is sent to

string content

The resource content

Returns
Type Description
Task

PutAsync<T>(string, T)

Put resource to backend

Declaration
public Task PutAsync<T>(string requestUri, T content) where T : IModel
Parameters
Type Name Description
string requestUri

The Uri the request is sent to

T content

The resource content

Returns
Type Description
Task
Type Parameters
Name Description
T

RemoveApiKey()

Remove the api key

Declaration
public void RemoveApiKey()

RemoveTenantAuthorization()

Remove the tenant authorization

Declaration
public void RemoveTenantAuthorization()

SetApiKey(string)

Set the api key

Declaration
public void SetApiKey(string apiKey)
Parameters
Type Name Description
string apiKey

The api key

SetTenantAuthorization(string)

Set the tenant authorization

Declaration
public void SetTenantAuthorization(string tenantIdentifier)
Parameters
Type Name Description
string tenantIdentifier

The tenant identifier

ToString()

The string representation

Declaration
public override string ToString()
Returns
Type Description
string
Overrides
object.ToString()

UpsertObjectAsync<T>(string, T, T, DateTime?)

Insert or update backend resource

Declaration
public Task UpsertObjectAsync<T>(string requestUri, T newObject, T existingObject, DateTime? createdDate = null) where T : IModel
Parameters
Type Name Description
string requestUri

The Uri the request is sent to

T newObject

Content of new resource

T existingObject

Content of existing resource (optional)

DateTime? createdDate

The created date for new objects

Returns
Type Description
Task
Type Parameters
Name Description
T

The object type

Implements

IDisposable

Extension Methods

ConsoleExtensions.WriteProperties(object, bool)
ValueTypeExtensions.GetValueType(object)
ObjectInfo.GetPropertyValue(object, string)
ObjectInfo.GetPropertyValue<T>(object, string, T)
ObjectInfo.ResolvePropertyValue(object, string)
ObjectInfo.SetPropertyValue(object, string, object)
☀
☾
Back to top Generated by DocFX