atgo

package module
v0.0.0-...-4635480 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2020 License: Apache-2.0 Imports: 18 Imported by: 0

README

Home

AfricasTalking Golang SDK

Godoc Go Report Card [License]

  • This SDK helps you intergrate your Golang application with Africa's Talking APIs to powering your communications solutions across africa.

  • With simplified access to telco infrastructure, developers use Africa's Talking powerful SMS, USSD, Voice, Airtime and Payments APIs to bring their ideas to life, as they build and sustain scalable businesses.

  • Africa's Talking provide a variety of communication and payments API products listed below, that are everything you need to build high impact mobile engagement solutions. The platform allows you to work on building superior customer engagement experiences without the complexity that comes from working directly with mobile operators.

1. SMS API

SMS API

Engage easily and effectively with your customers through text messaging.

2. USSD API

USSD API

Build real-time interactive text based solutions that can be accessed on every type of mobile phone.

3. Voice API

Voice API

Enrich your users call experience by adding features that would be inaccessible using normal physical phone lines.

4. Payments API

Payments API

Build solutions to collect and disburse money through mobile money processor channels.

5. Airtime API

Airtime API

Incentivise or make micro payments to your users by instantly sending virtual airtime.

6. IoT API

IoT API

Connect, manage and visualize data from your remote devices through Africa's Talking easy-to-use APIs.

Documentation

Index

Constants

View Source
const (
	SMSTestURL     = "https://api.sandbox.africastalking.com"
	VoiceTestURL   = "https://calls.sandbox.africastalking.com"
	PaymentTestURL = "https://payments.sandbox.africastalking.com"
	AirtimeTestURL = "https://api.sandbox.africastalking.com"
	UserTestURL    = "https://api.sandbox.africastalking.com"
)

Sandbox Endpoints

View Source
const (
	SMSBaseURL     = "https://api.africastalking.com"
	VoiceBaseURL   = "https://calls.africastalking.com"
	PaymentBaseURL = "https://payments.africastalking.com"
	AirtimeBaseURL = "https://api.africastalking.com"
	IoTBaseURL     = "https://iot.africastalking.com"
	UserBaseURL    = "https://api.africastalking.com"
	AuthBaseURL    = "https://api.africastalking.com"
)

Production Endpoints

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	StatusCode int
	Code       string `json:"code"`
	Message    string `json:"message"`
}

func (*APIError) Error

func (err *APIError) Error() string

type AccessToken

type AccessToken struct {
	AccessToken  string `json:"access_token"`
	ClientID     string `json:"client_id"`
	ExpiresIn    int64  `json:"expires_in"`
	RefreshToken string `json:"refresh_token"`
	TokenType    string `json:"token_type"`
	UserID       string `json:"user_id"`
}

type Client

type Client struct {
	Username        string
	BaseURL         string
	AccessToken     string
	UserID          string
	SMSEndpoint     string
	VoiceEndpoint   string
	PaymentEndpoint string
	AirtimeEndpoint string
	IoTEndpoint     string
	UserEndpoint    string
	AuthEndpoint    string
	APIKey          string
	HTTPClient      *http.Client
	Log             *zap.Logger // *zap.Logger // log the requests.
}

func NewAfricasTalkingClient

func NewAfricasTalkingClient(username, apiKey string) (*Client, error)

NewAfricasTalkingClient returns new Client struct Use "test" for Sandbox Environment and "prod" for Production Environment

func (*Client) BankCheckout

func (c *Client) BankCheckout(ctx context.Context, p *pay.BankCheckoutPayload) (res *pay.BankCheckoutResponse, err error)

Collect money into your payment wallet.

func (*Client) BankCheckoutValidate

func (c *Client) BankCheckoutValidate(ctx context.Context, p *pay.BankCheckoutValidatePayload) (res *pay.BankCheckoutValidateResponse, err error)

Validate a bank checkout charge requestFormBody

func (*Client) BankTransfer

func (c *Client) BankTransfer(ctx context.Context, p *pay.BankTransferPayload) (res *pay.BankTransferResponse, err error)

Initiate a bank transfer requestFormBody.

func (*Client) CardCheckout

func (c *Client) CardCheckout(ctx context.Context, p *pay.CardCheckoutPayload) (res *pay.CardCheckoutResponse, err error)

Collect money into your Payment Wallet by initiating transactions that deduct money from a customers Debit or Credit Card. These APIs are currently only available in Nigeria on MasterCard and Verve cards.

func (*Client) CardCheckoutValidate

