Skip to main content

Classes Reference

Classes are split across two packages:

  • com.microblink.linking — retailer account linking (order history scraping)
  • com.microblink.digital — email receipt parsing (Gmail, Outlook, IMAP)

BlinkReceiptLinkingSdk

Singleton object for initializing the account-linking SDK. Call initialize() before using AccountLinkingClient.

Package: com.microblink.linking

Declaration

object BlinkReceiptLinkingSdk

Initialization

initialize(context, complete, license)

@JvmOverloads
fun initialize(
context: Context,
complete: InitializeCallback? = null,
license: String? = null
)

Initializes the account-linking SDK. complete is notified when initialization finishes. Pass license to supply the key inline; otherwise set licenseKey before calling.


Properties

licenseKey()

fun licenseKey(): String?

Returns the currently configured BlinkReceipt license key.


productIntelligenceKey

var productIntelligenceKey: String?

Product Intelligence key. Required for enriched product data on order results.


versionName(context)

fun versionName(context: Context): String

SDK version name string.


versionCode(context)

fun versionCode(context: Context): String?

SDK version code identifier.


AccountLinkingClient

The primary interface for linking retailer accounts and fetching order history. Implements Closeable — call close() when done to release resources.

Package: com.microblink.linking

Declaration

class AccountLinkingClient(context: Context) : Closeable

Configuration Properties

dayCutoff

var dayCutoff: Int

How many days back to search for orders on each fetch.


dateCutoff

var dateCutoff: Date?

Alternative to dayCutoff. When set, overrides dayCutoff and uses this specific date as the search boundary.


latestOrdersOnly

var latestOrdersOnly: Boolean

When true, subsequent fetches only retrieve orders newer than the last fetch. When false, continues fetching history back to the cutoff on each call.

Default: true


countryCode

var countryCode: String

ISO country code for the retailer's regional site (currently used for Amazon UK).

Default: "US"


webProxy

var webProxy: WebProxy?

Optional web proxy configuration for network requests.


Methods

link(account)

fun link(account: Account): Task<Boolean>
fun link(vararg accounts: Account): Task<Boolean>

Links one or more retailer accounts. Returns a Task<Boolean> that resolves true on success. See Account and Credentials.


verify(retailerId, success, failure, preview)

fun verify(
retailerId: Int,
success: (verified: Boolean, uuid: String) -> Unit,
failure: (throwable: AccountLinkingException) -> Unit,
preview: (view: View?) -> Unit? = { }
)

Verifies that stored credentials for the given retailer are still valid.

Parameters:

ParameterDescription
retailerIdRetailer constant from com.microblink.linking (e.g., RETAILER_AMAZON)
successCalled with true if credentials are valid, plus a session UUID
failureCalled with an AccountLinkingException on error
previewOptional callback receiving a View for in-progress web interaction

orders(retailerId, success, failure, preview)

fun orders(
retailerId: Int,
success: (retailerId: Int, results: ScanResults?, remaining: Int, uuid: String) -> Unit,
failure: (retailerId: Int, throwable: AccountLinkingException) -> Unit = { _, _ -> },
preview: (view: View?) -> Unit? = { }
)

Fetches new orders for the specified retailer since the last successful fetch.

Parameters:

ParameterDescription
retailerIdRetailer constant
successCalled for each order with the retailer ID, parsed ScanResults (nullable), remaining order count, and session UUID
failureCalled with the retailer ID and exception on error; has a default no-op implementation
previewOptional callback receiving a View for in-progress web interaction

accounts()

fun accounts(): Task<List<Account>?>

Returns all currently linked accounts stored on the device.


fun unlink(): Task<Boolean>
fun unlink(account: Account): Task<Boolean>

Unlinks all accounts, or a specific account. Returns a Task<Boolean> that resolves true on success.


resetHistory()

fun resetHistory(): Task<Boolean>
fun resetHistory(retailerId: Int): Task<Boolean>

Resets order fetch history for all linked accounts or a specific retailer, causing the next orders() call to re-fetch from the cutoff.


close()

override fun close()

Releases resources. Should be called when the client is no longer needed.


Account

Represents one linked retailer account.

Package: com.microblink.linking

Declaration

class Account(
val retailerId: Int,
val credentials: Credentials
)

Properties

retailerId

val retailerId: Int

Retailer identifier. Use the @RetailerId-annotated constants in com.microblink.linking (e.g., RETAILER_AMAZON, RETAILER_TARGET).


credentials

val credentials: Credentials

Credentials for this account. See Credentials.


Credentials

Sealed class representing account credentials. Pass to Account when linking.

Package: com.microblink.linking

Declaration

sealed class Credentials

Subclasses

Credentials.None

data object None : Credentials

Use when no explicit credentials are needed — the SDK handles authentication via webview. Suitable for retailers that use web-based OAuth flows.


Credentials.Password

data class Password(
val username: String,
val password: String
) : Credentials

