client

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AV_VERIFIED     = "verified"
	AV_NOT_VERIFIED = "no_verified"
	AV_UNKNOWN      = "unknown"
	AV_PENDING      = "pending"
)
View Source
const (
	DEFAULT_URL         = "https://sonar.fonix.io"
	DEFAULT_URL_AVSOLO  = "https://avsolo.fonix.io"
	DEFAULT_URL_KYCSOLO = "https://kycsolo.fonix.io"
	DEFAULT_URL_REFUND  = "https://refund.fonix.io"
	V2_SENDSMS          = "v2/sendsms"
	V2_SENDSMSBIN       = "v2/sendbinsms"
	V2_CHARGESMS        = "v2/chargesms"
	V2_SENDWAPPUSH      = "v2/sendwappush"
	V2_ADULTVERIFY      = "v2/adultverify"
	V2_OPERATORLOOKUP   = "v2/operator_lookup"
	V2_AVSOLO           = "v2/avsolo"
	V2_KYCSOLO          = "v2/kyc"
	V2_REFUND           = "v2/refund"
	V2_CHARGEMOBILE     = "v2/chargemobile"
)
View Source
const (
	DEFAULT_MO_PATH = "/mock/mosms"
	DEFAULT_DR_PATH = "/mock/drs"
)
View Source
const (
	REFUND_SUCCESS = "success"
	REFUND_FAILURE = "failure"
	REFUND_PENDING = "pending"
)
View Source
const (
	VERSION = "0.1.0"
)

Variables

View Source
var (
	//default timeout for requests is 15 seconds, can be changed by using custom http client
	// or you can change it via this VAr before creation of client.
	CLIENT_TIMEOUT = 15 * time.Second
)
View Source
var (
	ErrUnknownValue = errors.New("unknown value")
)

Functions

func DrHandler added in v0.0.6

func DrHandler(w http.ResponseWriter, r *http.Request)

func GetBoolFromMaybeValue added in v0.0.4

func GetBoolFromMaybeValue(rawVal interface{}) (bool, error)

func IsUnknownValueMatch added in v0.0.4

func IsUnknownValueMatch(rawVal interface{}) bool

func MoHandler added in v0.0.6

func MoHandler(w http.ResponseWriter, r *http.Request)

func Output added in v0.0.5

func Output(content OutputFormat, formatType string) (string, error)

func StartMockDrMoHandler added in v0.0.6

func StartMockDrMoHandler(port int)

Types

type ApiError added in v0.0.2

type ApiError struct {
	StatusCode   int
	ErrorData    errorResponseContent
	HttpResponse *http.Response
}

func (*ApiError) Error added in v0.0.2

func (ar *ApiError) Error() string

type ApiParams

type ApiParams interface {
	ToParams() string
}

type AvParams

type AvParams struct {
	NetworkRetry string
	Numbers      string
	Dummy        string
}

func (*AvParams) ToParams

func (avParams *AvParams) ToParams() string

type ChargeMobileParams added in v0.0.9

type ChargeMobileParams struct {
	Numbers           string
	Amount            int
	Currency          string
	RequestID         string
	ChargeDescription string
	TimeToLive        int
	ChargeSilent      string //default to "no"
	Body              string
	Dummy             string
	SmsFallback       string // only include if "yes"
}

func (*ChargeMobileParams) ToParams added in v0.0.9

func (chargeParams *ChargeMobileParams) ToParams() string

type ChargeMobileResponse added in v0.0.9

type ChargeMobileResponse struct {
	TxGuid   string `json:"txguid"`
	Numbers  string `json:"numbers"`
	Encoding string `json:"encoding"`
}

func (*ChargeMobileResponse) ToConsole added in v0.0.9

func (sr *ChargeMobileResponse) ToConsole() string

type ChargeMobileResponseWrapper added in v0.0.9

type ChargeMobileResponseWrapper struct {
	Success *ChargeMobileResponse `json:"success"`
}

type Client

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

func New

func New(apiKey string) *Client

func (*Client) AdultVerify

func (client *Client) AdultVerify(ctx context.Context, avParams *AvParams) (*SuccessAvResponse, error)

func (*Client) AvSolo

func (client *Client) AvSolo(ctx context.Context, avParams *AvParams) (*SuccessAvSoloResponse, error)

func (*Client) ChargeMobile added in v0.0.9

func (client *Client) ChargeMobile(ctx context.Context, chargeParams *ChargeMobileParams) (*ChargeMobileResponse, error)

