bca

package module
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2022 License: MIT Imports: 24 Imported by: 2 modules, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

bca-go

go-bca is the (unofficial) BCA SDK for the Go programming language.

This SDK was kickstarted by the OpenAPI Generator project.

Installation

go get github.com/satraul/bca-go

Usage

import (
    "log"

    bca "github.com/satraul/bca-go"
)

func main() {
    api := bca.NewAPIClient(bca.NewConfiguration())
    auth, err := api.Login(ctx, "username", "password", "1.2.3.4")
    if err != nil {
        panic(err)
    }

    balance, err := api.BalanceInquiry(ctx, auth)
    if err != nil {
        panic(err)
    }
    log.Printf("%+v\n", balance)

    if err := api.Logout(ctx, auth); err != nil {
        panic(err)
    }
}

See the a full example at example/example.go.

Documentation for API Endpoints

All URIs are relative to https://m.klikbca.com

Class Method HTTP request Description
BCAApi AccountStatementView Post /accountstmt.do?value(actions)=acctstmtview AccountStatementView
BCAApi BalanceInquiry Post /balanceinquiry.do BalanceInquiry
BCAApi Login Post /authentication.do Login
BCAApi Logout Get /authentication.do?value(actions)=logout Logout

Documentation For Authorization

Login will return session cookies ([]*http.Cookie) that are used for auth in all other endpoints.

Contributing

Pull requests are welcome.

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ContextOAuth2 takes an oauth2.TokenSource as authentication for the request.
	ContextOAuth2 = contextKey("token")

	// ContextBasicAuth takes BasicAuth as authentication for the request.
	ContextBasicAuth = contextKey("basic")

	// ContextAccessToken takes a string oauth2 access token as authentication for the request.
	ContextAccessToken = contextKey("accesstoken")

	// ContextAPIKey takes an APIKey as authentication for the request
	ContextAPIKey = contextKey("apikey")
)

Functions

func CacheExpires

func CacheExpires(r *http.Response) time.Time

CacheExpires helper function to determine remaining time before repeating a request.

Types

type APIClient

type APIClient struct {
	BCAApi *BCAApiService
	// contains filtered or unexported fields
}

APIClient manages communication with the BCA API v1.0 In most cases there should be only one, shared, APIClient.

func (*APIClient) ChangeBasePath

func (c *APIClient) ChangeBasePath(path string)

ChangeBasePath changes base path to allow switching to mocks

func (*APIClient) GetConfig

func (c *APIClient) GetConfig() *Configuration

Allow modification of underlying config for alternate implementations and testing Caution: modifying the configuration while live can cause data races and potentially unwanted behavior

type APIKey

type APIKey struct {
	Key    string
	Prefix string
}

APIKey provides API key based authentication to a request passed via context using ContextAPIKey

type APIResponse

type APIResponse struct {
	*http.Response `json:"-"`
	Message        string `json:"message,omitempty"`
	// Operation is the name of the OpenAPI operation.
	Operation string `json:"operation,omitempty"`
	// RequestURL is the request URL. This value is always available, even if the
	// embedded *http.Response is nil.
	RequestURL string `json:"url,omitempty"`
	// Method is the HTTP method used for the request.  This value is always
	// available, even if the embedded *http.Response is nil.
	Method string `json:"method,omitempty"`
	// Payload holds the contents of the response body (which may be nil or empty).
	// This is provided here as the raw response.Body() reader will have already
	// been drained.
	Payload []byte `json:"-"`
}

APIResponse stores the API response returned by the server.

func NewAPIResponse

func NewAPIResponse(r *http.Response) *APIResponse

NewAPIResponse returns a new APIResonse object.

func NewAPIResponseWithError

func NewAPIResponseWithError(errorMessage string) *APIResponse

NewAPIResponseWithError returns a new APIResponse object with the provided error message.

type BCAApiService

type BCAApiService service

BCAApiService BCAApi service

func NewAPIClient

func NewAPIClient(cfg *Configuration) *BCAApiService

NewAPIClient creates a new API client. Requires a userAgent string describing your application. optionally a custom http.Client to allow for advanced features such as caching.

