Skip to main content

Class AgentBase

Namespace: SuperOffice.WebApi.Agents
Assembly: SuperOffice.WebApi.dll
Base class for client Agents. Uses a <xref href=“System.Net.Http.HttpClient” data-throw-if-not-resolved=“false”></xref> to call the SuperOffice REST API. Will use a default implementation with gzip and progress callbacks if nothing is specified.

Inheritance

objectAgentBase

Derived

AIAgent, ApiAgent, AppointmentAgent, ArchiveAgent, AssociateAgent, BLOBAgent, BatchAgent, BulkUpdateAgent, CRMScriptAgent, ChatAgent, ConfigurationAgent, ContactAgent, CustomObjectAgent, CustomerServiceAgent, DashAgent, DashboardAgent, DatabaseAgent, DatabaseTableAgent, DiagnosticsAgent, DocumentAgent, DocumentMigrationAgent, EMailAgent, ErpSyncAgent, FavouriteAgent, FindAgent, ForeignSystemAgent, FreeTextAgent, ImportAgent, LicenseAgent, ListAgent, MDOAgent, MarketingAgent, MessagingAgent, NavigatorAgent, NewsFeedAgent, NumberAllocationAgent, PersonAgent, PhoneListAgent, PocketAgent, PreferenceAgent, PreviewsAgent, ProjectAgent, QuoteAgent, RelationAgent, ReportAgent, ResourceAgent, SaintAgent, SaleAgent, SelectionAgent, SentryAgent, TargetsAgent, TicketAgent, TimeZoneAgent, TooltipsAgent, UserAgent, UserDefinedFieldInfoAgent, ViewStateAgent, WebhookAgent, WorkflowAgent

Implements

IAgentBase, IDisposable

Inherited Members

object.ToString(), object.Equals(object), object.Equals(object, object), object.ReferenceEquals(object, object), object.GetHashCode(), object.GetType(), object.MemberwiseClone()

Remarks

Disposes of the client when the agent is disposed, if no client provided to ctor.

Constructors

AgentBase(string, HttpClient)

Agent base class.

Parameters

baseUrl string URL to web API endpoint httpClient HttpClient client to use to communicate with endpoint. Will make a default http client if nothing is provided.

AgentBase(WebApiOptions, HttpClient)

Agent base class.

Parameters

configuration WebApiOptions Settings and URL to web API endpoint httpClient HttpClient client to use to communicate with endpoint. Will make a default http client if nothing is provided.

Fields

_binary

Field Value

string

_client

Field Value

HttpClient

_config

Field Value

WebApiOptions

_disposeClient

Field Value

bool

_json

Field Value

string

Properties

Client

The HTTP Client we are using. Create a default SO HttpClient if not specified in constructor.

Property Value

HttpClient

ClientCancellationTokenSource

Used in SendRequest to allow clients to cancel requests.

Property Value

CancellationTokenSource

Configuration

Configuration this agent was initalized with.

Property Value

WebApiOptions

HasRunningRequest

Is an HTTP request in flight?

Property Value

bool

ProgressListener

Progress callback receiver for downloads

Property Value

IProgressListener

UploadProgressListener

Progress callback receiver for uploads

Property Value

IProgressListener

Methods

BuildRequestFromObject(HttpMethod, string, object, WebApiOptions, string)

Parameters

method HttpMethod url string body object config WebApiOptions contentType string

Returns

HttpRequestMessage

BuildRequestFromObjectWithStream(HttpMethod, string, object, Stream, WebApiOptions, string)

Parameters

method HttpMethod url string body object stream Stream config WebApiOptions contentType string

Returns

HttpRequestMessage

BuildRequestFromStream(HttpMethod, string, Stream, WebApiOptions, string)

Parameters

method HttpMethod url string body Stream config WebApiOptions contentType string

Returns

HttpRequestMessage

CancelRequest()

Used by the client to terminate the current method call.

Dispose()

Disposes of the HTTP Client if we own it.

Finally(RequestOptions)

Parameters

options RequestOptions

Merge(RequestOptions)

Parameters

options RequestOptions

Returns

WebApiOptions

ParseAuthorization(IAuthorization)

Creates authentication headers based on <xref href=“SuperOffice.WebApi.Authorization.IAuthorization” data-throw-if-not-resolved=“false”></xref> scheme and parameter.

Parameters

authorization IAuthorization Contains authorization scheme and parameter values.

Returns

AuthenticationHeaderValue Authorization header.

ParseResponse<T&gt;(HttpResponseMessage)

Parameters

response HttpResponseMessage

Returns

Task<T&gt;

Type Parameters

T

SendRequest(HttpRequestMessage, RequestOptions)

Parameters

request HttpRequestMessage config RequestOptions

Returns

Task<HttpResponseMessage&gt;

SendRequestObject(HttpMethod, string, object, WebApiOptions, string)

Parameters

method HttpMethod url string args object config WebApiOptions contentType string

Returns

Task<HttpResponseMessage&gt;

SendRequestObjectWithStream(HttpMethod, string, object, Stream, WebApiOptions, string)

Parameters

method HttpMethod url string args object stream Stream config WebApiOptions contentType string

Returns

Task<HttpResponseMessage&gt;

ThrowOnResponseErrorAsync(HttpRequestMessage, HttpResponseMessage)

Return NULL on NOT-FOUND errors

Parameters

request HttpRequestMessage response HttpResponseMessage

Returns

Task