Interface DataApi


public interface DataApi

Data API client to interact with data in a Salesforce org.

Modifier and TypeMethodDescription
java.util.Map<ReferenceId, RecordModificationResult>commitUnitOfWork(UnitOfWork unitOfWork)Commits a UnitOfWork, executing all operations registered with it.
RecordModificationResultcreate(Record record)Creates a new record of the given type with the given fields
RecordModificationResultdelete(java.lang.String type, java.lang.String id)Deletes an existing record of the given type and id.
java.lang.StringgetAccessToken()Returns the access token used by this API client.
RecordBuildernewRecordBuilder(java.lang.String type)Creates a new and empty RecordBuilder that can be used to build a Record object for use with the update(Record) and create(Record) methods.
RecordBuildernewRecordBuilder(Record record)Creates a new RecordBuilder, pre-initialized from the given Record. The type and all fields present in that Record will be set on the returned RecordBuilder.
UnitOfWorkBuildernewUnitOfWorkBuilder()Creates a new and empty UnitOfWorkBuilder that can be used to build a UnitOfWork object for the commitUnitOfWork(UnitOfWork) method.
RecordQueryResultquery(java.lang.String soql)Queries for records with a given SOQL string.
RecordQueryResultqueryMore(RecordQueryResult queryResult)Queries for more records, based on the given RecordQueryResult.
RecordModificationResultupdate(Record record)Updates an existing record of the given type and id with the given fields.

@Nonnull RecordQueryResult query​(java.lang.String soql) throws DataApiException

Queries for records with a given SOQL string.

Parameters: soql - The SOQL string. Returns: a RecordQueryResult that contains the queried data. Throws: DataApiException - If error occurred during the query. See Also: Salesforce Object Query Language (SOQL)

@Nonnull RecordQueryResult queryMore​(RecordQueryResult queryResult) throws DataApiException

Queries for more records, based on the given RecordQueryResult.

Parameters: queryResult - The query result to query more data for. Returns: A new RecordQueryResult with additional data or an empty one if the given RecordQueryResult was already in the done state. Throws: DataApiException - If error occurred during the query. java.lang.IllegalArgumentException - If the RecordQueryResult instance wasn't created by this DataApi instance. See Also: RecordQueryResult.isDone()

@Nonnull RecordModificationResult create​(Record record) throws DataApiException

Creates a new record of the given type with the given fields.

Parameters: record - The record to create. Returns: A RecordModificationResult for this operation. Throws: DataApiException - If an API error occurred during record creation. java.lang.IllegalArgumentException - If the Record instance wasn't created by a RecordBuilder obtained from this DataApi instance.

@Nonnull RecordModificationResult update​(Record record) throws DataApiException

Updates an existing record of the given type and id with the given fields.

Parameters: record - The record to update. Returns: A RecordModificationResult for this operation. Throws: DataApiException - If an API error occurred during record update. java.lang.IllegalArgumentException - If the Record instance wasn't created by a RecordBuilder obtained from this DataApi instance.

@Nonnull RecordModificationResult delete​(java.lang.String type, java.lang.String id) throws DataApiException

Deletes an existing record of the given type and id.

Parameters: type - The object type of the record to delete. id - The id of the record to delete. Returns: A RecordModificationResult for this operation. Throws: DataApiException - If an API error occurred during record deletion.

@Nonnull RecordBuilder newRecordBuilder​(java.lang.String type)

Creates a new and empty RecordBuilder that can be used to build a Record object for use with the update(Record) and create(Record) methods.

Parameters: type - The type of the record to build. Returns: A new and empty RecordBuilder.

@Nonnull RecordBuilder newRecordBuilder​(Record record)

Creates a new RecordBuilder, pre-initialized from the given Record. The type and all fields present in that Record will be set on the returned RecordBuilder.

Parameters: record - The Record to copy the type and fields from. Returns: A new RecordBuilder, pre-initialized from the given Record. Throws: java.lang.IllegalArgumentException - If the Record instance wasn't created by a RecordBuilder obtained from this DataApi instance.

@Nonnull UnitOfWorkBuilder newUnitOfWorkBuilder()

Creates a new and empty UnitOfWorkBuilder that can be used to build a UnitOfWork object for the commitUnitOfWork(UnitOfWork) method.

Returns: A new and empty FieldsBuilder.

@Nonnull java.util.Map<ReferenceId,​RecordModificationResult> commitUnitOfWork​(UnitOfWork unitOfWork) throws DataApiException

Commits a UnitOfWork, executing all operations registered with it. If any of these operations fail, the whole unit is rolled back. To examine results for a single operation, inspect the returned map (which is keyed with ReferenceId returned from UnitOfWorkBuilder.registerCreate(Record), UnitOfWorkBuilder.registerUpdate(Record), and UnitOfWorkBuilder.registerDelete(String, String).

Parameters: unitOfWork - The UnitOfWork to commit. Returns: A map of RecordModificationResults, indexed by their ReferenceIds. Throws: DataApiException - If an error occurred while committing the UnitOfWork. java.lang.IllegalArgumentException - If the UnitOfWork instance wasn't created by a UnitOfWorkBuilder obtained from this DataApi instance. See Also: newUnitOfWorkBuilder()

@Nonnull java.lang.String getAccessToken()

Returns the access token used by this API client. Can be used to initialize a third-party API client or to perform custom API calls with a HTTP library.

Returns: the access token used by this API client.