Initial Commit
This commit is contained in:
53
src/transactionType.ts
Normal file
53
src/transactionType.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* 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}`);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user