User

Balance, profile, payments and the webhook URL — client.user.

balance

Balance in USD.

Future<Balance> balance()

Balance: balance, zbalance, income?, and the getter available. balance includes the sum frozen by numbers and unconfirmed rents in progress (zbalance, which may be negative): available = balance − max(zbalance, 0). income is the partner income. The server caches the answer for 60 s.

final balance = await client.user.balance();
print('${balance.available} of ${balance.balance} USD available');

Errors: ApiException ERROR_WRONG_KEY, ACCOUNT_BLOCKED, API_ACCESS_DISABLED, API_ACCESS_IP.

profile

The account profile.

Future<Profile> profile()

Profile: id, name?, username?, email?, locale?, currency?, numberCountry?, numberReject, webhookUrl?, apiAccess?, number? (int), country? (String), …

final profile = await client.user.profile();
print('${profile.email} ${profile.webhookUrl}');

paymentHistory

Top-up orders (paginated, newest first) and the available payment methods.

Future<PaymentHistory> paymentHistory({int page = 1})

PaymentHistory: orders (Paginator<PaymentOrder>), paylist, domains, currency. PaymentOrder.sum stays a decimal string ("89.00"); currency and formText may be null; PaymentOrder.raw holds every field as sent. paylist maps a group id to its payment methods; when the server sends it as a JSON array (ids 0, 1, 2…) the keys are '0', '1', …

final orders = (await client.user.paymentHistory()).orders;
print('${orders.total} orders, page ${orders.currentPage}/${orders.lastPage}');

setWebhookUrl

Set the URL that receives SMS webhooks (see Webhooks).

Future<void> setWebhookUrl(String url)
await client.user.setWebhookUrl('https://example.com/onlinesim-hook');

Errors: ApiException VALIDATION_ERROR for an invalid URL; message holds the server's field messages.

clearWebhookUrl

Remove the webhook URL, also from operations in progress.

Future<void> clearWebhookUrl()
await client.user.clearWebhookUrl();

webhookLogs

Webhook delivery log, newest first, 10 per page.

Future<Paginator<WebhookLog>> webhookLogs({int page = 1})

WebhookLog: id, userId, webhookUrl, type, params, status, error?, createdAt, updatedAt — type is WebhookType.receivingSms or WebhookType.rentSms, status is success, fail or pending, params the payload that was sent (a WebhookPayload).

final logs = await client.user.webhookLogs();
for (final log in logs.data) {
  print('${log.createdAt} ${log.status} ${log.error}');
}