Skip to main content

Class CustomObjectAgent

Namespace: SuperOffice.WebApi.Agents
Assembly: SuperOffice.WebApi.dll
Agent for working with Custom Objects (extra tables): read schema and full CRUD over rows. Purpose-built replacement for using DatabaseTableAgent against custom objects.

Inheritance

objectAgentBaseCustomObjectAgent

Implements

ICustomObjectAgent, IAgentBase, IDisposable

Inherited Members

AgentBase._json, AgentBase._binary, AgentBase._config, AgentBase._client, AgentBase._disposeClient, AgentBase.Merge(RequestOptions), AgentBase.BuildRequestFromObject(HttpMethod, string, object, WebApiOptions, string), AgentBase.BuildRequestFromStream(HttpMethod, string, Stream, WebApiOptions, string), AgentBase.BuildRequestFromObjectWithStream(HttpMethod, string, object, Stream, WebApiOptions, string), AgentBase.ParseAuthorization(IAuthorization), AgentBase.CancelRequest(), AgentBase.SendRequestObject(HttpMethod, string, object, WebApiOptions, string), AgentBase.SendRequestObjectWithStream(HttpMethod, string, object, Stream, WebApiOptions, string), AgentBase.SendRequest(HttpRequestMessage, RequestOptions), AgentBase.ThrowOnResponseErrorAsync(HttpRequestMessage, HttpResponseMessage), AgentBase.ParseResponse<T&gt;(HttpResponseMessage), AgentBase.Finally(RequestOptions), AgentBase.Dispose(), AgentBase.Configuration, AgentBase.Client, AgentBase.HasRunningRequest, AgentBase.ClientCancellationTokenSource, AgentBase.ProgressListener, AgentBase.UploadProgressListener, object.ToString(), object.Equals(object), object.Equals(object, object), object.ReferenceEquals(object, object), object.GetHashCode(), object.GetType(), object.MemberwiseClone()

Examples

<pre><code class=“lang-csharp”>using SuperOffice.WebApi; using SuperOffice.WebApi.Agents; var mySession = new WebApiOptions(“http://example.com/super/api”); mySession.Authorization = new AuthorizationUsernamePassword(“user”, “pass”); using (CustomObjectAgent agent = new CustomObjectAgent(mySession)) { // call methods on agent here… }</code></pre>

Constructors

CustomObjectAgent(HttpClient)

Constructor: Agent for working with Custom Objects (extra tables): read schema and full CRUD over rows. Purpose-built replacement for using DatabaseTableAgent against custom objects.

Parameters

httpClient HttpClient Use this HTTP client instead of making own HttpClient instance.

CustomObjectAgent(WebApiOptions, HttpClient)

Constructor: Agent for working with Custom Objects (extra tables): read schema and full CRUD over rows. Purpose-built replacement for using DatabaseTableAgent against custom objects.

Parameters

options WebApiOptions Base URL and authentication values. httpClient HttpClient Optional: Use this HTTP client instead of making a new one.

Methods

CreateDefaultCustomObjectAsync(string, RequestOptions)

Returns a new Custom Object row pre-populated with the default values declared by the Custom Object Definition. The row is not yet persisted.

Parameters

definitionName string Database table name of the Custom Object Definition, e.g. ‘y_equipment’. requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<CustomObject&gt; A new Custom Object row pre-populated with default values. Not yet persisted.

CreateDefaultCustomObjectDefinitionAsync(RequestOptions)

Set default values into a new CustomObjectDefinition. NetServer calculates default values on the entity, which is required when creating/storing a new instance

Parameters

requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<CustomObjectDefinition&gt; A blank CustomObjectDefinition

DeleteCustomObjectAsync(string, int, RequestOptions)

Deletes a single Custom Object row by primary key.

Parameters

definitionName string Database table name of the Custom Object Definition, e.g. ‘y_equipment’. id int Primary key of the row to delete. requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task This method has no return value

GetCustomObjectAsync(string, int, RequestOptions)

Returns a single Custom Object row by definition name and primary key.

Parameters

definitionName string Database table name of the Custom Object Definition, e.g. ‘y_equipment’. id int Primary key of the row to fetch. requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<CustomObject&gt; The Custom Object row, or null if no row with that id exists.

GetCustomObjectDefinitionAsync(string, RequestOptions)

Returns the schema (table + field definitions) for a Custom Object Definition by its database table name.

Parameters

definitionName string Database table name of the Custom Object Definition, e.g. ‘y_equipment’. requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<CustomObjectDefinition&gt; The Custom Object Definition, or null if no definition with that name exists.

GetCustomObjectsIconsAsync(RequestOptions)

Returns SVG icon data for all Custom Object tables, keyed by table name.

Parameters

requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<StringDictionary&gt; Map of table name to SVG icon data URI.

GetCustomObjectsMetadataAsync(RequestOptions)

Returns bootstrap metadata for all Custom Object tables.

Parameters

requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<CustomObjectMetadata[]&gt; Metadata for all custom object tables.

HasScreenChooserAsync(string, bool, RequestOptions)

Returns true if a screen chooser is configured for the given Custom Object Definition and mode.

Parameters

definitionName string Database table name of the Custom Object Definition. edit bool True to check for a custom edit screen; false to check for a custom view screen. requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<bool&gt; True if a screen chooser (view or edit) is configured for this Custom Object.

SaveCustomObjectAsync(string, CustomObject, RequestOptions)

Saves a Custom Object row. If the row has a primary key set it will be updated, otherwise a new row is inserted.

Parameters

definitionName string Database table name of the Custom Object Definition, e.g. ‘y_equipment’. row CustomObject The Custom Object row to save. requestOptions RequestOptions Override language/culture codes on this request.

Returns

Task<CustomObject&gt; The saved Custom Object row, with any server-assigned values (e.g. primary key) filled in.