This package provides a go client for interacting with the MobileNig API
mobilenig-go is compatible with modern Go releases in module mode, with Go installed:
go get github.com/NdoleStudio/mobilenig-goAlternatively the same can be achieved if you use import in a package:
import "github.com/NdoleStudio/mobilenig-go"- Bills
- DStv
GET /bills/user_check- Validate a DStv userGET /bills/dstv- Pay a DStv subscriptionGET /bills/query- Fetch a DStv transactionGET /bills/get_package- Fetch current DStv package
- DStv
An instance of the mobilenig client can be created using New(). The http.Client supplied will be used to make requests to the API.
package main
import (
"github.com/NdoleStudio/mobilenig-go"
)
func main() {
client := mobilenig.New(
mobilenig.WithUsername("" /* MobileNig Username */),
mobilenig.WithAPIKey("" /* MobileNig API Key */),
mobilenig.WithEnvironment(mobilenig.TestEnvironment),
)
}All API calls return an error as the last return object. All successful calls will return a nil error.
payload, response, err := mobilenigClient.Token(context.Background())
if err != nil {
//handle error
}This handles all API requests whose URL begins with /bills/
GET /bills/user_check: Validate a DStv user
user, _, err := mobilenigClient.Bills.CheckDStvUser(context.Background(), "4131953321")
if err != nil {
log.Fatal(err)
}
log.Println(user.Details.LastName) // e.g INI OBONG BASSEYGET /bills/dstv - Pay a DStv subscription
transaction, _, _ = client.Bills.PayDStv(context.Background(), &PayDstvOptions{
TransactionID: "122790223",
Price: "790",
ProductCode: "PRWE36",
CustomerName: "ESU INI OBONG BASSEY",
CustomerNumber: "275953782",
SmartcardNumber: "4131953321",
})
log.Println(transaction.TransactionID) // e.g 122790223GET /bills/query - Fetch a DStv transaction
transaction, _, err := client.Bills.QueryDStv(context.Background(), "122790223")
if err != nil {
log.Fatal(err)
}
log.Println(transaction.TransactionID) // e.g 122790223GET /bills/get_package - Returns the client's current DStv package
dstvPackage, _, err := client.Bills.GetDStvPackage(context.Background(), "122790223")
if err != nil {
log.Fatal(err)
}
log.Println(dstvPackage) // e.g DStv French TouchYou can run the unit tests for this SDK from the root directory using the command below:
go test -vThis project is licensed under the MIT License - see the LICENSE file for details