func (*Client) ChargeSms

func (client *Client) ChargeSms(ctx context.Context, smsParams *SmsParams) (*SuccessChargeResponse, error)

func (*Client) KycSolo added in v0.0.4

func (client *Client) KycSolo(ctx context.Context, kycParams *KycSoloParams) (*KycSoloResponseWrapper, error)

func (*Client) OperatorLookup

func (client *Client) OperatorLookup(ctx context.Context, oplkParams *OperatorLookupParams) (*SuccessOperatorLookupResponse, error)

func (*Client) Refund added in v0.0.8

func (client *Client) Refund(ctx context.Context, refundParams *RefundParams) (*RefundResponse, error)

func (*Client) SendBinSms

func (client *Client) SendBinSms(ctx context.Context, smsParams *SmsBinParams) (*SuccessResponse, error)

func (*Client) SendSms

func (client *Client) SendSms(ctx context.Context, smsParams *SmsParams) (*SuccessResponse, error)

func (*Client) SendWapPush

func (client *Client) SendWapPush(ctx context.Context, smsParams *SmsWapParams) (*SuccessWapResponse, error)

func (*Client) SetBaseAvSoloURL added in v0.0.3

func (c *Client) SetBaseAvSoloURL(baseAvSoloURL string) *Client

func (*Client) SetBaseKycSoloURL added in v0.0.4

func (c *Client) SetBaseKycSoloURL(baseKycSoloURL string) *Client

func (*Client) SetBaseRefundURL added in v0.0.8

func (c *Client) SetBaseRefundURL(baseRefundURL string) *Client

func (*Client) SetBaseURL

func (c *Client) SetBaseURL(baseURL string) *Client

Configuration

func (*Client) SetHttpClient

func (c *Client) SetHttpClient(httpClient *http.Client) *Client

type KycSoloParams added in v0.0.4

type KycSoloParams struct {
	Name        string
	Surname     string
	Number      string
	HouseNumber string
	PostCode    string
	DOB         string
	RequestID   string
	Dummy       string
}

func (*KycSoloParams) ToParams added in v0.0.4

func (kycParams *KycSoloParams) ToParams() string

type KycSoloResponseWrapper added in v0.0.4

type KycSoloResponseWrapper struct {
	CompletedData *SuccessKycSoloResponse `json:"completed"`
	PendingData   *errorResponseContent   `json:"pending"`
}

type OperatorLookupParams

type OperatorLookupParams struct {
	Number string
	Dummy  string
}

func (*OperatorLookupParams) ToParams

func (oplkParams *OperatorLookupParams) ToParams() string

type OutputFormat added in v0.0.5

type OutputFormat interface {
	//ToConsole(color bool) string
	ToConsole() string
}

type RefundParams added in v0.0.8

type RefundParams struct {
	RequestID  string
	Numbers    string
	ChargeGuid string
	Dummy      string
}

func (*RefundParams) ToParams added in v0.0.8

func (refundParams *RefundParams) ToParams() string

type RefundResponse added in v0.0.8

type RefundResponse struct {
	Status              string
	IfVersion           string `json:"ifversion"`
	StatusCode          string `json:"statuscode"`
	StatusText          string `json:"statustext"`
	Guid                string `json:"guid"`
	RequestID           string `json:"requestid"`
	ChargeGuid          string `json:"charge_guid"`
	RefundTime          string `json:"refund_time"`
	RefundAmountInPence int    `json:"refunded_amount_in_pence"`
}

func (*RefundResponse) ToConsole added in v0.0.8

func (sr *RefundResponse) ToConsole() string

type RefundResponseWrapper added in v0.0.8

type RefundResponseWrapper struct {
	Success *RefundResponse `json:"success"`
	Failure *RefundResponse `json:"failure"`
	Pending *RefundResponse `json:"pending"`
}

type SmsBinParams

type SmsBinParams struct {
	Originator string
	Numbers    string
	BinBody    string
	Dummy      string
	RequestID  string
}

func (*SmsBinParams) ToParams

func (smsParams *SmsBinParams) ToParams() string

type SmsParams

type SmsParams struct {
	Originator string
	Numbers    string
	Body       string
	Dummy      string
	RequestID  string
}

func (*SmsParams) ToParams

func (smsParams *SmsParams) ToParams() string

type SmsWapParams

type SmsWapParams struct {
	Originator string
	Numbers    string
	PushTitle  string
	PushLink   string
	Dummy      string
	RequestID  string
}

