in progress

This commit is contained in:
2025-12-02 18:54:48 +03:00
parent 1af2045a1b
commit d7bd28b759
8 changed files with 224 additions and 0 deletions

46
flash_call.go Normal file
View File

@@ -0,0 +1,46 @@
package sigmasms
import (
"bytes"
"encoding/json"
"net/http"
)
type FlashCallRequest struct {
APIKey string `json:"api_key"`
Phone string `json:"phone"`
CodeLen int `json:"code_len"` // 4, 5, 6
}
type FlashCallResponse struct {
Status string `json:"status"`
CallID string `json:"call_id"`
From string `json:"from"` // номер, с которого звонили
Code string `json:"code"` // обычно это последние digits из from
}
func FlashCall(apiKey, phone string, codeLen int) (*FlashCallResponse, error) {
body := FlashCallRequest{
APIKey: apiKey,
Phone: phone,
CodeLen: codeLen,
}
data, _ := json.Marshal(body)
resp, err := http.Post(
"https://voice.sigmasms.ru/flashcall",
"application/json",
bytes.NewReader(data),
)
if err != nil {
return nil, err
}
defer resp.Body.Close()
var result FlashCallResponse
if err := json.NewDecoder(resp.Body).Decode(&result); err != nil {
return nil, err
}
return &result, nil
}