aml

package module
v0.0.0-...-b626437 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2026 License: MIT Imports: 12 Imported by: 0

README

go-aml

Go client for the TDCC AML (Anti-Money Laundering) APIs.

Features

  • Name check (single query)
  • Query remaining/over limit count
  • Batch upload/download endpoints (planned)

Installation

go get github.com/flc1125/go-aml

Usage

package main

import (
	"context"
	"fmt"

	"github.com/flc1125/go-aml"
)

func main() {
	client, err := aml.NewClient("ACCOUNT", "PASSWORD")
	if err != nil {
		panic(err)
	}

	// Single name check
	resp, _, err := client.CheckName(context.Background(), &aml.CheckNameRequest{
		EnglishName: aml.Ptr("John Doe"),
		Nationality: aml.Ptr("US"),
	})
	if err != nil {
		panic(err)
	}
	fmt.Println("RCScore:", resp.RCScore)

	// Query remaining / over-limit count
	overResp, _, err := client.QueryOver(context.Background())
	if err != nil {
		panic(err)
	}
	fmt.Println("Remain:", overResp.Remain, "Over:", overResp.Over)
}

Documentation

See docs/api.md for the API spec summary.

License

MIT. See LICENSE.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsErrorResponse

func IsErrorResponse(err error) bool

func NewRetryableHTTPClient

func NewRetryableHTTPClient(opts ...RetryableHTTPClientOption) *http.Client

func Ptr

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

Ptr returns a pointer to the value.

Types

type CheckNameRequest

type CheckNameRequest struct {
	NonEnglishName string `url:"NonEnglishName"` // 非英文姓名,無資料為空字串
	EnglishName    string `url:"EnglishName"`    // 英文姓名,無資料為空字串
	DOB            string `url:"DOB"`            // 生日 (YYYY/MM/DD,如:2017/09/01),無資料為空字串
	Nationality    string `url:"Nationality"`    // 國籍,ISO 國家代碼(如臺灣為 TW,美國為 US) ,無資料為空字串
}

type CheckNameResponse

type CheckNameResponse struct {
	RCScore int `json:"rcscore"` // 相似度分數,會回傳RC>=91 或 RC=0,如果上傳結果失敗,回傳-1。
}

type Client

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

func NewClient

func NewClient(account, password string, opts ...ClientOption) (*Client, error)

NewClient returns a new AML API client with authentication.

func (*Client) CheckName

func (c *Client) CheckName(ctx context.Context, request *CheckNameRequest, opts ...RequestOption) (*CheckNameResponse, *Response, error)

func (*Client) Do

func (c *Client) Do(req *http.Request, v any) (*Response, error)

func (*Client) DownloadBatch

func (c *Client) DownloadBatch(ctx context.Context, request *DownloadBatchRequest, opts ...RequestOption) (*DownloadBatchResponse, *Response, error)

func (*Client) NewRequest

func (c *Client) NewRequest(ctx context.Context, method, path string, data any, opts []RequestOption) (*http.Request, error)

func (*Client) QueryOver

func (c *Client) QueryOver(ctx context.Context, opts ...RequestOption) (*QueryOverResponse, *Response, error)

func (*Client) UploadBatch

func (c *Client) UploadBatch(ctx context.Context, request *UploadBatchRequest, opts ...RequestOption) (*UploadBatchResponse, *Response, error)

type ClientOption

type ClientOption func(*Client) error

func WithAuth

func WithAuth(account, password string) ClientOption

WithAuth sets the account and password for the client

func WithBaseURL

func WithBaseURL(urlStr string) ClientOption

WithBaseURL sets the baseURL for the client

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) ClientOption

WithHTTPClient sets the httpClient for the client

func WithUserAgent

func WithUserAgent(userAgent string) ClientOption

WithUserAgent sets the userAgent for the client

type DownloadBatchRequest

type DownloadBatchRequest struct {
}

type DownloadBatchResponse

type DownloadBatchResponse struct {
}