func (*SmsWapParams) ToParams

func (smsParams *SmsWapParams) ToParams() string

type SuccessAvResponse

type SuccessAvResponse struct {
	TxGuid  string `json:"txguid"`
	Numbers string `json:"numbers"`
}

func (*SuccessAvResponse) ToConsole added in v0.0.5

func (sr *SuccessAvResponse) ToConsole() string

type SuccessAvResponseWrapper

type SuccessAvResponseWrapper struct {
	SuccessData SuccessAvResponse `json:"success"`
}

type SuccessAvSoloResponse

type SuccessAvSoloResponse struct {
	Status    string
	IfVersion string `json:"ifversion"`
	Operator  string `json:"operator"`
	Guid      string `json:"guid"`
}

func (*SuccessAvSoloResponse) ToConsole added in v0.0.5

func (sr *SuccessAvSoloResponse) ToConsole() string

type SuccessAvSoloResponseWrapper

type SuccessAvSoloResponseWrapper struct {
	VerifiedData    *SuccessAvSoloResponse `json:"verified"`
	NotVerifiedData *SuccessAvSoloResponse `json:"not_verified"`
	UnknownData     *SuccessAvSoloResponse `json:"unknown"`
	PendingData     *SuccessAvSoloResponse `json:"pending"`
}

type SuccessChargeResponse

type SuccessChargeResponse struct {
	TxGuid   string `json:"txguid"`
	Numbers  string `json:"numbers"`
	Price    string `json:"price"`
	Encoding string `json:"encoding"`
}

func (*SuccessChargeResponse) ToConsole added in v0.0.5

func (sr *SuccessChargeResponse) ToConsole() string

type SuccessChargeResponseWrapper

type SuccessChargeResponseWrapper struct {
	SuccessData SuccessChargeResponse `json:"success"`
}

type SuccessKycSoloResponse added in v0.0.4

type SuccessKycSoloResponse struct {
	Guid             string      `json:"guid"`
	IfVersion        string      `json:"ifversion"`
	StatusCode       string      `json:"statuscode"`
	StatusText       string      `json:"statustext"`
	RequestID        string      `json:"requestid"`
	StatusTime       string      `json:"status_time"`
	FirstNameMatch   interface{} `json:"first_name_match"` // match fields and is_Stole are weird string or bool types
	LastNameMatch    interface{} `json:"last_name_match"`  // this means end client needs to do a cast and see
	FullNameMatch    interface{} `json:"full_name_match"`
	PostCodeMatch    interface{} `json:"postcode_match"`
	HouseMatch       interface{} `json:"house_match"`
	FullAddressMatch interface{} `json:"full_address_match"`
	BirthdayMatch    interface{} `json:"birthday_match"`
	IsStolen         interface{} `json:"is_stolen"`
	ContractType     string      `json:"contract_type"`
}

type SuccessOperatorLookupResponse

type SuccessOperatorLookupResponse struct {
	Mnc      string `json:"mnc"`
	Mcc      string `json:"mcc"`
	Operator string `json:"operator"`
}

func (*SuccessOperatorLookupResponse) ToConsole added in v0.0.5

func (sr *SuccessOperatorLookupResponse) ToConsole() string

type SuccessOperatorLookupResponseWrapper

type SuccessOperatorLookupResponseWrapper struct {
	SuccessData SuccessOperatorLookupResponse `json:"success"`
}

type SuccessResponse

type SuccessResponse struct {
	TxGuid   string `json:"txguid"`
	Numbers  string `json:"numbers"`
	SmsParts string `json:"smsparts"`
	Encoding string `json:"encoding"`
}

func (*SuccessResponse) ToConsole added in v0.0.5

func (sr *SuccessResponse) ToConsole() string

type SuccessResponseWrapper

type SuccessResponseWrapper struct {
	SuccessData SuccessResponse `json:"success"`
}

type SuccessWapResponse

type SuccessWapResponse struct {
	TxGuid   string `json:"txguid"`
	Numbers  string `json:"numbers"`
	SmsParts string `json:"smsparts"`
}

func (*SuccessWapResponse) ToConsole added in v0.0.5

func (sr *SuccessWapResponse) ToConsole() string

type SuccessWapResponseWrapper

type SuccessWapResponseWrapper struct {
	SuccessData SuccessWapResponse `json:"success"`
}

Jump to

Keyboard shortcuts

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