Username/password credentials for retailers that support direct credential authentication.

Properties:

PropertyTypeDescription
usernameStringAccount username or email
passwordStringAccount password

BlinkReceiptDigitalSdk

SDK initialization and configuration for email receipt parsing. Call initialize() in Application.onCreate() before using any client class.

Package: com.microblink.digital

Declaration

class BlinkReceiptDigitalSdk

Initialization

initialize(context)

fun initialize(context: Context)

Initializes the digital SDK.


initialize(context, callback)

fun initialize(context: Context, callback: InitializeCallback)

Initializes with a callback notified on completion.


initialize(context, licenseKey, callback)

fun initialize(context: Context, licenseKey: String, callback: InitializeCallback)

Initializes with a license key supplied inline.


Properties

licenseKey()

fun licenseKey(): String?

Returns the configured BlinkReceipt license key.


productIntelligenceKey()

fun productIntelligenceKey(): String?
fun productIntelligenceKey(key: String)

Product Intelligence key. Required for enriched product data on parsed e-receipts.


clientUserId()

fun clientUserId(): String?
fun clientUserId(clientUserId: String)

Optional client-supplied user identifier for mapping e-receipt results to your own user records.


versionName(context)

fun versionName(context: Context): String

SDK version name string.


versionCode(context)

fun versionCode(context: Context): String

SDK version code identifier.


GmailClient

Handles Gmail OAuth authentication and e-receipt parsing via the Gmail API.

Package: com.microblink.digital

Declaration

class GmailClient(context: Context, clientId: String) : Client
class GmailClient(context: Context, threads: Int, clientId: String) : Client

clientId is the OAuth 2.0 Client ID from the Google API Console.

Configuration Properties

dayCutoff()

fun dayCutoff(): Int
fun dayCutoff(days: Int)

Search depth in days.


dateCutoff()

fun dateCutoff(): Date?
fun dateCutoff(date: Date)

Specific date boundary, overrides dayCutoff when set.


searchUntil()

fun searchUntil(): Date?
fun searchUntil(date: Date)

Upper boundary for the search period.


countryCode()

fun countryCode(): String?
fun countryCode(code: String)

ISO country code to improve parsing accuracy for region-specific receipts.


sendersToSearch()

fun sendersToSearch(): Map<String, Merchant>?
fun sendersToSearch(senders: Map<String, Merchant>)

Maps sender email addresses to merchant identifiers for filtering.


filterSensitive()

fun filterSensitive(): Boolean
fun filterSensitive(filter: Boolean)

Whether to redact sensitive data from parsed results.


useAggregation()

fun useAggregation(): Boolean
fun useAggregation(aggregate: Boolean)

Whether to aggregate related emails (e.g., shipping updates) into a single result.


subProducts()

fun subProducts(): Boolean
fun subProducts(enabled: Boolean)

Whether sub-products are included in parsed results.


overrideEndpoint()

fun overrideEndpoint(): String?
fun overrideEndpoint(endpoint: String)

Override the server-side endpoint for result posting.


Authentication Methods

login()

fun login(): Task<GoogleSignInAccount>
fun login(activity: Activity, executor: Executor): Task<GoogleSignInAccount>

Initiates the Gmail OAuth sign-in flow.


account()

fun account(): Task<GoogleSignInAccount>
fun account(activity: Activity): Task<GoogleSignInAccount>

Returns the currently signed-in Google account.


logout()

fun logout(): Task<Boolean>
fun logout(executor: Executor): Task<Boolean>

Signs out the current Gmail account and clears stored tokens.


onAccountAuthorizationActivityResult(requestCode, resultCode, data)

fun onAccountAuthorizationActivityResult(
requestCode: Int,
resultCode: Int,
data: Intent
): Task<GoogleSignInAccount>

Pass-through for Activity.onActivityResult() to handle OAuth callback. Required for the OAuth flow to complete.


verify()

fun verify(): Task<Boolean>

Validates that stored Gmail credentials are still active.


Parsing Methods

messages(activity)

fun messages(activity: Activity): Task<List<ScanResults>>
fun messages(activity: Activity, executor: Executor): Task<List<ScanResults>>

Fetches and parses e-receipts from the signed-in Gmail account.


messages(provider, sender, html)

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

Parses e-receipt data from a raw HTML string for testing purposes.


clearLastCheckedTime()

fun clearLastCheckedTime(): Task<Boolean>

Resets the last-checked timestamp, causing the next messages() call to re-fetch from the cutoff date.


close()

fun close()

Releases client resources.


OutlookClient

Handles Outlook OAuth authentication and e-receipt parsing via the Microsoft Graph API.

Package: com.microblink.digital

Declaration

class OutlookClient(
context: Context,
@RawRes configuration: Int,
callback: InitializeCallback
) : Client

configuration is a @RawRes resource ID pointing to a MSAL configuration JSON file with your Azure App Registration client ID and redirect URI.

