Cascade REST API ұсынады. Төменде — net/http клиентімен Go тіліндегі практикалық минимум.
Пайдалы сілтемелер: API, send, verify, examples, FAQ, pricing, documentation.
Орнату
Стандартты кітапхана жеткілікті; жеке Cascade модулі болмауы мүмкін.
# go mod init example.com/app
Send мысалы
package main
import (
"bytes"
"encoding/json"
"net/http"
"os"
)
func cascade(path string, payload any) (map[string]any, error) {
b, _ := json.Marshal(payload)
req, _ := http.NewRequest(http.MethodPost, "https://cascade.kz/api"+path, bytes.NewReader(b))
req.Header.Set("Authorization", "Bearer "+os.Getenv("OTP_API_TOKEN"))
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Accept", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil { return nil, err }
defer res.Body.Close()
var out map[string]any
json.NewDecoder(res.Body).Decode(&out)
return out, nil
}
success тексере отырып /otp/send және /otp/verify шақырыңыз. Қараңыз: API, errors, compare.