Repository navigation
Releases
Releases · s00d/onlinesim-swift-api
v1.0.1
Aligned with the regenerated backend API spec.
Fixed
- Decoding:
NumberOperation.responseis optional (absent when no number could be issued; a getState item without it no longer fails to decode, which madewaitCodepoll until its timeout);PaymentOrder.currency/formText,FreeCountry.countryText/countryOriginalandFreeNumber.countryOriginalacceptnull(String?);Profile.numberisInt?andProfile.countryisString?(they were swapped). The changed models decode leniently. RentSms.code: the integer0of anotifySMS is normalised to"0"; rentsumis read from a number or a decimal string.user.paymentHistory()no longer dropspaylistwhen the server sends it as a JSON array (ids 0, 1, 2…): its items are kept under the keys"0","1","2"…numbers.waitCoderetries.apiTRY_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;.noNumberonly 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.MockRentgainsstatusandinitialDays. Webhook-log params:code""without a code, rentnumberin full digits, renttime_leftin minutes,time_startper type.profile.phpaccepts anyscheme://…URL.getPaymentHistoryaddsforms/buttons/domains;getFreeListlists 44 first, clampscountto 10..500, sends ISO-8601created_atandignore/content.- Docs: rent reservation and
sum, available = balance − max(zbalance, 0),bananswer"0",nexterrors, webhooknumber/timeLeft/timeStart, thewaitCoderetry policy, the mock's behaviour.
v1.0.0
First release of the Swift SDK for the OnlineSim API, on the same contract as the other OnlineSim SDKs (the JS SDK 2.1.0 is the reference). SwiftPM package OnlineSim, distributed by git tags.
Added
OnlineSimClient(apiKey:baseURL:lang:devID:timeout:transport:)(baseURLdefaulthttps://onlinesim.host/api/,timeoutin seconds) with the sectionsnumbers,rent,user,free. Every method isasync throws; the client and every model areSendable(checked with complete strict concurrency, built in the Swift 6 language mode in CI).- Swift 5.9+, macOS 12, iOS 15, tvOS 15, watchOS 8 and Linux (
FoundationNetworking). Zero dependencies. - The API key is sent as
Authorization: Bearer <key>, never in the query string. Booleans as1/0,rejectas a comma list, unset parameters omitted,orderbylowercase. Transportprotocol (send(_:) async throws -> TransportResponse) with the defaultURLSessionTransport(your ownURLSessionfor a proxy or custom TLS).- Errors: one
OnlineSimErrorenum —.api(code:message:),.noNumber(code:message:),.transport(message:status:body:),.waitTimeout(tzid:timeout:),.invalidPayload(message:)— withcodeandmessage. An HTTP 456 wrong-key answer is.api; profile validation errors are.api(code: "VALIDATION_ERROR", …). numbers:price,get,getWithNumber,state,stateOne,next,close,ban,tariffs,tariffsOne,waitCode(interval/timeoutin seconds,keepOpen,fullMessage,since, injectableWaitClock; retries transient transport errors).rent:get(extendable by default),state,stateOne,extend,tariffs,tariffsOne,close.user:balance,profile,paymentHistory,setWebhookURL,clearWebhookURL,webhookLogs.free.list.parseWebhook(_:)for inboundreceiving_sms/rent_smswebhooks (lenient), fromDataorString.- Codable models with Swift names (
webhookURL,guardIntervalRemainingSeconds, …). Normalisation of server quirks: decimal-string money (balance, rentsum) parsed toDouble, empty PHP maps[]read as empty dictionaries, country codes and rent days asIntkeys. MockOnlineSim: a built-in, in-process fake of the OnlineSim API for testing integrations offline — no network, key, money or clock.mock.client()returns a normalOnlineSimClientwired to it (the mock is theTransport). Test helpers:addSms,addSmsAfter,failNext,failNextTransport,setBalance,balance,operations,rents,requests,reset. See the testing guide.- DocC comments on the public API,
.spi.ymlfor Swift Package Index. - Offline XCTest suite (fake transport, fixtures, mock tests through the real client), docs examples compiled against the package, opt-in integration test, CI on macOS (latest Xcode, plus iOS/tvOS/watchOS builds) and Linux (Swift 5.9 and latest),
swift format lint --strict, smoke test of the package from a clean copy, documentation site (Nuxt Content).