Authentication Methods

login(activity)

fun login(activity: Activity): Task<TokenCredentials>

Initiates the Outlook OAuth sign-in flow.


logout()

fun logout(): Task<Boolean>
fun logout(executor: Executor): Task<Boolean>

Signs out and clears stored tokens.


signedInAccount()

fun signedInAccount(): Task<IAccount>
fun signedInAccount(executor: Executor): Task<IAccount>

Returns the currently signed-in Microsoft account.


accounts()

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

Returns all cached Outlook accounts on the device.


verify()

fun verify(): Task<Boolean>

Validates that stored Outlook credentials are still active.


Parsing Methods

messages(provider, sender, html)

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

Parses e-receipt data from a raw HTML string for testing purposes.


remoteMessages()

fun remoteMessages(): Task<JobResults>
fun remoteMessages(executor: Executor): Task<JobResults>
fun remoteMessages(email: String, emlFile: ByteArray): Task<JobResults>

Queues a remote scrape job. Returns a JobResults with the job ID.


clearLastCheckedTime()

fun clearLastCheckedTime(): Task<Boolean>
fun clearLastCheckedTime(executor: Executor): Task<Boolean>

Resets the last-checked timestamp.


Configuration Properties

Same properties as GmailClient: dayCutoff, dateCutoff, searchUntil, countryCode, sendersToSearch, filterSensitive, useAggregation, subProducts.


close()

fun close()

Releases client resources.


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

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

link(credentials)

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

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


verify(credentials)

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

Validates that the provided credentials can authenticate successfully.


logout()

fun logout(): 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>>

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


remoteMessages(credentials)

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

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


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>

Resets the last-checked timestamp.


close()

fun close()

Releases client resources.


Provider

Enum of supported email providers.

Package: com.microblink.digital

Declaration

enum class Provider

Entries

EntryDescription
GMAILGmail via OAuth (use GmailClient)
OUTLOOK_SDKOutlook via OAuth (use OutlookClient)
AOLAOL Mail via IMAP (use ImapClient)
YAHOOYahoo Mail via IMAP (use ImapClient)

Properties & Methods

IMAP

val IMAP: Set<Provider>

The set of IMAP-compatible providers: {AOL, YAHOO}.


checkIfImapProvider(provider, shouldThrow)

fun checkIfImapProvider(provider: Provider, shouldThrow: Boolean): Boolean

Returns true if the provider uses IMAP. If shouldThrow is true and the provider is not IMAP, throws an exception.


imapHosts(provider)

fun imapHosts(provider: Provider): Host

Returns the IMAP host configuration for the given provider.


type()

fun type(): String

Returns a string identifier for this provider.


ProviderResults

Result returned from an IMAP link() call, bundling the setup outcome with the credentials that were used.

Package: com.microblink.digital

Declaration

data class ProviderResults(
val results: ProviderSetupResults,
val credentials: Credentials
)

Properties

results

val results: ProviderSetupResults

The outcome of the provider setup attempt. See ProviderSetupResults enum.


credentials

val credentials: Credentials

The credentials that were used in the setup attempt.


JobResults

Result returned from a remote scrape job (remoteMessages()).

Package: com.microblink.digital

Declaration

data class JobResults(
val id: Long? = null,
val success: Boolean? = false,
val code: JobStatusCode? = JobStatusCode.NONE,
val message: String? = null
)

Properties

id

val id: Long?

Server-assigned job identifier. Use this to poll for job completion if needed.

Default: null


success

val success: Boolean?

true if the job was queued successfully.

Default: false


code

val code: JobStatusCode?

Status code from the job submission. See JobStatusCode.

Default: JobStatusCode.NONE


message

val message: String?

Human-readable status or error message.

Default: null


JobStatusCode

Status codes returned by remote scrape job operations.

Package: com.microblink.digital

Declaration

enum class JobStatusCode(val code: Int)

Entries

EntryDescription
NONENo status / default
NO_PROVIDERNo email provider configured
INVALID_PROVIDERProvider value is not recognized
NO_CREDENTIALSNo credentials were supplied
CANT_OBTAIN_TOKENOAuth token could not be retrieved
INVALID_CREDENTIALSCredentials were rejected by the provider
EXPIRED_TOKENOAuth token has expired
NO_CLIENT_CONFIGURATIONMissing MSAL or OAuth client configuration
BAD_INPUTInvalid input parameters
TIMEOUTJob timed out
IMAP_NO_BOXESNo IMAP mailboxes found for the account
INVALID_RECEIPT_IDSProvided receipt IDs are invalid
CLIENT_ENDPOINT_ERRORSErrors from the configured client endpoint
JOB_IN_PROGRESSA job is already running for this account
IMAP_FAILED_CONNECTIONCould not connect to the IMAP server
UNKNOWNUnclassified error

Properties

code

val code: Int

Integer code value associated with this status.