go-sdk

command module
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: May 20, 2024 License: GPL-2.0 Imports: 5 Imported by: 0

README ΒΆ

OVALFi GO-SDK

A Go SDK for Oval Finance's API Service

CONTRIBUTORS * FORKS * STARS * ISSUES * LICENSE

View Demo Β· Documentation Β· Report Bug Β· Request Feature


πŸ“” 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
  • Yield Offering APIs
  • Deposit APIs
  • Withdrawal 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

Documentation ΒΆ

The Go Gopher

There is no documentation for this package.

Directories ΒΆ

Path Synopsis
Package api defines implementations of endpoints and calls
Package api defines implementations of endpoints and calls
Package helpers hold utility functions and methods
Package helpers hold utility functions and methods
Package model defines object and payload models
Package model defines object and payload models
example
Package example holds sample models for requests
Package example holds sample models for requests

Jump to

Keyboard shortcuts

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