netgsm-go

module
v0.0.0-...-860a35e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 25, 2025 License: MIT

README

netgsm

Unofficial Netgsm Go client.

Install

go get github.com/mobinova/netgsm-go

Quick start

package main

import (
	"context"
	"log"

	"github.com/mobinova/netgsm-go/netgsm"
	"github.com/mobinova/netgsm-go/netgsm/sms"
)

func main() {
	client, err := netgsm.NewClient(
		netgsm.WithCredentials("850XXXXXXX", "password"),
		netgsm.WithAppName("my-app"),
	)
	if err != nil {
		log.Fatal(err)
	}

	svc := sms.New(client)
	resp, err := svc.Send(context.Background(), sms.SendRequest{
		MsgHeader: "NETGSM",
		Messages: []sms.Message{
			{No: "905555555555", Msg: "Hello"},
		},
	})
	if err != nil {
		log.Fatal(err)
	}
	log.Println(resp.Code, resp.JobID)
}

SMS (REST v2)

svc := sms.New(client)
resp, err := svc.ReportV2(ctx, sms.ReportRequest{
	JobIDs: []string{"123456"},
})

SMS (XML)

svc := sms.New(client)
resp, err := svc.SendXML(ctx, sms.SendXMLRequest{
	MsgHeader: "NETGSM",
	Msg:       "Hello",
	Nos:       []string{"905555555555"},
})

IYS

iysSvc := iys.New(client)
resp, err := iysSvc.Add(ctx, iys.AddRequest{
	BrandCode:     "123",
	Type:          "MESAJ",
	Source:        "HS_WEB",
	Recipient:     "+905555555555",
	Status:        "ONAY",
	ConsentDate:   time.Now(),
	RecipientType: "BIREYSEL",
})

Voice

voiceSvc := voice.New(client)
resp, err := voiceSvc.Upload(ctx, voice.VoiceUploadRequest{
	FileName: "message.wav",
	Reader:   fileReader,
})

Fax

faxSvc := fax.New(client)
resp, err := faxSvc.Send(ctx, fax.FaxSendRequest{
	FileName: "doc.pdf",
	Reader:   fileReader,
	No:       "03121234567",
})

Balance

balSvc := balance.New(client)
resp, err := balSvc.JSON(ctx, balance.BalanceJSONRequest{Stip: "2"})

Netsantral (PBX HTTP GET)

nsSvc := netsantral.New(client)
resp, err := nsSvc.Originate(ctx, netsantral.OriginateRequest{
	PBXBaseRequest: netsantral.PBXBaseRequest{Tenant: "85030XXXXX"},
	CustomerNum:    "905555555555",
	PBXNum:         "85030XXXXX",
	InternalNum:    "100",
	RingTimeout:    "20",
})

Directories

Path Synopsis
cmd
examples/fax command
examples/iys command
examples/sms command
examples/voice command
fax
iys
sms

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL