[{"data":1,"prerenderedAt":596},["ShallowReactive",2],{"navigation":3,"\u002Fwebhooks":43,"\u002Fwebhooks-surround":592},[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":29,"body":45,"description":586,"extension":587,"meta":588,"navigation":589,"path":30,"seo":590,"stem":31,"__hash__":591},"docs\u002Fwebhooks.md",{"type":46,"value":47,"toc":582},"minimark",[48,80,84,91,128,139,355,359,578],[49,50,51,52,60,61,64,65,68,69,72,73,79],"p",{},"Set a URL with ",[53,54,56],"a",{"href":55},"\u002Fuser#set_webhook_url",[57,58,59],"code",{},"client.user.set_webhook_url",". For each SMS the server POSTs a JSON body to it: ",[57,62,63],{},"webhook_type"," ",[57,66,67],{},"receiving_sms"," for numbers, ",[57,70,71],{},"rent_sms"," for rents. Delivery attempts are listed by ",[53,74,76],{"href":75},"\u002Fuser#webhook_logs",[57,77,78],{},"client.user.webhook_logs",".",[81,82,83],"h2",{"id":83},"parse_webhook",[49,85,86,87,90],{},"Parse an inbound webhook body from a JSON string or an already parsed ",[57,88,89],{},"Hash"," (string or symbol keys).",[92,93,98],"pre",{"className":94,"code":95,"language":96,"meta":97,"style":97},"language-ruby shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","OnlineSim.parse_webhook(payload) # => Hash\n","ruby","",[57,99,100],{"__ignoreMap":97},[101,102,104,108,111,114,117,121,124],"span",{"class":103,"line":12},"line",[101,105,107],{"class":106},"sBMFI","OnlineSim",[101,109,79],{"class":110},"sMK4o",[101,112,83],{"class":113},"s2Zo4",[101,115,116],{"class":110},"(",[101,118,120],{"class":119},"sTEyZ","payload",[101,122,123],{"class":110},")",[101,125,127],{"class":126},"sHwdD"," # => Hash\n",[49,129,130,131,134,135,138],{},"Lenient: numeric fields may arrive as strings, missing or malformed fields become ",[57,132,133],{},"nil",", unknown fields are dropped. It raises ",[57,136,137],{},"OnlineSim::Error"," only when the input is not a JSON object.",[92,140,142],{"className":94,"code":141,"language":96,"meta":97,"style":97},"require \"onlinesim\"\n\n# Rack app (config.ru): run WebhookApp\nWebhookApp = lambda do |env|\n  hook = OnlineSim.parse_webhook(env[\"rack.input\"].read)\n  puts \"#{hook['operation_id']} #{hook['code']}\" if hook[\"webhook_type\"] == \"receiving_sms\"\n  [200, { \"content-type\" => \"text\u002Fplain\" }, [\"ok\"]]\nend\n",[57,143,144,160,166,171,195,233,302,349],{"__ignoreMap":97},[101,145,146,150,153,157],{"class":103,"line":12},[101,147,149],{"class":148},"sbssI","require",[101,151,152],{"class":110}," \"",[101,154,156],{"class":155},"sfazB","onlinesim",[101,158,159],{"class":110},"\"\n",[101,161,162],{"class":103,"line":17},[101,163,165],{"emptyLinePlaceholder":164},true,"\n",[101,167,168],{"class":103,"line":22},[101,169,170],{"class":126},"# Rack app (config.ru): run WebhookApp\n",[101,172,173,176,179,182,186,189,192],{"class":103,"line":27},[101,174,175],{"class":119},"WebhookApp ",[101,177,178],{"class":110},"=",[101,180,181],{"class":113}," lambda",[101,183,185],{"class":184},"s7zQu"," do",[101,187,188],{"class":110}," |",[101,190,191],{"class":119},"env",[101,193,194],{"class":110},"|\n",[101,196,197,200,202,205,207,209,211,213,216,219,222,224,227,230],{"class":103,"line":32},[101,198,199],{"class":119},"  hook ",[101,201,178],{"class":110},[101,203,204],{"class":106}," OnlineSim",[101,206,79],{"class":110},[101,208,83],{"class":113},[101,210,116],{"class":110},[101,212,191],{"class":119},[101,214,215],{"class":110},"[",[101,217,218],{"class":110},"\"",[101,220,221],{"class":155},"rack.input",[101,223,218],{"class":110},[101,225,226],{"class":110},"].",[101,228,229],{"class":113},"read",[101,231,232],{"class":110},")\n",[101,234,235,238,240,243,246,248,251,254,256,259,262,264,266,268,270,272,274,276,279,282,284,286,288,290,293,296,298,300],{"class":103,"line":37},[101,236,237],{"class":113},"  puts",[101,239,152],{"class":110},[101,241,242],{"class":110},"#{",[101,244,245],{"class":119},"hook",[101,247,215],{"class":110},[101,249,250],{"class":110},"'",[101,252,253],{"class":155},"operation_id",[101,255,250],{"class":110},[101,257,258],{"class":110},"]}",[101,260,261],{"class":110}," #{",[101,263,245],{"class":119},[101,265,215],{"class":110},[101,267,250],{"class":110},[101,269,57],{"class":155},[101,271,250],{"class":110},[101,273,258],{"class":110},[101,275,218],{"class":110},[101,277,278],{"class":184}," if",[101,280,281],{"class":119}," hook",[101,283,215],{"class":110},[101,285,218],{"class":110},[101,287,63],{"class":155},[101,289,218],{"class":110},[101,291,292],{"class":110},"]",[101,294,295],{"class":110}," ==",[101,297,152],{"class":110},[101,299,67],{"class":155},[101,301,159],{"class":110},[101,303,304,307,310,313,316,318,321,323,326,328,331,333,336,339,341,344,346],{"class":103,"line":42},[101,305,306],{"class":110},"  [",[101,308,309],{"class":148},"200",[101,311,312],{"class":110},",",[101,314,315],{"class":110}," {",[101,317,152],{"class":110},[101,319,320],{"class":155},"content-type",[101,322,218],{"class":110},[101,324,325],{"class":110}," =>",[101,327,152],{"class":110},[101,329,330],{"class":155},"text\u002Fplain",[101,332,218],{"class":110},[101,334,335],{"class":110}," },",[101,337,338],{"class":110}," [",[101,340,218],{"class":110},[101,342,343],{"class":155},"ok",[101,345,218],{"class":110},[101,347,348],{"class":110},"]]\n",[101,350,352],{"class":103,"line":351},8,[101,353,354],{"class":184},"end\n",[81,356,358],{"id":357},"payload-fields","Payload fields",[360,361,362,378],"table",{},[363,364,365],"thead",{},[366,367,368,372,375],"tr",{},[369,370,371],"th",{},"Field",[369,373,374],{},"Type",[369,376,377],{},"Description",[379,380,381,402,421,437,453,489,508,524,543,562],"tbody",{},[366,382,383,388,399],{},[384,385,386],"td",{},[57,387,63],{},[384,389,390,393,394,393,397],{},[57,391,392],{},"\"receiving_sms\"",", ",[57,395,396],{},"\"rent_sms\"",[57,398,133],{},[384,400,401],{},"Kind of operation.",[366,403,404,408,415],{},[384,405,406],{},[57,407,253],{},[384,409,410,393,413],{},[57,411,412],{},"Integer",[57,414,133],{},[384,416,417,420],{},[57,418,419],{},"tzid"," of the operation or rent.",[366,422,423,428,434],{},[384,424,425],{},[57,426,427],{},"user_id",[384,429,430,393,432],{},[57,431,412],{},[57,433,133],{},[384,435,436],{},"Account id.",[366,438,439,444,450],{},[384,440,441],{},[57,442,443],{},"country_code",[384,445,446,393,448],{},[57,447,412],{},[57,449,133],{},[384,451,452],{},"Country code of the number.",[366,454,455,460,467],{},[384,456,457],{},[57,458,459],{},"number",[384,461,462,393,465],{},[57,463,464],{},"String",[57,466,133],{},[384,468,469,470,473,474,477,478,481,482,484,485,488],{},"Numbers: ",[57,471,472],{},"+"," and the full number (",[57,475,476],{},"+79001234567","), or ",[57,479,480],{},"hidden",". Rent: the full number in digits without ",[57,483,472],{}," (",[57,486,487],{},"79001234567",").",[366,490,491,496,502],{},[384,492,493],{},[57,494,495],{},"sender",[384,497,498,393,500],{},[57,499,464],{},[57,501,133],{},[384,503,504,505,79],{},"Sender of the SMS, e.g. ",[57,506,507],{},"VK",[366,509,510,515,521],{},[384,511,512],{},[57,513,514],{},"message",[384,516,517,393,519],{},[57,518,464],{},[57,520,133],{},[384,522,523],{},"Full SMS text.",[366,525,526,530,536],{},[384,527,528],{},[57,529,57],{},[384,531,532,393,534],{},[57,533,464],{},[57,535,133],{},[384,537,538,539,542],{},"Code extracted from the SMS; ",[57,540,541],{},"\"\""," when none was found.",[366,544,545,550,556],{},[384,546,547],{},[57,548,549],{},"time_start",[384,551,552,393,554],{},[57,553,464],{},[57,555,133],{},[384,557,558,559,79],{},"Numbers: when the operation was ordered. Rent: when the SMS arrived. ",[57,560,561],{},"YYYY-MM-DD HH:MM:SS",[366,563,564,569,575],{},[384,565,566],{},[57,567,568],{},"time_left",[384,570,571,393,573],{},[57,572,412],{},[57,574,133],{},[384,576,577],{},"Time left: seconds for numbers, minutes for rent.",[579,580,581],"style",{},"html pre.shiki code .sBMFI, html code.shiki .sBMFI{--shiki-light:#E2931D;--shiki-default:#FFCB6B;--shiki-dark:#FFCB6B}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 .sTEyZ, html code.shiki .sTEyZ{--shiki-light:#90A4AE;--shiki-default:#EEFFFF;--shiki-dark:#BABED8}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 .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}html pre.shiki code .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}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":97,"searchDepth":17,"depth":17,"links":583},[584,585],{"id":83,"depth":17,"text":83},{"id":357,"depth":17,"text":358},"Receive SMS as HTTP callbacks and parse them with OnlineSim.parse_webhook.","md",{},{"order":32},{"title":29,"description":586},"hYYexerkSYr9JV-HVbv6Wwu5mR1HN3k_Io_FEgu4Vkg",[593,595],{"title":19,"path":20,"stem":21,"description":594,"order":22},"Balance, profile, payments and the webhook URL — client.user.",null,1795163990846]