Repository navigation
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).