bila

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

README

Bila Go API Library

Go Reference

The Bila Go library provides convenient access to the Bila REST API from applications written in Go.

It is generated with Stainless.

Installation

import (
	"github.com/bilasdk/go" // imported as bila
)

Or to pin the version:

go get -u 'github.com/bilasdk/go@v0.1.0'

Requirements

This library requires Go 1.22+.

Usage

The full API of this library can be found in api.md.

package main

import (
	"context"
	"fmt"

	"github.com/bilasdk/go"
	"github.com/bilasdk/go/option"
)

func main() {
	client := bila.NewClient(
		option.WithAPIKey("My API Key"), // defaults to os.LookupEnv("BILA_API_KEY")
		option.WithEnvironmentSandbox(), // defaults to option.WithEnvironmentProduction()
	)
	accounts, err := client.Accounts.List(context.TODO(), bila.AccountListParams{})
	if err != nil {
		panic(err.Error())
	}
	fmt.Printf("%+v\n", accounts.Message)
}

Request fields

The bila library uses the omitzero semantics from the Go 1.24+ encoding/json release for request fields.

Required primitive fields (int64, string, etc.) feature the tag `api:"required"`. These fields are always serialized, even their zero values.

Optional primitive types are wrapped in a param.Opt[T]. These fields can be set with the provided constructors, bila.String(string), bila.Int(int64), etc.

Any param.Opt[T], map, slice, struct or string enum uses the tag `json:"...,omitzero"`. Its zero value is considered omitted.

The param.IsOmitted(any) function can confirm the presence of any omitzero field.

p := bila.ExampleParams{
	ID:   "id_xxx",           // required property
	Name: bila.String("..."), // optional property

	Point: bila.Point{
		X: 0,           // required field will serialize as 0
		Y: bila.Int(1), // optional field will serialize as 1
		// ... omitted non-required fields will not be serialized
	},

	Origin: bila.Origin{}, // the zero value of [Origin] is considered omitted
}

To send null instead of a param.Opt[T], use param.Null[T](). To send null instead of a struct T, use param.NullStruct[T]().

p.Name = param.Null[string]()       // 'null' instead of string
p.Point = param.NullStruct[Point]() // 'null' instead of struct

param.IsNull(p.Name)  // true
param.IsNull(p.Point) // true

Request structs contain a .SetExtraFields(map[string]any) method which can send non-conforming fields in the request body. Extra fields overwrite any struct fields with a matching key. For security reasons, only use SetExtraFields with trusted data.

To send a custom value instead of a struct, use param.Override[T](value).

// In cases where the API specifies a given type,
// but you want to send something else, use [SetExtraFields]:
p.SetExtraFields(map[string]any{
	"x": 0.01, // send "x" as a float instead of int
})

// Send a number instead of an object
custom := param.Override[bila.FooParams](12)
Request unions

Unions are represented as a struct with fields prefixed by "Of" for each of its variants, only one field can be non-zero. The non-zero field will be serialized.

Sub-properties of the union can be accessed via methods on the union struct. These methods return a mutable pointer to the underlying data, if present.

// Only one field can be non-zero, use param.IsOmitted() to check if a field is set
type AnimalUnionParam struct {
	OfCat *Cat `json:",omitzero,inline`
	OfDog *Dog `json:",omitzero,inline`
}

animal := AnimalUnionParam{
	OfCat: &Cat{
		Name: "Whiskers",
		Owner: PersonParam{
			Address: AddressParam{Street: "3333 Coyote Hill Rd", Zip: 0},
		},
	},
}

// Mutating a field
if address := animal.GetOwner().GetAddress(); address != nil {
	address.ZipCode = 94304
}
Response objects

All fields in response structs are ordinary value types (not pointers or wrappers). Response structs also include a special JSON field containing metadata about each property.

type Animal struct {
	Name   string `json:"name,nullable"`
	Owners int    `json:"owners"`
	Age    int    `json:"age"`
	JSON   struct {
		Name        respjson.Field
		Owner       respjson.Field
		Age         respjson.Field
		ExtraFields map[string]respjson.Field
	} `json:"-"`
}

To handle optional data, use the .Valid() method on the JSON field. .Valid() returns true if a field is not null, not present, or couldn't be marshaled.

If .Valid() is false, the corresponding field will simply be its zero value.

raw := `{"owners": 1, "name": null}`

var res Animal
json.Unmarshal([]byte(raw), &res)

// Accessing regular fields

res.Owners // 1
res.Name   // ""
res.Age    // 0

// Optional field checks

res.JSON.Owners.Valid() // true
res.JSON.Name.Valid()   // false
res.JSON.Age.Valid()    // false

// Raw JSON values

res.JSON.Owners.Raw()                  // "1"
res.JSON.Name.Raw() == "null"          // true
res.JSON.Name.Raw() == respjson.Null   // true
res.JSON.Age.Raw() == ""               // true
res.JSON.Age.Raw() == respjson.Omitted // true

These .JSON structs also include an ExtraFields map containing any properties in the json response that were not specified in the struct. This can be useful for API features not yet present in the SDK.

body := res.JSON.ExtraFields["my_unexpected_field"].Raw()
Response Unions

In responses, unions are represented by a flattened struct containing all possible fields from each of the object variants. To convert it to a variant use the .AsFooVariant() method or the .AsAny() method if present.

If a response value union contains primitive values, primitive fields will be alongside the properties but prefixed with Of and feature the tag json:"...,inline".

type AnimalUnion struct {
	// From variants [Dog], [Cat]
	Owner Person `json:"owner"`
	// From variant [Dog]
	DogBreed string `json:"dog_breed"`
	// From variant [Cat]
	CatBreed string `json:"cat_breed"`
	// ...

	JSON struct {
		Owner respjson.Field
		// ...
	} `json:"-"`
}

// If animal variant
if animal.Owner.Address.ZipCode == "" {
	panic("missing zip code")
}

// Switch on the variant
switch variant := animal.AsAny().(type) {
case Dog:
case Cat:
default:
	panic("unexpected type")
}
RequestOptions

This library uses the functional options pattern. Functions defined in the option package return a RequestOption, which is a closure that mutates a RequestConfig. These options can be supplied to the client or at individual requests. For example:

client := bila.NewClient(
	// Adds a header to every request made by the client
	option.WithHeader("X-Some-Header", "custom_header_info"),
)

client.Accounts.List(context.TODO(), ...,
	// Override the header
	option.WithHeader("X-Some-Header", "some_other_custom_header_info"),
	// Add an undocumented field to the request body, using sjson syntax
	option.WithJSONSet("some.json.path", map[string]string{"my": "object"}),
)

The request option option.WithDebugLog(nil) may be helpful while debugging.

See the full list of request options.

Pagination

This library provides some conveniences for working with paginated list endpoints.

You can use .ListAutoPaging() methods to iterate through items across all pages:

Or you can use simple .List() methods to fetch a single page and receive a standard response object with additional helper methods like .GetNextPage(), e.g.:

Errors

When the API returns a non-success status code, we return an error with type *bila.Error. This contains the StatusCode, *http.Request, and *http.Response values of the request, as well as the JSON of the error body (much like other response objects in the SDK).

To handle errors, we recommend that you use the errors.As pattern:

_, err := client.Accounts.List(context.TODO(), bila.AccountListParams{})
if err != nil {
	var apierr *bila.Error
	if errors.As(err, &apierr) {
		println(string(apierr.DumpRequest(true)))  // Prints the serialized HTTP request
		println(string(apierr.DumpResponse(true))) // Prints the serialized HTTP response
	}
	panic(err.Error()) // GET "/api/v1/bila/accounts": 400 Bad Request { ... }
}

When other errors occur, they are returned unwrapped; for example, if HTTP transport fails, you might receive *url.Error wrapping *net.OpError.

Timeouts

Requests do not time out by default; use context to configure a timeout for a request lifecycle.

Note that if a request is retried, the context timeout does not start over. To set a per-retry timeout, use option.WithRequestTimeout().

// This sets the timeout for the request, including all the retries.
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Minute)
defer cancel()
client.Accounts.List(
	ctx,
	bila.AccountListParams{},
	// This sets the per-retry timeout
	option.WithRequestTimeout(20*time.Second),
)
File uploads

Request parameters that correspond to file uploads in multipart requests are typed as io.Reader. The contents of the io.Reader will by default be sent as a multipart form part with the file name of "anonymous_file" and content-type of "application/octet-stream".

The file name and content-type can be customized by implementing Name() string or ContentType() string on the run-time type of io.Reader. Note that os.File implements Name() string, so a file returned by os.Open will be sent with the file name on disk.

We also provide a helper bila.File(reader io.Reader, filename string, contentType string) which can be used to wrap any io.Reader with the appropriate file name and content type.

Retries

Certain errors will be automatically retried 2 times by default, with a short exponential backoff. We retry by default all connection errors, 408 Request Timeout, 409 Conflict, 429 Rate Limit, and >=500 Internal errors.

You can use the WithMaxRetries option to configure or disable this:

// Configure the default for all requests:
client := bila.NewClient(
	option.WithMaxRetries(0), // default is 2
)

// Override per-request:
client.Accounts.List(
	context.TODO(),
	bila.AccountListParams{},
	option.WithMaxRetries(5),
)
Accessing raw response data (e.g. response headers)

You can access the raw HTTP response data by using the option.WithResponseInto() request option. This is useful when you need to examine response headers, status codes, or other details.

// Create a variable to store the HTTP response
var response *http.Response
accounts, err := client.Accounts.List(
	context.TODO(),
	bila.AccountListParams{},
	option.WithResponseInto(&response),
)
if err != nil {
	// handle error
}
fmt.Printf("%+v\n", accounts)

fmt.Printf("Status Code: %d\n", response.StatusCode)
fmt.Printf("Headers: %+#v\n", response.Header)
Making custom/undocumented requests

This library is typed for convenient access to the documented API. If you need to access undocumented endpoints, params, or response properties, the library can still be used.

Undocumented endpoints

To make requests to undocumented endpoints, you can use client.Get, client.Post, and other HTTP verbs. RequestOptions on the client, such as retries, will be respected when making these requests.

var (
    // params can be an io.Reader, a []byte, an encoding/json serializable object,
    // or a "…Params" struct defined in this library.
    params map[string]any

    // result can be an []byte, *http.Response, a encoding/json deserializable object,
    // or a model defined in this library.
    result *http.Response
)
err := client.Post(context.Background(), "/unspecified", params, &result)
if err != nil {
    …
}
Undocumented request params