func (c *Client) CardCheckoutValidate(ctx context.Context, p *pay.CardCheckoutValidatePayload) (res *pay.CardCheckoutValidateResponse, err error)

Allows your application to validate card checkout charge requests.

func (*Client) Dequeue

func (c *Client) Dequeue(ctx context.Context, args map[string]string) (res string, err error)

Pass the calls enqueued to a separate number to be handled. Payload attributes `p *DequeuePayload` passed as key value args.

func (*Client) Dial

func (c *Client) Dial(ctx context.Context, args map[string]string) (res string, err error)

Connect the user who called your phone number to an external phone number. Payload attributes `p *DialPayload` passed as key value args.

func (*Client) Enqueue

func (c *Client) Enqueue(ctx context.Context, args map[string]string) (res string, err error)

Pass an incoming calls to a queue to be handled later. Payload attributes `p *EnqueuePayload` passed as key value args.

func (*Client) FetchPremiumSubscription

func (c *Client) FetchPremiumSubscription(ctx context.Context, p *sms.FetchSubPayload) (res *sms.FetchSubResponse, err error)

Incrementally fetch your premium sms subscriptions.

func (*Client) FetchProductTransactions

func (c *Client) FetchProductTransactions(ctx context.Context, p *pay.ProductTransactionsPayload) (res *pay.ProductTransactionsResponse, err error)

Fetch transactions of a particular payment product.

func (*Client) FetchSMS

func (c *Client) FetchSMS(ctx context.Context, p *sms.FetchMsgPayload) (res *sms.FetchMsgResponse, err error)

Incrementally fetch messages from application inbox.

func (*Client) FetchWalletBalance

func (c *Client) FetchWalletBalance(ctx context.Context, p *pay.WalletBalancePayload) (res *pay.WalletBalanceResponse, err error)

Fetch your wallet balance

func (*Client) FetchWalletTransactions

func (c *Client) FetchWalletTransactions(ctx context.Context, p *pay.WalletTransactionsPayload) (res *pay.WalletTransactionsResponse, err error)

Fetch your wallet transactions

func (*Client) FindTransaction

func (c *Client) FindTransaction(ctx context.Context, p *pay.FindTransactionPayload) (res *pay.FindTransactionResponse, err error)

Fetch transactions of a particular payment product.

func (*Client) GenerateToken

func (c *Client) GenerateToken(ctx context.Context, p *user.GeneratePayload) (res *user.AccessTokenResponse, err error)

Generates a valid auth token

func (*Client) GetDigits

func (c *Client) GetDigits(ctx context.Context, args map[string]string) (res string, err error)

Get digits a user enters on their phone in response to a prompt from application Payload attributes `p *GetDigitsPayload` passed as key value args.

func (*Client) InitiateAppData

func (c *Client) InitiateAppData(ctx context.Context, p string) (res *user.UserResponse, err error)

Initiate an application data requestFormBody.

func (*Client) MakeCall

func (c *Client) MakeCall(ctx context.Context, args map[string]string) (res *voice.MakeCallResponse, err error)

Makes outbound calls. Payload attributes `p *MakeCallPayload` passed as key value args.

func (*Client) MobileB2B

func (c *Client) MobileB2B(ctx context.Context, p *pay.MobileB2BPayload) (res *pay.MobileB2BResponse, err error)

Mobile Business To Business (B2B) APIs allow you to send payments to businesses e.g banks from your Payment Wallet.

func (*Client) MobileB2C

func (c *Client) MobileB2C(ctx context.Context, p *pay.MobileB2CPayload) (res *pay.MobileB2CResponse, err error)

Mobile Business To Consumer (B2C) APIs allow you to send payments to mobile subscribers from your Payment Wallet.

func (*Client) MobileCheckout

func (c *Client) MobileCheckout(ctx context.Context, p *pay.MobileCheckoutPayload) (res *pay.MobileCheckoutResponse, err error)

Mobile Checkout APIs allow you to initiate Customer to Business (C2B) payments on a mobile subscriber’s device. This allows for a smoother checkout experience, since the client will no longer need to remember the amount or an account number to complete the transaction.

func (*Client) NewCheckoutToken

func (c *Client) NewCheckoutToken(ctx context.Context, args map[string]string) (res *sms.CheckoutTokenResponse, err error)

Generate a checkout token Payload attributes `p *CheckoutTokenPayload` passed as key value args.

func (*Client) NewPremiumSubscription

func (c *Client) NewPremiumSubscription(ctx context.Context, args map[string]string) (res *sms.NewSubResponse, err error)

