Documentation
¶
Index ¶
- Constants
- Variables
- type ChannelType
- type Client
- type FnOption
- func WithBaseURL(baseURL string) FnOption
- func WithChannel(channel ChannelType) FnOption
- func WithClient(client heimdall.Doer) FnOption
- func WithCustomIPs(customIPs ...string) FnOption
- func WithDivision(division string) FnOption
- func WithHystrixOptions(options ...hystrix.Option) FnOption
- func WithPassword(password string) FnOption
- func WithSender(sender string) FnOption
- func WithTimeout(timeout time.Duration) FnOption
- func WithUploadBy(uploadBy string) FnOption
- func WithUserID(userID string) FnOption
- type Option
- type RequestMessage
- type ResponseMessage
- type StatusParam
- type UnknownError
Constants ¶
const ( FormKeyUserID = "userid" FormKeyPassword = "password" FormKeySender = "sender" FormKeyMSISDN = "msisdn" FormKeyMessage = "message" FormKeyDivision = "division" FormKeyBatchName = "batchname" FormKeyUploadBy = "uploadby" FormKeyChannel = "channel" )
List of form keys used for request in Jatis.
const ( // DefaultBaseURL is the default base URL for the Jatis API. DefaultBaseURL = "https://sms-api.jatismobile.com/index.ashx" // DefaultTimeout is the default timeout for the Jatis API. DefaultTimeout = 30 * time.Second )
const ( // DefaultBatchOTP is the default batch name for OTP. DefaultBatchOTP = "otp" // DefaultBaseDecimal is the default base 10 for decimal. DefaultBaseDecimal = 10 )
const ( KeyURLDecodedStatus = "Status" KeyURLDecodedMessageID = "MessageId" )
List of key used to access the value of URL decoded values.
Variables ¶
var ErrNilArgs = errors.New("nil arguments")
ErrNilArgs is returned when the argument is nil.
Functions ¶
This section is empty.
Types ¶
type ChannelType ¶ added in v0.2.0
type ChannelType uint64
ChannelType specifies the channel type used in this package.
const ( ChannelRegular ChannelType = iota ChannelAlert ChannelOTP )
List of channel used in Jatis.
type Client ¶ added in v0.1.0
type Client interface {
// SendSMS sends message to the Jatis platform.
SendSMS(ctx context.Context, request *RequestMessage) (respBody *ResponseMessage, err error)
}
Client is the interface of Jatis SMS client.
type FnOption ¶ added in v0.1.0
type FnOption func(o *Option)
FnOption is a function that modifies Option.
func WithBaseURL ¶ added in v0.1.0
WithBaseURL sets the base URL for the Jatis API.
func WithChannel ¶ added in v0.1.0
func WithChannel(channel ChannelType) FnOption
WithChannel sets the channel for the Jatis API.
func WithClient ¶ added in v0.1.0
WithClient sets the client for the Jatis API.
func WithCustomIPs ¶ added in v0.1.0
WithCustomIPs sets the custom IPs for the Jatis API.
func WithDivision ¶ added in v0.1.0
WithDivision sets the division for the Jatis API.
func WithHystrixOptions ¶ added in v0.1.0
WithHystrixOptions sets the hystrix options for the Jatis API.
func WithPassword ¶ added in v0.1.0
WithPassword sets the password for the Jatis API.
func WithSender ¶ added in v0.1.0
WithSender sets the sender for the Jatis API.
func WithTimeout ¶ added in v0.1.0
WithTimeout sets the timeout for the Jatis API.
func WithUploadBy ¶ added in v0.1.0
WithUploadBy sets the upload by for the Jatis API.
func WithUserID ¶ added in v0.1.0
WithUserID sets the user ID for the Jatis API.
type Option ¶ added in v0.1.0
type Option struct {
BaseURL string
UserID string
Password string
Sender string
Division string
UploadBy string
Channel *ChannelType
CustomIPs []string
Timeout time.Duration
Client heimdall.Doer
HystrixOptions []hystrix.Option
// contains filtered or unexported fields
}
Option is a struct containing all configurations for Jatis.
type RequestMessage ¶ added in v0.1.0
type RequestMessage struct {
PhoneNumber string
Text string
BatchName string
Channel *ChannelType
}
RequestMessage defines the request message to Jatis.
func (*RequestMessage) Default ¶ added in v0.1.0
func (r *RequestMessage) Default(o *Option) *RequestMessage
Default returns the default request message for Jatis.
type ResponseMessage ¶ added in v0.1.0
type ResponseMessage struct {
MessageID string
Status string
StatusNumber StatusParam
}
ResponseMessage defines the response message from Jatis.
func (*ResponseMessage) Error ¶ added in v0.1.0
func (r *ResponseMessage) Error() string
ResponseMessage implements the error interface.
type StatusParam ¶ added in v0.2.0
type StatusParam uint64
StatusParam is the status parameter in the response message.
const ( StatusSuccess StatusParam = iota + 1 StatusMissingParameter StatusInvalidUserIDOrPassword StatusInvalidMessage StatusInvalidMSISDN StatusInvalidSender StatusDeniedIPAddress StatusInternalServerError StatusInvalidDivision )
List of all status parameters used in Jatis.
const ( StatusInvalidChannel StatusParam = iota + 20 StatusTokenNotEnough StatusTokenNotAvailable )
List of all status parameters used in Jatis.
func (StatusParam) String ¶ added in v0.2.0
func (s StatusParam) String() string
String returns the string representation of the status param.
func (StatusParam) Uint64String ¶ added in v0.2.2
func (s StatusParam) Uint64String() string
Uint64String converts the uint64 to the string version.
type UnknownError ¶ added in v0.1.0
UnknownError is an error that is not defined by the documentation from the SMS Jatis.
func (UnknownError) Error ¶ added in v0.1.0
func (e UnknownError) Error() string
Error implements the error interface.