SuccessMortgagePartners.TotalExpert.Client 0.1.0

dotnet add package SuccessMortgagePartners.TotalExpert.Client --version 0.1.0
                    
NuGet\Install-Package SuccessMortgagePartners.TotalExpert.Client -Version 0.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SuccessMortgagePartners.TotalExpert.Client" Version="0.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SuccessMortgagePartners.TotalExpert.Client" Version="0.1.0" />
                    
Directory.Packages.props
<PackageReference Include="SuccessMortgagePartners.TotalExpert.Client" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SuccessMortgagePartners.TotalExpert.Client --version 0.1.0
                    
#r "nuget: SuccessMortgagePartners.TotalExpert.Client, 0.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SuccessMortgagePartners.TotalExpert.Client@0.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SuccessMortgagePartners.TotalExpert.Client&version=0.1.0
                    
Install as a Cake Addin
#tool nuget:?package=SuccessMortgagePartners.TotalExpert.Client&version=0.1.0
                    
Install as a Cake Tool

SuccessMortgagePartners.TotalExpert.Client

A .NET client for the Total Expert public API, published to NuGet.org.

  • Client-credentials tokens, cached for their lifetime and renewed automatically (and once more after a 401).
  • Create, read, update and delete for contacts, users, lead opportunities, contact groups and loans (where Total Expert supports each operation).
  • Filtering, sorting and paging, including ListAllAsync, which walks every page.
  • Retries that never repeat a create or update Total Expert may already have saved.
  • IHttpClientFactory integration and one-line setup from configuration.
  • Targets net10.0 and netstandard2.0.

Install

dotnet add package SuccessMortgagePartners.TotalExpert.Client

Configure

Bind the TotalExpert configuration section (appsettings, Azure App Configuration, Key Vault references, environment variables…):

builder.Services.AddTotalExpertClient(builder.Configuration);
Key Notes
TotalExpert:BaseUrl API host. Defaults to https://public.totalexpert.net. A trailing /v1 is optional.
TotalExpert:ClientId Required.
TotalExpert:ClientSecret Required. Keep it in Key Vault or user secrets, never in source control.
TotalExpert:Scope Optional. Leave unset to get every scope granted to the client. Lead opportunities need leadOpportunitiesSalesPipelineInteraction; loans need loanInteraction.
TotalExpert:MaxRetries Optional, default 3. See Retries.
TotalExpert:TokenRefreshSkew, TotalExpert:Timeout Optional TimeSpans: renew tokens this long before they expire (default 5 minutes); per-request timeout (default 100 seconds).

Or set the options in code:

builder.Services.AddTotalExpertClient(options =>
{
    options.ClientId = "...";
    options.ClientSecret = "...";
});

Settings are validated when the host starts.

Use

Inject ITotalExpertClient. Each API area is a property: Contacts, Users, LeadOpportunities, ContactGroups, Loans.

public sealed class LeadIntake(ITotalExpertClient totalExpert)
{
    public async Task<string> CreateLeadAsync(string loanOfficerEmail, CancellationToken ct)
    {
        var loanOfficer = await totalExpert.Users.FindByEmailAsync(loanOfficerEmail, ct);
        if (loanOfficer is null || !loanOfficer.IsActive)
        {
            throw new InvalidOperationException("Unknown or inactive loan officer.");
        }

        var contact = await totalExpert.Contacts.FindFirstAsync(
            new TotalExpertQuery().Where("owner_id", loanOfficer.Id).Where("email", "john.doe@example.com"), ct);

        var contactId = contact?.Id ?? (await totalExpert.Contacts.CreateAsync(new ContactInput
        {
            FirstName = "John",
            LastName = "Doe",
            Email = "john.doe@example.com",
            Source = "Website",
            Owner = UserReference.ById(loanOfficer.Id),
        }, ct)).Id;

        var lead = await totalExpert.LeadOpportunities.CreateAsync(new LeadOpportunityInput
        {
            FirstName = "John",
            LastName = "Doe",
            Email = "john.doe@example.com",
            Source = "Website",
            ContactId = contactId,
            AssignedUser = AssignedUser.ById(loanOfficer.Id),
            Product = new LeadProduct("mortgage", new JsonObject { ["loan_purpose"] = "Purchase" }),
        }, ct);

        return lead.Id;
    }
}

Operations

Area Get List / ListAll / FindFirst Create Update Delete
Contacts ✓ ✓ ✓ ✓ ✓
Users ✓ ✓ (plus FindByEmailAsync) ✓ ✓ Total Expert has none; set Status = "0"
LeadOpportunities ✓ ✓ (plus ListForContactAsync) ✓ ✓ Total Expert has none; move the lead to stage 8 (Closed)
ContactGroups ✓ ✓ ✓ ✓ ✓
Loans ✓ ✓ ✓ ✓ ✓
  • GetAsync returns null when the record doesn't exist. Every other non-success response throws TotalExpertApiException with the status code, the operation, Total Expert's error/message text and the raw body. The body and message can quote what you sent, so treat them as personal data when logging.
  • Creates dedupe. Total Expert matches contacts (and loans) against existing records. CreateResult.Created is false when it matched and updated an existing record instead of creating one.
  • Updates are partial. *Input classes send only the properties you set, so UpdateAsync(id, new ContactInput { City = "Anytown" }) changes only the city.
  • Lead opportunity updates always need ContactId. Total Expert saves assignment, stage and the other fields separately, so check UpdateLeadOpportunityResult.Errors for the parts that failed. ReferredByContacts replaces the whole list; send an empty list to clear it. A 207 (lead saved, custom fields not) shows as CustomFieldsFailed.
  • Fields the models don't name are still available. Responses keep them in AdditionalProperties (raw JSON), and inputs send anything in AdditionalFields:
