Skip to content

Commit ad44a92

Browse files
committed
Add Payment flows APIs
1 parent c2dd79c commit ad44a92

File tree

3 files changed

+517
-1
lines changed

3 files changed

+517
-1
lines changed

src/fireblocks-sdk.ts

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ import {
139139
ScreeningSupportedAssetResponse,
140140
ScreeningSupportedProviders,
141141
RegisterAssetResponse,
142-
UnspentInputsResponse,
142+
UnspentInputsResponse
143143
} from "./types";
144144
import { AxiosProxyConfig, AxiosResponse, InternalAxiosRequestConfig } from "axios";
145145
import { PIIEncryption } from "./pii-client";
@@ -162,6 +162,9 @@ import {
162162
WithdrawResponse
163163
} from "./staking";
164164

165+
import { PaymentsApiClient } from "./payments/payments-api-client";
166+
import { Payments } from "./payments/payments-types"
167+
165168
export * from "./types";
166169

167170
export interface SDKOptions {
@@ -208,6 +211,7 @@ export class FireblocksSDK {
208211
private readonly apiClient: ApiClient;
209212
private readonly apiNcw: NcwApiClient;
210213
private readonly stakingApiClient: StakingApiClient;
214+
private readonly paymentsApiClient: PaymentsApiClient;
211215

212216
private piiClient: PIIEncryption;
213217

@@ -235,6 +239,8 @@ export class FireblocksSDK {
235239
this.apiNcw = new NcwApiClient(this.apiClient);
236240

237241
this.stakingApiClient = new StakingApiClient(this.apiClient);
242+
243+
this.paymentsApiClient = new PaymentsApiClient(this.apiClient);
238244
}
239245

240246
/**
@@ -2447,4 +2453,52 @@ export class FireblocksSDK {
24472453
};
24482454
return this.apiClient.issuePostRequest(`/v1/vault/assets/bulk`, body, requestOptions);
24492455
}
2456+
2457+
/**
2458+
* Creates new payment workflow configuration
2459+
* @param request - Payments.CreateWorkflowConfigurationRequest
2460+
*/
2461+
public async createPaymentWorkflowConfiguration(request: Payments.CreateWorkflowConfigurationRequest): Promise<Payments.WorkflowConfiguration> {
2462+
return await this.paymentsApiClient.createPaymentWorkflowConfiguration(request);
2463+
}
2464+
2465+
/**
2466+
* Get payment workflow configuration
2467+
* @param configId - configuration id
2468+
*/
2469+
public async getPaymentWorkflowConfiguration(configId: string): Promise<Payments.WorkflowConfiguration> {
2470+
return await this.paymentsApiClient.getPaymentWorkflowConfiguration(configId);
2471+
}
2472+
2473+
/**
2474+
* Delete payment workflow configuration
2475+
* @param configId - configuration id
2476+
*/
2477+
public async deletePaymentWorkflowConfiguration(configId: string): Promise<Payments.WorkflowConfigurationId> {
2478+
return await this.paymentsApiClient.deletePaymentWorkflowConfiguration(configId);
2479+
}
2480+
2481+
/**
2482+
* Creates new payment workflow execution
2483+
* @param request - Payments.CreateWorkflowExecutionRequest
2484+
*/
2485+
public async createPaymentWorkflowExecution(request: Payments.CreateWorkflowExecutionRequest): Promise<Payments.WorkflowExecution> {
2486+
return await this.paymentsApiClient.createPaymentWorkflowExecution(request);
2487+
}
2488+
2489+
/**
2490+
* Get payment workflow execution
2491+
* @param workflowExeuctionId
2492+
*/
2493+
public async getPaymentWorkflowExecution(workflowExeuctionId: string): Promise<Payments.WorkflowExecution> {
2494+
return await this.paymentsApiClient.getPaymentWorkflowExecution(workflowExeuctionId);
2495+
}
2496+
2497+
/**
2498+
* Execute payment workflow
2499+
* @param workflowExeuctionId
2500+
*/
2501+
public async executePaymentFlow(workflowExeuctionId: string): Promise<Payments.WorkflowExecution> {
2502+
return await this.paymentsApiClient.executePaymentFlow(workflowExeuctionId);
2503+
}
24502504
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { Payments } from "./payments-types";
2+
import { ApiClient } from "../api-client";
3+
import CreateWorkflowConfigurationRequest = Payments.CreateWorkflowConfigurationRequest;
4+
import WorkflowConfiguration = Payments.WorkflowConfiguration;
5+
import WorkflowConfigurationId = Payments.WorkflowConfigurationId;
6+
import CreateWorkflowExecutionRequest = Payments.CreateWorkflowExecutionRequest;
7+
import WorkflowExecution = Payments.WorkflowExecution;
8+
9+
const PAYMENTS_BASE_PATH = "/v1/payments";
10+
11+
export class PaymentsApiClient {
12+
constructor(private readonly apiClient: ApiClient) {}
13+
14+
public async createPaymentWorkflowConfiguration(request: CreateWorkflowConfigurationRequest): Promise<WorkflowConfiguration> {
15+
return await this.apiClient.issuePostRequest(`${PAYMENTS_BASE_PATH}/workflow_config`, request);
16+
}
17+
18+
public async getPaymentWorkflowConfiguration(configId: string): Promise<WorkflowConfiguration> {
19+
return await this.apiClient.issueGetRequest(`${PAYMENTS_BASE_PATH}/workflow_config/${configId}`);
20+
}
21+
22+
public async deletePaymentWorkflowConfiguration(configId: string): Promise<WorkflowConfigurationId> {
23+
return await this.apiClient.issueDeleteRequest(`${PAYMENTS_BASE_PATH}/workflow_config/${configId}`);
24+
}
25+
26+
public async createPaymentWorkflowExecution(request: CreateWorkflowExecutionRequest): Promise<WorkflowExecution> {
27+
return await this.apiClient.issuePostRequest(`${PAYMENTS_BASE_PATH}/workflow_execution`, request);
28+
}
29+
30+
public async getPaymentWorkflowExecution(workflowExeuctionId: string): Promise<WorkflowExecution> {
31+
return await this.apiClient.issueGetRequest(`${PAYMENTS_BASE_PATH}/workflow_execution/${workflowExeuctionId}`);
32+
}
33+
34+
public async executePaymentFlow(workflowExeuctionId: string): Promise<WorkflowExecution> {
35+
return await this.apiClient.issuePostRequest(`${PAYMENTS_BASE_PATH}/workflow_execution/${workflowExeuctionId}/actions/execute`, {});
36+
}
37+
}

0 commit comments

Comments
 (0)