This library is the abstraction of OY! Indonesia API for access from applications written with Go.
For the API documentation, check OY! API Reference.
For the details of this library, see the GoDoc.
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
.
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
.
It is recommended you use With Client method. The following pattern is applied throughout the library for a given $product$
:
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)
If you're dealing with multiple secret key
s, 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)
The following is a list of pointers to documentations for sub-packages of oy-go.
For any requests, bugs, or comments, please open an issue or submit a pull request.
MIT © LICENSE