Skip to content

ovalfi/go-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OVALFi GO-SDK

A Go SDK for Oval Finance's API Service

CONTRIBUTORS * FORKS * STARS * ISSUES * LICENSE


📔 Table of Contents

🌟 About the Project

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.

👾 Tech Stack

Server

🔑 Environment Variables

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'

🧰 Getting Started

‼️ Prerequisites

This project requires Go >= 1.17

 brew install go

⚙️ Installation

Install go-sdk with

  go get github.com/ovalfi/go-sdk

💡 Example

Creating A Customer

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()
    
    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
}

Getting Business Portfolios

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
}

🧭 Roadmap

  • Customer APIs
  • Payout APIs
  • Transfer APIs
  • Payment APIs
  • Currency Swap APIs
  • Transaction APIs
  • Beneficiary APIs

📖 Issues

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

Contributions are always welcome.

Development

Clone the project

  git clone git@github.com:ovalfi/go-sdk.git

Go to the project directory

  cd my-project

Install dependencies

  go mod tidy

Run 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.go

🧪 Running Tests

To run tests, run the following command

  cd go-sdk
  go test

⚠️ License

License

Distributed under the GNU General Public License v2.0. See LICENSE.txt for more information.

💎 Acknowledgements