To make requests using undocumented parameters, you may use either the option.WithQuerySet() or the option.WithJSONSet() methods.

params := FooNewParams{
    ID:   "id_xxxx",
    Data: FooNewParamsData{
        FirstName: bila.String("John"),
    },
}
client.Foo.New(context.Background(), params, option.WithJSONSet("data.last_name", "Doe"))
Undocumented response properties

To access undocumented response properties, you may either access the raw JSON of the response as a string with result.JSON.RawJSON(), or get the raw JSON of a particular field on the result with result.JSON.Foo.Raw().

Any fields that are not present on the response struct will be saved and can be accessed by result.JSON.ExtraFields() which returns the extra fields as a map[string]Field.

Middleware

We provide option.WithMiddleware which applies the given middleware to requests.

func Logger(req *http.Request, next option.MiddlewareNext) (res *http.Response, err error) {
	// Before the request
	start := time.Now()
	LogReq(req)

	// Forward the request to the next handler
	res, err = next(req)

	// Handle stuff after the request
	end := time.Now()
	LogRes(res, err, start - end)

    return res, err
}

client := bila.NewClient(
	option.WithMiddleware(Logger),
)

When multiple middlewares are provided as variadic arguments, the middlewares are applied left to right. If option.WithMiddleware is given multiple times, for example first in the client then the method, the middleware in the client will run first and the middleware given in the method will run next.

You may also replace the default http.Client with option.WithHTTPClient(client). Only one http client is accepted (this overwrites any previous client) and receives requests after any middleware has been applied.

Semantic versioning

This package generally follows SemVer conventions, though certain backwards-incompatible changes may be released as minor versions:

  1. Changes to library internals which are technically public but not intended or documented for external use. (Please open a GitHub issue to let us know if you are relying on such internals.)
  2. Changes that we do not expect to impact the vast majority of users in practice.

We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.

We are keen for your feedback; please open an issue with questions, bugs, or suggestions.

Contributing

See the contributing documentation.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool(b bool) param.Opt[bool]

func BoolPtr

func BoolPtr(v bool) *bool

func DefaultClientOptions

func DefaultClientOptions() []option.RequestOption

DefaultClientOptions read from the environment (BILA_API_KEY, BILA_BASE_URL). This should be used to initialize new clients.

func File

func File(rdr io.Reader, filename string, contentType string) file

func Float

func Float(f float64) param.Opt[float64]

func FloatPtr

func FloatPtr(v float64) *float64

func Int

func Int(i int64) param.Opt[int64]

func IntPtr

func IntPtr(v int64) *int64

func Opt

func Opt[T comparable](v T) param.Opt[T]

func Ptr

func Ptr[T any](v T) *T

func String

func String(s string) param.Opt[string]

func StringPtr

func StringPtr(v string) *string

func Time

func Time(t time.Time) param.Opt[time.Time]

func TimePtr

func TimePtr(v time.Time) *time.Time

Types

type AccountDetailsDto added in v0.1.0

