zenziva

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2020 License: MIT Imports: 6 Imported by: 0

README

Golang Zenziva SMS Library

Zenziva SMS Online Gateway Library based on Zenziva Documentation with golang.

Installation

If you are using go mod, then you skip this installation step.

Simple install the package to your $GOPATH with the go tool from shell:

$ go get -u github.com/faytranevozter/zenziva-go-sms

Make sure Git is installed on your machine and in your system's PATH.

Usage

Reguler type

import zen "github.com/faytranevozter/zenziva-go-sms"

sms := zen.Zenziva{
  Username: "userkey",
  Password: "passkey",
}

Masking type

sms := zen.Zenziva{
  Username: "userkey",
  Password: "passkey",
  Type:     "masking",
}

SMS Center type

sms := zen.Zenziva{
  Username:  "userkey",
  Password:  "passkey",
  Type:      "sms_center",
  Subdomain: "mysubdomain",
}

Avalilable type: reguler, masking, sms_center, whatsapp_reguler (coming soon), whatsapp_center (coming soon)

Sending SMS

Chaining method

res, err := sms.To("089765432123").Message("Helaw!").OTP(true).Send()
if err != nil {
  fmt.Println("Failed:", err)
}

Simple method

res, err := sms.SimpleSend("089765432123", "Helaw!")
if err != nil {
  fmt.Println("Failed:", err)
}

Simple method + otp

res, err := sms.SimpleSendOTP("089765432123", "Helaw!", true)
if err != nil {
  fmt.Println("Failed:", err)
}
Handling Response
Checking SMS Status
res, err := sms.SimpleSend("089765432123", "Helaw!")
if err != nil {
  fmt.Println("Failed:", err)
}

if res.Status {
  // sent
} else {
  // failed
}

Get Response or Error
// print(res)
// {
//   "message_id": "41",
//   "to": "081111111111",
//   "status": true,
//   "message": "Success"
// }

Credits and License

Author

Fahrur Rifai fahrur.dev
Twitter @faytranevozter

License

MIT License

Documentation

Index

Constants

View Source
const (
	SCHEME = "https"
	DOMAIN = "zenziva.net"
)

static const

Variables

This section is empty.

Functions

This section is empty.

Types

type Response

type Response struct {
	MessageID string `json:"message_id"`
	To        string `json:"to"`
	Status    bool   `json:"status"`
	Message   string `json:"message"`
}

Response API

type Zenziva

type Zenziva struct {
	Username  string  `json:"username"`
	Password  string  `json:"password"`
	Type      string  `json:"type"`
	Subdomain string  `json:"subdomain"`
	Payload   payload `json:"payload"`
}

Zenziva model

func (*Zenziva) Message

func (zen *Zenziva) Message(text string) *Zenziva

Message : set message

func (*Zenziva) OTP

func (zen *Zenziva) OTP(status bool) *Zenziva

OTP : set message is otp or not

func (*Zenziva) Send

func (zen *Zenziva) Send() (res Response, err error)

Send : Used to send message

func (*Zenziva) SimpleSend

func (zen *Zenziva) SimpleSend(to, message string) (res Response, err error)

SimpleSend : Used to send message with simpler method

func (*Zenziva) SimpleSendOTP

func (zen *Zenziva) SimpleSendOTP(to, message string, otp bool) (res Response, err error)

SimpleSendOTP : Used to send message with simpler method + otp

func (*Zenziva) To

func (zen *Zenziva) To(phone string) *Zenziva

To : set phone number

Jump to

Keyboard shortcuts

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