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
Quick Reference
Properties
| Property | Description |
|---|---|
dayCutoff | How many days back to search for orders |
dateCutoff | Specific date boundary, overrides dayCutoff |
latestOrdersOnly | Whether to only fetch orders newer than the last fetch |
countryCode | ISO country code for the retailer's regional site |
webProxy | Optional web proxy configuration |
Methods
| Method | Description |
|---|---|
link(account) | Links one or more retailer accounts |
verify(retailerId, success, failure, preview) | Verifies stored credentials for a retailer |
orders(retailerId, success, failure, preview) | Fetches new orders for the specified retailer |
accounts() | Returns all currently linked accounts |
unlink() | Unlinks all accounts or a specific account |
resetHistory() | Resets order fetch history |
close() | Releases resources |
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:
| Parameter | Description |
|---|---|
retailerId | Retailer constant from com.microblink.linking (e.g., RETAILER_AMAZON) |
success | Called with true if credentials are valid, plus a session UUID |
failure | Called with an AccountLinkingException on error |
preview | Optional 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:
| Parameter | Description |
|---|---|
retailerId | Retailer constant |
success | Called for each order with the retailer ID, parsed ScanResults (nullable), remaining order count, and session UUID |
failure | Called with the retailer ID and exception on error; has a default no-op implementation |
preview | Optional callback receiving a View for in-progress web interaction |
accounts()
fun accounts(): Task<List<Account>?>
Returns all currently linked accounts stored on the device.
unlink()
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.