[{"data":1,"prerenderedAt":687},["ShallowReactive",2],{"navigation":3,"\u002Fwebhooks":43,"\u002Fwebhooks-surround":683},[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":677,"extension":678,"meta":679,"navigation":680,"path":30,"seo":681,"stem":31,"__hash__":682},"docs\u002Fwebhooks.md",{"type":46,"value":47,"toc":673},"minimark",[48,80,86,90,100,194,205,466,470,669],[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",".",[49,81,82,83,79],{},"Parsing needs no client: it works with ",[57,84,85],{},"default-features = false",[87,88,89],"h2",{"id":89},"parse_webhook",[49,91,92,93,96,97,79],{},"Parse an inbound webhook body from its JSON text; ",[57,94,95],{},"parse_webhook_value"," takes an already parsed ",[57,98,99],{},"serde_json::Value",[101,102,107],"pre",{"className":103,"code":104,"language":105,"meta":106,"style":106},"language-rust shiki shiki-themes material-theme-lighter material-theme material-theme-palenight","fn parse_webhook(body: &str) -> Result\u003CWebhookPayload>\nfn parse_webhook_value(value: &serde_json::Value) -> Result\u003CWebhookPayload>\n","rust","",[57,108,109,157],{"__ignoreMap":106},[110,111,113,117,121,125,129,132,135,139,142,145,148,151,154],"span",{"class":112,"line":12},"line",[110,114,116],{"class":115},"sbssI","fn",[110,118,120],{"class":119},"s2Zo4"," parse_webhook",[110,122,124],{"class":123},"sMK4o","(",[110,126,128],{"class":127},"sTEyZ","body",[110,130,131],{"class":123},":",[110,133,134],{"class":123}," &",[110,136,138],{"class":137},"sBMFI","str",[110,140,141],{"class":123},")",[110,143,144],{"class":123}," ->",[110,146,147],{"class":137}," Result",[110,149,150],{"class":123},"\u003C",[110,152,153],{"class":137},"WebhookPayload",[110,155,156],{"class":123},">\n",[110,158,159,161,164,166,169,171,173,176,179,182,184,186,188,190,192],{"class":112,"line":17},[110,160,116],{"class":115},[110,162,163],{"class":119}," parse_webhook_value",[110,165,124],{"class":123},[110,167,168],{"class":127},"value",[110,170,131],{"class":123},[110,172,134],{"class":123},[110,174,175],{"class":137},"serde_json",[110,177,178],{"class":123},"::",[110,180,181],{"class":137},"Value",[110,183,141],{"class":123},[110,185,144],{"class":123},[110,187,147],{"class":137},[110,189,150],{"class":123},[110,191,153],{"class":137},[110,193,156],{"class":123},[49,195,196,197,200,201,204],{},"Lenient: numeric fields may arrive as strings, missing or malformed fields become ",[57,198,199],{},"None",", unknown fields are dropped. It fails (",[57,202,203],{},"Error::Decode",") only when the body is not a JSON object.",[101,206,208],{"className":103,"code":207,"language":105,"meta":106,"style":106},"use onlinesim_rs_api::parse_webhook;\nuse onlinesim_rs_api::types::WebhookType;\n\n\u002F\u002F In your HTTP handler, with the request body as text:\nfn on_webhook(body: &str) -> onlinesim_rs_api::Result\u003C()> {\n    let hook = parse_webhook(body)?;\n    if hook.webhook_type == Some(WebhookType::ReceivingSms) {\n        println!(\"{:?} {:?}\", hook.operation_id, hook.code);\n    }\n    Ok(()) \u002F\u002F answer HTTP 200\n}\n\nfn main() {\n    on_webhook(r#\"{\"webhook_type\":\"receiving_sms\",\"operation_id\":\"1520\",\"code\":\"195895\"}\"#).unwrap();\n}\n",[57,209,210,225,243,249,255,289,310,343,390,396,408,414,419,432,461],{"__ignoreMap":106},[110,211,212,215,218,220,222],{"class":112,"line":12},[110,213,214],{"class":115},"use",[110,216,217],{"class":137}," onlinesim_rs_api",[110,219,178],{"class":123},[110,221,89],{"class":137},[110,223,224],{"class":123},";\n",[110,226,227,229,231,233,236,238,241],{"class":112,"line":17},[110,228,214],{"class":115},[110,230,217],{"class":137},[110,232,178],{"class":123},[110,234,235],{"class":137},"types",[110,237,178],{"class":123},[110,239,240],{"class":137},"WebhookType",[110,242,224],{"class":123},[110,244,245],{"class":112,"line":22},[110,246,248],{"emptyLinePlaceholder":247},true,"\n",[110,250,251],{"class":112,"line":27},[110,252,254],{"class":253},"sHwdD","\u002F\u002F In your HTTP handler, with the request body as text:\n",[110,256,257,259,262,264,266,268,270,272,274,276,278,280,283,286],{"class":112,"line":32},[110,258,116],{"class":115},[110,260,261],{"class":119}," on_webhook",[110,263,124],{"class":123},[110,265,128],{"class":127},[110,267,131],{"class":123},[110,269,134],{"class":123},[110,271,138],{"class":137},[110,273,141],{"class":123},[110,275,144],{"class":123},[110,277,217],{"class":137},[110,279,178],{"class":123},[110,281,282],{"class":137},"Result",[110,284,285],{"class":123},"\u003C()>",[110,287,288],{"class":123}," {\n",[110,290,291,295,298,301,303,305,307],{"class":112,"line":37},[110,292,294],{"class":293},"spNyl","    let",[110,296,297],{"class":127}," hook ",[110,299,300],{"class":123},"=",[110,302,120],{"class":119},[110,304,124],{"class":123},[110,306,128],{"class":127},[110,308,309],{"class":123},")?;\n",[110,311,312,316,319,321,324,327,330,332,334,336,339,341],{"class":112,"line":42},[110,313,315],{"class":314},"s7zQu","    if",[110,317,318],{"class":127}," hook",[110,320,79],{"class":123},[110,322,323],{"class":127},"webhook_type ",[110,325,326],{"class":123},"==",[110,328,329],{"class":137}," Some",[110,331,124],{"class":123},[110,333,240],{"class":137},[110,335,178],{"class":123},[110,337,338],{"class":137},"ReceivingSms",[110,340,141],{"class":123},[110,342,288],{"class":123},[110,344,346,349,351,354,358,361,364,366,369,372,374,376,379,381,383,385,387],{"class":112,"line":345},8,[110,347,348],{"class":119},"        println!",[110,350,124],{"class":123},[110,352,353],{"class":123},"\"{",[110,355,357],{"class":356},"sfazB",":?",[110,359,360],{"class":123},"}",[110,362,363],{"class":123}," {",[110,365,357],{"class":356},[110,367,368],{"class":123},"}\"",[110,370,371],{"class":123},",",[110,373,318],{"class":127},[110,375,79],{"class":123},[110,377,378],{"class":127},"operation_id",[110,380,371],{"class":123},[110,382,318],{"class":127},[110,384,79],{"class":123},[110,386,57],{"class":127},[110,388,389],{"class":123},");\n",[110,391,393],{"class":112,"line":392},9,[110,394,395],{"class":123},"    }\n",[110,397,399,402,405],{"class":112,"line":398},10,[110,400,401],{"class":137},"    Ok",[110,403,404],{"class":123},"(())",[110,406,407],{"class":253}," \u002F\u002F answer HTTP 200\n",[110,409,411],{"class":112,"line":410},11,[110,412,413],{"class":123},"}\n",[110,415,417],{"class":112,"line":416},12,[110,418,248],{"emptyLinePlaceholder":247},[110,420,422,424,427,430],{"class":112,"line":421},13,[110,423,116],{"class":115},[110,425,426],{"class":119}," main",[110,428,429],{"class":123},"()",[110,431,288],{"class":123},[110,433,435,438,440,443,446,449,452,455,458],{"class":112,"line":434},14,[110,436,437],{"class":119},"    on_webhook",[110,439,124],{"class":123},[110,441,442],{"class":356},"r",[110,444,445],{"class":123},"#\"",[110,447,448],{"class":356},"{\"webhook_type\":\"receiving_sms\",\"operation_id\":\"1520\",\"code\":\"195895\"}",[110,450,451],{"class":123},"\"#",[110,453,454],{"class":123},").",[110,456,457],{"class":119},"unwrap",[110,459,460],{"class":123},"();\n",[110,462,464],{"class":112,"line":463},15,[110,465,413],{"class":123},[87,467,469],{"id":468},"payload-fields","Payload fields",[471,472,473,489],"table",{},[474,475,476],"thead",{},[477,478,479,483,486],"tr",{},[480,481,482],"th",{},"Field",[480,484,485],{},"Type",[480,487,488],{},"Description",[490,491,492,516,533,547,561,594,611,625,638,655],"tbody",{},[477,493,494,499,504],{},[495,496,497],"td",{},[57,498,63],{},[495,500,501],{},[57,502,503],{},"Option\u003CWebhookType>",[495,505,506,508,509,512,513,515],{},[57,507,338],{}," or ",[57,510,511],{},"RentSms","; ",[57,514,199],{}," for anything else.",[477,517,518,522,527],{},[495,519,520],{},[57,521,378],{},[495,523,524],{},[57,525,526],{},"Option\u003Ci64>",[495,528,529,532],{},[57,530,531],{},"tzid"," of the operation or rent.",[477,534,535,540,544],{},[495,536,537],{},[57,538,539],{},"user_id",[495,541,542],{},[57,543,526],{},[495,545,546],{},"Account id.",[477,548,549,554,558],{},[495,550,551],{},[57,552,553],{},"country_code",[495,555,556],{},[57,557,526],{},[495,559,560],{},"Country code of the number.",[477,562,563,568,573],{},[495,564,565],{},[57,566,567],{},"number",[495,569,570],{},[57,571,572],{},"Option\u003CString>",[495,574,575,576,579,580,583,584,587,588,590,591,454],{},"Numbers: ",[57,577,578],{},"+"," and the full number (",[57,581,582],{},"+79001234567","), or ",[57,585,586],{},"hidden",". Rent: the full number in digits without ",[57,589,578],{}," (",[57,592,593],{},"79001234567",[477,595,596,601,605],{},[495,597,598],{},[57,599,600],{},"sender",[495,602,603],{},[57,604,572],{},[495,606,607,608,79],{},"Sender of the SMS, e.g. ",[57,609,610],{},"VK",[477,612,613,618,622],{},[495,614,615],{},[57,616,617],{},"message",[495,619,620],{},[57,621,572],{},[495,623,624],{},"Full SMS text.",[477,626,627,631,635],{},[495,628,629],{},[57,630,57],{},[495,632,633],{},[57,634,572],{},[495,636,637],{},"Code extracted from the SMS; empty when none was found.",[477,639,640,645,649],{},[495,641,642],{},[57,643,644],{},"time_start",[495,646,647],{},[57,648,572],{},[495,650,651,652,79],{},"Numbers: when the operation was ordered. Rent: when the SMS arrived. ",[57,653,654],{},"YYYY-MM-DD HH:MM:SS",[477,656,657,662,666],{},[495,658,659],{},[57,660,661],{},"time_left",[495,663,664],{},[57,665,526],{},[495,667,668],{},"Time left: seconds for numbers, minutes for rent.",[670,671,672],"style",{},"html pre.shiki code .sbssI, html code.shiki .sbssI{--shiki-light:#F76D47;--shiki-default:#F78C6C;--shiki-dark:#F78C6C}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 .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 .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 .spNyl, html code.shiki .spNyl{--shiki-light:#9C3EDA;--shiki-default:#C792EA;--shiki-dark:#C792EA}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 .sfazB, html code.shiki .sfazB{--shiki-light:#91B859;--shiki-default:#C3E88D;--shiki-dark:#C3E88D}",{"title":106,"searchDepth":17,"depth":17,"links":674},[675,676],{"id":89,"depth":17,"text":89},{"id":468,"depth":17,"text":469},"Receive SMS as HTTP callbacks and parse them with parse_webhook.","md",{},{"order":32},{"title":29,"description":677},"L-9MQpbVjuVBMZXms994Z7B_2xziAU-fw0DlMX9Paq4",[684,686],{"title":19,"path":20,"stem":21,"description":685,"order":22},"Balance, profile, payments and the webhook URL — client.user().",null,1795164593582]