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

69
sms.go Normal file
View File

@@ -0,0 +1,69 @@
package sigmasms
import (
"log"
"github.com/google/uuid"
)
/*
{
"recipient": "+79999999999",
"type": "sms",
"payload": {
"sender": "Имя отправителя",
"text": "Текст сообщения"
}
}
*/
var (
TypeSMS = "sms"
)
type Payload struct {
Sender string `json:"sender"`
Text string `json:"text"`
}
type SendSMSResponse struct {
Error string `json:"error"`
ID uuid.UUID `json:"id"`
Price float64 `json:"price"`
Recepient string `json:"recipient"`
Status string `json:"status"`
}
type SendSMSRequest struct {
Recepient string `json:"recipient"`
Type string `json:"type"`
Payload Payload `json:"payload"`
}
func SendSMS(apiKey, phone, sender, text string) (*SendSMSResponse, error) {
req := SendSMSRequest{
Recepient: phone,
Type: TypeSMS,
Payload: Payload{
Sender: sender,
Text: text,
},
}
resp := make(map[string]any)
err := requestPost(
"https://user.sigmasms.ru/api/sendings",
apiKey,
&req,
&resp,
)
if err != nil {
return nil, err
}
log.Println(resp)
return nil, nil
}