A Go SDK for Oval Finance's API Service
CONTRIBUTORS * FORKS * STARS * ISSUES * LICENSE
This project is an sdk alternative to using OvalFi's public REST APIs. It is written in go and
uses restyClient to talk to the public REST APIs over HTTP.
Server
To run this project, you will need to add the following environment variables to your .env file
PUBLIC_KEY
BASE_URL
BEARER_TOKEN
Also, we have a system in place to track API requests via the SDK. For every context you pass in the communication with our APIs, we require that you add a requestID of type uuid.UUID string to the context.
This must be passed in the context like below:
{
ctx := context.WithValue(context.Background(), "api_RequestIDContextKey", requestID),
}
Note:In our payload response to your API calls, we now have an header field like this: `X-Request-Id: 71fb13a7-595f-49b8-bdd3-2eb7dcf476c1'
This project requires Go >= 1.17
brew install goInstall go-sdk with
go get github.com/ovalfi/go-sdkpackage main
import (
"context"
"github.com/ovalfi/go-sdk/api"
"github.com/ovalfi/go-sdk/model"
)
func main() {
logger := log.New() // Any logger of your choice
client := resty.New() // A REST API client of your choice
apiCalls := api.New(&logger, client, config.PUBLIC_KEY, config.BEARER_TOKEN, config.BASE_URL)
ctx := context.Background()
customer, err := apiCalls.CreateCustomer(ctx, model.CreateCustomerRequest{
Name: "Nonso",
Email: "chinonso@ovalfinance.com",
Reference: "ref123",
MobileNumber: "09012345678",
YieldOfferingID: "ef8891af-e887-4e2c-ac79-7a9682d1ad77",
}
)
if err != nil {
handleError(err) // Handle the error per your business logic
return
}
UseCustomer(customer) // Use the customers per your business logic
}package main
import (
"context"
"github.com/ovalfi/go-sdk/api"
"github.com/ovalfi/go-sdk/model"
)
func main() {
logger := log.New() // Any logger of your choice
client := resty.New() // A REST API client of your choice
apiCalls := api.New(&logger, client, config.PUBLIC_KEY, config.BEARER_TOKEN, config.BASE_URL)
ctx := context.Background()
portfolios, err := apiCalls.GetBusinessPortfolios(ctx)
if err != nil {
handleError(err) // Handle the error per your business logic
return
}
UsePortfolios(portfolios) // Use the portfolios per your business logic
}- Customer APIs
- Payout APIs
- Transfer APIs
- Payment APIs
- Currency Swap APIs
- Transaction APIs
- Beneficiary APIs
If you come across a bug or unexpected behaviour, create an issue here. Use the template below to file your complaints.
- What happened
- Expected behavior
- Steps to reproduce
- Versions
Contributions are always welcome.
Clone the project
git clone git@github.com:ovalfi/go-sdk.gitGo to the project directory
cd my-projectInstall dependencies
go mod tidyRun the local version
Uncomment the lines in main.go and change your BASE_URL environment variables to
https://sandbox-api.ovalfi-app.com/api/
go run main.goTo run tests, run the following command
cd go-sdk
go testDistributed under the GNU General Public License v2.0. See LICENSE.txt for more information.