citcallgo

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2019 License: MIT Imports: 10 Imported by: 0

README

citcall-client

Client for Citcall in Go Lang

Verify Success Response

{"rc":"00","info":"valid","trxid":"20190801155256104472275025","trxid_verify":"20190801155200606557556587","msisdn":"+6281234567890","token":null,"token_verify":"12345"} 

Verify Invalid token

{"rc":79,"info":"Invalid token"}

Contributors

Documentation

Index

Constants

View Source
const (
	CitcallOK                          = 0
	CitcallWrongMethod                 = 99
	CitcallAuthorizationFailed         = 98
	CitcallMissingParameter            = 88
	CitcallUserIDNotFound              = 77
	CitcallSenderIDClosed              = 44
	CitcallUnknownErrorOrFailed        = 6
	CitcallServiceTemporaryUnavailable = 34
	CitcallWrongPassword               = 76
	CitcallMaintenanceInProgress       = 66
	CitcallInsufficientAmount          = 14
)

Variables

This section is empty.

Functions

This section is empty.

Types

type CitcallSmsOtpRequest

type CitcallSmsOtpRequest struct {
	SenderID  string `json:"senderid`
	MSISDN    string `json:"msisdn"`
	Text      string `json:"text"`
	Token     string `json:"token"`
	ValidTime int    `json:"valid_time"`
	LimitTry  int    `json:"limit_try`
}

CitcallSmsOtpRequest citcall SMSOTP Request

type CitcallSmsOtpResponse

type CitcallSmsOtpResponse struct {
	ResponseCode FlexInt `json:"rc"`
	Info         string  `json:"info"`
	SmsCount     int     `json:"sms_count"`
	MSISDN       string  `json:"msisdn"`
	Text         string  `json:"text"`
	TrxID        string  `json:"trxid"`
	Currency     string  `json:"currency"`
	Price        int     `json:"price"`
	Token        int     `json:"token"`

	ErrorStatus bool `json:"-"`
}

CitcallSmsOtpResponse citcall SMSOTP Response

func (CitcallSmsOtpResponse) Error

func (e CitcallSmsOtpResponse) Error() string

type CitcallSmsOtpVerifyRequest

type CitcallSmsOtpVerifyRequest struct {
	TrxID  string `json:"trxid"`
	MSISDN string `json:"msisdn"`
	Token  string `json:"token"`
}

CitcallSmsOtpVerifyRequest citcall SMSOTP Verify Request

type CitcallSmsOtpVerifyResponse

type CitcallSmsOtpVerifyResponse struct {
	ResponseCode FlexInt `json:"rc"`
	Info         string  `json:"info"`
	TrxID        string  `json:"trxid"`
	TrxIDVerify  string  `json:"trxid_verify"`
	Token        string  `json:"token"`
	TokenVerify  string  `json:"token_verify"`

	ErrorStatus bool `json:"-"`
}

CitcallSmsOtpVerifyResponse citcall SMSOTP Verify Response

func (CitcallSmsOtpVerifyResponse) Error

type Client

type Client struct {
	APIEnvType   EnvironmentType
	SecretAPIKey string

	LogLevel int
	Logger   *log.Logger
}

Client struct

func NewClient

func NewClient() Client

NewClient : this function will always be called when the library is in use

func (*Client) ExecuteRequest

func (c *Client) ExecuteRequest(req *http.Request, v interface{}) (httpStatus int, err error)

ExecuteRequest : execute request

func (*Client) NewRequest

func (c *Client) NewRequest(method string, fullPath string, body io.Reader) (*http.Request, error)

NewRequest : send new request

type EnvironmentType

type EnvironmentType int8

EnvironmentType value

const (

	// Sandbox : represent sandbox environment
	Sandbox EnvironmentType

	// Production : represent production environment
	Production
)

func (EnvironmentType) CreateSmsOtpURL

func (e EnvironmentType) CreateSmsOtpURL() string

CreateSmsOtpURL : Create SMSOTP URL

func (EnvironmentType) CreateSmsOtpVerifyURL

func (e EnvironmentType) CreateSmsOtpVerifyURL() string

CreateSmsOtpVerifyURL : Create VERIFY URL

func (EnvironmentType) String

func (e EnvironmentType) String() string

implement stringer

type FlexInt

type FlexInt int

A FlexInt is an int that can be unmarshalled from a JSON field that has either a number or a string value. E.g. if the json field contains an string "42", the FlexInt value will be "42".

func (*FlexInt) UnmarshalJSON

func (fi *FlexInt) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmarshaler interface, which allows us to ingest values of any json type as an int and run our custom conversion

type SmsGateway

type SmsGateway struct {
	Client Client
}

SmsGateway struct

func (*SmsGateway) SendSmsOtp

func (gateway *SmsGateway) SendSmsOtp(req *CitcallSmsOtpRequest) (response *CitcallSmsOtpResponse, err error)

SendSmsOtp send sms for OTP

func (*SmsGateway) VerifySmsOtp

func (gateway *SmsGateway) VerifySmsOtp(req *CitcallSmsOtpVerifyRequest) (response *CitcallSmsOtpVerifyResponse, err error)

VerifySmsOtp Verify SMS OTP

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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