54 lines
1.3 KiB
TypeScript
54 lines
1.3 KiB
TypeScript
/**
|
|
* Transaction Type module for managing Dragonchain transaction types
|
|
*/
|
|
|
|
import { DragonchainClient } from './client';
|
|
import {
|
|
ContentType,
|
|
TransactionTypeCreateRequest,
|
|
TransactionTypeCreateResponse,
|
|
TransactionType,
|
|
TransactionListResponse,
|
|
SuccessResponse,
|
|
} from './types';
|
|
|
|
export class TransactionTypeClient {
|
|
private client: DragonchainClient;
|
|
|
|
constructor(client: DragonchainClient) {
|
|
this.client = client;
|
|
}
|
|
|
|
/**
|
|
* Creates a new transaction type
|
|
*/
|
|
async create(request: TransactionTypeCreateRequest): Promise<TransactionTypeCreateResponse> {
|
|
return this.client.post<TransactionTypeCreateResponse>(
|
|
'/api/v1/transaction-type',
|
|
ContentType.JSON,
|
|
request
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Gets a transaction type by name
|
|
*/
|
|
async get(txnType: string): Promise<TransactionType> {
|
|
return this.client.get<TransactionType>(`/api/v1/transaction-type/${txnType}`);
|
|
}
|
|
|
|
/**
|
|
* Lists all transaction types
|
|
*/
|
|
async list(): Promise<TransactionListResponse> {
|
|
return this.client.get<TransactionListResponse>('/api/v1/transaction-types');
|
|
}
|
|
|
|
/**
|
|
* Deletes a transaction type
|
|
*/
|
|
async delete(txnType: string): Promise<SuccessResponse> {
|
|
return this.client.delete<SuccessResponse>(`/api/v1/transaction-type/${txnType}`);
|
|
}
|
|
}
|