[{"data":1,"prerenderedAt":1066},["ShallowReactive",2],{"navigation":3,"landing":43},[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":45,"body":46,"description":1061,"extension":1062,"meta":1063,"navigation":144,"path":6,"seo":1064,"stem":7,"__hash__":1065},"landing\u002Findex.md","onlinesim-ruby-api",{"type":47,"value":48,"toc":1055},"minimark",[49,54,67,110,114,117,417,421,486,649,683,713,763,767,778,875,1036,1051],[50,51,53],"h2",{"id":52},"install","Install",[55,56,57,58,62,63,66],"p",{},"Ruby 3.0 or newer. No runtime dependencies: the client uses ",[59,60,61],"code",{},"Net::HTTP"," and ",[59,64,65],{},"JSON"," from the standard library.",[68,69,70,95],"code-group",{},[71,72,78],"pre",{"className":73,"code":74,"filename":75,"language":76,"meta":77,"style":77},"language-bash shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","bundle add onlinesim\n","bundler","bash","",[59,79,80],{"__ignoreMap":77},[81,82,84,88,92],"span",{"class":83,"line":12},"line",[81,85,87],{"class":86},"sBMFI","bundle",[81,89,91],{"class":90},"sfazB"," add",[81,93,94],{"class":90}," onlinesim\n",[71,96,99],{"className":73,"code":97,"filename":98,"language":76,"meta":77,"style":77},"gem install onlinesim\n","gem",[59,100,101],{"__ignoreMap":77},[81,102,103,105,108],{"class":83,"line":12},[81,104,98],{"class":86},[81,106,107],{"class":90}," install",[81,109,94],{"class":90},[50,111,113],{"id":112},"quick-start","Quick start",[55,115,116],{},"Check the balance, order a number, wait for the SMS code.",[71,118,122],{"className":119,"code":120,"language":121,"meta":77,"style":77},"language-ruby shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","require \"onlinesim\"\n\nclient = OnlineSim::Client.new(api_key: ENV[\"ONLINESIM_KEY\"])\n\nbalance = client.user.balance\nputs \"available: #{balance['balance'] - [balance['zbalance'], 0].max} USD\"\n\norder = client.numbers.get_with_number(\"google\", 44)\nputs \"enter #{order['number']} in the app\"\n\n# Polls every 5 s for up to 10 min, then closes the operation.\ncode = client.numbers.wait_code(order[\"tzid\"])\nputs \"code: #{code}\"\n","ruby",[59,123,124,140,146,190,194,214,279,283,320,352,357,364,399],{"__ignoreMap":77},[81,125,126,130,134,137],{"class":83,"line":12},[81,127,129],{"class":128},"sbssI","require",[81,131,133],{"class":132},"sMK4o"," \"",[81,135,136],{"class":90},"onlinesim",[81,138,139],{"class":132},"\"\n",[81,141,142],{"class":83,"line":17},[81,143,145],{"emptyLinePlaceholder":144},true,"\n",[81,147,148,152,155,158,161,164,167,170,173,176,179,182,184,187],{"class":83,"line":22},[81,149,151],{"class":150},"sTEyZ","client ",[81,153,154],{"class":132},"=",[81,156,157],{"class":86}," OnlineSim",[81,159,160],{"class":132},"::",[81,162,163],{"class":86},"Client",[81,165,166],{"class":132},".",[81,168,169],{"class":128},"new",[81,171,172],{"class":132},"(api_key:",[81,174,175],{"class":150}," ENV[",[81,177,178],{"class":132},"\"",[81,180,181],{"class":90},"ONLINESIM_KEY",[81,183,178],{"class":132},[81,185,186],{"class":150},"]",[81,188,189],{"class":132},")\n",[81,191,192],{"class":83,"line":27},[81,193,145],{"emptyLinePlaceholder":144},[81,195,196,199,201,204,206,209,211],{"class":83,"line":32},[81,197,198],{"class":150},"balance ",[81,200,154],{"class":132},[81,202,203],{"class":150}," client",[81,205,166],{"class":132},[81,207,21],{"class":208},"s2Zo4",[81,210,166],{"class":132},[81,212,213],{"class":208},"balance\n",[81,215,216,219,221,224,227,230,233,236,238,240,242,245,248,250,252,254,257,259,262,265,268,271,274,277],{"class":83,"line":37},[81,217,218],{"class":208},"puts",[81,220,133],{"class":132},[81,222,223],{"class":90},"available: ",[81,225,226],{"class":132},"#{",[81,228,229],{"class":150},"balance",[81,231,232],{"class":132},"[",[81,234,235],{"class":132},"'",[81,237,229],{"class":90},[81,239,235],{"class":132},[81,241,186],{"class":132},[81,243,244],{"class":132}," -",[81,246,247],{"class":132}," [",[81,249,229],{"class":150},[81,251,232],{"class":132},[81,253,235],{"class":132},[81,255,256],{"class":90},"zbalance",[81,258,235],{"class":132},[81,260,261],{"class":132},"],",[81,263,264],{"class":128}," 0",[81,266,267],{"class":132},"].",[81,269,270],{"class":208},"max",[81,272,273],{"class":132},"}",[81,275,276],{"class":90}," USD",[81,278,139],{"class":132},[81,280,281],{"class":83,"line":42},[81,282,145],{"emptyLinePlaceholder":144},[81,284,286,289,291,293,295,297,299,302,305,307,310,312,315,318],{"class":83,"line":285},8,[81,287,288],{"class":150},"order ",[81,290,154],{"class":132},[81,292,203],{"class":150},[81,294,166],{"class":132},[81,296,11],{"class":208},[81,298,166],{"class":132},[81,300,301],{"class":208},"get_with_number",[81,303,304],{"class":132},"(",[81,306,178],{"class":132},[81,308,309],{"class":90},"google",[81,311,178],{"class":132},[81,313,314],{"class":132},",",[81,316,317],{"class":128}," 44",[81,319,189],{"class":132},[81,321,323,325,327,330,332,335,337,339,342,344,347,350],{"class":83,"line":322},9,[81,324,218],{"class":208},[81,326,133],{"class":132},[81,328,329],{"class":90},"enter ",[81,331,226],{"class":132},[81,333,334],{"class":150},"order",[81,336,232],{"class":132},[81,338,235],{"class":132},[81,340,341],{"class":90},"number",[81,343,235],{"class":132},[81,345,346],{"class":132},"]}",[81,348,349],{"class":90}," in the app",[81,351,139],{"class":132},[81,353,355],{"class":83,"line":354},10,[81,356,145],{"emptyLinePlaceholder":144},[81,358,360],{"class":83,"line":359},11,[81,361,363],{"class":362},"sHwdD","# Polls every 5 s for up to 10 min, then closes the operation.\n",[81,365,367,370,372,374,376,378,380,383,385,387,389,391,394,396],{"class":83,"line":366},12,[81,368,369],{"class":150},"code ",[81,371,154],{"class":132},[81,373,203],{"class":150},[81,375,166],{"class":132},[81,377,11],{"class":208},[81,379,166],{"class":132},[81,381,382],{"class":208},"wait_code",[81,384,304],{"class":132},[81,386,334],{"class":150},[81,388,232],{"class":132},[81,390,178],{"class":132},[81,392,393],{"class":90},"tzid",[81,395,178],{"class":132},[81,397,398],{"class":132},"])\n",[81,400,402,404,406,409,411,413,415],{"class":83,"line":401},13,[81,403,218],{"class":208},[81,405,133],{"class":132},[81,407,408],{"class":90},"code: ",[81,410,226],{"class":132},[81,412,59],{"class":150},[81,414,273],{"class":132},[81,416,139],{"class":132},[50,418,420],{"id":419},"client-options","Client options",[71,422,424],{"className":119,"code":423,"language":121,"meta":77,"style":77},"client = OnlineSim::Client.new(\n  api_key: \"your-api-key\",\n  lang: \"en\",\n  timeout: 15\n)\n",[59,425,426,445,460,474,482],{"__ignoreMap":77},[81,427,428,430,432,434,436,438,440,442],{"class":83,"line":12},[81,429,151],{"class":150},[81,431,154],{"class":132},[81,433,157],{"class":86},[81,435,160],{"class":132},[81,437,163],{"class":86},[81,439,166],{"class":132},[81,441,169],{"class":128},[81,443,444],{"class":132},"(\n",[81,446,447,450,452,455,457],{"class":83,"line":17},[81,448,449],{"class":132},"  api_key:",[81,451,133],{"class":132},[81,453,454],{"class":90},"your-api-key",[81,456,178],{"class":132},[81,458,459],{"class":132},",\n",[81,461,462,465,467,470,472],{"class":83,"line":22},[81,463,464],{"class":132},"  lang:",[81,466,133],{"class":132},[81,468,469],{"class":90},"en",[81,471,178],{"class":132},[81,473,459],{"class":132},[81,475,476,479],{"class":83,"line":27},[81,477,478],{"class":132},"  timeout:",[81,480,481],{"class":128}," 15\n",[81,483,484],{"class":83,"line":32},[81,485,189],{"class":132},[487,488,489,508],"table",{},[490,491,492],"thead",{},[493,494,495,499,502,505],"tr",{},[496,497,498],"th",{},"Option",[496,500,501],{},"Type",[496,503,504],{},"Default",[496,506,507],{},"Description",[509,510,511,534,553,575,598,623],"tbody",{},[493,512,513,519,524,527],{},[514,515,516],"td",{},[59,517,518],{},"api_key",[514,520,521],{},[59,522,523],{},"String",[514,525,526],{},"—",[514,528,529,530,533],{},"Sent as ",[59,531,532],{},"Authorization: Bearer \u003Capi_key>",", never in the URL. Not needed for tariffs and free numbers.",[493,535,536,541,545,550],{},[514,537,538],{},[59,539,540],{},"base_url",[514,542,543],{},[59,544,523],{},[514,546,547],{},[59,548,549],{},"https:\u002F\u002Fonlinesim.host\u002Fapi\u002F",[514,551,552],{},"API base; trailing slash optional.",[493,554,555,560,564,569],{},[514,556,557],{},[59,558,559],{},"lang",[514,561,562],{},[59,563,523],{},[514,565,566],{},[59,567,568],{},"\"en\"",[514,570,571,572,574],{},"Language of server texts (",[59,573,559],{}," query parameter).",[493,576,577,582,590,592],{},[514,578,579],{},[59,580,581],{},"dev_id",[514,583,584,586,587],{},[59,585,523],{},", ",[59,588,589],{},"Integer",[514,591,526],{},[514,593,594,595,597],{},"Partner developer id (",[59,596,581],{},"), sent only when set.",[493,599,600,605,610,615],{},[514,601,602],{},[59,603,604],{},"timeout",[514,606,607],{},[59,608,609],{},"Numeric",[514,611,612],{},[59,613,614],{},"30",[514,616,617,618,622],{},"Per-request timeout, ",[619,620,621],"strong",{},"seconds"," (connect, read and write each).",[493,624,625,630,633,638],{},[514,626,627],{},[59,628,629],{},"transport",[514,631,632],{},"object",[514,634,635],{},[59,636,637],{},"OnlineSim::NetHttpTransport.new",[514,639,640,641,644,645,648],{},"Anything with ",[59,642,643],{},"call(method, url, headers, body, timeout)"," returning ",[59,646,647],{},"[status, body]",": a proxy setup, custom TLS, or a fake in tests.",[55,650,651,654,655,658,659,662,663,586,666,586,669,672,673,676,677,676,680,166],{},[59,652,653],{},"NetHttpTransport.new(**options)"," passes ",[59,656,657],{},"options"," to ",[59,660,661],{},"Net::HTTP.start"," (",[59,664,665],{},"ca_file:",[59,667,668],{},"cert:",[59,670,671],{},"key:",", …). TLS is verified by default; the proxy comes from ",[59,674,675],{},"http_proxy"," \u002F ",[59,678,679],{},"https_proxy",[59,681,682],{},"no_proxy",[55,684,685,686,586,692,586,697,586,702,707,708,166],{},"Sections: ",[687,688,689],"a",{"href":10},[59,690,691],{},"client.numbers",[687,693,694],{"href":15},[59,695,696],{},"client.rent",[687,698,699],{"href":20},[59,700,701],{},"client.user",[687,703,704],{"href":25},[59,705,706],{},"client.free",". Webhook bodies are parsed by the module function ",[687,709,710],{"href":30},[59,711,712],{},"OnlineSim.parse_webhook",[55,714,715,716,6,719,722,723,726,727,729,730,733,734,737,738,741,742,745,746,749,750,753,754,756,757,586,759,762],{},"Results are plain ",[59,717,718],{},"Hash",[59,720,721],{},"Array"," values with the server's string keys (",[59,724,725],{},"order[\"tzid\"]","). Two things are normalised: money that the server sends as a decimal string (",[59,728,229],{},", rent ",[59,731,732],{},"sum"," in ",[59,735,736],{},"rent.state",") becomes a ",[59,739,740],{},"Float",", and maps that arrive as an empty PHP array ",[59,743,744],{},"[]"," become ",[59,747,748],{},"{}",". ",[59,751,752],{},"payment_history[\"paylist\"]"," is left as sent: an ",[59,755,721],{}," when its ids are 0, 1, 2… Durations (",[59,758,604],{},[59,760,761],{},"interval",") are seconds.",[50,764,766],{"id":765},"error-handling","Error handling",[55,768,769,770,773,774,777],{},"Every error is an ",[59,771,772],{},"OnlineSim::Error"," (a ",[59,775,776],{},"StandardError",").",[487,779,780,793],{},[490,781,782],{},[493,783,784,787,790],{},[496,785,786],{},"Class",[496,788,789],{},"When",[496,791,792],{},"Attributes",[509,794,795,815,836,859],{},[493,796,797,802,808],{},[514,798,799],{},[59,800,801],{},"ApiError",[514,803,804,805,777],{},"The API answered with an error code (also a wrong key, HTTP 456, and the rate limit, HTTP 429 ",[59,806,807],{},"TRY_AGAIN_LATER",[514,809,810,586,812],{},[59,811,59],{},[59,813,814],{},"message",[493,816,817,822,830],{},[514,818,819],{},[59,820,821],{},"NoNumberError",[514,823,824,827,828,166],{},[59,825,826],{},"NO_NUMBER",": no number right now. Subclass of ",[59,829,801],{},[514,831,832,586,834],{},[59,833,59],{},[59,835,814],{},[493,837,838,843,846],{},[514,839,840],{},[59,841,842],{},"TransportError",[514,844,845],{},"Network error, request timeout, or a body that is not JSON.",[514,847,848,662,851,854,855,858],{},[59,849,850],{},"status",[59,852,853],{},"nil"," without a response), ",[59,856,857],{},"body"," (first 500 chars)",[493,860,861,866,873],{},[514,862,863],{},[59,864,865],{},"TimeoutError",[514,867,868,870,871,166],{},[59,869,382],{}," got no code within its ",[59,872,604],{},[514,874,526],{},[71,876,878],{"className":119,"code":877,"language":121,"meta":77,"style":77},"begin\n  client.numbers.get(\"google\", 44)\nrescue OnlineSim::NoNumberError\n  # try another country or later\nrescue OnlineSim::ApiError => e\n  warn \"#{e.code}: #{e.message}\" # e.g. WARNING_LOW_BALANCE\nrescue OnlineSim::TransportError => e\n  warn \"network: #{e.status} #{e.body}\"\nend\n",[59,879,880,886,914,926,931,948,984,999,1031],{"__ignoreMap":77},[81,881,882],{"class":83,"line":12},[81,883,885],{"class":884},"s7zQu","begin\n",[81,887,888,891,893,895,897,900,902,904,906,908,910,912],{"class":83,"line":17},[81,889,890],{"class":150},"  client",[81,892,166],{"class":132},[81,894,11],{"class":208},[81,896,166],{"class":132},[81,898,899],{"class":208},"get",[81,901,304],{"class":132},[81,903,178],{"class":132},[81,905,309],{"class":90},[81,907,178],{"class":132},[81,909,314],{"class":132},[81,911,317],{"class":128},[81,913,189],{"class":132},[81,915,916,919,921,923],{"class":83,"line":22},[81,917,918],{"class":884},"rescue",[81,920,157],{"class":86},[81,922,160],{"class":132},[81,924,925],{"class":150},"NoNumberError\n",[81,927,928],{"class":83,"line":27},[81,929,930],{"class":362},"  # try another country or later\n",[81,932,933,935,937,939,942,945],{"class":83,"line":32},[81,934,918],{"class":884},[81,936,157],{"class":86},[81,938,160],{"class":132},[81,940,941],{"class":150},"ApiError ",[81,943,944],{"class":132},"=>",[81,946,947],{"class":150}," e\n",[81,949,950,953,955,957,960,962,964,966,969,971,973,975,977,979,981],{"class":83,"line":37},[81,951,952],{"class":208},"  warn",[81,954,133],{"class":132},[81,956,226],{"class":132},[81,958,959],{"class":150},"e",[81,961,166],{"class":132},[81,963,59],{"class":208},[81,965,273],{"class":132},[81,967,968],{"class":90},": ",[81,970,226],{"class":132},[81,972,959],{"class":150},[81,974,166],{"class":132},[81,976,814],{"class":208},[81,978,273],{"class":132},[81,980,178],{"class":132},[81,982,983],{"class":362}," # e.g. WARNING_LOW_BALANCE\n",[81,985,986,988,990,992,995,997],{"class":83,"line":42},[81,987,918],{"class":884},[81,989,157],{"class":86},[81,991,160],{"class":132},[81,993,994],{"class":150},"TransportError ",[81,996,944],{"class":132},[81,998,947],{"class":150},[81,1000,1001,1003,1005,1008,1010,1012,1014,1016,1018,1021,1023,1025,1027,1029],{"class":83,"line":285},[81,1002,952],{"class":208},[81,1004,133],{"class":132},[81,1006,1007],{"class":90},"network: ",[81,1009,226],{"class":132},[81,1011,959],{"class":150},[81,1013,166],{"class":132},[81,1015,850],{"class":208},[81,1017,273],{"class":132},[81,1019,1020],{"class":132}," #{",[81,1022,959],{"class":150},[81,1024,166],{"class":132},[81,1026,857],{"class":208},[81,1028,273],{"class":132},[81,1030,139],{"class":132},[81,1032,1033],{"class":83,"line":322},[81,1034,1035],{"class":884},"end\n",[55,1037,1038,1040,1041,1044,1045,1047,1048,166],{},[59,1039,814],{}," is the server's text when it sends one, otherwise a short English description of the code (",[59,1042,1043],{},"OnlineSim::ERROR_MESSAGES","), otherwise the code itself. Profile validation failures become ",[59,1046,801],{}," with code ",[59,1049,1050],{},"VALIDATION_ERROR",[1052,1053,1054],"style",{},"html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}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 .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}html pre.shiki code .sMK4o, html code.shiki .sMK4o{--shiki-light:#39ADB5;--shiki-default:#89DDFF;--shiki-dark:#89DDFF}html pre.shiki code .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}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 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}",{"title":77,"searchDepth":17,"depth":17,"links":1056},[1057,1058,1059,1060],{"id":52,"depth":17,"text":53},{"id":112,"depth":17,"text":113},{"id":419,"depth":17,"text":420},{"id":765,"depth":17,"text":766},"Zero-dependency Ruby client for the OnlineSim API — SMS numbers, rent, account and free numbers.","md",{},{"title":45,"description":1061},"cjtk-5cIhuG-H61TzRDqU41xIpNVuYC7H5OQOvf0_LU",1795163990092]