await totalExpert.Contacts.UpdateAsync(contactId, new ContactInput
{
    AdditionalFields = new Dictionary<string, object?> { ["do_not_contact"] = "1" },
});
  • Loose types are handled. Total Expert often sends amounts, ids and flags as strings ("325000.00", "1"). The models read them as decimal?, long? and bool?, and an empty string reads as null. Dates stay as the strings Total Expert sends, because their format varies by field.
  • Loan status, type, program and purpose are plain strings on Loan/LoanInput (LoanStatus = "Funded"). Total Expert wraps each one in an object ({"loan_status": {"loan_status": "Funded"}}), and the client reads and writes that shape for you. Which loan fields are filled in depends on the loan's account class and your organization's setup.

Filtering, sorting and paging

var query = new TotalExpertQuery()
    .Where("owner_email", "jane.lo@example.com")
    .Where("internal_updated_at_start", "2026-01-01T00:00:00Z")
    .OrderBy("-internal_updated_at");

await foreach (var contact in totalExpert.Contacts.ListAllAsync(query, ct))
{
    // every matching contact, 100 per request
}

var page = await totalExpert.Contacts.ListAsync(query.Page(1, 25), ct);   // one page

Each resource accepts its own filter and sort fields. These were checked against a live org (the integration tests check that results really are filtered and in order, and that pages don't overlap):

Area Filters Sorts
Contacts owner_id, owner_email, email, email_contains, last_name, last_name_contains, phone_cell, external_id, group_id, internal_updated_at_start (_end needs _start too), source (not exact) internal_updated_at, internal_created_at, last_name, id
Users email, username, status internal_updated_at
LeadOpportunities user_id, contact_id created_at, updated_at, lead_stage
Loans owner_id, owner_email, external_id, loan_number, borrower_id, loan_status, internal_updated_at_start internal_updated_at, loan_amount, id
ContactGroups none (Total Expert rejects filters with 422) group_name

Paging works on every list. Filter values can't contain commas. Total Expert's rate limit is 1,000 requests per minute.

Retries

The client retries on its own, so don't add a generic retry handler on top:

  • Any request is retried after 429, which means Total Expert rejected it before processing it (using Retry-After when sent, otherwise 1 s, 2 s, 4 s…).
  • A GET is also retried after 408, 500, 502, 503, 504, a timeout or a network error.
  • A create or update is not retried after those, because Total Expert may already have saved it and a retry could create a duplicate contact or lead.

If your app adds a standard resilience handler to every HttpClient (for example ConfigureHttpClientDefaults(b => b.AddStandardResilienceHandler())), remove it from this client:

builder.Services.AddTotalExpertClient(builder.Configuration)
    .RemoveAllResilienceHandlers();   // Microsoft.Extensions.Http.Resilience

AddTotalExpertClient returns the API client's IHttpClientBuilder, so you can add your own handlers (logging, telemetry) the same way.

Build and test

dotnet build            # warnings are errors
dotnet test
dotnet pack src/SuccessMortgagePartners.TotalExpert.Client -c Release -o artifacts

Integration tests against a real Total Expert org are in tests/SuccessMortgagePartners.TotalExpert.Client.IntegrationTests and are skipped unless TOTALEXPERT_INTEGRATION=1; see the README there.

docs/ holds the Total Expert OpenAPI export and an extract of the Postman documentation for the endpoints this client covers.

CI and release

CI runs on Azure Pipelines from azure-pipelines.yml; the code stays on GitHub.

  • develop is the default branch. Pull requests target develop.
  • Every push and pull request to develop or main builds, tests and packs.
  • Every merge (push) to main also pushes the package to NuGet.org and creates the vX.Y.Z tag and GitHub release. The version is <Version> in src/SuccessMortgagePartners.TotalExpert.Client/SuccessMortgagePartners.TotalExpert.Client.csproj; a version with a suffix (1.2.0-preview.1) is published as a prerelease.
  • To release: bump <Version> on develop, then merge develop into main. If that version is already on NuGet.org from another commit, the run warns and publishes nothing. If a release run fails after the NuGet push, wait until the version shows on nuget.org, then use Rerun failed jobs on that run. Don't push release tags by hand.

One-time setup in Azure DevOps (the same as encompass-client):

  1. In the Development project, Pipelines → New pipeline → GitHub (YAML), pick this repo and the existing azure-pipelines.yml. Use the existing github.com_SuccessMortgagePartners connection.
  2. Library → Variable group totalexpert-client-release with secret variable NuGetApiKey (a NuGet.org key with Push new packages and package versions for the glob SuccessMortgagePartners.*; 0.1.0 creates the package). Allow the pipeline to use it, and add a Branch control check that allows only refs/heads/main.
  3. Service connection (GitHub) named github-releases-totalexpert-client, for creating the tag and GitHub release (OAuth, or a fine-grained token limited to this repo with Contents: read and write), with a Branch control check allowing only refs/heads/main.
  4. Environment totalexpert-client-nuget, with a Branch control check for refs/heads/main. Add an approval check too if you want a person to confirm each publish.
  5. releaseEnabled in azure-pipelines.yml is 'true'. Set it to 'false' to stop publishing; runs on main then build and pack only.

License

MIT — see LICENSE.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.0 105 11/11/2026