type AccountDetailsDto struct {
	// Account holder name
	AccountName string `json:"accountName" api:"required"`
	// Account detail type
	Type string `json:"type" api:"required"`
	// Till number (for mobile money)
	TillNumber string `json:"tillNumber"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AccountName respjson.Field
		Type        respjson.Field
		TillNumber  respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (AccountDetailsDto) RawJSON added in v0.1.0

func (r AccountDetailsDto) RawJSON() string

Returns the unmodified JSON received from the API

func (*AccountDetailsDto) UnmarshalJSON added in v0.1.0

func (r *AccountDetailsDto) UnmarshalJSON(data []byte) error

type AccountGetBalanceResponse

type AccountGetBalanceResponse struct {
	// Response message
	Message string `json:"message" api:"required"`
	// Request success status
	Status bool                          `json:"status" api:"required"`
	Data   AccountGetBalanceResponseData `json:"data"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Message     respjson.Field
		Status      respjson.Field
		Data        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (AccountGetBalanceResponse) RawJSON

func (r AccountGetBalanceResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*AccountGetBalanceResponse) UnmarshalJSON

func (r *AccountGetBalanceResponse) UnmarshalJSON(data []byte) error

type AccountGetBalanceResponseData

type AccountGetBalanceResponseData struct {
	// Available balance
	AvailableBalance string `json:"availableBalance" api:"required"`
	// Currency code
	Currency string `json:"currency" api:"required"`
	// Ledger balance
	LedgerBalance string `json:"ledgerBalance" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AvailableBalance respjson.Field
		Currency         respjson.Field
		LedgerBalance    respjson.Field
		ExtraFields      map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (AccountGetBalanceResponseData) RawJSON

Returns the unmodified JSON received from the API

func (*AccountGetBalanceResponseData) UnmarshalJSON

func (r *AccountGetBalanceResponseData) UnmarshalJSON(data []byte) error

type AccountGetResponse

type AccountGetResponse struct {
	// Response message
	Message string `json:"message" api:"required"`
	// Request success status
	Status bool               `json:"status" api:"required"`
	Data   AccountResponseDto `json:"data"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Message     respjson.Field
		Status      respjson.Field
		Data        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (AccountGetResponse) RawJSON

func (r AccountGetResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*AccountGetResponse) UnmarshalJSON

func (r *AccountGetResponse) UnmarshalJSON(data []byte) error

type AccountListParams

type AccountListParams struct {
	// Page number (default: 1)
	Page param.Opt[float64] `query:"page,omitzero" json:"-"`
	// Items per page (default: 50)
	PerPage param.Opt[float64] `query:"perPage,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (AccountListParams) URLQuery

func (r AccountListParams) URLQuery() (v url.Values, err error)

URLQuery serializes AccountListParams's query parameters as `url.Values`.

type AccountListResponse

type AccountListResponse struct {
	// Response message
	Message string `json:"message" api:"required"`
	// Request success status
	Status bool                    `json:"status" api:"required"`
	Data   AccountListResponseData `json:"data"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Message     respjson.Field
		Status      respjson.Field
		Data        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (AccountListResponse) RawJSON

func (r AccountListResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*AccountListResponse) UnmarshalJSON

func (r *AccountListResponse) UnmarshalJSON(data []byte) error

type AccountListResponseData

type AccountListResponseData struct {
	// List of accounts
	Data []AccountResponseDto `json:"data" api:"required"`
	// Pagination metadata
	Meta shared.PaginationMetaDto `json:"meta" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Meta        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (AccountListResponseData) RawJSON

func (r AccountListResponseData) RawJSON() string

Returns the unmodified JSON received from the API

func (*AccountListResponseData) UnmarshalJSON

func (r *AccountListResponseData) UnmarshalJSON(data []byte) error

type AccountResponseDto added in v0.1.0

type AccountResponseDto struct {
	// Account UUID
	ID string `json:"id" api:"required" format:"uuid"`
	// Account creation timestamp
	CreatedAt time.Time `json:"createdAt" api:"required" format:"date-time"`
	// Currency code
	Currency string `json:"currency" api:"required"`
	// Account details
	Details AccountDetailsDto `json:"details" api:"required"`
	// Account status
	//
	// Any of "active", "inactive", "suspended".
	Status AccountResponseDtoStatus `json:"status" api:"required"`
	// Account type
	//
	// Any of "main", "sub", "virtual".
	Type AccountResponseDtoType `json:"type" api:"required"`
	// Available balance
	AvailableBalance string `json:"availableBalance"`
	// Ledger balance
	LedgerBalance string `json:"ledgerBalance"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID               respjson.Field
		CreatedAt        respjson.Field
		Currency         respjson.Field
		Details          respjson.Field
		Status           respjson.Field
		Type             respjson.Field
		AvailableBalance respjson.Field
		LedgerBalance    respjson.Field
		ExtraFields      map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (AccountResponseDto) RawJSON added in v0.1.0

func (r AccountResponseDto) RawJSON() string

Returns the unmodified JSON received from the API

func (*AccountResponseDto) UnmarshalJSON added in v0.1.0

func (r *AccountResponseDto) UnmarshalJSON(data []byte) error

type AccountResponseDtoStatus added in v0.1.0

type AccountResponseDtoStatus string

Account status

const (
	AccountResponseDtoStatusActive    AccountResponseDtoStatus = "active"
	AccountResponseDtoStatusInactive  AccountResponseDtoStatus = "inactive"
	AccountResponseDtoStatusSuspended AccountResponseDtoStatus = "suspended"
)

type AccountResponseDtoType added in v0.1.0

type AccountResponseDtoType string

Account type

const (
	AccountResponseDtoTypeMain    AccountResponseDtoType = "main"
	AccountResponseDtoTypeSub     AccountResponseDtoType = "sub"
	AccountResponseDtoTypeVirtual AccountResponseDtoType = "virtual"
)

type AccountService

type AccountService struct {
	// contains filtered or unexported fields
}

Account/wallet management endpoints

AccountService contains methods and other services that help with interacting with the bila API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewAccountService method instead.

func NewAccountService

func NewAccountService(opts ...option.RequestOption) (r AccountService)

NewAccountService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*AccountService) Get

func (r *AccountService) Get(ctx context.Context, id string, opts ...option.RequestOption) (res *AccountGetResponse, err error)

Retrieve a single account by its UUID

func (*AccountService) GetBalance

func (r *AccountService) GetBalance(ctx context.Context, id string, opts ...option.RequestOption) (res *AccountGetBalanceResponse, err error)

Retrieve the balance of a specific account

func (*AccountService) List

Retrieve a paginated list of accounts/wallets for the authenticated merchant

type BankListParams

type BankListParams struct {
	// Filter banks by country code
	Country param.Opt[string] `query:"country,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (BankListParams) URLQuery

func (r BankListParams) URLQuery() (v url.Values, err error)

URLQuery serializes BankListParams's query parameters as `url.Values`.

type BankListResponse

type BankListResponse struct {
	// Response message
	Message string `json:"message" api:"required"`
	// Request success status
	Status bool                   `json:"status" api:"required"`
	Data   []BankListResponseData `json:"data"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Message     respjson.Field
		Status      respjson.Field
		Data        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BankListResponse) RawJSON

func (r BankListResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*BankListResponse) UnmarshalJSON

func (r *BankListResponse) UnmarshalJSON(data []byte) error

type BankListResponseData

type BankListResponseData struct {
	// Bank ID
	ID string `json:"id" api:"required"`
	// Bank code
	Code string `json:"code" api:"required"`
	// Country code
	Country string `json:"country" api:"required"`
	// Bank name
	Name string `json:"name" api:"required"`
	// Bank type
	Type string `json:"type"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Code        respjson.Field
		Country     respjson.Field
		Name        respjson.Field
		Type        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BankListResponseData) RawJSON

func (r BankListResponseData) RawJSON() string

Returns the unmodified JSON received from the API

func (*BankListResponseData) UnmarshalJSON

func (r *BankListResponseData) UnmarshalJSON(data []byte) error

type BankService

type BankService struct {
	// contains filtered or unexported fields
}

Bank reference data endpoints

BankService contains methods and other services that help with interacting with the bila API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewBankService method instead.

func NewBankService

func NewBankService(opts ...option.RequestOption) (r BankService)

NewBankService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*BankService) List

func (r *BankService) List(ctx context.Context, query BankListParams, opts ...option.RequestOption) (res *BankListResponse, err error)

Retrieve a list of all supported banks and financial institutions

type BilaCollectionCustomerDto added in v0.1.0

type BilaCollectionCustomerDto struct {
	// Customer name
	Name string `json:"name" api:"required"`
	// Mobile money operator
	Operator string `json:"operator" api:"required"`
	// Customer phone number
	Phone string `json:"phone" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Name        respjson.Field
		Operator    respjson.Field
		Phone       respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BilaCollectionCustomerDto) RawJSON added in v0.1.0

func (r BilaCollectionCustomerDto) RawJSON() string

Returns the unmodified JSON received from the API

func (*BilaCollectionCustomerDto) UnmarshalJSON added in v0.1.0

func (r *BilaCollectionCustomerDto) UnmarshalJSON(data []byte) error

type BilaCollectionResponseDto added in v0.1.0

type BilaCollectionResponseDto struct {
	// Collection ID
	ID string `json:"id" api:"required"`
	// Collection amount
	Amount float64 `json:"amount" api:"required"`
	// Collection creation timestamp
	CreatedAt time.Time `json:"createdAt" api:"required" format:"date-time"`
	// Currency code
	Currency string `json:"currency" api:"required"`
	// Customer details
	Customer BilaCollectionCustomerDto `json:"customer" api:"required"`
	// Client reference
	Reference string `json:"reference" api:"required"`
	// Collection status
	//
	// Any of "pending", "successful", "failed", "otp-required", "pay-offline".
	Status BilaCollectionResponseDtoStatus `json:"status" api:"required"`
	// Collection completion timestamp
	CompletedAt time.Time `json:"completedAt" format:"date-time"`
	// Who bears the transaction fee
	//
	// Any of "merchant", "customer".
	FeeBearer BilaCollectionResponseDtoFeeBearer `json:"feeBearer"`
	// Collection narration
	Narration string `json:"narration"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Amount      respjson.Field
		CreatedAt   respjson.Field
		Currency    respjson.Field
		Customer    respjson.Field
		Reference   respjson.Field
		Status      respjson.Field
		CompletedAt respjson.Field
		FeeBearer   respjson.Field
		Narration   respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (BilaCollectionResponseDto) RawJSON added in v0.1.0

func (r BilaCollectionResponseDto) RawJSON() string

Returns the unmodified JSON received from the API

func (*BilaCollectionResponseDto) UnmarshalJSON added in v0.1.0

func (r *BilaCollectionResponseDto) UnmarshalJSON(data []byte) error

type BilaCollectionResponseDtoFeeBearer added in v0.1.0

type BilaCollectionResponseDtoFeeBearer string

Who bears the transaction fee

const (
	BilaCollectionResponseDtoFeeBearerMerchant BilaCollectionResponseDtoFeeBearer = "merchant"
	BilaCollectionResponseDtoFeeBearerCustomer BilaCollectionResponseDtoFeeBearer = "customer"
)

type BilaCollectionResponseDtoStatus added in v0.1.0

type BilaCollectionResponseDtoStatus string

Collection status

const (
	BilaCollectionResponseDtoStatusPending     BilaCollectionResponseDtoStatus = "pending"
	BilaCollectionResponseDtoStatusSuccessful  BilaCollectionResponseDtoStatus = "successful"
	BilaCollectionResponseDtoStatusFailed      BilaCollectionResponseDtoStatus = "failed"
	BilaCollectionResponseDtoStatusOtpRequired BilaCollectionResponseDtoStatus = "otp-required"
	BilaCollectionResponseDtoStatusPayOffline  BilaCollectionResponseDtoStatus = "pay-offline"
)

type Client

type Client struct {

	// Account/wallet management endpoints
	Accounts AccountService
	// Transfer recipient management endpoints
	TransferRecipients TransferRecipientService
	// Payout/transfer operation endpoints
	Transfers TransferService
	// Payment collection operation endpoints
	Collections CollectionService
	// Transaction history endpoints
	Transactions TransactionService
	// Webhook configuration and delivery history
	Webhooks WebhookService
	// Bank reference data endpoints
	Banks BankService
	// Account resolution/verification endpoints
	Resolve ResolveService
	// contains filtered or unexported fields
}

Client creates a struct with services and top level methods that help with interacting with the bila API. You should not instantiate this client directly, and instead use the NewClient method instead.

func NewClient

func NewClient(opts ...option.RequestOption) (r Client)

NewClient generates a new client with the default option read from the environment (BILA_API_KEY, BILA_BASE_URL). The option passed in as arguments are applied after these default arguments, and all option will be passed down to the services and requests that this client makes.

func (*Client) Delete

func (r *Client) Delete(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error

Delete makes a DELETE request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Execute

func (r *Client) Execute(ctx context.Context, method string, path string, params any, res any, opts ...option.RequestOption) error

Execute makes a request with the given context, method, URL, request params, response, and request options. This is useful for hitting undocumented endpoints while retaining the base URL, auth, retries, and other options from the client.

If a byte slice or an io.Reader is supplied to params, it will be used as-is for the request body.

The params is by default serialized into the body using encoding/json. If your type implements a MarshalJSON function, it will be used instead to serialize the request. If a URLQuery method is implemented, the returned url.Values will be used as query strings to the url.

If your params struct uses param.Field, you must provide either [MarshalJSON], [URLQuery], and/or [MarshalForm] functions. It is undefined behavior to use a struct uses param.Field without specifying how it is serialized.

Any "…Params" object defined in this library can be used as the request argument. Note that 'path' arguments will not be forwarded into the url.

The response body will be deserialized into the res variable, depending on its type:

  • A pointer to a *http.Response is populated by the raw response.
  • A pointer to a byte array will be populated with the contents of the request body.
  • A pointer to any other type uses this library's default JSON decoding, which respects UnmarshalJSON if it is defined on the type.
  • A nil value will not read the response body.

For even greater flexibility, see option.WithResponseInto and option.WithResponseBodyInto.

func (*Client) Get

func (r *Client) Get(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error

Get makes a GET request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Patch

func (r *Client) Patch(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error

Patch makes a PATCH request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Post

func (r *Client) Post(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error

Post makes a POST request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

func (*Client) Put

func (r *Client) Put(ctx context.Context, path string, params any, res any, opts ...option.RequestOption) error

Put makes a PUT request with the given URL, params, and optionally deserializes to a response. See [Execute] documentation on the params and response.

type CollectionGetResponse

type CollectionGetResponse struct {
	// Response message
	Message string `json:"message" api:"required"`
	// Request success status
	Status bool                      `json:"status" api:"required"`
	Data   BilaCollectionResponseDto `json:"data"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Message     respjson.Field
		Status      respjson.Field
		Data        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (CollectionGetResponse) RawJSON

func (r CollectionGetResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*CollectionGetResponse) UnmarshalJSON

func (r *CollectionGetResponse) UnmarshalJSON(data []byte) error

type CollectionGetStatusByReferenceResponse

type CollectionGetStatusByReferenceResponse struct {
	// Response message
	Message string `json:"message" api:"required"`
	// Request success status
	Status bool                      `json:"status" api:"required"`
	Data   BilaCollectionResponseDto `json:"data"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Message     respjson.Field
		Status      respjson.Field
		Data        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (CollectionGetStatusByReferenceResponse) RawJSON

Returns the unmodified JSON received from the API

func (*CollectionGetStatusByReferenceResponse) UnmarshalJSON

func (r *CollectionGetStatusByReferenceResponse) UnmarshalJSON(data []byte) error

type CollectionInitiateMobileMoneyCollectionParams

type CollectionInitiateMobileMoneyCollectionParams struct {
	// Collection amount
	Amount float64 `json:"amount" api:"required"`
	// Country code
	//
	// Any of "zm".
	Country CollectionInitiateMobileMoneyCollectionParamsCountry `json:"country,omitzero" api:"required"`
	// Mobile money operator
	//
	// Any of "airtel", "mtn", "zamtel".
	Operator CollectionInitiateMobileMoneyCollectionParamsOperator `json:"operator,omitzero" api:"required"`
	// Customer phone number
	Phone string `json:"phone" api:"required"`
	// Unique client reference
	Reference string `json:"reference" api:"required"`
	// Target wallet ID to credit
	WalletID string `json:"walletId" api:"required" format:"uuid"`
	// Customer name for the transaction record
	CustomerName param.Opt[string] `json:"customerName,omitzero"`
	// Collection narration
	Narration param.Opt[string] `json:"narration,omitzero"`
	// Who bears the transaction fee
	//
	// Any of "merchant", "customer".
	Bearer CollectionInitiateMobileMoneyCollectionParamsBearer `json:"bearer,omitzero"`
	// contains filtered or unexported fields
}

func (CollectionInitiateMobileMoneyCollectionParams) MarshalJSON

func (r CollectionInitiateMobileMoneyCollectionParams) MarshalJSON() (data []byte, err error)

func (*CollectionInitiateMobileMoneyCollectionParams) UnmarshalJSON

func (r *CollectionInitiateMobileMoneyCollectionParams) UnmarshalJSON(data []byte) error

type CollectionInitiateMobileMoneyCollectionParamsBearer

type CollectionInitiateMobileMoneyCollectionParamsBearer string

Who bears the transaction fee

const (
	CollectionInitiateMobileMoneyCollectionParamsBearerMerchant CollectionInitiateMobileMoneyCollectionParamsBearer = "merchant"
	CollectionInitiateMobileMoneyCollectionParamsBearerCustomer CollectionInitiateMobileMoneyCollectionParamsBearer = "customer"
)

type CollectionInitiateMobileMoneyCollectionParamsCountry

type CollectionInitiateMobileMoneyCollectionParamsCountry string

Country code

const (
	CollectionInitiateMobileMoneyCollectionParamsCountryZm CollectionInitiateMobileMoneyCollectionParamsCountry = "zm"
)

type CollectionInitiateMobileMoneyCollectionParamsOperator

type CollectionInitiateMobileMoneyCollectionParamsOperator string

Mobile money operator

const (
	CollectionInitiateMobileMoneyCollectionParamsOperatorAirtel CollectionInitiateMobileMoneyCollectionParamsOperator = "airtel"
	CollectionInitiateMobileMoneyCollectionParamsOperatorMtn    CollectionInitiateMobileMoneyCollectionParamsOperator = "mtn"
	CollectionInitiateMobileMoneyCollectionParamsOperatorZamtel CollectionInitiateMobileMoneyCollectionParamsOperator = "zamtel"
)

type CollectionInitiateMobileMoneyCollectionResponse

type CollectionInitiateMobileMoneyCollectionResponse struct {
	// Response message
	Message string `json:"message" api:"required"`
	// Request success status
	Status bool                      `json:"status" api:"required"`
	Data   BilaCollectionResponseDto `json:"data"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Message     respjson.Field
		Status      respjson.Field
		Data        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (CollectionInitiateMobileMoneyCollectionResponse) RawJSON

Returns the unmodified JSON received from the API

func (*CollectionInitiateMobileMoneyCollectionResponse) UnmarshalJSON

type CollectionListParams

type CollectionListParams struct {
	// Filter by account ID
	AccountID param.Opt[string] `query:"accountId,omitzero" json:"-"`
	// Filter by end date (ISO 8601)
	EndDate param.Opt[string] `query:"endDate,omitzero" json:"-"`
	// Page number (default: 1)
	Page param.Opt[float64] `query:"page,omitzero" json:"-"`
	// Items per page (default: 50)
	PerPage param.Opt[float64] `query:"perPage,omitzero" json:"-"`
	// Filter by start date (ISO 8601)
	StartDate param.Opt[string] `query:"startDate,omitzero" json:"-"`
	// Filter by collection status
	//
	// Any of "pending", "successful", "failed", "otp-required", "pay-offline".
	Status CollectionListParamsStatus `query:"status,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (CollectionListParams) URLQuery

func (r CollectionListParams) URLQuery() (v url.Values, err error)

URLQuery serializes CollectionListParams's query parameters as `url.Values`.

type CollectionListParamsStatus

type CollectionListParamsStatus string

Filter by collection status

const (
	CollectionListParamsStatusPending     CollectionListParamsStatus = "pending"
	CollectionListParamsStatusSuccessful  CollectionListParamsStatus = "successful"
	CollectionListParamsStatusFailed      CollectionListParamsStatus = "failed"
	CollectionListParamsStatusOtpRequired CollectionListParamsStatus = "otp-required"
	CollectionListParamsStatusPayOffline  CollectionListParamsStatus = "pay-offline"
)

type CollectionListResponse

type CollectionListResponse struct {
	// Response message
	Message string `json:"message" api:"required"`
	// Request success status
	Status bool                       `json:"status" api:"required"`
	Data   CollectionListResponseData `json:"data"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Message     respjson.Field
		Status      respjson.Field
		Data        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (CollectionListResponse) RawJSON

func (r CollectionListResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*CollectionListResponse) UnmarshalJSON

func (r *CollectionListResponse) UnmarshalJSON(data []byte) error

type CollectionListResponseData

type CollectionListResponseData struct {
	// List of collections
	Data []BilaCollectionResponseDto `json:"data" api:"required"`
	// Pagination metadata
	Meta shared.PaginationMetaDto `json:"meta" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Meta        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (CollectionListResponseData) RawJSON

func (r CollectionListResponseData) RawJSON() string

Returns the unmodified JSON received from the API

func (*CollectionListResponseData) UnmarshalJSON

func (r *CollectionListResponseData) UnmarshalJSON(data []byte) error

type CollectionService

type CollectionService struct {
	// contains filtered or unexported fields
}

Payment collection operation endpoints

CollectionService contains methods and other services that help with interacting with the bila API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewCollectionService method instead.

func NewCollectionService

func NewCollectionService(opts ...option.RequestOption) (r CollectionService)

NewCollectionService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*CollectionService) Get

Retrieve a single collection by its UUID

func (*CollectionService) GetStatusByReference

func (r *CollectionService) GetStatusByReference(ctx context.Context, reference string, opts ...option.RequestOption) (res *CollectionGetStatusByReferenceResponse, err error)

Retrieve collection status by client reference

func (*CollectionService) InitiateMobileMoneyCollection

Initiate a payment collection from a mobile money account. Creates a transaction record in your dashboard.

func (*CollectionService) List

Retrieve a paginated list of payment collections for the authenticated merchant

type Error

type Error = apierror.Error

type PaginationMetaDto added in v0.1.0

type PaginationMetaDto = shared.PaginationMetaDto

This is an alias to an internal type.

type RecipientResponseDto added in v0.1.0

type RecipientResponseDto struct {
	// Recipient UUID
	ID string `json:"id" api:"required" format:"uuid"`
	// Account holder name
	AccountName string `json:"accountName" api:"required"`
	// Country code
	Country string `json:"country" api:"required"`
	// Creation timestamp
	CreatedAt time.Time `json:"createdAt" api:"required" format:"date-time"`
	// Transfer recipient type
	//
	// Any of "bank-account", "mobile-money".
	Type RecipientResponseDtoType `json:"type" api:"required"`
	// Bank account number (bank-account only)
	AccountNumber string `json:"accountNumber"`
	// Bank ID (bank-account only)
	BankID string `json:"bankId"`
	// Bank name (bank-account only)
	BankName string `json:"bankName"`
	// Mobile money operator (mobile-money only)
	Operator string `json:"operator"`
	// Phone number (mobile-money only)
	Phone string `json:"phone"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID            respjson.Field
		AccountName   respjson.Field
		Country       respjson.Field
		CreatedAt     respjson.Field
		Type          respjson.Field
		AccountNumber respjson.Field
		BankID        respjson.Field
		BankName      respjson.Field
		Operator      respjson.Field
		Phone         respjson.Field
		ExtraFields   map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (RecipientResponseDto) RawJSON added in v0.1.0

func (r RecipientResponseDto) RawJSON() string

Returns the unmodified JSON received from the API

func (*RecipientResponseDto) UnmarshalJSON added in v0.1.0

func (r *RecipientResponseDto) UnmarshalJSON(data []byte) error

type RecipientResponseDtoType added in v0.1.0

type RecipientResponseDtoType string

Transfer recipient type

const (
	RecipientResponseDtoTypeBankAccount RecipientResponseDtoType = "bank-account"
	RecipientResponseDtoTypeMobileMoney RecipientResponseDtoType = "mobile-money"
)

type ResolveBankAccountParams

type ResolveBankAccountParams struct {
	// Bank account number
	AccountNumber string `json:"accountNumber" api:"required"`
	// Bank ID
	BankID string `json:"bankId" api:"required"`
	// Country code
	//
	// Any of "zm".
	Country ResolveBankAccountParamsCountry `json:"country,omitzero"`
	// contains filtered or unexported fields
}

func (ResolveBankAccountParams) MarshalJSON

func (r ResolveBankAccountParams) MarshalJSON() (data []byte, err error)

func (*ResolveBankAccountParams) UnmarshalJSON

func (r *ResolveBankAccountParams) UnmarshalJSON(data []byte) error

type ResolveBankAccountParamsCountry

type ResolveBankAccountParamsCountry string

Country code

const (
	ResolveBankAccountParamsCountryZm ResolveBankAccountParamsCountry = "zm"
)

type ResolveBankAccountResponse

type ResolveBankAccountResponse struct {
	// Response message
	Message string `json:"message" api:"required"`
	// Request success status
	Status bool                       `json:"status" api:"required"`
	Data   ResolvedAccountResponseDto `json:"data"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Message     respjson.Field
		Status      respjson.Field
		Data        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ResolveBankAccountResponse) RawJSON

func (r ResolveBankAccountResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*ResolveBankAccountResponse) UnmarshalJSON

func (r *ResolveBankAccountResponse) UnmarshalJSON(data []byte) error

type ResolveMobileMoneyParams

type ResolveMobileMoneyParams struct {
	// Country code
	//
	// Any of "zm".
	Country ResolveMobileMoneyParamsCountry `json:"country,omitzero" api:"required"`
	// Mobile money operator
	//
	// Any of "airtel", "mtn", "zamtel".
	Operator ResolveMobileMoneyParamsOperator `json:"operator,omitzero" api:"required"`
	// Mobile phone number
	Phone string `json:"phone" api:"required"`
	// contains filtered or unexported fields
}

func (ResolveMobileMoneyParams) MarshalJSON

func (r ResolveMobileMoneyParams) MarshalJSON() (data []byte, err error)

func (*ResolveMobileMoneyParams) UnmarshalJSON

func (r *ResolveMobileMoneyParams) UnmarshalJSON(data []byte) error

type ResolveMobileMoneyParamsCountry

type ResolveMobileMoneyParamsCountry string

Country code

const (
	ResolveMobileMoneyParamsCountryZm ResolveMobileMoneyParamsCountry = "zm"
)

type ResolveMobileMoneyParamsOperator

type ResolveMobileMoneyParamsOperator string

Mobile money operator

const (
	ResolveMobileMoneyParamsOperatorAirtel ResolveMobileMoneyParamsOperator = "airtel"
	ResolveMobileMoneyParamsOperatorMtn    ResolveMobileMoneyParamsOperator = "mtn"
	ResolveMobileMoneyParamsOperatorZamtel ResolveMobileMoneyParamsOperator = "zamtel"
)

type ResolveMobileMoneyResponse

type ResolveMobileMoneyResponse struct {
	// Response message
	Message string `json:"message" api:"required"`
	// Request success status
	Status bool                       `json:"status" api:"required"`
	Data   ResolvedAccountResponseDto `json:"data"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Message     respjson.Field
		Status      respjson.Field
		Data        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ResolveMobileMoneyResponse) RawJSON

func (r ResolveMobileMoneyResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*ResolveMobileMoneyResponse) UnmarshalJSON

func (r *ResolveMobileMoneyResponse) UnmarshalJSON(data []byte) error

type ResolveService

type ResolveService struct {
	// contains filtered or unexported fields
}

Account resolution/verification endpoints

ResolveService contains methods and other services that help with interacting with the bila API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewResolveService method instead.

func NewResolveService

func NewResolveService(opts ...option.RequestOption) (r ResolveService)

NewResolveService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*ResolveService) BankAccount

Verify and retrieve bank account holder details

func (*ResolveService) MobileMoney

Verify and retrieve mobile money account holder details

type ResolvedAccountResponseDto added in v0.1.0

type ResolvedAccountResponseDto struct {
	// Account holder name
	AccountName string `json:"accountName" api:"required"`
	// Country code
	Country string `json:"country" api:"required"`
	// Bank account number
	AccountNumber string `json:"accountNumber"`
	// Bank ID
	BankID string `json:"bankId"`
	// Bank name
	BankName string `json:"bankName"`
	// Mobile money operator
	Operator string `json:"operator"`
	// Phone number
	Phone string `json:"phone"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AccountName   respjson.Field
		Country       respjson.Field
		AccountNumber respjson.Field
		BankID        respjson.Field
		BankName      respjson.Field
		Operator      respjson.Field
		Phone         respjson.Field
		ExtraFields   map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (ResolvedAccountResponseDto) RawJSON added in v0.1.0

func (r ResolvedAccountResponseDto) RawJSON() string

Returns the unmodified JSON received from the API

func (*ResolvedAccountResponseDto) UnmarshalJSON added in v0.1.0

func (r *ResolvedAccountResponseDto) UnmarshalJSON(data []byte) error

type TransactionGetResponse

type TransactionGetResponse struct {
	// Response message
	Message string `json:"message" api:"required"`
	// Request success status
	Status bool                   `json:"status" api:"required"`
	Data   TransactionResponseDto `json:"data"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Message     respjson.Field
		Status      respjson.Field
		Data        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (TransactionGetResponse) RawJSON

func (r TransactionGetResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*TransactionGetResponse) UnmarshalJSON

func (r *TransactionGetResponse) UnmarshalJSON(data []byte) error

type TransactionListParams

type TransactionListParams struct {
	// Filter by account ID
	AccountID param.Opt[string] `query:"accountId,omitzero" json:"-"`
	// Filter by end date (ISO 8601)
	EndDate param.Opt[string] `query:"endDate,omitzero" json:"-"`
	// Page number (default: 1)
	Page param.Opt[float64] `query:"page,omitzero" json:"-"`
	// Items per page (default: 50)
	PerPage param.Opt[float64] `query:"perPage,omitzero" json:"-"`
	// Filter by start date (ISO 8601)
	StartDate param.Opt[string] `query:"startDate,omitzero" json:"-"`
	// Filter by transaction type
	//
	// Any of "credit", "debit".
	Type TransactionListParamsType `query:"type,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (TransactionListParams) URLQuery

func (r TransactionListParams) URLQuery() (v url.Values, err error)

URLQuery serializes TransactionListParams's query parameters as `url.Values`.

type TransactionListParamsType

type TransactionListParamsType string

Filter by transaction type

const (
	TransactionListParamsTypeCredit TransactionListParamsType = "credit"
	TransactionListParamsTypeDebit  TransactionListParamsType = "debit"
)

type TransactionListResponse

type TransactionListResponse struct {
	// Response message
	Message string `json:"message" api:"required"`
	// Request success status
	Status bool                        `json:"status" api:"required"`
	Data   TransactionListResponseData `json:"data"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Message     respjson.Field
		Status      respjson.Field
		Data        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (TransactionListResponse) RawJSON

func (r TransactionListResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*TransactionListResponse) UnmarshalJSON

func (r *TransactionListResponse) UnmarshalJSON(data []byte) error

type TransactionListResponseData

type TransactionListResponseData struct {
	// List of transactions
	Data []TransactionResponseDto `json:"data" api:"required"`
	// Pagination metadata
	Meta shared.PaginationMetaDto `json:"meta" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Meta        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (TransactionListResponseData) RawJSON

func (r TransactionListResponseData) RawJSON() string

Returns the unmodified JSON received from the API

func (*TransactionListResponseData) UnmarshalJSON

func (r *TransactionListResponseData) UnmarshalJSON(data []byte) error

type TransactionResponseDto added in v0.1.0

type TransactionResponseDto struct {
	// Transaction UUID
	ID string `json:"id" api:"required"`
	// Account / wallet ID
	AccountID string `json:"accountId" api:"required"`
	// Transaction amount
	Amount float64 `json:"amount" api:"required"`
	// Balance after transaction
	BalanceAfter float64 `json:"balanceAfter" api:"required"`
	// Balance before transaction
	BalanceBefore float64 `json:"balanceBefore" api:"required"`
	// Transaction timestamp
	CreatedAt time.Time `json:"createdAt" api:"required" format:"date-time"`
	// Currency code
	Currency string `json:"currency" api:"required"`
	// Transaction status
	//
	// Any of "pending", "successful", "failed", "cancelled".
	Status TransactionResponseDtoStatus `json:"status" api:"required"`
	// Transaction type
	//
	// Any of "credit", "debit".
	Type TransactionResponseDtoType `json:"type" api:"required"`
	// Transaction description
	Description string `json:"description"`
	// Client reference
	Reference string `json:"reference"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID            respjson.Field
		AccountID     respjson.Field
		Amount        respjson.Field
		BalanceAfter  respjson.Field
		BalanceBefore respjson.Field
		CreatedAt     respjson.Field
		Currency      respjson.Field
		Status        respjson.Field
		Type          respjson.Field
		Description   respjson.Field
		Reference     respjson.Field
		ExtraFields   map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (TransactionResponseDto) RawJSON added in v0.1.0

func (r TransactionResponseDto) RawJSON() string

Returns the unmodified JSON received from the API

func (*TransactionResponseDto) UnmarshalJSON added in v0.1.0

func (r *TransactionResponseDto) UnmarshalJSON(data []byte) error

type TransactionResponseDtoStatus added in v0.1.0

type TransactionResponseDtoStatus string

Transaction status

const (
	TransactionResponseDtoStatusPending    TransactionResponseDtoStatus = "pending"
	TransactionResponseDtoStatusSuccessful TransactionResponseDtoStatus = "successful"
	TransactionResponseDtoStatusFailed     TransactionResponseDtoStatus = "failed"
	TransactionResponseDtoStatusCancelled  TransactionResponseDtoStatus = "cancelled"
)

type TransactionResponseDtoType added in v0.1.0

type TransactionResponseDtoType string

Transaction type

const (
	TransactionResponseDtoTypeCredit TransactionResponseDtoType = "credit"
	TransactionResponseDtoTypeDebit  TransactionResponseDtoType = "debit"
)

type TransactionService

type TransactionService struct {
	// contains filtered or unexported fields
}

Transaction history endpoints

TransactionService contains methods and other services that help with interacting with the bila API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewTransactionService method instead.

func NewTransactionService

func NewTransactionService(opts ...option.RequestOption) (r TransactionService)

NewTransactionService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*TransactionService) Get

Retrieve a single transaction by its UUID

func (*TransactionService) List

Retrieve a paginated list of transactions

type TransferGetResponse

type TransferGetResponse struct {
	// Response message
	Message string `json:"message" api:"required"`
	// Request success status
	Status bool                `json:"status" api:"required"`
	Data   TransferResponseDto `json:"data"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Message     respjson.Field
		Status      respjson.Field
		Data        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (TransferGetResponse) RawJSON

func (r TransferGetResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*TransferGetResponse) UnmarshalJSON

func (r *TransferGetResponse) UnmarshalJSON(data []byte) error

type TransferGetStatusByReferenceResponse

type TransferGetStatusByReferenceResponse struct {
	// Response message
	Message string `json:"message" api:"required"`
	// Request success status
	Status bool                `json:"status" api:"required"`
	Data   TransferResponseDto `json:"data"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Message     respjson.Field
		Status      respjson.Field
		Data        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (TransferGetStatusByReferenceResponse) RawJSON

Returns the unmodified JSON received from the API

func (*TransferGetStatusByReferenceResponse) UnmarshalJSON

func (r *TransferGetStatusByReferenceResponse) UnmarshalJSON(data []byte) error

type TransferInitiateBankTransferParams

type TransferInitiateBankTransferParams struct {
	// Source account UUID
	AccountID string `json:"accountId" api:"required" format:"uuid"`
	// Transfer amount
	Amount float64 `json:"amount" api:"required"`
	// Unique client reference (alphanumeric, dots, underscores, hyphens)
	Reference string `json:"reference" api:"required"`
	// Bank account number (required if no transferRecipientId)
	AccountNumber param.Opt[string] `json:"accountNumber,omitzero"`
	// Bank ID (required if no transferRecipientId)
	BankID param.Opt[string] `json:"bankId,omitzero"`
	// Transfer narration
	Narration param.Opt[string] `json:"narration,omitzero"`
	// Recipient name for the transaction record
	RecipientName param.Opt[string] `json:"recipientName,omitzero"`
	// Transfer recipient UUID (use this OR accountNumber+bankId)
	TransferRecipientID param.Opt[string] `json:"transferRecipientId,omitzero" format:"uuid"`
	// Source wallet ID to debit (optional, uses main wallet if not specified)
	WalletID param.Opt[string] `json:"walletId,omitzero"`
	// Country code
	//
	// Any of "zm".
	Country TransferInitiateBankTransferParamsCountry `json:"country,omitzero"`
	// contains filtered or unexported fields
}

func (TransferInitiateBankTransferParams) MarshalJSON

func (r TransferInitiateBankTransferParams) MarshalJSON() (data []byte, err error)

func (*TransferInitiateBankTransferParams) UnmarshalJSON

func (r *TransferInitiateBankTransferParams) UnmarshalJSON(data []byte) error

type TransferInitiateBankTransferParamsCountry

type TransferInitiateBankTransferParamsCountry string

Country code

const (
	TransferInitiateBankTransferParamsCountryZm TransferInitiateBankTransferParamsCountry = "zm"
)

type TransferInitiateBankTransferResponse

type TransferInitiateBankTransferResponse struct {
	// Response message
	Message string `json:"message" api:"required"`
	// Request success status
	Status bool                `json:"status" api:"required"`
	Data   TransferResponseDto `json:"data"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Message     respjson.Field
		Status      respjson.Field
		Data        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (TransferInitiateBankTransferResponse) RawJSON

Returns the unmodified JSON received from the API

func (*TransferInitiateBankTransferResponse) UnmarshalJSON

func (r *TransferInitiateBankTransferResponse) UnmarshalJSON(data []byte) error

type TransferInitiateMobileMoneyTransferParams

type TransferInitiateMobileMoneyTransferParams struct {
	// Transfer amount
	Amount float64 `json:"amount" api:"required"`
	// Country code
	//
	// Any of "zm".
	Country TransferInitiateMobileMoneyTransferParamsCountry `json:"country,omitzero" api:"required"`
	// Mobile money operator
	//
	// Any of "airtel", "mtn", "zamtel".
	Operator TransferInitiateMobileMoneyTransferParamsOperator `json:"operator,omitzero" api:"required"`
	// Recipient phone number
	Phone string `json:"phone" api:"required"`
	// Unique client reference
	Reference string `json:"reference" api:"required"`
	// Transfer narration
	Narration param.Opt[string] `json:"narration,omitzero"`
	// Recipient name for the transaction record
	RecipientName param.Opt[string] `json:"recipientName,omitzero"`
	// Source wallet ID to debit (defaults to main wallet if omitted)
	WalletID param.Opt[string] `json:"walletId,omitzero" format:"uuid"`
	// contains filtered or unexported fields
}

func (TransferInitiateMobileMoneyTransferParams) MarshalJSON

func (r TransferInitiateMobileMoneyTransferParams) MarshalJSON() (data []byte, err error)

func (*TransferInitiateMobileMoneyTransferParams) UnmarshalJSON

func (r *TransferInitiateMobileMoneyTransferParams) UnmarshalJSON(data []byte) error

type TransferInitiateMobileMoneyTransferParamsCountry

type TransferInitiateMobileMoneyTransferParamsCountry string

Country code

const (
	TransferInitiateMobileMoneyTransferParamsCountryZm TransferInitiateMobileMoneyTransferParamsCountry = "zm"
)

type TransferInitiateMobileMoneyTransferParamsOperator

type TransferInitiateMobileMoneyTransferParamsOperator string

Mobile money operator

const (
	TransferInitiateMobileMoneyTransferParamsOperatorAirtel TransferInitiateMobileMoneyTransferParamsOperator = "airtel"
	TransferInitiateMobileMoneyTransferParamsOperatorMtn    TransferInitiateMobileMoneyTransferParamsOperator = "mtn"
	TransferInitiateMobileMoneyTransferParamsOperatorZamtel TransferInitiateMobileMoneyTransferParamsOperator = "zamtel"
)

type TransferInitiateMobileMoneyTransferResponse

type TransferInitiateMobileMoneyTransferResponse struct {
	// Response message
	Message string `json:"message" api:"required"`
	// Request success status
	Status bool                `json:"status" api:"required"`
	Data   TransferResponseDto `json:"data"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Message     respjson.Field
		Status      respjson.Field
		Data        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (TransferInitiateMobileMoneyTransferResponse) RawJSON

Returns the unmodified JSON received from the API

func (*TransferInitiateMobileMoneyTransferResponse) UnmarshalJSON

func (r *TransferInitiateMobileMoneyTransferResponse) UnmarshalJSON(data []byte) error

type TransferListParams

type TransferListParams struct {
	// Filter by account ID
	AccountID param.Opt[string] `query:"accountId,omitzero" json:"-"`
	// Filter by end date (ISO 8601)
	EndDate param.Opt[string] `query:"endDate,omitzero" json:"-"`
	// Page number (default: 1)
	Page param.Opt[float64] `query:"page,omitzero" json:"-"`
	// Items per page (default: 50)
	PerPage param.Opt[float64] `query:"perPage,omitzero" json:"-"`
	// Filter by start date (ISO 8601)
	StartDate param.Opt[string] `query:"startDate,omitzero" json:"-"`
	// Filter by transfer status
	//
	// Any of "pending", "successful", "failed".
	Status TransferListParamsStatus `query:"status,omitzero" json:"-"`
	// Filter by transfer type
	//
	// Any of "bank-account", "mobile-money".
	Type TransferListParamsType `query:"type,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (TransferListParams) URLQuery

func (r TransferListParams) URLQuery() (v url.Values, err error)

URLQuery serializes TransferListParams's query parameters as `url.Values`.

type TransferListParamsStatus

type TransferListParamsStatus string

Filter by transfer status

const (
	TransferListParamsStatusPending    TransferListParamsStatus = "pending"
	TransferListParamsStatusSuccessful TransferListParamsStatus = "successful"
	TransferListParamsStatusFailed     TransferListParamsStatus = "failed"
)

type TransferListParamsType

type TransferListParamsType string

Filter by transfer type

const (
	TransferListParamsTypeBankAccount TransferListParamsType = "bank-account"
	TransferListParamsTypeMobileMoney TransferListParamsType = "mobile-money"
)

type TransferListResponse

type TransferListResponse struct {
	// Response message
	Message string `json:"message" api:"required"`
	// Request success status
	Status bool                     `json:"status" api:"required"`
	Data   TransferListResponseData `json:"data"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Message     respjson.Field
		Status      respjson.Field
		Data        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (TransferListResponse) RawJSON

func (r TransferListResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*TransferListResponse) UnmarshalJSON

func (r *TransferListResponse) UnmarshalJSON(data []byte) error

type TransferListResponseData

type TransferListResponseData struct {
	// List of transfers
	Data []TransferResponseDto `json:"data" api:"required"`
	// Pagination metadata
	Meta shared.PaginationMetaDto `json:"meta" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Meta        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (TransferListResponseData) RawJSON

func (r TransferListResponseData) RawJSON() string

Returns the unmodified JSON received from the API

func (*TransferListResponseData) UnmarshalJSON

func (r *TransferListResponseData) UnmarshalJSON(data []byte) error

type TransferRecipientDto added in v0.1.0

type TransferRecipientDto struct {
	// Account holder / recipient name
	AccountName string `json:"accountName" api:"required"`
	// Bank account number (bank-account only)
	AccountNumber string `json:"accountNumber"`
	// Bank name (bank-account only)
	BankName string `json:"bankName"`
	// Mobile money operator (mobile-money only)
	Operator string `json:"operator"`
	// Phone number (mobile-money only)
	Phone string `json:"phone"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		AccountName   respjson.Field
		AccountNumber respjson.Field
		BankName      respjson.Field
		Operator      respjson.Field
		Phone         respjson.Field
		ExtraFields   map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (TransferRecipientDto) RawJSON added in v0.1.0

func (r TransferRecipientDto) RawJSON() string

Returns the unmodified JSON received from the API

func (*TransferRecipientDto) UnmarshalJSON added in v0.1.0

func (r *TransferRecipientDto) UnmarshalJSON(data []byte) error

type TransferRecipientGetResponse

type TransferRecipientGetResponse struct {
	// Response message
	Message string `json:"message" api:"required"`
	// Request success status
	Status bool                 `json:"status" api:"required"`
	Data   RecipientResponseDto `json:"data"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Message     respjson.Field
		Status      respjson.Field
		Data        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (TransferRecipientGetResponse) RawJSON

Returns the unmodified JSON received from the API

func (*TransferRecipientGetResponse) UnmarshalJSON

func (r *TransferRecipientGetResponse) UnmarshalJSON(data []byte) error

type TransferRecipientListParams

type TransferRecipientListParams struct {
	// Page number (default: 1)
	Page param.Opt[float64] `query:"page,omitzero" json:"-"`
	// Items per page (default: 50)
	PerPage param.Opt[float64] `query:"perPage,omitzero" json:"-"`
	// Filter by recipient type
	//
	// Any of "bank-account", "mobile-money".
	Type TransferRecipientListParamsType `query:"type,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (TransferRecipientListParams) URLQuery

func (r TransferRecipientListParams) URLQuery() (v url.Values, err error)

URLQuery serializes TransferRecipientListParams's query parameters as `url.Values`.

type TransferRecipientListParamsType

type TransferRecipientListParamsType string

Filter by recipient type

const (
	TransferRecipientListParamsTypeBankAccount TransferRecipientListParamsType = "bank-account"
	TransferRecipientListParamsTypeMobileMoney TransferRecipientListParamsType = "mobile-money"
)

type TransferRecipientListResponse

type TransferRecipientListResponse struct {
	// Response message
	Message string `json:"message" api:"required"`
	// Request success status
	Status bool                              `json:"status" api:"required"`
	Data   TransferRecipientListResponseData `json:"data"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Message     respjson.Field
		Status      respjson.Field
		Data        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (TransferRecipientListResponse) RawJSON

Returns the unmodified JSON received from the API

func (*TransferRecipientListResponse) UnmarshalJSON

func (r *TransferRecipientListResponse) UnmarshalJSON(data []byte) error

type TransferRecipientListResponseData

type TransferRecipientListResponseData struct {
	// List of recipients
	Data []RecipientResponseDto `json:"data" api:"required"`
	// Pagination metadata
	Meta shared.PaginationMetaDto `json:"meta" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Meta        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (TransferRecipientListResponseData) RawJSON

Returns the unmodified JSON received from the API

func (*TransferRecipientListResponseData) UnmarshalJSON

func (r *TransferRecipientListResponseData) UnmarshalJSON(data []byte) error

type TransferRecipientNewBankAccountParams

type TransferRecipientNewBankAccountParams struct {
	// Bank account number
	AccountNumber string `json:"accountNumber" api:"required"`
	// Bank ID
	BankID string `json:"bankId" api:"required"`
	// Account holder name (optional, will be resolved)
	AccountName param.Opt[string] `json:"accountName,omitzero"`
	// Country code
	//
	// Any of "zm".
	Country TransferRecipientNewBankAccountParamsCountry `json:"country,omitzero"`
	// contains filtered or unexported fields
}

func (TransferRecipientNewBankAccountParams) MarshalJSON

func (r TransferRecipientNewBankAccountParams) MarshalJSON() (data []byte, err error)

func (*TransferRecipientNewBankAccountParams) UnmarshalJSON

func (r *TransferRecipientNewBankAccountParams) UnmarshalJSON(data []byte) error

type TransferRecipientNewBankAccountParamsCountry

type TransferRecipientNewBankAccountParamsCountry string

Country code

const (
	TransferRecipientNewBankAccountParamsCountryZm TransferRecipientNewBankAccountParamsCountry = "zm"
)

type TransferRecipientNewBankAccountResponse

type TransferRecipientNewBankAccountResponse struct {
	// Response message
	Message string `json:"message" api:"required"`
	// Request success status
	Status bool                 `json:"status" api:"required"`
	Data   RecipientResponseDto `json:"data"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Message     respjson.Field
		Status      respjson.Field
		Data        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (TransferRecipientNewBankAccountResponse) RawJSON

Returns the unmodified JSON received from the API

func (*TransferRecipientNewBankAccountResponse) UnmarshalJSON

func (r *TransferRecipientNewBankAccountResponse) UnmarshalJSON(data []byte) error

type TransferRecipientNewMobileMoneyParams

type TransferRecipientNewMobileMoneyParams struct {
	// Country code
	//
	// Any of "zm".
	Country TransferRecipientNewMobileMoneyParamsCountry `json:"country,omitzero" api:"required"`
	// Mobile money operator
	//
	// Any of "airtel", "mtn", "zamtel".
	Operator TransferRecipientNewMobileMoneyParamsOperator `json:"operator,omitzero" api:"required"`
	// Mobile phone number
	Phone string `json:"phone" api:"required"`
	// Account holder name (optional, will be resolved)
	AccountName param.Opt[string] `json:"accountName,omitzero"`
	// contains filtered or unexported fields
}

func (TransferRecipientNewMobileMoneyParams) MarshalJSON

func (r TransferRecipientNewMobileMoneyParams) MarshalJSON() (data []byte, err error)

func (*TransferRecipientNewMobileMoneyParams) UnmarshalJSON

func (r *TransferRecipientNewMobileMoneyParams) UnmarshalJSON(data []byte) error

type TransferRecipientNewMobileMoneyParamsCountry

type TransferRecipientNewMobileMoneyParamsCountry string

Country code

const (
	TransferRecipientNewMobileMoneyParamsCountryZm TransferRecipientNewMobileMoneyParamsCountry = "zm"
)

type TransferRecipientNewMobileMoneyParamsOperator

type TransferRecipientNewMobileMoneyParamsOperator string

Mobile money operator

const (
	TransferRecipientNewMobileMoneyParamsOperatorAirtel TransferRecipientNewMobileMoneyParamsOperator = "airtel"
	TransferRecipientNewMobileMoneyParamsOperatorMtn    TransferRecipientNewMobileMoneyParamsOperator = "mtn"
	TransferRecipientNewMobileMoneyParamsOperatorZamtel TransferRecipientNewMobileMoneyParamsOperator = "zamtel"
)

type TransferRecipientNewMobileMoneyResponse

type TransferRecipientNewMobileMoneyResponse struct {
	// Response message
	Message string `json:"message" api:"required"`
	// Request success status
	Status bool                 `json:"status" api:"required"`
	Data   RecipientResponseDto `json:"data"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Message     respjson.Field
		Status      respjson.Field
		Data        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (TransferRecipientNewMobileMoneyResponse) RawJSON

Returns the unmodified JSON received from the API

func (*TransferRecipientNewMobileMoneyResponse) UnmarshalJSON

func (r *TransferRecipientNewMobileMoneyResponse) UnmarshalJSON(data []byte) error

type TransferRecipientService

type TransferRecipientService struct {
	// contains filtered or unexported fields
}

Transfer recipient management endpoints

TransferRecipientService contains methods and other services that help with interacting with the bila API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewTransferRecipientService method instead.

func NewTransferRecipientService

func NewTransferRecipientService(opts ...option.RequestOption) (r TransferRecipientService)

NewTransferRecipientService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*TransferRecipientService) Get

Retrieve a single transfer recipient by its UUID

func (*TransferRecipientService) List

Retrieve a paginated list of saved transfer recipients

func (*TransferRecipientService) NewBankAccount

Create a new bank account transfer recipient

func (*TransferRecipientService) NewMobileMoney

Create a new mobile money transfer recipient

type TransferResponseDto added in v0.1.0

type TransferResponseDto struct {
	// Transfer ID
	ID string `json:"id" api:"required"`
	// Transfer amount
	Amount float64 `json:"amount" api:"required"`
	// Creation timestamp (from Payment)
	CreatedAt time.Time `json:"createdAt" api:"required" format:"date-time"`
	// Currency code
	Currency string `json:"currency" api:"required"`
	// Recipient details
	Recipient TransferRecipientDto `json:"recipient" api:"required"`
	// Client reference
	Reference string `json:"reference" api:"required"`
	// Transfer status
	//
	// Any of "pending", "successful", "failed".
	Status TransferResponseDtoStatus `json:"status" api:"required"`
	// Transfer recipient type
	//
	// Any of "bank-account", "mobile-money".
	Type TransferResponseDtoType `json:"type" api:"required"`
	// Completion timestamp (from Payment.processedAt)
	CompletedAt time.Time `json:"completedAt" format:"date-time"`
	// Transfer narration
	Narration string `json:"narration"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		Amount      respjson.Field
		CreatedAt   respjson.Field
		Currency    respjson.Field
		Recipient   respjson.Field
		Reference   respjson.Field
		Status      respjson.Field
		Type        respjson.Field
		CompletedAt respjson.Field
		Narration   respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (TransferResponseDto) RawJSON added in v0.1.0

func (r TransferResponseDto) RawJSON() string

Returns the unmodified JSON received from the API

func (*TransferResponseDto) UnmarshalJSON added in v0.1.0

func (r *TransferResponseDto) UnmarshalJSON(data []byte) error

type TransferResponseDtoStatus added in v0.1.0

type TransferResponseDtoStatus string

Transfer status

const (
	TransferResponseDtoStatusPending    TransferResponseDtoStatus = "pending"
	TransferResponseDtoStatusSuccessful TransferResponseDtoStatus = "successful"
	TransferResponseDtoStatusFailed     TransferResponseDtoStatus = "failed"
)

type TransferResponseDtoType added in v0.1.0

type TransferResponseDtoType string

Transfer recipient type

const (
	TransferResponseDtoTypeBankAccount TransferResponseDtoType = "bank-account"
	TransferResponseDtoTypeMobileMoney TransferResponseDtoType = "mobile-money"
)

type TransferService

type TransferService struct {
	// contains filtered or unexported fields
}

Payout/transfer operation endpoints

TransferService contains methods and other services that help with interacting with the bila API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewTransferService method instead.

func NewTransferService

func NewTransferService(opts ...option.RequestOption) (r TransferService)

NewTransferService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*TransferService) Get

func (r *TransferService) Get(ctx context.Context, id string, opts ...option.RequestOption) (res *TransferGetResponse, err error)

Retrieve a single transfer by its UUID

func (*TransferService) GetStatusByReference

func (r *TransferService) GetStatusByReference(ctx context.Context, reference string, opts ...option.RequestOption) (res *TransferGetStatusByReferenceResponse, err error)

Retrieve transfer status by client reference

func (*TransferService) InitiateBankTransfer

Initiate a transfer to a bank account. Creates a transaction record in your dashboard.

func (*TransferService) InitiateMobileMoneyTransfer

Initiate a transfer to a mobile money account. Creates a transaction record in your dashboard.

func (*TransferService) List

Retrieve a paginated list of transfers/payouts for the authenticated merchant

type WebhookConfigResponseDto added in v0.1.0

type WebhookConfigResponseDto struct {
	// Webhook config UUID
	ID        string    `json:"id" api:"required" format:"uuid"`
	CreatedAt time.Time `json:"createdAt" api:"required" format:"date-time"`
	// Subscribed event types
	Events []string `json:"events" api:"required"`
	// Whether the webhook is active
	IsActive bool `json:"isActive" api:"required"`
	// Merchant UUID
	MerchantID string `json:"merchantId" api:"required" format:"uuid"`
	// Signing secret; plaintext only on create/rotate-secret, otherwise masked
	Secret    string    `json:"secret" api:"required"`
	UpdatedAt time.Time `json:"updatedAt" api:"required" format:"date-time"`
	// Webhook endpoint URL
	URL string `json:"url" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID          respjson.Field
		CreatedAt   respjson.Field
		Events      respjson.Field
		IsActive    respjson.Field
		MerchantID  respjson.Field
		Secret      respjson.Field
		UpdatedAt   respjson.Field
		URL         respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (WebhookConfigResponseDto) RawJSON added in v0.1.0

func (r WebhookConfigResponseDto) RawJSON() string

Returns the unmodified JSON received from the API

func (*WebhookConfigResponseDto) UnmarshalJSON added in v0.1.0

func (r *WebhookConfigResponseDto) UnmarshalJSON(data []byte) error

type WebhookDeactivateResponse added in v0.1.0

type WebhookDeactivateResponse struct {
	// Response message
	Message string `json:"message" api:"required"`
	// Request success status
	Status bool `json:"status" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Message     respjson.Field
		Status      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (WebhookDeactivateResponse) RawJSON added in v0.1.0

func (r WebhookDeactivateResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*WebhookDeactivateResponse) UnmarshalJSON added in v0.1.0

func (r *WebhookDeactivateResponse) UnmarshalJSON(data []byte) error

type WebhookGetDeliveriesParams

type WebhookGetDeliveriesParams struct {
	// ISO 8601 end of createdAt range (inclusive)
	EndDate param.Opt[string] `query:"endDate,omitzero" json:"-"`
	// Filter by event type
	EventType param.Opt[string] `query:"eventType,omitzero" json:"-"`
	// Page number
	Page param.Opt[float64] `query:"page,omitzero" json:"-"`
	// Items per page
	PerPage param.Opt[float64] `query:"perPage,omitzero" json:"-"`
	// ISO 8601 start of createdAt range (inclusive)
	StartDate param.Opt[string] `query:"startDate,omitzero" json:"-"`
	// Filter by status (QUEUED, DELIVERED, FAILED, RETRYING)
	Status param.Opt[string] `query:"status,omitzero" json:"-"`
	// contains filtered or unexported fields
}

func (WebhookGetDeliveriesParams) URLQuery

func (r WebhookGetDeliveriesParams) URLQuery() (v url.Values, err error)

URLQuery serializes WebhookGetDeliveriesParams's query parameters as `url.Values`.

type WebhookGetDeliveriesResponse

type WebhookGetDeliveriesResponse struct {
	// Response message
	Message string `json:"message" api:"required"`
	// Request success status
	Status bool                             `json:"status" api:"required"`
	Data   WebhookGetDeliveriesResponseData `json:"data"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Message     respjson.Field
		Status      respjson.Field
		Data        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (WebhookGetDeliveriesResponse) RawJSON

Returns the unmodified JSON received from the API

func (*WebhookGetDeliveriesResponse) UnmarshalJSON

func (r *WebhookGetDeliveriesResponse) UnmarshalJSON(data []byte) error

type WebhookGetDeliveriesResponseData

type WebhookGetDeliveriesResponseData struct {
	// List of webhook deliveries
	Data []WebhookGetDeliveriesResponseDataData `json:"data" api:"required"`
	// Pagination metadata
	Meta shared.PaginationMetaDto `json:"meta" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Data        respjson.Field
		Meta        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (WebhookGetDeliveriesResponseData) RawJSON

Returns the unmodified JSON received from the API

func (*WebhookGetDeliveriesResponseData) UnmarshalJSON

func (r *WebhookGetDeliveriesResponseData) UnmarshalJSON(data []byte) error

type WebhookGetDeliveriesResponseDataData

type WebhookGetDeliveriesResponseDataData struct {
	// Delivery UUID
	ID string `json:"id" api:"required" format:"uuid"`
	// Number of delivery attempts
	Attempts  float64   `json:"attempts" api:"required"`
	CreatedAt time.Time `json:"createdAt" api:"required" format:"date-time"`
	// When the delivery succeeded
	DeliveredAt time.Time `json:"deliveredAt" api:"required" format:"date-time"`
	// Webhook event type
	EventType string `json:"eventType" api:"required"`
	// When the delivery permanently failed
	FailedAt time.Time `json:"failedAt" api:"required" format:"date-time"`
	// Maximum delivery attempts
	MaxAttempts float64 `json:"maxAttempts" api:"required"`
	// When the next retry is scheduled
	NextRetryAt time.Time `json:"nextRetryAt" api:"required" format:"date-time"`
	// Event payload JSON as stored for delivery
	Payload map[string]any `json:"payload" api:"required"`
	// Response body from the merchant endpoint (truncated)
	ResponseBody string `json:"responseBody" api:"required"`
	// HTTP status code from the merchant endpoint
	ResponseStatus float64 `json:"responseStatus" api:"required"`
	// Delivery status
	//
	// Any of "QUEUED", "DELIVERED", "FAILED", "RETRYING".
	Status string `json:"status" api:"required"`
	// Webhook config UUID
	WebhookConfigID string `json:"webhookConfigId" api:"required" format:"uuid"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		ID              respjson.Field
		Attempts        respjson.Field
		CreatedAt       respjson.Field
		DeliveredAt     respjson.Field
		EventType       respjson.Field
		FailedAt        respjson.Field
		MaxAttempts     respjson.Field
		NextRetryAt     respjson.Field
		Payload         respjson.Field
		ResponseBody    respjson.Field
		ResponseStatus  respjson.Field
		Status          respjson.Field
		WebhookConfigID respjson.Field
		ExtraFields     map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (WebhookGetDeliveriesResponseDataData) RawJSON

Returns the unmodified JSON received from the API

func (*WebhookGetDeliveriesResponseDataData) UnmarshalJSON

func (r *WebhookGetDeliveriesResponseDataData) UnmarshalJSON(data []byte) error

type WebhookListEventsResponse

type WebhookListEventsResponse struct {
	// Response message
	Message string `json:"message" api:"required"`
	// Request success status
	Status bool     `json:"status" api:"required"`
	Data   []string `json:"data"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Message     respjson.Field
		Status      respjson.Field
		Data        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (WebhookListEventsResponse) RawJSON

func (r WebhookListEventsResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*WebhookListEventsResponse) UnmarshalJSON

func (r *WebhookListEventsResponse) UnmarshalJSON(data []byte) error

type WebhookListResponse

type WebhookListResponse struct {
	// Response message
	Message string `json:"message" api:"required"`
	// Request success status
	Status bool                       `json:"status" api:"required"`
	Data   []WebhookConfigResponseDto `json:"data"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Message     respjson.Field
		Status      respjson.Field
		Data        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (WebhookListResponse) RawJSON

func (r WebhookListResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*WebhookListResponse) UnmarshalJSON

func (r *WebhookListResponse) UnmarshalJSON(data []byte) error

type WebhookNewParams

type WebhookNewParams struct {
	// Event types to subscribe to
	//
	// Any of "order.created", "order.paid", "order.cancelled", "stock.low",
	// "payment.created", "payment.completed", "payment.failed", "collection.pending",
	// "collection.completed", "collection.failed", "withdrawal.created",
	// "withdrawal.completed", "withdrawal.failed", "transaction.updated",
	// "transfer.pending", "transfer.completed", "transfer.failed",
	// "settlement.completed".
	Events []string `json:"events,omitzero" api:"required"`
	// Webhook endpoint URL
	URL string `json:"url" api:"required"`
	// contains filtered or unexported fields
}

func (WebhookNewParams) MarshalJSON

func (r WebhookNewParams) MarshalJSON() (data []byte, err error)

func (*WebhookNewParams) UnmarshalJSON

func (r *WebhookNewParams) UnmarshalJSON(data []byte) error

type WebhookNewResponse

type WebhookNewResponse struct {
	// Response message
	Message string `json:"message" api:"required"`
	// Request success status
	Status bool                     `json:"status" api:"required"`
	Data   WebhookConfigResponseDto `json:"data"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Message     respjson.Field
		Status      respjson.Field
		Data        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (WebhookNewResponse) RawJSON

func (r WebhookNewResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*WebhookNewResponse) UnmarshalJSON

func (r *WebhookNewResponse) UnmarshalJSON(data []byte) error

type WebhookRotateSecretResponse

type WebhookRotateSecretResponse struct {
	// Response message
	Message string `json:"message" api:"required"`
	// Request success status
	Status bool                            `json:"status" api:"required"`
	Data   WebhookRotateSecretResponseData `json:"data"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Message     respjson.Field
		Status      respjson.Field
		Data        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (WebhookRotateSecretResponse) RawJSON

func (r WebhookRotateSecretResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*WebhookRotateSecretResponse) UnmarshalJSON

func (r *WebhookRotateSecretResponse) UnmarshalJSON(data []byte) error

type WebhookRotateSecretResponseData

type WebhookRotateSecretResponseData struct {
	// New signing secret (64-character hex, shown once)
	Secret string `json:"secret" api:"required"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Secret      respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (WebhookRotateSecretResponseData) RawJSON

Returns the unmodified JSON received from the API

func (*WebhookRotateSecretResponseData) UnmarshalJSON

func (r *WebhookRotateSecretResponseData) UnmarshalJSON(data []byte) error

type WebhookService

type WebhookService struct {
	// contains filtered or unexported fields
}

Webhook configuration and delivery history

WebhookService contains methods and other services that help with interacting with the bila API.

Note, unlike clients, this service does not read variables from the environment automatically. You should not instantiate this service directly, and instead use the NewWebhookService method instead.

func NewWebhookService

func NewWebhookService(opts ...option.RequestOption) (r WebhookService)

NewWebhookService generates a new service that applies the given options to each request. These options are applied after the parent client's options (if there is one), and before any request-specific options.

func (*WebhookService) Deactivate

func (r *WebhookService) Deactivate(ctx context.Context, id string, opts ...option.RequestOption) (res *WebhookDeactivateResponse, err error)

Deactivate a webhook

func (*WebhookService) GetDeliveries

Get delivery history

func (*WebhookService) List

func (r *WebhookService) List(ctx context.Context, opts ...option.RequestOption) (res *WebhookListResponse, err error)

List webhook configs

func (*WebhookService) ListEvents

func (r *WebhookService) ListEvents(ctx context.Context, opts ...option.RequestOption) (res *WebhookListEventsResponse, err error)

List webhook event types

func (*WebhookService) New

Create a webhook config

func (*WebhookService) RotateSecret

func (r *WebhookService) RotateSecret(ctx context.Context, id string, opts ...option.RequestOption) (res *WebhookRotateSecretResponse, err error)

Rotate webhook signing secret

func (*WebhookService) Update

Update a webhook config

type WebhookUpdateParams

type WebhookUpdateParams struct {
	// Whether the webhook is active
	IsActive param.Opt[bool] `json:"isActive,omitzero"`
	// Webhook endpoint URL
	URL param.Opt[string] `json:"url,omitzero"`
	// Event types to subscribe to
	//
	// Any of "order.created", "order.paid", "order.cancelled", "stock.low",
	// "payment.created", "payment.completed", "payment.failed", "collection.pending",
	// "collection.completed", "collection.failed", "withdrawal.created",
	// "withdrawal.completed", "withdrawal.failed", "transaction.updated",
	// "transfer.pending", "transfer.completed", "transfer.failed",
	// "settlement.completed".
	Events []string `json:"events,omitzero"`
	// contains filtered or unexported fields
}

func (WebhookUpdateParams) MarshalJSON

func (r WebhookUpdateParams) MarshalJSON() (data []byte, err error)

func (*WebhookUpdateParams) UnmarshalJSON

func (r *WebhookUpdateParams) UnmarshalJSON(data []byte) error

type WebhookUpdateResponse

type WebhookUpdateResponse struct {
	// Response message
	Message string `json:"message" api:"required"`
	// Request success status
	Status bool                     `json:"status" api:"required"`
	Data   WebhookConfigResponseDto `json:"data"`
	// JSON contains metadata for fields, check presence with [respjson.Field.Valid].
	JSON struct {
		Message     respjson.Field
		Status      respjson.Field
		Data        respjson.Field
		ExtraFields map[string]respjson.Field
		// contains filtered or unexported fields
	} `json:"-"`
}

func (WebhookUpdateResponse) RawJSON

func (r WebhookUpdateResponse) RawJSON() string

Returns the unmodified JSON received from the API

func (*WebhookUpdateResponse) UnmarshalJSON

func (r *WebhookUpdateResponse) UnmarshalJSON(data []byte) error

Directories

Path Synopsis
encoding/json
Package json implements encoding and decoding of JSON as defined in RFC 7159.
Package json implements encoding and decoding of JSON as defined in RFC 7159.
encoding/json/shims
This package provides shims over Go 1.2{2,3} APIs which are missing from Go 1.22, and used by the Go 1.24 encoding/json package.
This package provides shims over Go 1.2{2,3} APIs which are missing from Go 1.22, and used by the Go 1.24 encoding/json package.
packages

Jump to

Keyboard shortcuts

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