func (*BCAApiService) AccountStatementView

func (a *BCAApiService) AccountStatementView(ctx _context.Context, startDate time.Time, endDate time.Time, cookies []*http.Cookie) ([]Entry, error)

AccountStatementView AccountStatementView

  • @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param contentType
  • @param userAgent
  • @param referer
  • @param valueActions
  • @param cookie
  • @param contentLength
  • @param r1
  • @param value28D129
  • @param value28startDt29
  • @param value28startMt29
  • @param value28startYr29
  • @param value28endDt29
  • @param value28endMt29
  • @param value28endYr29

@return map[string]interface{}

func (*BCAApiService) BalanceInquiry

func (a *BCAApiService) BalanceInquiry(ctx _context.Context, cookies []*http.Cookie) (Balance, error)

BalanceInquiry BalanceInquiry

  • @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param contentType
  • @param userAgent
  • @param referer
  • @param cookie
  • @param contentLength

@return map[string]interface{}

func (*BCAApiService) Login

func (a *BCAApiService) Login(ctx _context.Context, userID string, password string, userIP string) ([]*http.Cookie, error)

Login Login

  • @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param userID
  • @param password
  • @param userIP - Client's public IP

@return []*http.Cookie

func (*BCAApiService) Logout

func (a *BCAApiService) Logout(ctx _context.Context, cookies []*http.Cookie) error

Logout Logout

  • @param ctx _context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
  • @param userAgent
  • @param referer
  • @param valueActions
  • @param cookie

@return map[string]interface{}

type Balance

type Balance struct {
	AccountNumber string          `json:"accountNumber"`
	Currency      string          `json:"currency"`
	BalanceRaw    string          `json:"balanceRaw"`
	Balance       decimal.Decimal `json:"balance"`
}

Balance is data in balance inquiry

type BasicAuth

type BasicAuth struct {
	UserName string `json:"userName,omitempty"`
	Password string `json:"password,omitempty"`
}

BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth

type Configuration

type Configuration struct {
	BasePath      string            `json:"basePath,omitempty"`
	Host          string            `json:"host,omitempty"`
	Scheme        string            `json:"scheme,omitempty"`
	DefaultHeader map[string]string `json:"defaultHeader,omitempty"`
	UserAgent     string            `json:"userAgent,omitempty"`
	Debug         bool              `json:"debug,omitempty"`
	Servers       []ServerConfiguration
	HTTPClient    *http.Client
}

Configuration stores the configuration of the API client

func NewConfiguration

func NewConfiguration() *Configuration

NewConfiguration returns a new Configuration object

func (*Configuration) AddDefaultHeader

func (c *Configuration) AddDefaultHeader(key string, value string)

AddDefaultHeader adds a new HTTP header to the default header in the request

func (*Configuration) ServerUrl

func (c *Configuration) ServerUrl(index int, variables map[string]string) (string, error)

ServerUrl returns URL based on server settings

type Entry

type Entry struct {
	Date        time.Time       `json:"date"`
	Description string          `json:"description"`
	Payee       string          `json:"payee"`
	Type        string          `json:"type"`
	AmountRaw   string          `json:"balanceRaw"`
	Amount      decimal.Decimal `json:"balance"`
}

Entry is a row in statement view

type GenericOpenAPIError

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

GenericOpenAPIError Provides access to the body, error and model on returned errors.

func (GenericOpenAPIError) Body

func (e GenericOpenAPIError) Body() []byte

Body returns the raw bytes of the response

func (GenericOpenAPIError) Error

func (e GenericOpenAPIError) Error() string

Error returns non-empty string if there was an error.

func (GenericOpenAPIError) Model

func (e GenericOpenAPIError) Model() interface{}

Model returns the unpacked model of the error

type ServerConfiguration

type ServerConfiguration struct {
	Url         string
	Description string
	Variables   map[string]ServerVariable
}

ServerConfiguration stores the information about a server

type ServerVariable

type ServerVariable struct {
	Description  string
	DefaultValue string
	EnumValues   []string
}

ServerVariable stores the information about a server variable

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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