/// <summary> /// Lists all the vTiger entity types available through the API /// </summary> /// <returns>List of entity types</returns> public async Task <Module[]> GetAllAsync() { var typeInfos = await parentClient.InvokeOperationAsync <Module[]>( "listtypes", new Dictionary <string, string>(0), HttpMethod.Get ); if (typeInfos?.Any() ?? false) { throw new WebServiceException($"Failed to retrieve CRM modules"); } return(typeInfos); }
/// <summary> /// Retrieves an entity by identifier asynchronously. /// </summary> /// <typeparam name="TEntity">The type of the entity.</typeparam> /// <param name="moduleName">The name of the module / entity type.</param> /// <param name="entityId">The entity identifier.</param> /// <param name="select">The list of fields to select (defaults to SQL-like '*' - all the fields).</param> /// <param name="jsonSettings">The JSON serialization settings.</param> /// <returns> /// The entity asynchronously retrieved by identifier /// </returns> public async Task <TEntity> FindOneByIdAsync <TEntity>(string moduleName, string entityId, IList <string> select = null, JsonSerializerSettings jsonSettings = null) where TEntity : class { var record = await parentClient.InvokeOperationAsync <TEntity>( "retrieve", new Dictionary <string, string> { { "id", entityId } }, HttpMethod.Get, jsonSettings ); if (null == record) { return(null); } if (select?.Any() ?? false || typeof(TEntity) != typeof(JToken)) { return(record); } var recordJtoken = record as JToken; foreach (var field in recordJtoken.Values()) { field.Remove(); } return(recordJtoken as TEntity); }