Skip to main content

ImapClient

Handles e-receipt parsing from IMAP email accounts (Gmail IMAP, Yahoo, AOL, and custom IMAP providers).

Package: com.microblink.digital

Declaration

class ImapClient(context: Context, callback: InitializeCallback) : Client
class ImapClient(context: Context, threads: Int, callback: InitializeCallback) : Client

Quick Reference

Properties

PropertyDescription
dayCutoffSearch depth in days
dateCutoffSpecific date boundary, overrides dayCutoff
searchUntilUpper boundary for the search period
countryCodeISO country code for parsing accuracy
sendersToSearchMaps sender email addresses to merchant identifiers
filterSensitiveWhether to redact sensitive data from results
useAggregationWhether to aggregate related emails into a single result
subProductsWhether sub-products are included in results
overrideDateOverride the cutoff date for this client instance
overrideEndpointOverride the server-side endpoint for result posting

Methods

MethodDescription
link(credentials)Links an IMAP account
verify(credentials)Validates that credentials can authenticate
logout()Unlinks and removes stored IMAP credentials
accounts()Returns all linked IMAP accounts
messages(credentials)Fetches and parses e-receipts
remoteMessages(credentials)Queues a remote scrape job
rawEmails(flag)Enables raw email content in results
clearLastCheckedTime()Resets the last-checked timestamp
close()Releases client resources

Configuration Properties

dayCutoff

var dayCutoff: Int

Search depth in days.


dateCutoff

var dateCutoff: Date?

Specific date boundary, overrides dayCutoff.


searchUntil

var searchUntil: Date?

Upper boundary for the search period.


countryCode

var countryCode: String

ISO country code for parsing accuracy.


sendersToSearch

var sendersToSearch: Map<String, Merchant>?

Maps sender email addresses to merchant identifiers for filtering.


filterSensitive

var filterSensitive: Boolean

Whether to redact sensitive data from results.


useAggregation

var useAggregation: Boolean

Whether to aggregate related emails into a single result.


subProducts

var subProducts: Boolean

Whether sub-products are included in parsed results.


overrideDate

var overrideDate: Date?

Override the cutoff date for this specific client instance.


overrideEndpoint

var overrideEndpoint: String?

Override the server-side endpoint for result posting.


Methods

fun link(credentials: Credentials.Password): Task<ProviderSetupResults>
fun link(executor: Executor, credentials: Credentials.Password): Task<ProviderSetupResults>

Links an IMAP account with the given credentials. Returns a ProviderSetupResults value indicating the outcome of the setup flow.


verify(credentials)

fun verify(credentials: Credentials.Password): Task<Boolean>
fun verify(executor: Executor, credentials: Credentials.Password): Task<Boolean>

Validates that the provided credentials can authenticate successfully.


logout()

fun logout(): Task<Boolean>
fun logout(credentials: Credentials.Password): Task<Boolean>
fun logout(executor: Executor, credentials: Credentials.Password?): Task<Boolean>

Unlinks and removes stored IMAP credentials.


accounts()

fun accounts(): Task<List<Credentials.Password>>

Returns all linked IMAP accounts stored on the device.


messages(credentials)

fun messages(credentials: Credentials.Password): Task<List<ScanResults>>
fun messages(executor: Executor, credentials: Credentials.Password): Task<List<ScanResults>>

Fetches and parses e-receipts from the specified IMAP account.


fun messages(callback: MessagesCallback)
fun messages(executor: Executor, callback: MessagesCallback)

Callback-based variants for fetching and parsing e-receipts.


fun messages(executor: Executor, provider: Provider, sender: String, html: String): Task<List<ScanResults>>

Parses e-receipt data from raw HTML using the specified executor.


remoteMessages(credentials)

fun remoteMessages(credentials: Credentials.Password): Task<JobResults>
fun remoteMessages(executor: Executor, credentials: Credentials.Password): Task<JobResults>

Queues a remote scrape job for the specified IMAP account. Returns a JobResults with the job ID.


fun remoteMessages(callback: JobResultsCallback)
fun remoteMessages(executor: Executor, callback: JobResultsCallback)

Callback-based variants for queuing a remote scrape job.


fun remoteMessages(email: String, provider: Provider, eml: String): Task<JobResults>
fun remoteMessages(executor: Executor, email: String, provider: Provider, eml: String): Task<JobResults>

Queues a remote scrape job using raw EML content.


rawEmails(flag)

fun rawEmails(flag: Boolean): ImapClient

When true, returns raw email content alongside parsed results. Returns this for chaining.


clearLastCheckedTime()

fun clearLastCheckedTime(): Task<Boolean>
fun clearLastCheckedTime(provider: Provider): Task<Boolean>
fun clearLastCheckedTime(executor: Executor, providers: Array<Provider>): Task<Boolean>

Resets the last-checked timestamp. Can target a specific provider or an array of providers.


close()

fun close()

Releases client resources.