type ErrorDetail

type ErrorDetail struct {
	Row          int    `json:"row"`
	PrimaryKey   string `json:"primaryKey"`
	ErrorMessage string `json:"errorMessage"`
}

ErrorDetail represents the detail of an error.

type ErrorResponse

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

ErrorResponse represents a tapd error response.

func (*ErrorResponse) Error

func (e *ErrorResponse) Error() string

func (*ErrorResponse) Unwrap

func (e *ErrorResponse) Unwrap() error

type QueryOverResponse

type QueryOverResponse struct {
	Remain int `json:"remain"` // 累計至前一日剩餘筆數
	Over   int `json:"over"`   // 累計至前一日超額查詢筆數
}

type QueryOverResponseData

type QueryOverResponseData struct {
	Remain int `json:"remain"`
	Over   int `json:"over"`
}

QueryOverResponseData represents the data of a query over response.

type RawBody

type RawBody struct {
	Status string          `json:"status"`
	Data   json.RawMessage `json:"data"`
	Error  json.RawMessage `json:"errors"`
}

RawBody represents a raw body.

type RequestOption

type RequestOption func(*http.Request) error

func WithRequestHeader

func WithRequestHeader(name, value string) RequestOption

func WithRequestHeaderFunc

func WithRequestHeaderFunc(fn func(http.Header)) RequestOption

func WithRequestHeaders

func WithRequestHeaders(headers map[string]string) RequestOption

func WithRequestUserAgent

func WithRequestUserAgent(userAgent string) RequestOption

type Response

type Response struct {
	*http.Response
}

Response represents an API response.

type RetryableHTTPClientOption

type RetryableHTTPClientOption func(client *retryablehttp.Client)

func WithRetryableHTTPClientBackoff

func WithRetryableHTTPClientBackoff(backoff retryablehttp.Backoff) RetryableHTTPClientOption

func WithRetryableHTTPClientCheckRetry

func WithRetryableHTTPClientCheckRetry(checkRetry retryablehttp.CheckRetry) RetryableHTTPClientOption

func WithRetryableHTTPClientLogger

func WithRetryableHTTPClientLogger(logger retryablehttp.Logger) RetryableHTTPClientOption

func WithRetryableHTTPClientRetryMax

func WithRetryableHTTPClientRetryMax(retryMax int) RetryableHTTPClientOption

func WithRetryableHTTPClientRetryWaitMax

func WithRetryableHTTPClientRetryWaitMax(waitMax time.Duration) RetryableHTTPClientOption

func WithRetryableHTTPClientRetryWaitMin

func WithRetryableHTTPClientRetryWaitMin(waitMin time.Duration) RetryableHTTPClientOption

type Service

type Service interface {
	// UploadBatch 整批上傳檔案
	UploadBatch(ctx context.Context, request *UploadBatchRequest, opts ...RequestOption) (*UploadBatchResponse, *Response, error)

	DownloadBatch(ctx context.Context, request *DownloadBatchRequest, opts ...RequestOption) (*DownloadBatchResponse, *Response, error)

	CheckName(ctx context.Context, request *CheckNameRequest, opts ...RequestOption) (*CheckNameResponse, *Response, error)

	// QueryOver 查詢單筆線上查詢剩餘與超額筆數
	QueryOver(ctx context.Context, opts ...RequestOption) (*QueryOverResponse, *Response, error)
}

type UploadBatchRequest

type UploadBatchRequest struct {
}

type UploadBatchResponse

type UploadBatchResponse struct {
}

type UploadBatchResponseData

type UploadBatchResponseData struct {
	BatchNo string `json:"batchNo"`
}

UploadBatchResponseData represents the data of an upload batch response.

type UploadHandlerResponseData

type UploadHandlerResponseData struct {
	Message string `json:"message"`
	Rows    int    `json:"rows"`
}

UploadHandlerResponseData represents the data of an upload handler response.

Jump to

Keyboard shortcuts

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