onlinesim 1.0.1
onlinesim: ^1.0.1 copied to clipboard
Typed Dart client for the OnlineSim SMS API: numbers, rent, account, free numbers and webhooks, with a built-in offline mock for tests. Flutter and web.
Changelog #
1.0.1 #
Aligned with the regenerated backend API spec.
Fixed #
- Models:
Profile.numberisint?andProfile.countryisString?(they were swapped);FreeCountry.countryText/countryOriginal,FreeNumber.countryOriginalandPaymentOrder.currencyare nullable.Operation.responseis empty when the server sends none;RentSms.codeis'0'for anotifySMS (the server sends the integer0); rentsumis read from a number or a decimal string. Balance.availableisbalance − max(zbalance, 0).user.paymentHistory()no longer dropspaylistwhen the server sends it as a JSON array (ids 0, 1, 2…); it is kept as a map keyed'0','1', ….numbers.waitCoderetriesApiExceptionTRY_AGAIN_LATER(HTTP 429 rate limit),ERROR_UNDEFINEDandINTERVAL_CONCURRENT_REQUESTS_ERRORuntil its timeout instead of throwing at once.- Error messages:
"0"(ban not applied, the operation already has an SMS),ACCOUNT_CLEANED,USER_NOT_ACTIVATED,ERROR_UNDEFINED,FORWARD_NOT_SUPPORTEDadded;ERROR_NO_KEY,NO_NUMBER_FOR_FORWARD,ACCOUNT_IDENTIFICATION_REQUIRED,API_DISABLED(no longer sent) removed;NoNumberExceptiononly forNO_NUMBER;ERROR_WRONG_KEYreads "Wrong or missing API key". MockOnlineSimfollows the backend:setOperationReviseanswers{"tzid":"N","response":"1"}andERROR_WRONG_TZID/ERROR_NO_TZID;setOperationOktzid0→ERROR_NO_TZID; a missing key is HTTP 200ERROR_WRONG_KEY(456 only for a wrong key, also on public endpoints);getNumwithnumberaddstitle,response_text,guard_interval_remaining_seconds. Rent:getRentNumreserves the price (status0) and the first non-notifySMS confirms and charges it, unknown country →UNDEFINED_COUNTRY,suma number in getRentNum/extendRentState and a string in getRentState,guard_interval_remaining_secondswithnumber;extendRentStaterefusals are allTRY_AGAIN_LATER;closeRentNumunknown tzid →ERROR_NO_OPERATIONS, releases the reservation of an unconfirmed rent. Webhook-log params:code""without a code, rentnumberin full digits, renttime_leftin minutes,time_startper type.profile.phpaccepts anyscheme://…URL.getPaymentHistoryaddsdomains/forms/buttons;getFreeListlists 44 first, clampscountto 10..500, sends ISO-8601created_atandignore/content.MockRentgainsstatusandinitialDays.- Docs: rent reservation and
sum, available = balance − max(zbalance, 0),bananswer"0", webhooknumber/timeLeft/timeStart, thewaitCoderetry policy, the mock's behaviour.
1.0.0 #
First release.
Added #
OnlineSimclient:OnlineSim(apiKey:, baseUrl:, lang:, devId:, timeout:, transport:)with the sectionsnumbers,rent,userandfree. The key is sent asAuthorization: Bearer <key>, never in the URL. Pure Dart onpackage:http(Flutter, CLI, server, web); the transport is an injectableOnlineSimTransport(HttpTransportwraps anyhttp.Client).numbers:price,get,getWithNumber,state,stateOne,next,close,ban,tariffs,tariffsOne,waitCode(Durationinterval/timeout,keepOpen,fullMessage,since, injectablesleep/now, retries transient network errors).rent:get(extendable by default),state,stateOne,extend,close,tariffs,tariffsOne.user:balance,profile,paymentHistory,setWebhookUrl,clearWebhookUrl,webhookLogs.free.listfor public free numbers.parseWebhookfor inboundreceiving_sms/rent_smswebhooks.- Typed models with camelCase fields; decimal-string money parsed to
double, PHP[]empty maps returned as{}. - Sealed exceptions:
OnlineSimException→ApiException(code,message) →NoNumberException,TransportException(status,body),WaitTimeoutException,WebhookFormatException. MockOnlineSim: an in-process fake of the API for testing integrations offline — no network, key, money or clock.mock.client()returns a normalOnlineSimwired to it; the mock itself is anOnlineSimTransport. Helpers:addSms,addSmsAfter,failNext,failNextTransport,setBalance,balance,operations,rents,requests,reset.- Documentation site: https://s00d.github.io/onlinesim-dart-api/