Git Product home page Git Product logo

africastalking-go's Introduction

# daraja-go

STILL IN BETA!

Unit-testing GO REPORT DOCS

African's Talking Go SDK

African's Talking Go SDK is a comprehensive Go library for interacting with the Africa's Talking API, a platform that provides various communication and payment services across Africa.

Features

  • SMS: Send and receive SMS messages to and from any network in Africa
  • Voice: Make and receive voice calls, play media, and control the call flow
  • USSD: Create interactive menus and sessions for your users
  • Airtime: Send airtime to mobile subscribers across Africa
  • Payments: Accept and disburse payments via mobile money, card, and bank

Installation

To install the SDK, you need to have Go 1.17 or higher installed on your machine. You also need to have an account with Africa's Talking and get an API key and a username.

  • Install the SDK using the go get command:
go get github.com/MikeMwita/africastalking-go
  • Import the SDK in your code using the import statement:
import "github.com/MikeMwita/africastalking-go"

Usage

To use the SDK, you need to create a client object and pass it your username and API key. You can then use the client object to access the different services and their methods. For example, you can use something like this:

package main

import (
	"fmt"
	"log"

	"github.com/YOUR_USERNAME/africastalking-go"
)

func main() {
	// Create a client object with your username and API key
	client := africastalking.NewClient("YOUR_USERNAME", "YOUR_API_KEY")

	// Use the client object to access the SMS service
	smsService := client.SMS

	// Create an SMS sender object with the required parameters
	smsSender := smsService.SmsSender{
		Recipients: []string{"+254712345678"},
		Message:    "Hello, this is a test message from Africa's Talking",
		Sender:     "YOUR_SENDER",
	}

	// Call the Send method and get the result
	res, err := smsService.Send(smsSender)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(res)
}

Testing

To test the SDK, you need to have a test database and a test account with Africa's Talking. You also need to set some environment variables for the test configuration.

  • Create a test database and populate it with some test data
  • Create a test account with Africa's Talking and get a test API key and a test username
  • Set the following environment variables:
export AT_TEST_DB_CONNECTION_STRING=YOUR_TEST_DB_CONNECTION_STRING # The connection string for your test database
export AT_TEST_API_KEY=YOUR_TEST_API_KEY # The API key for your test account
export AT_TEST_USERNAME=YOUR_TEST_USERNAME # The username for your test account
  • Run the tests using the go test command and pass it the -cover flag:
go test -cover ./...

africastalking-go's People

Contributors

mikemwita avatar

Stargazers

 avatar Gibson Kemboi avatar

Watchers

 avatar

africastalking-go's Issues

Open Source Contributions

Cool package. Please add a contribution.md template and also a readme on how to set up the project so we can contribute as well

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.