Subscribe a phone number Payload attributes `p *NewSubPayload` passed as key value args.

func (*Client) Play

func (c *Client) Play(ctx context.Context, args map[string]string) (res string, err error)

Play back an audio file located anywhere on the web. Payload attributes `p *PlayPayload` passed as key value args.

func (*Client) PublishIoT

func (c *Client) PublishIoT(ctx context.Context, p *edge.IoTPayload) (res *edge.IoTResponse, err error)

Publishes messages to remote devices.

func (*Client) PurgePremiumSubscription

func (c *Client) PurgePremiumSubscription(ctx context.Context, args map[string]string) (res *sms.PurgeSubResponse, err error)

Delete a Premium SMS Subscription Payload attributes `p *PurgeSubPayload` passed as key value args.

func (*Client) QueuedCall

func (c *Client) QueuedCall(ctx context.Context, args map[string]string) (res *voice.QueuedStatusResult, err error)

Used when you have more calls than you can handle africastalking one time. Payload attributes `p *QueuedCallsPayload` passed as key value args.

func (*Client) Record

func (c *Client) Record(ctx context.Context, args map[string]string) (res string, err error)

Record a calls session into an mp3 file. Payload attributes `p *RecordPayload` passed as key value args.

func (*Client) Redirect

func (c *Client) Redirect(ctx context.Context, args map[string]string) (res string, err error)

Transfer control of the calls to the script whose URL is passed in. Payload attributes `p *RedirectPayload` passed as key value args.

func (*Client) Reject

func (c *Client) Reject(ctx context.Context, args map[string]string) (res string, err error)

Reject an incoming calls without incurring any usage charges. Payload attributes `p *RejectPayload` passed as key value args.

func (*Client) Say

func (c *Client) Say(ctx context.Context, args map[string]string) (res string, err error)

Set a text to be read out to the caller. Payload attributes `p *SayPayload` passed as key value args.

func (*Client) SendAirtime

func (c *Client) SendAirtime(ctx context.Context, args map[string]string) (res *airtyme.AirtimeResponse, err error)

Send Airtime. Payload attributes `p *airtyme.AirtimePayload` passed as key value args.

func (*Client) SendBulkSMS

func (c *Client) SendBulkSMS(ctx context.Context, args map[string]string) (res *sms.BulkResponse, err error)

Send Bulk SMS Payload attributes `p *BulkPayload` passed as key value args.

func (*Client) SendPremiumSMS

func (c *Client) SendPremiumSMS(ctx context.Context, args map[string]string) (res *sms.PremiumSMSResponse, err error)

Send Premium SMS Payload attributes `p *PremiumPayload` passed as key value args.

func (*Client) TopupStash

func (c *Client) TopupStash(ctx context.Context, p *pay.TopupStashPayload) (res *pay.TopupStashResponse, err error)

Move money from a Payment Product to an application stash. An application stash is the wallet that funds your service usage expenses.

func (*Client) TransferCall

func (c *Client) TransferCall(ctx context.Context, args map[string]string) (res *voice.CallTransferResponse, err error)

Transfers calls to another number. Payload attributes `p *CallTransferPayload` passed as key value args.

func (*Client) UploadMedia

func (c *Client) UploadMedia(ctx context.Context, args map[string]string) (res string, err error)

Uploads media or audio files to Africa'sTalking servers with the extension .mp3 or .wav Payload attributes `p *UploadMediaFile` passed as key value args.

func (*Client) WalletTransfer

func (c *Client) WalletTransfer(ctx context.Context, p *pay.WalletTransferPayload) (res *pay.WalletTransferResponse, err error)

Transfer money from one Payment Product to another Payment Product hosted on Africa’s Talking.

type ErrorResponse

type ErrorResponse struct {
	Response        *http.Response        `json:"-"`
	Name            string                `json:"name"`
	DebugID         string                `json:"debug_id"`
	Message         string                `json:"message"`
	InformationLink string                `json:"information_link"`
	Details         []ErrorResponseDetail `json:"details"`
}

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

Error method implementation for ErrorResponse struct

type ErrorResponseDetail

type ErrorResponseDetail struct {
	Field string `json:"field"`
	Issue string `json:"issue"`
}

type Logger

type Logger struct {
	*zap.SugaredLogger
}

Logger is an adapted zap logger

func New

func New(serviceName string, production bool) *Logger

New creates a new zap logger

func (*Logger) Log

func (logger *Logger) Log(keyvals ...interface{}) error

Log is called by the log middleware to log HTTP requests key values

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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