Initial Commit
This commit is contained in:
54
transaction/transaction.go
Normal file
54
transaction/transaction.go
Normal file
@@ -0,0 +1,54 @@
|
||||
package transaction
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"git.dragonchain.com/dragonchain/dragonchain-prime-sdk-go/client"
|
||||
"git.dragonchain.com/dragonchain/dragonchain-prime-sdk-go/models"
|
||||
)
|
||||
|
||||
type TransactionClient struct {
|
||||
client *client.Client
|
||||
}
|
||||
|
||||
func NewTransactionClient(c *client.Client) *TransactionClient {
|
||||
return &TransactionClient{client: c}
|
||||
}
|
||||
|
||||
func (tc *TransactionClient) Create(req *models.TransactionCreateRequest) (*models.TransactionCreateResponse, error) {
|
||||
var resp models.TransactionCreateResponse
|
||||
err := tc.client.Post("/api/v1/transaction", models.ContentTypeJSON, req, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
||||
func (tc *TransactionClient) CreateBulk(req *models.TransactionBulkRequest) (*models.TransactionBulkResponse, error) {
|
||||
var resp models.TransactionBulkResponse
|
||||
err := tc.client.Post("/api/v1/transaction/bulk", models.ContentTypeJSON, req, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
||||
func (tc *TransactionClient) Get(transactionID string) (*models.Transaction, error) {
|
||||
var resp models.Transaction
|
||||
path := fmt.Sprintf("/api/v1/transaction/%s", transactionID)
|
||||
err := tc.client.Get(path, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
|
||||
func (tc *TransactionClient) List() (*models.ListTransactionsResponse, error) {
|
||||
var resp models.ListTransactionsResponse
|
||||
path := "/api/v1/transaction/"
|
||||
err := tc.client.Get(path, &resp)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return &resp, nil
|
||||
}
|
||||
Reference in New Issue
Block a user