client

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2021 License: MIT Imports: 12 Imported by: 2

Documentation

Overview

Package client provides a Xendit client for invoking APIs across all products

Example

This example shows the usage of Xendit's API client

package main

import (
	"fmt"
	"log"

	"github.com/xendit/xendit-go/client"
	"github.com/xendit/xendit-go/invoice"
)

func main() {
	api := client.New("examplesecretkey")

	data := invoice.GetParams{
		ID: "invoice-id",
	}

	resp, err := api.Invoice.Get(&data)
	if err != nil {
		log.Fatal(err)
	}

	fmt.Printf("retrieved invoice: %+v\n", resp)
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	Invoice          *invoice.Client
	EWallet          *ewallet.Client
	Balance          *balance.Client
	RetailOutlet     *retailoutlet.Client
	VirtualAccount   *virtualaccount.Client
	Card             *card.Client
	Payout           *payout.Client
	RecurringPayment *recurringpayment.Client
	CardlessCredit   *cardlesscredit.Client
	Disbursement     *disbursement.Client
	// contains filtered or unexported fields
}

API is the Xendit client which contains all products

func New

func New(secretKey string) *API

New creates a new Xendit API client

func (*API) WithAPIRequester

func (a *API) WithAPIRequester(apiRequester xendit.APIRequester) *API

WithAPIRequester set custom APIRequester for Xendit Client Can be chained with constructor like below:

client.New(yourSecretKey).WithAPIRequester(yourCustomRequester)

func (*API) WithCustomHTTPClient

func (a *API) WithCustomHTTPClient(client *http.Client) *API

WithCustomHTTPClient set custom HTTP Client for default API Requester Can be chained with constructor like below:

client.New(yourSecretKey).WithCustomHTTPClient(yourCustomHTTPClient)

func (*API) WithCustomURL

func (a *API) WithCustomURL(xenditURL string) *API

WithCustomURL set custom xendit URL for Xendit Client Can be chained with constructor like below:

client.New(yourSecretKey).WithCustomURL(yourCustomURL)

Jump to

Keyboard shortcuts

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