Files
prime-sdk-go/transactiontype/transactiontype.go
Andrew Miller e15b205f9c Add remote smart contract and gRPC connection support
Add Remote field to SmartContractCreateRequest and GrpcConnectionInfo
struct to SmartContract model for remote smart contract execution
via gRPC.
2026-02-11 11:20:21 -05:00

56 lines
1.6 KiB
Go
Executable File

package transactiontype
import (
"context"
"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(ctx context.Context, req *models.TransactionTypeCreateRequest) (*models.TransactionTypeCreateResponse, error) {
var resp models.TransactionTypeCreateResponse
err := ttc.client.Post(ctx, "/api/v1/transaction-type", models.ContentTypeJSON, req, &resp)
if err != nil {
return nil, err
}
return &resp, nil
}
func (ttc *TransactionTypeClient) Get(ctx context.Context, txnType string) (*models.TransactionType, error) {
var resp models.TransactionType
path := fmt.Sprintf("/api/v1/transaction-type/%s", txnType)
err := ttc.client.Get(ctx, path, &resp)
if err != nil {
return nil, err
}
return &resp, nil
}
func (ttc *TransactionTypeClient) List(ctx context.Context) (*models.TransactionListResponse, error) {
var resp models.TransactionListResponse
err := ttc.client.Get(ctx, "/api/v1/transaction-types", &resp)
if err != nil {
return nil, err
}
return &resp, nil
}
func (ttc *TransactionTypeClient) Delete(ctx context.Context, txnType string) (*models.SuccessResponse, error) {
var resp models.SuccessResponse
path := fmt.Sprintf("/api/v1/transaction-type/%s", txnType)
err := ttc.client.Delete(ctx, path, &resp)
if err != nil {
return nil, err
}
return &resp, nil
}