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