Skip to content
/ oy-go Public

Unofficial OY! REST API Client for Go - Checkout, Account Inquiry, Disbursement, Scheduled Disbursement, Balance

License

Notifications You must be signed in to change notification settings

nadhirfr/oy-go

Repository files navigation

OY! Indonesia API Go Client

go.dev reference Go Report Card

This library is the abstraction of OY! Indonesia API for access from applications written with Go.

Documentation

For the API documentation, check OY! API Reference.

For the details of this library, see the GoDoc.

Installation

Install oy-go with:

go get -u github.com/nadhirfr/oy-go

Then, import it using:

import (
    oygo "github.com/nadhirfr/oy-go"
    "github.com/nadhirfr/oy-go/$product$"
)

with $product$ is the product of OY! such as checkout and balance.

Go Module Support

This library supports Go modules by default. Simply require oy-go in go.mod with a version like so:

module github.com/my/package

go 1.17

require (
  github.com/nadhirfr/oy-go v1.0.0
)

And use the same style of import paths as above:

import (
    oygo "github.com/nadhirfr/oy-go"
    "github.com/nadhirfr/oy-go/$product$"
)

with $product$ is the product of OY! such as checkout and balance.

Usage

It is recommended you use With Client method. The following pattern is applied throughout the library for a given $product$:

Without Client

If you're only dealing with a single secret key, you can simply import the packages required for the products you're interacting with without the need to create a client.

import (
    oygo "github.com/nadhirfr/oy-go"
    "github.com/nadhirfr/oy-go/$product$"
)

// Setup
oygo.Opt.Username = "exampleusername"
oygo.Opt.SecretKey = "examplesecretkey"


// Create
resp, err := $product$.Create($product$.CreateParams)

// Get
resp, err := $product$.Get($product$.GetParams)

// GetAll
resp, err := $product$.GetAll($product$.GetAllParams)

With Client

If you're dealing with multiple secret keys, it is recommended you use client.API. This allows you to create as many clients as needed, each with their own individual key.

import (
    oygo "github.com/nadhirfr/oy-go"
    "github.com/nadhirfr/oy-go/client"
)

// Basic setup
oyClient := client.New("examplesecretkey", "exampleusername")

// Create
resp, err := oyClient.$product$.Create($product$.CreateParams)

// Get
resp, err := oyClient.$product$.Get($product$.GetParams)

// GetAll
resp, err := oyClient.$product$.GetAll($product$.GetAllParams)

Sub-Packages Documentations

The following is a list of pointers to documentations for sub-packages of oy-go.

Contribute

For any requests, bugs, or comments, please open an issue or submit a pull request.

License

MIT © LICENSE

About

Unofficial OY! REST API Client for Go - Checkout, Account Inquiry, Disbursement, Scheduled Disbursement, Balance

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages