Qo'shildi: Docker konfiguratsiyasi yangilandi, .env va .gitignore fayllari yaratildi, Redis va muhit o'zgaruvchilari qo'shildi.
This commit is contained in:
53
internal/services/playmobile.go
Normal file
53
internal/services/playmobile.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/JscorpTech/notification/internal/domain"
|
||||
)
|
||||
|
||||
type pmbSMSService struct {
|
||||
BaseURL string
|
||||
}
|
||||
|
||||
// /broker-api/send
|
||||
func NewPmbSMSService() domain.SMSServicePort {
|
||||
return &pmbSMSService{
|
||||
BaseURL: "https://send.smsxabar.uz",
|
||||
}
|
||||
}
|
||||
|
||||
func (e *pmbSMSService) SendSMS(to, body string) error {
|
||||
client := http.Client{
|
||||
Timeout: 60 * time.Second,
|
||||
}
|
||||
payload := domain.PmbPayload{
|
||||
Messages: []domain.PmbMessage{
|
||||
{
|
||||
Recipient: "+998888112309",
|
||||
MessageID: "salomsdfs",
|
||||
Sms: domain.PmbSMS{
|
||||
Originator: "3600",
|
||||
Content: domain.PmbContent{
|
||||
Text: "salom",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
var buf bytes.Buffer
|
||||
_ = json.NewEncoder(&buf).Encode(payload)
|
||||
req, _ := http.NewRequest("POST", e.BaseURL+"/broker-api/send", &buf)
|
||||
res, err := client.Do(req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var data map[string]interface{}
|
||||
json.NewDecoder(res.Body).Decode(&data)
|
||||
fmt.Print(data)
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user