Skip to content

NdoleStudio/ynote-go

Repository files navigation

ynote-go

Build codecov Scrutinizer Code Quality Go Report Card GitHub contributors GitHub license PkgGoDev

This package provides a generic go client for the Y-Note API

Installation

ynote-go is compatible with modern Go releases in module mode, with Go installed:

go get github.com/NdoleStudio/ynote-go

Alternatively the same can be achieved if you use import in a package:

import "github.com/NdoleStudio/ynote-go"

Implemented

  • Token
    • POST /oauth2/token: Get Access Token
  • Refund
    • POST /prod/refund: Refund a transaction
    • GET /prod/refund/status/{transactionID}: Get the status of a refund transaction

Usage

Initializing the Client

An instance of the client can be created using New().

package main

import (
    "github.com/NdoleStudio/ynote-go"
)

func main() {
    client := ynote.New(
        ynote.WithClientID(""),
        ynote.WithClientSecret(""),
    )
}

Error handling

All API calls return an error as the last return object. All successful calls will return a nil error.

transaction, response, err := client.Refund.Status(context.Background(), "messageID")
if err != nil {
    //handle error
}

Testing

You can run the unit tests for this client from the root directory using the command below:

go test -v

License

This project is licensed under the MIT License - see the LICENSE file for details