Files
dragonchain-prime-sdk-go/transactiontype/transactiontype.go
2025-11-10 16:44:59 -05:00

55 lines
1.5 KiB
Go

package transactiontype
import (
"fmt"
"git.dragonchain.com/dragonchain/dragonchain-prime-sdk-go/client"
"git.dragonchain.com/dragonchain/dragonchain-prime-sdk-go/models"
)
type TransactionTypeClient struct {
client *client.Client
}
func NewTransactionTypeClient(c *client.Client) *TransactionTypeClient {
return &TransactionTypeClient{client: c}
}
func (ttc *TransactionTypeClient) Create(req *models.TransactionTypeCreateRequest) (*models.TransactionTypeCreateResponse, error) {
var resp models.TransactionTypeCreateResponse
err := ttc.client.Post("/api/v1/transaction-type", models.ContentTypeJSON, req, &resp)
if err != nil {
return nil, err
}
return &resp, nil
}
func (ttc *TransactionTypeClient) Get(txnType string) (*models.TransactionType, error) {
var resp models.TransactionType
path := fmt.Sprintf("/api/v1/transaction-type/%s", txnType)
err := ttc.client.Get(path, &resp)
if err != nil {
return nil, err
}
return &resp, nil
}
func (ttc *TransactionTypeClient) List() (*models.TransactionListResponse, error) {
var resp models.TransactionListResponse
err := ttc.client.Get("/api/v1/transaction-types", &resp)
if err != nil {
return nil, err
}
return &resp, nil
}
func (ttc *TransactionTypeClient) Delete(txnType string) (*models.SuccessResponse, error) {
var resp models.SuccessResponse
path := fmt.Sprintf("/api/v1/transaction-type/%s", txnType)
err := ttc.client.Delete(path, &resp)
if err != nil {
return nil, err
}
return &resp, nil
}