sms

package
v0.0.0-...-c2300e3 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package sms provide utilities for sending sms esms docs: https://developers.esms.vn

Index

Constants

This section is empty.

Variables

View Source
var (
	// TypeBrandName Brand name chăm sóc khách hàng
	TypeBrandName = Type{"2"}
	// Type10Numbers Tin nhắn đầu số cố định 10 số, chuyên dùng cho chăm sóc khách hàng.
	Type10Numbers = Type{"8"}
	// TypePriorityZalo Tin nhắn Zalo ưu tiên
	TypePriorityZalo = Type{"24"}
	// TypeNormalZalo Tin nhắn Zalo thường
	TypeNormalZalo = Type{"25"}
)

Set of possible sms types.

Functions

This section is empty.

Types

type Config

type Config struct {
	Address   string
	APIKey    string
	SecretKey string
	BrandName string
	Client    *http.Client
}

Config represents the mandatory settings needed to work with sms.

type Message

type Message struct {
	RequestID uuid.UUID
	Phone     string
	Content   string
	Type      Type
	DryRun    bool
}

Message represents an sms message

type OTPInfo

type OTPInfo struct {
	Phone string
}

OTPInfo provides info for sending OTP

type SMS

type SMS struct {
	// contains filtered or unexported fields
}

func New

func New(cfg Config) *SMS

func (*SMS) CheckOTP

func (s *SMS) CheckOTP(ctx context.Context, otp VerifyOTPInfo) error

CheckOTP verify user OTP

func (*SMS) Send

func (s *SMS) Send(ctx context.Context, msg Message) (smsID string, err error)

Send an SMS message to a phone number

func (*SMS) SendOTP

func (s *SMS) SendOTP(ctx context.Context, otp OTPInfo) (smsID string, err error)

SendOTP sent an OTP message to a phone number

type Type

type Type struct {
	// contains filtered or unexported fields
}

Type represents an sms type.

func ParseType

func ParseType(value string) (Type, error)

ParseType parses the string value and returns a type if one exists.

func (*Type) Equal

func (t *Type) Equal(t2 Type) bool

Equal provides support for the go-cmp package and testing.

func (*Type) ID

func (t *Type) ID() string

ID returns the ID of the role.

func (*Type) MarshalText

func (t *Type) MarshalText() ([]byte, error)

MarshalText implement the marshal interface for JSON conversions.

func (*Type) UnmarshalText

func (t *Type) UnmarshalText(data []byte) error

UnmarshalText implement the unmarshal interface for JSON conversions.

type VerifyOTPInfo

type VerifyOTPInfo struct {
	Phone string
	Code  string
}

VerifyOTPInfo provides info for verifying OTP

Jump to

Keyboard shortcuts

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