[{"data":1,"prerenderedAt":2010},["ShallowReactive",2],{"navigation":3,"\u002Ftesting":43,"\u002Ftesting-surround":2005},[4,8,13,18,23,28,33,38],{"title":5,"path":6,"stem":7},"Getting started","\u002F","index",{"title":9,"path":10,"stem":11,"order":12},"Numbers","\u002Fnumbers","numbers",1,{"title":14,"path":15,"stem":16,"order":17},"Rent","\u002Frent","rent",2,{"title":19,"path":20,"stem":21,"order":22},"User","\u002Fuser","user",3,{"title":24,"path":25,"stem":26,"order":27},"Free numbers","\u002Ffree","free",4,{"title":29,"path":30,"stem":31,"order":32},"Webhooks","\u002Fwebhooks","webhooks",5,{"title":34,"path":35,"stem":36,"order":37},"Testing","\u002Ftesting","testing",6,{"title":39,"path":40,"stem":41,"order":42},"Changelog","\u002Fchangelog","changelog",7,{"id":44,"title":34,"body":45,"description":1999,"extension":2000,"meta":2001,"navigation":2002,"path":35,"seo":2003,"stem":36,"__hash__":2004},"docs\u002Ftesting.md",{"type":46,"value":47,"toc":1991},"minimark",[48,68,73,155,293,413,443,506,515,519,537,862,887,891,919,1257,1317,1321,1337,1609,1613,1790,1794,1987],[49,50,51,55,56,59,60,63,64,67],"p",{},[52,53,54],"code",{},"MockOnlineSim"," is an in-process fake of the OnlineSim API that ships with the package. It is a ",[52,57,58],{},"Transport"," that answers like the real backend — same shapes, same error codes, HTTP 456 for a wrong key (HTTP 200 ",[52,61,62],{},"ERROR_WRONG_KEY"," for none) — and keeps a balance, operations and rents. Your code talks to a normal ",[52,65,66],{},"OnlineSimClient",", so nothing in it changes for tests. It is deterministic: no randomness, no clock, numbers and ids come from a counter.",[69,70,72],"h2",{"id":71},"setup","Setup",[74,75,80],"pre",{"className":76,"code":77,"language":78,"meta":79,"style":79},"language-swift shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","import OnlineSim\n\nlet mock = MockOnlineSim(balance: 10)\nlet client = mock.client() \u002F\u002F an OnlineSimClient wired to the mock\n","swift","",[52,81,82,94,100,133],{"__ignoreMap":79},[83,84,86,90],"span",{"class":85,"line":12},"line",[83,87,89],{"class":88},"s7zQu","import",[83,91,93],{"class":92},"sBMFI"," OnlineSim\n",[83,95,96],{"class":85,"line":17},[83,97,99],{"emptyLinePlaceholder":98},true,"\n",[83,101,102,106,110,114,118,121,124,127,130],{"class":85,"line":22},[83,103,105],{"class":104},"sbssI","let",[83,107,109],{"class":108},"sTEyZ"," mock ",[83,111,113],{"class":112},"sMK4o","=",[83,115,117],{"class":116},"s2Zo4"," MockOnlineSim",[83,119,120],{"class":112},"(",[83,122,123],{"class":116},"balance",[83,125,126],{"class":112},":",[83,128,129],{"class":104}," 10",[83,131,132],{"class":112},")\n",[83,134,135,137,140,142,145,148,151],{"class":85,"line":27},[83,136,105],{"class":104},[83,138,139],{"class":108}," client ",[83,141,113],{"class":112},[83,143,144],{"class":108}," mock.",[83,146,147],{"class":116},"client",[83,149,150],{"class":112},"()",[83,152,154],{"class":153},"sHwdD"," \u002F\u002F an OnlineSimClient wired to the mock\n",[74,156,158],{"className":76,"code":157,"language":78,"meta":79,"style":79},"init(\n    apiKey: String = \"mock-key\",\n    balance: Double = 100,                                       \u002F\u002F USD\n    prices: [Int: [String: Double]] = MockOnlineSim.defaultPrices, \u002F\u002F country → service → USD\n    rentTariffs: [Int: MockRentTariff] = MockOnlineSim.defaultRentTariffs,\n    guardInterval: Int = 0                                       \u002F\u002F seconds\n)\n",[52,159,160,169,197,215,248,272,289],{"__ignoreMap":79},[83,161,162,166],{"class":85,"line":12},[83,163,165],{"class":164},"spNyl","init",[83,167,168],{"class":112},"(\n",[83,170,171,175,178,181,184,187,191,194],{"class":85,"line":17},[83,172,174],{"class":173},"sjYur","    apiKey",[83,176,177],{"class":108},": ",[83,179,180],{"class":92},"String",[83,182,183],{"class":112}," =",[83,185,186],{"class":112}," \"",[83,188,190],{"class":189},"sfazB","mock-key",[83,192,193],{"class":112},"\"",[83,195,196],{"class":108},",\n",[83,198,199,202,204,207,209,212],{"class":85,"line":22},[83,200,201],{"class":173},"    balance",[83,203,177],{"class":108},[83,205,206],{"class":92},"Double",[83,208,183],{"class":112},[83,210,211],{"class":104}," 100",[83,213,214],{"class":108},",                                       \u002F\u002F USD\n",[83,216,217,220,222,225,228,230,233,235,237,240,243,245],{"class":85,"line":27},[83,218,219],{"class":173},"    prices",[83,221,177],{"class":108},[83,223,224],{"class":112},"[",[83,226,227],{"class":92},"Int",[83,229,126],{"class":112},[83,231,232],{"class":112}," [",[83,234,180],{"class":92},[83,236,126],{"class":112},[83,238,239],{"class":92}," Double",[83,241,242],{"class":112},"]]",[83,244,183],{"class":112},[83,246,247],{"class":108}," MockOnlineSim.defaultPrices, \u002F\u002F country → service → USD\n",[83,249,250,253,255,257,259,261,264,267,269],{"class":85,"line":32},[83,251,252],{"class":173},"    rentTariffs",[83,254,177],{"class":108},[83,256,224],{"class":112},[83,258,227],{"class":92},[83,260,126],{"class":112},[83,262,263],{"class":108}," MockRentTariff",[83,265,266],{"class":112},"]",[83,268,183],{"class":112},[83,270,271],{"class":108}," MockOnlineSim.defaultRentTariffs,\n",[83,273,274,277,279,281,283,286],{"class":85,"line":37},[83,275,276],{"class":173},"    guardInterval",[83,278,177],{"class":108},[83,280,227],{"class":92},[83,282,183],{"class":112},[83,284,285],{"class":104}," 0",[83,287,288],{"class":153},"                                       \u002F\u002F seconds\n",[83,290,291],{"class":85,"line":42},[83,292,132],{"class":112},[294,295,296,312],"table",{},[297,298,299],"thead",{},[300,301,302,306,309],"tr",{},[303,304,305],"th",{},"Parameter",[303,307,308],{},"Default",[303,310,311],{},"Description",[313,314,315,339,353,372,391],"tbody",{},[300,316,317,323,328],{},[318,319,320],"td",{},[52,321,322],{},"apiKey",[318,324,325],{},[52,326,327],{},"\"mock-key\"",[318,329,330,331,334,335,338],{},"Key the mock accepts. ",[52,332,333],{},"mock.client()"," uses it; ",[52,336,337],{},"mock.client(apiKey: \"x\")"," tests a wrong key.",[300,340,341,345,350],{},[318,342,343],{},[52,344,123],{},[318,346,347],{},[52,348,349],{},"100",[318,351,352],{},"Starting balance, USD.",[300,354,355,360,365],{},[318,356,357],{},[52,358,359],{},"prices",[318,361,362],{},[52,363,364],{},"[7: [\"vkcom\": 0.5, \"telegram\": 1.2, \"google\": 0.3], 44: [\"google\": 0.2, \"vkcom\": 0.36]]",[318,366,367,368,371],{},"Number prices; replace the defaults. Also feed ",[52,369,370],{},"numbers.tariffs()",".",[300,373,374,379,384],{},[318,375,376],{},[52,377,378],{},"rentTariffs",[318,380,381],{},[52,382,383],{},"[7: MockRentTariff(days: [1: 1, 3: 2.5, 7: 5], extend: 1)]",[318,385,386,387,390],{},"Rent prices; ",[52,388,389],{},"extend: 0"," makes rents of that country non-extendable.",[300,392,393,398,403],{},[318,394,395],{},[52,396,397],{},"guardInterval",[318,399,400],{},[52,401,402],{},"0",[318,404,405,408,409,412],{},[52,406,407],{},"> 0",": an operation without SMS, or an unconfirmed rent without any SMS, cannot be closed (",[52,410,411],{},"NO_COMPLETE_TZID",").",[49,414,415,418,419,424,425,428,429,432,433,436,437,439,440,442],{},[52,416,417],{},"mock.client(apiKey:lang:devID:timeout:)"," takes the usual ",[420,421,423],"a",{"href":422},"\u002F#client-options","client options"," except ",[52,426,427],{},"baseURL"," and ",[52,430,431],{},"transport",". To build the client yourself, pass ",[52,434,435],{},"mock.transport"," (the mock itself) as ",[52,438,431],{},"; any ",[52,441,427],{}," works:",[74,444,446],{"className":76,"code":445,"language":78,"meta":79,"style":79},"import OnlineSim\n\nlet mock = MockOnlineSim()\nlet client = OnlineSimClient(apiKey: \"mock-key\", transport: mock.transport)\n",[52,447,448,454,458,471],{"__ignoreMap":79},[83,449,450,452],{"class":85,"line":12},[83,451,89],{"class":88},[83,453,93],{"class":92},[83,455,456],{"class":85,"line":17},[83,457,99],{"emptyLinePlaceholder":98},[83,459,460,462,464,466,468],{"class":85,"line":22},[83,461,105],{"class":104},[83,463,109],{"class":108},[83,465,113],{"class":112},[83,467,117],{"class":116},[83,469,470],{"class":112},"()\n",[83,472,473,475,477,479,482,484,486,488,490,492,494,497,499,501,504],{"class":85,"line":27},[83,474,105],{"class":104},[83,476,139],{"class":108},[83,478,113],{"class":112},[83,480,481],{"class":116}," OnlineSimClient",[83,483,120],{"class":112},[83,485,322],{"class":116},[83,487,126],{"class":112},[83,489,186],{"class":112},[83,491,190],{"class":189},[83,493,193],{"class":112},[83,495,496],{"class":108},", ",[83,498,431],{"class":116},[83,500,126],{"class":112},[83,502,503],{"class":108}," mock.transport",[83,505,132],{"class":112},[49,507,508,510,511,514],{},[52,509,54],{}," is a ",[52,512,513],{},"Sendable"," final class: its state is one value behind one lock, so the helpers below are synchronous and the mock can serve concurrent requests.",[69,516,518],{"id":517},"a-full-example","A full example",[49,520,521,522,525,526,529,530,532,533,536],{},"Order a number, let an SMS arrive while ",[52,523,524],{},"waitCode"," polls, check the code and the money. ",[52,527,528],{},"addSmsAfter"," delivers the SMS after a number of polls instead of after some time, so ",[52,531,524],{}," runs with ",[52,534,535],{},"interval: 0"," and the test takes milliseconds.",[74,538,540],{"className":76,"code":539,"language":78,"meta":79,"style":79},"import OnlineSim\nimport XCTest\n\nfinal class SignUpTests: XCTestCase {\n    func testReceivesTheCode() async throws {\n        let mock = MockOnlineSim(balance: 10)\n        let client = mock.client()\n\n        let order = try await client.numbers.getWithNumber(\"google\", country: 44)\n        XCTAssertEqual(order.number, \"+44900000001\")\n\n        try mock.addSmsAfter(order.tzid, \"Your Google code: 123-456\", polls: 2) \u002F\u002F the third poll sees it\n        let code = try await client.numbers.waitCode(order.tzid, interval: 0)\n\n        XCTAssertEqual(code, \"123456\")\n        XCTAssertEqual(mock.operations().first?.status, .tzOverOk) \u002F\u002F waitCode closed it\n        XCTAssertEqual(mock.balance(), 9.8) \u002F\u002F the price is spent once an SMS arrived\n    }\n}\n",[52,541,542,548,555,559,578,597,618,632,637,680,700,705,743,774,779,798,827,850,856],{"__ignoreMap":79},[83,543,544,546],{"class":85,"line":12},[83,545,89],{"class":88},[83,547,93],{"class":92},[83,549,550,552],{"class":85,"line":17},[83,551,89],{"class":88},[83,553,554],{"class":92}," XCTest\n",[83,556,557],{"class":85,"line":22},[83,558,99],{"emptyLinePlaceholder":98},[83,560,561,564,567,570,572,575],{"class":85,"line":27},[83,562,563],{"class":164},"final",[83,565,566],{"class":164}," class",[83,568,569],{"class":92}," SignUpTests",[83,571,126],{"class":112},[83,573,574],{"class":92}," XCTestCase ",[83,576,577],{"class":112},"{\n",[83,579,580,583,586,588,591,594],{"class":85,"line":32},[83,581,582],{"class":164},"    func",[83,584,585],{"class":116}," testReceivesTheCode",[83,587,150],{"class":112},[83,589,590],{"class":164}," async",[83,592,593],{"class":164}," throws",[83,595,596],{"class":112}," {\n",[83,598,599,602,604,606,608,610,612,614,616],{"class":85,"line":37},[83,600,601],{"class":104},"        let",[83,603,109],{"class":108},[83,605,113],{"class":112},[83,607,117],{"class":116},[83,609,120],{"class":112},[83,611,123],{"class":116},[83,613,126],{"class":112},[83,615,129],{"class":104},[83,617,132],{"class":112},[83,619,620,622,624,626,628,630],{"class":85,"line":42},[83,621,601],{"class":104},[83,623,139],{"class":108},[83,625,113],{"class":112},[83,627,144],{"class":108},[83,629,147],{"class":116},[83,631,470],{"class":112},[83,633,635],{"class":85,"line":634},8,[83,636,99],{"emptyLinePlaceholder":98},[83,638,640,642,645,647,650,653,656,659,661,663,666,668,670,673,675,678],{"class":85,"line":639},9,[83,641,601],{"class":104},[83,643,644],{"class":108}," order ",[83,646,113],{"class":112},[83,648,649],{"class":88}," try",[83,651,652],{"class":88}," await",[83,654,655],{"class":108}," client.numbers.",[83,657,658],{"class":116},"getWithNumber",[83,660,120],{"class":112},[83,662,193],{"class":112},[83,664,665],{"class":189},"google",[83,667,193],{"class":112},[83,669,496],{"class":108},[83,671,672],{"class":116},"country",[83,674,126],{"class":112},[83,676,677],{"class":104}," 44",[83,679,132],{"class":112},[83,681,683,686,688,691,693,696,698],{"class":85,"line":682},10,[83,684,685],{"class":116},"        XCTAssertEqual",[83,687,120],{"class":112},[83,689,690],{"class":108},"order.number, ",[83,692,193],{"class":112},[83,694,695],{"class":189},"+44900000001",[83,697,193],{"class":112},[83,699,132],{"class":112},[83,701,703],{"class":85,"line":702},11,[83,704,99],{"emptyLinePlaceholder":98},[83,706,708,711,713,715,717,720,722,725,727,729,732,734,737,740],{"class":85,"line":707},12,[83,709,710],{"class":88},"        try",[83,712,144],{"class":108},[83,714,528],{"class":116},[83,716,120],{"class":112},[83,718,719],{"class":108},"order.tzid, ",[83,721,193],{"class":112},[83,723,724],{"class":189},"Your Google code: 123-456",[83,726,193],{"class":112},[83,728,496],{"class":108},[83,730,731],{"class":116},"polls",[83,733,126],{"class":112},[83,735,736],{"class":104}," 2",[83,738,739],{"class":112},")",[83,741,742],{"class":153}," \u002F\u002F the third poll sees it\n",[83,744,746,748,751,753,755,757,759,761,763,765,768,770,772],{"class":85,"line":745},13,[83,747,601],{"class":104},[83,749,750],{"class":108}," code ",[83,752,113],{"class":112},[83,754,649],{"class":88},[83,756,652],{"class":88},[83,758,655],{"class":108},[83,760,524],{"class":116},[83,762,120],{"class":112},[83,764,719],{"class":108},[83,766,767],{"class":116},"interval",[83,769,126],{"class":112},[83,771,285],{"class":104},[83,773,132],{"class":112},[83,775,777],{"class":85,"line":776},14,[83,778,99],{"emptyLinePlaceholder":98},[83,780,782,784,786,789,791,794,796],{"class":85,"line":781},15,[83,783,685],{"class":116},[83,785,120],{"class":112},[83,787,788],{"class":108},"code, ",[83,790,193],{"class":112},[83,792,793],{"class":189},"123456",[83,795,193],{"class":112},[83,797,132],{"class":112},[83,799,801,803,805,808,811,813,816,819,822,824],{"class":85,"line":800},16,[83,802,685],{"class":116},[83,804,120],{"class":112},[83,806,807],{"class":108},"mock.",[83,809,810],{"class":116},"operations",[83,812,150],{"class":112},[83,814,815],{"class":108},".first",[83,817,818],{"class":112},"?",[83,820,821],{"class":108},".status, .tzOverOk",[83,823,739],{"class":112},[83,825,826],{"class":153}," \u002F\u002F waitCode closed it\n",[83,828,830,832,834,836,838,840,842,845,847],{"class":85,"line":829},17,[83,831,685],{"class":116},[83,833,120],{"class":112},[83,835,807],{"class":108},[83,837,123],{"class":116},[83,839,150],{"class":112},[83,841,496],{"class":108},[83,843,844],{"class":104},"9.8",[83,846,739],{"class":112},[83,848,849],{"class":153}," \u002F\u002F the price is spent once an SMS arrived\n",[83,851,853],{"class":85,"line":852},18,[83,854,855],{"class":112},"    }\n",[83,857,859],{"class":85,"line":858},19,[83,860,861],{"class":112},"}\n",[49,863,864,865,868,869,872,873,875,876,879,880,883,884,886],{},"The ",[52,866,867],{},"msg"," of an operation is the code by default: the first run of 4–8 digits, with spaces and dashes between digits removed (",[52,870,871],{},"123-456"," → ",[52,874,793],{},"); a text without such a run comes back whole. ",[52,877,878],{},"messageToCode: false"," (or ",[52,881,882],{},"fullMessage"," in ",[52,885,524],{},") gives the full text.",[69,888,890],{"id":889},"errors","Errors",[49,892,893,896,897,900,901,879,904,907,908,911,912,915,916,412],{},[52,894,895],{},"failNext(_:endpoint:)"," makes the next request answer ",[52,898,899],{},"{\"response\": code}"," — the client turns it into ",[52,902,903],{},"OnlineSimError.api",[52,905,906],{},".noNumber",") exactly as for the real server. Pass ",[52,909,910],{},"endpoint"," to fail only that endpoint. ",[52,913,914],{},"failNextTransport(status:endpoint:)"," makes the next request fail with a non-JSON HTTP 502 (",[52,917,918],{},".transport",[74,920,922],{"className":76,"code":921,"language":78,"meta":79,"style":79},"import OnlineSim\nimport XCTest\n\nfinal class FailureTests: XCTestCase {\n    func testHandlesAMissingNumberAndANetworkHiccup() async throws {\n        let mock = MockOnlineSim()\n        let client = mock.client()\n\n        mock.failNext(\"NO_NUMBER\", endpoint: \"getNum.php\")\n        do {\n            _ = try await client.numbers.get(\"google\")\n            XCTFail(\"expected NO_NUMBER\")\n        } catch OnlineSimError.noNumber {}\n\n        mock.failNextTransport(status: 503)\n        do {\n            _ = try await client.user.balance()\n            XCTFail(\"expected a transport error\")\n        } catch OnlineSimError.transport(_, let status, _) {\n            XCTAssertEqual(status, 503)\n        }\n\n        let balance = try await client.user.balance() \u002F\u002F one-shot\n        XCTAssertEqual(balance.balance, 100)\n    }\n}\n",[52,923,924,930,936,940,955,970,982,996,1000,1032,1039,1065,1081,1098,1102,1121,1127,1144,1159,1183,1199,1205,1210,1233,1247,1252],{"__ignoreMap":79},[83,925,926,928],{"class":85,"line":12},[83,927,89],{"class":88},[83,929,93],{"class":92},[83,931,932,934],{"class":85,"line":17},[83,933,89],{"class":88},[83,935,554],{"class":92},[83,937,938],{"class":85,"line":22},[83,939,99],{"emptyLinePlaceholder":98},[83,941,942,944,946,949,951,953],{"class":85,"line":27},[83,943,563],{"class":164},[83,945,566],{"class":164},[83,947,948],{"class":92}," FailureTests",[83,950,126],{"class":112},[83,952,574],{"class":92},[83,954,577],{"class":112},[83,956,957,959,962,964,966,968],{"class":85,"line":32},[83,958,582],{"class":164},[83,960,961],{"class":116}," testHandlesAMissingNumberAndANetworkHiccup",[83,963,150],{"class":112},[83,965,590],{"class":164},[83,967,593],{"class":164},[83,969,596],{"class":112},[83,971,972,974,976,978,980],{"class":85,"line":37},[83,973,601],{"class":104},[83,975,109],{"class":108},[83,977,113],{"class":112},[83,979,117],{"class":116},[83,981,470],{"class":112},[83,983,984,986,988,990,992,994],{"class":85,"line":42},[83,985,601],{"class":104},[83,987,139],{"class":108},[83,989,113],{"class":112},[83,991,144],{"class":108},[83,993,147],{"class":116},[83,995,470],{"class":112},[83,997,998],{"class":85,"line":634},[83,999,99],{"emptyLinePlaceholder":98},[83,1001,1002,1005,1008,1010,1012,1015,1017,1019,1021,1023,1025,1028,1030],{"class":85,"line":639},[83,1003,1004],{"class":108},"        mock.",[83,1006,1007],{"class":116},"failNext",[83,1009,120],{"class":112},[83,1011,193],{"class":112},[83,1013,1014],{"class":189},"NO_NUMBER",[83,1016,193],{"class":112},[83,1018,496],{"class":108},[83,1020,910],{"class":116},[83,1022,126],{"class":112},[83,1024,186],{"class":112},[83,1026,1027],{"class":189},"getNum.php",[83,1029,193],{"class":112},[83,1031,132],{"class":112},[83,1033,1034,1037],{"class":85,"line":682},[83,1035,1036],{"class":88},"        do",[83,1038,596],{"class":112},[83,1040,1041,1044,1046,1048,1050,1052,1055,1057,1059,1061,1063],{"class":85,"line":702},[83,1042,1043],{"class":108},"            _ ",[83,1045,113],{"class":112},[83,1047,649],{"class":88},[83,1049,652],{"class":88},[83,1051,655],{"class":108},[83,1053,1054],{"class":164},"get",[83,1056,120],{"class":112},[83,1058,193],{"class":112},[83,1060,665],{"class":189},[83,1062,193],{"class":112},[83,1064,132],{"class":112},[83,1066,1067,1070,1072,1074,1077,1079],{"class":85,"line":707},[83,1068,1069],{"class":116},"            XCTFail",[83,1071,120],{"class":112},[83,1073,193],{"class":112},[83,1075,1076],{"class":189},"expected NO_NUMBER",[83,1078,193],{"class":112},[83,1080,132],{"class":112},[83,1082,1083,1086,1089,1092,1095],{"class":85,"line":745},[83,1084,1085],{"class":112},"        }",[83,1087,1088],{"class":88}," catch",[83,1090,1091],{"class":108}," OnlineSimError.",[83,1093,1094],{"class":116},"noNumber",[83,1096,1097],{"class":112}," {}\n",[83,1099,1100],{"class":85,"line":776},[83,1101,99],{"emptyLinePlaceholder":98},[83,1103,1104,1106,1109,1111,1114,1116,1119],{"class":85,"line":781},[83,1105,1004],{"class":108},[83,1107,1108],{"class":116},"failNextTransport",[83,1110,120],{"class":112},[83,1112,1113],{"class":116},"status",[83,1115,126],{"class":112},[83,1117,1118],{"class":104}," 503",[83,1120,132],{"class":112},[83,1122,1123,1125],{"class":85,"line":800},[83,1124,1036],{"class":88},[83,1126,596],{"class":112},[83,1128,1129,1131,1133,1135,1137,1140,1142],{"class":85,"line":829},[83,1130,1043],{"class":108},[83,1132,113],{"class":112},[83,1134,649],{"class":88},[83,1136,652],{"class":88},[83,1138,1139],{"class":108}," client.user.",[83,1141,123],{"class":116},[83,1143,470],{"class":112},[83,1145,1146,1148,1150,1152,1155,1157],{"class":85,"line":852},[83,1147,1069],{"class":116},[83,1149,120],{"class":112},[83,1151,193],{"class":112},[83,1153,1154],{"class":189},"expected a transport error",[83,1156,193],{"class":112},[83,1158,132],{"class":112},[83,1160,1161,1163,1165,1167,1169,1171,1174,1176,1179,1181],{"class":85,"line":858},[83,1162,1085],{"class":112},[83,1164,1088],{"class":88},[83,1166,1091],{"class":108},[83,1168,431],{"class":116},[83,1170,120],{"class":112},[83,1172,1173],{"class":108},"_, ",[83,1175,105],{"class":104},[83,1177,1178],{"class":108}," status, _",[83,1180,739],{"class":112},[83,1182,596],{"class":112},[83,1184,1186,1189,1191,1194,1197],{"class":85,"line":1185},20,[83,1187,1188],{"class":116},"            XCTAssertEqual",[83,1190,120],{"class":112},[83,1192,1193],{"class":108},"status, ",[83,1195,1196],{"class":104},"503",[83,1198,132],{"class":112},[83,1200,1202],{"class":85,"line":1201},21,[83,1203,1204],{"class":112},"        }\n",[83,1206,1208],{"class":85,"line":1207},22,[83,1209,99],{"emptyLinePlaceholder":98},[83,1211,1213,1215,1218,1220,1222,1224,1226,1228,1230],{"class":85,"line":1212},23,[83,1214,601],{"class":104},[83,1216,1217],{"class":108}," balance ",[83,1219,113],{"class":112},[83,1221,649],{"class":88},[83,1223,652],{"class":88},[83,1225,1139],{"class":108},[83,1227,123],{"class":116},[83,1229,150],{"class":112},[83,1231,1232],{"class":153}," \u002F\u002F one-shot\n",[83,1234,1236,1238,1240,1243,1245],{"class":85,"line":1235},24,[83,1237,685],{"class":116},[83,1239,120],{"class":112},[83,1241,1242],{"class":108},"balance.balance, ",[83,1244,349],{"class":104},[83,1246,132],{"class":112},[83,1248,1250],{"class":85,"line":1249},25,[83,1251,855],{"class":112},[83,1253,1255],{"class":85,"line":1254},26,[83,1256,861],{"class":112},[49,1258,1259,1260,1263,1264,1266,1267,1270,1271,1274,1275,1278,1279,1282,1283,1286,1287,1290,1291,1293,1294,1274,1296,1299,1300,1303,1304,496,1307,1310,1311,496,1314,1316],{},"The state itself produces the real error codes too: ",[52,1261,1262],{},"WARNING_LOW_BALANCE"," when the balance is short, ",[52,1265,1014],{}," when ",[52,1268,1269],{},"reject"," matches the next number, ",[52,1272,1273],{},"UNDEFINED_COUNTRY"," \u002F ",[52,1276,1277],{},"ERROR_NO_SERVICE"," for unknown prices, ",[52,1280,1281],{},"ERROR_WRONG_TZID"," for an unknown or closed operation (",[52,1284,1285],{},"next"," too; ",[52,1288,1289],{},"ERROR_NO_TZID"," for tzid ",[52,1292,402],{},"), ",[52,1295,1273],{},[52,1297,1298],{},"UNDEFINED_DAYS"," for an unknown rent country or period, ",[52,1301,1302],{},"TRY_AGAIN_LATER"," for every refused ",[52,1305,1306],{},"rent.extend",[52,1308,1309],{},"ERROR_NO_OPERATIONS"," for an unknown rent in ",[52,1312,1313],{},"rent.close",[52,1315,62],{}," for a wrong key (HTTP 456) or no key (HTTP 200).",[69,1318,1320],{"id":1319},"inspecting-requests","Inspecting requests",[49,1322,1323,1326,1327,496,1330,1333,1334,371],{},[52,1324,1325],{},"mock.requests"," lists every request received: ",[52,1328,1329],{},"MockRequest(method:path:query:body:)",[52,1331,1332],{},"path"," relative to ",[52,1335,1336],{},"\u002Fapi\u002F",[74,1338,1340],{"className":76,"code":1339,"language":78,"meta":79,"style":79},"import OnlineSim\nimport XCTest\n\nfinal class RequestTests: XCTestCase {\n    func testSendsRejectAsACommaList() async throws {\n        let mock = MockOnlineSim()\n        _ = try await mock.client().numbers.get(\"google\", country: 44, reject: [\"4470\", \"4471\"])\n\n        XCTAssertEqual(mock.requests, [\n            MockRequest(\n                method: \"GET\", path: \"getNum.php\",\n                query: [\"service\": \"google\", \"country\": \"44\", \"reject\": \"4470,4471\", \"lang\": \"en\"])\n        ])\n    }\n}\n",[52,1341,1342,1348,1354,1358,1373,1388,1400,1466,1470,1479,1486,1514,1594,1601,1605],{"__ignoreMap":79},[83,1343,1344,1346],{"class":85,"line":12},[83,1345,89],{"class":88},[83,1347,93],{"class":92},[83,1349,1350,1352],{"class":85,"line":17},[83,1351,89],{"class":88},[83,1353,554],{"class":92},[83,1355,1356],{"class":85,"line":22},[83,1357,99],{"emptyLinePlaceholder":98},[83,1359,1360,1362,1364,1367,1369,1371],{"class":85,"line":27},[83,1361,563],{"class":164},[83,1363,566],{"class":164},[83,1365,1366],{"class":92}," RequestTests",[83,1368,126],{"class":112},[83,1370,574],{"class":92},[83,1372,577],{"class":112},[83,1374,1375,1377,1380,1382,1384,1386],{"class":85,"line":32},[83,1376,582],{"class":164},[83,1378,1379],{"class":116}," testSendsRejectAsACommaList",[83,1381,150],{"class":112},[83,1383,590],{"class":164},[83,1385,593],{"class":164},[83,1387,596],{"class":112},[83,1389,1390,1392,1394,1396,1398],{"class":85,"line":37},[83,1391,601],{"class":104},[83,1393,109],{"class":108},[83,1395,113],{"class":112},[83,1397,117],{"class":116},[83,1399,470],{"class":112},[83,1401,1402,1405,1407,1409,1411,1413,1415,1417,1420,1422,1424,1426,1428,1430,1432,1434,1436,1438,1440,1442,1444,1446,1448,1451,1453,1455,1457,1460,1462,1464],{"class":85,"line":42},[83,1403,1404],{"class":108},"        _ ",[83,1406,113],{"class":112},[83,1408,649],{"class":88},[83,1410,652],{"class":88},[83,1412,144],{"class":108},[83,1414,147],{"class":116},[83,1416,150],{"class":112},[83,1418,1419],{"class":108},".numbers.",[83,1421,1054],{"class":164},[83,1423,120],{"class":112},[83,1425,193],{"class":112},[83,1427,665],{"class":189},[83,1429,193],{"class":112},[83,1431,496],{"class":108},[83,1433,672],{"class":116},[83,1435,126],{"class":112},[83,1437,677],{"class":104},[83,1439,496],{"class":108},[83,1441,1269],{"class":116},[83,1443,126],{"class":112},[83,1445,232],{"class":108},[83,1447,193],{"class":112},[83,1449,1450],{"class":189},"4470",[83,1452,193],{"class":112},[83,1454,496],{"class":108},[83,1456,193],{"class":112},[83,1458,1459],{"class":189},"4471",[83,1461,193],{"class":112},[83,1463,266],{"class":108},[83,1465,132],{"class":112},[83,1467,1468],{"class":85,"line":634},[83,1469,99],{"emptyLinePlaceholder":98},[83,1471,1472,1474,1476],{"class":85,"line":639},[83,1473,685],{"class":116},[83,1475,120],{"class":112},[83,1477,1478],{"class":108},"mock.requests, [\n",[83,1480,1481,1484],{"class":85,"line":682},[83,1482,1483],{"class":116},"            MockRequest",[83,1485,168],{"class":112},[83,1487,1488,1491,1493,1495,1498,1500,1502,1504,1506,1508,1510,1512],{"class":85,"line":702},[83,1489,1490],{"class":116},"                method",[83,1492,126],{"class":112},[83,1494,186],{"class":112},[83,1496,1497],{"class":189},"GET",[83,1499,193],{"class":112},[83,1501,496],{"class":108},[83,1503,1332],{"class":116},[83,1505,126],{"class":112},[83,1507,186],{"class":112},[83,1509,1027],{"class":189},[83,1511,193],{"class":112},[83,1513,196],{"class":108},[83,1515,1516,1519,1521,1523,1525,1528,1530,1532,1534,1536,1538,1540,1542,1544,1546,1548,1550,1553,1555,1557,1559,1561,1563,1565,1567,1570,1572,1574,1576,1579,1581,1583,1585,1588,1590,1592],{"class":85,"line":707},[83,1517,1518],{"class":116},"                query",[83,1520,126],{"class":112},[83,1522,232],{"class":108},[83,1524,193],{"class":112},[83,1526,1527],{"class":189},"service",[83,1529,193],{"class":112},[83,1531,126],{"class":112},[83,1533,186],{"class":112},[83,1535,665],{"class":189},[83,1537,193],{"class":112},[83,1539,496],{"class":108},[83,1541,193],{"class":112},[83,1543,672],{"class":189},[83,1545,193],{"class":112},[83,1547,126],{"class":112},[83,1549,186],{"class":112},[83,1551,1552],{"class":189},"44",[83,1554,193],{"class":112},[83,1556,496],{"class":108},[83,1558,193],{"class":112},[83,1560,1269],{"class":189},[83,1562,193],{"class":112},[83,1564,126],{"class":112},[83,1566,186],{"class":112},[83,1568,1569],{"class":189},"4470,4471",[83,1571,193],{"class":112},[83,1573,496],{"class":108},[83,1575,193],{"class":112},[83,1577,1578],{"class":189},"lang",[83,1580,193],{"class":112},[83,1582,126],{"class":112},[83,1584,186],{"class":112},[83,1586,1587],{"class":189},"en",[83,1589,193],{"class":112},[83,1591,266],{"class":108},[83,1593,132],{"class":112},[83,1595,1596,1599],{"class":85,"line":745},[83,1597,1598],{"class":108},"        ]",[83,1600,132],{"class":112},[83,1602,1603],{"class":85,"line":776},[83,1604,855],{"class":112},[83,1606,1607],{"class":85,"line":781},[83,1608,861],{"class":112},[69,1610,1612],{"id":1611},"control-api","Control API",[294,1614,1615,1624],{},[297,1616,1617],{},[300,1618,1619,1622],{},[303,1620,1621],{},"Member",[303,1623,311],{},[313,1625,1626,1639,1651,1669,1696,1715,1730,1747,1767,1780],{},[300,1627,1628,1633],{},[318,1629,1630],{},[52,1631,1632],{},"client(apiKey:lang:devID:timeout:)",[318,1634,1635,1636,1638],{},"A normal ",[52,1637,66],{}," wired to the mock.",[300,1640,1641,1645],{},[318,1642,1643],{},[52,1644,431],{},[318,1646,1647,1648,1650],{},"The fake ",[52,1649,58],{}," (the mock itself).",[300,1652,1653,1658],{},[318,1654,1655],{},[52,1656,1657],{},"addSms(_ tzid:_ text:service:) throws",[318,1659,1660,1661,1664,1665,1668],{},"An SMS arrives now at a number operation or a rent (detected by ",[52,1662,1663],{},"tzid","). Throws ",[52,1666,1667],{},"MockOnlineSimError"," for an unknown or closed one.",[300,1670,1671,1676],{},[318,1672,1673],{},[52,1674,1675],{},"addSmsAfter(_ tzid:_ text:polls:service:) throws",[318,1677,1678,1679,1681,1682,1684,1685,6,1688,496,1691,6,1694,412],{},"The SMS arrives after ",[52,1680,731],{}," state requests for ",[52,1683,1663],{}," (",[52,1686,1687],{},"numbers.state",[52,1689,1690],{},"stateOne",[52,1692,1693],{},"rent.state",[52,1695,1690],{},[300,1697,1698,1703],{},[318,1699,1700],{},[52,1701,1702],{},"failNext(_ code:endpoint:)",[318,1704,1705,1706,1708,1709,1712,1713,371],{},"The next request (to ",[52,1707,910],{}," only, e.g. ",[52,1710,1711],{},"\"getNum.php\"",") answers ",[52,1714,899],{},[300,1716,1717,1721],{},[318,1718,1719],{},[52,1720,914],{},[318,1722,1723,1724,1726,1727,412],{},"The next request fails with a non-JSON body and HTTP ",[52,1725,1113],{}," (default ",[52,1728,1729],{},"502",[300,1731,1732,1740],{},[318,1733,1734,1274,1737],{},[52,1735,1736],{},"setBalance(_:)",[52,1738,1739],{},"balance()",[318,1741,1742,1743,1746],{},"Set \u002F read the total balance, USD (it includes the part frozen by open operations, as ",[52,1744,1745],{},"user.balance()"," reports it).",[300,1748,1749,1757],{},[318,1750,1751,1274,1754],{},[52,1752,1753],{},"operations()",[52,1755,1756],{},"rents()",[318,1758,1759,1760,496,1763,1766],{},"The current number operations \u002F open rents (",[52,1761,1762],{},"[MockOperation]",[52,1764,1765],{},"[MockRent]"," values), for assertions.",[300,1768,1769,1774],{},[318,1770,1771],{},[52,1772,1773],{},"requests",[318,1775,1776,1777,412],{},"Log of the requests received (",[52,1778,1779],{},"[MockRequest]",[300,1781,1782,1787],{},[318,1783,1784],{},[52,1785,1786],{},"reset()",[318,1788,1789],{},"Back to the initializer's state.",[69,1791,1793],{"id":1792},"what-the-mock-does","What the mock does",[1795,1796,1797,1836,1907,1961,1970],"ul",{},[1798,1799,1800,177,1803,1805,1806,1809,1810,1812,1813,1816,1817,1820,1821,1824,1825,1827,1828,1831,1832,1835],"li",{},[1801,1802,9],"strong",{},[52,1804,1054],{}," freezes the price; ",[52,1807,1808],{},"close"," after an SMS spends it, ",[52,1811,1808],{}," without one refunds it; ",[52,1814,1815],{},"ban"," after an SMS answers ",[52,1818,1819],{},"\"0\"",", like the server. Numbers are ",[52,1822,1823],{},"+\u003Ccountry>9000000NN",", ids count from 1. ",[52,1826,1285],{}," switches to the following SMS. The operation's ",[52,1829,1830],{},"time"," stays at 1200 s — there is no clock. Service ids in ",[52,1833,1834],{},"tariffs"," follow the alphabetical order of the slugs.",[1798,1837,1838,177,1840,1842,1843,1845,1846,496,1848,1845,1851,1854,1855,1858,1859,1862,1863,1845,1865,1868,1869,1872,1873,1845,1875,1684,1877,883,1879,1882,1883,1886,1887,1889,1890,1893,1894,6,1896,1898,1899,1902,1903,1906],{},[1801,1839,14],{},[52,1841,1054],{}," reserves the price (",[52,1844,1113],{}," ",[52,1847,402],{},[52,1849,1850],{},"checked",[52,1852,1853],{},"false",") and keeps the ",[52,1856,1857],{},"extension"," flag; the first SMS that is not ",[52,1860,1861],{},"notify"," confirms the rent (",[52,1864,1113],{},[52,1866,1867],{},"1",") and charges it — ",[52,1870,1871],{},"addSms(tzid, text, service: \"notify\")"," adds a notice with ",[52,1874,52],{},[52,1876,402],{},[52,1878,1819],{},[52,1880,1881],{},"RentSms.code",") that confirms nothing. ",[52,1884,1885],{},"extend"," works on a confirmed rent and charges at once. ",[52,1888,1808],{}," releases the reservation of an unconfirmed rent and gives no refund for a confirmed one. ",[52,1891,1892],{},"sum"," is a number in ",[52,1895,1054],{},[52,1897,1885],{}," and a decimal string on the wire of ",[52,1900,1901],{},"state",", like the server. SMS appear in ",[52,1904,1905],{},"messages",", newest first.",[1798,1908,1909,177,1911,1913,1914,1917,1918,1921,1922,1925,1926,1929,1930,1934,1935,1938,1939,1845,1941,1944,1945,1948,1949,1952,1953,1956,1957,1960],{},[1801,1910,19],{},[52,1912,123],{}," (frozen part included), a fixed profile, ",[52,1915,1916],{},"setWebhookURL"," accepts any ",[52,1919,1920],{},"scheme:\u002F\u002F…"," URL (",[52,1923,1924],{},"VALIDATION_ERROR"," otherwise), ",[52,1927,1928],{},"webhookLogs"," lists the deliveries the mock ",[1931,1932,1933],"em",{},"recorded"," when an SMS arrived while a webhook URL was set — it makes no HTTP call; their ",[52,1936,1937],{},"params"," follow the real payload (",[52,1940,52],{},[52,1942,1943],{},"\"\""," without a code, rent ",[52,1946,1947],{},"number"," in digits without ",[52,1950,1951],{},"+",", rent ",[52,1954,1955],{},"timeLeft"," in minutes). ",[52,1958,1959],{},"paymentHistory"," has no orders.",[1798,1962,1963,177,1966,1969],{},[1801,1964,1965],{},"Free",[52,1967,1968],{},"free.list"," returns two fixed countries (44 first) with one number and a few SMS each.",[1798,1971,1972,1973,1684,1976,1979,1980,1982,1983,1986],{},"Not imitated: anything that needs real time — the 5 s lock after ",[52,1974,1975],{},"setOperationOk",[52,1977,1978],{},"INTERVAL_CONCURRENT_REQUESTS_ERROR","), the 10 s lock of ",[52,1981,1306],{},", the 120 s before an unconfirmed rent may be closed and its 20-minute wait for the first SMS. ",[52,1984,1985],{},"guardInterval > 0"," stands in for \"too early to close\".",[1988,1989,1990],"style",{},"html pre.shiki code .s7zQu, html code.shiki .s7zQu{--shiki-light:#39ADB5;--shiki-light-font-style:italic;--shiki-default:#89DDFF;--shiki-default-font-style:italic;--shiki-dark:#89DDFF;--shiki-dark-font-style:italic}html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .s2Zo4, html code.shiki .s2Zo4{--shiki-light:#6182B8;--shiki-default:#82AAFF;--shiki-dark:#82AAFF}html pre.shiki code .sHwdD, html code.shiki .sHwdD{--shiki-light:#90A4AE;--shiki-light-font-style:italic;--shiki-default:#546E7A;--shiki-default-font-style:italic;--shiki-dark:#676E95;--shiki-dark-font-style:italic}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}html pre.shiki code .sjYur, html code.shiki .sjYur{--shiki-light:#6182B8;--shiki-light-font-style:italic;--shiki-default:#82AAFF;--shiki-default-font-style:italic;--shiki-dark:#82AAFF;--shiki-dark-font-style:italic}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}",{"title":79,"searchDepth":17,"depth":17,"links":1992},[1993,1994,1995,1996,1997,1998],{"id":71,"depth":17,"text":72},{"id":517,"depth":17,"text":518},{"id":889,"depth":17,"text":890},{"id":1319,"depth":17,"text":1320},{"id":1611,"depth":17,"text":1612},{"id":1792,"depth":17,"text":1793},"Test your integration offline with MockOnlineSim — no network, key or money.","md",{},{"order":37},{"title":34,"description":1999},"9rTY5PFBP6h1miACGHszFD9-RFB0F1b97xGfoetJJ10",[2006,2008],{"title":14,"path":15,"stem":16,"description":2007,"order":17},"Rent a number for days and receive every SMS sent to it — client.rent.",{"title":19,"path":20,"stem":21,"description":2009,"order":22},"Balance, profile, payments and the webhook URL — client.user.",1795164593469]