Skip to main content

Overview

The Devdraft Java SDK provides a complete client library for integrating payment processing, customer management, and webhook functionality into your Java applications.

Type-Safe

Strongly typed with comprehensive model classes

Maven & Gradle

Easy installation via Maven Central or Gradle

Java 11+

Compatible with Java 11 and later versions

Spring Boot Ready

Works seamlessly with Spring Boot applications

Installation

Maven

Add to your pom.xml:
<dependency>
  <groupId>com.devdraft</groupId>
  <artifactId>sdk</artifactId>
  <version>1.0.0</version>
</dependency>

Gradle

Add to your build.gradle:
implementation 'com.devdraft:sdk:1.0.0'
Or for Kotlin DSL (build.gradle.kts):
implementation("com.devdraft:sdk:1.0.0")

Requirements

  • Java 11 or higher
  • Maven 3.6+ or Gradle 6.0+

Quick Start

import org.openapitools.client.*;
import org.openapitools.client.api.*;
import org.openapitools.client.model.*;

public class QuickStart {
    public static void main(String[] args) {
        // Configure API client
        ApiClient defaultClient = Configuration.getDefaultApiClient();
        defaultClient.setBasePath("https://api.devdraft.ai");
        
        // Configure API key authentication
        ApiKeyAuth clientKey = (ApiKeyAuth) defaultClient.getAuthentication("x-client-key");
        clientKey.setApiKey(System.getenv("DEVDRAFT_CLIENT_KEY"));
        
        ApiKeyAuth clientSecret = (ApiKeyAuth) defaultClient.getAuthentication("x-client-secret");
        clientSecret.setApiKey(System.getenv("DEVDRAFT_CLIENT_SECRET"));
        
        // Create API instances
        TransfersApi transfersApi = new TransfersApi(defaultClient);
        
        try {
            // Create a transfer
            CreateDirectWalletTransferDto transferDto = new CreateDirectWalletTransferDto()
                .walletId("your-wallet-id")
                .network("solana")
                .stableCoinCurrency("usdc")
                .amount(new BigDecimal("100.00"));
            
            Object transfer = transfersApi.transferControllerCreateDirectWalletTransfer(transferDto);
            System.out.println("Transfer created: " + transfer);
        } catch (ApiException e) {
            System.err.println("Exception: " + e.getMessage());
            System.err.println("Status code: " + e.getCode());
            System.err.println("Response body: " + e.getResponseBody());
        }
    }
}

API Classes

The SDK is organized into API classes under the org.openapitools.client.api package:
API ClassDescription
ApiHealthApiService health checks and status monitoring
AppBalancesApiQuery application balances across stablecoins
CustomersApiCustomer management and KYC operations
ExchangeRatesApiReal-time currency exchange rates
InvoicesApiInvoice creation and management
LiquidationAddressesApiCryptocurrency liquidation addresses
PaymentIntentsApiPayment intent creation for bank and stablecoin
PaymentLinksApiGenerate and manage payment links
ProductsApiProduct catalog management
TaxesApiTax configuration and management
TestPaymentsApiTest payment processing in sandbox
TransfersApiInitiate and manage fund transfers
WalletsApiWallet management and balances
WebhooksApiWebhook configuration and management

API Health

Monitor service health and availability.

Methods

healthControllerCheckV0()

Authenticated health check endpoint requiring API credentials.
import org.openapitools.client.*;
import org.openapitools.client.api.ApiHealthApi;
import org.openapitools.client.model.*;

ApiClient defaultClient = Configuration.getDefaultApiClient();
ApiHealthApi apiInstance = new ApiHealthApi(defaultClient);

try {
    HealthResponseDto result = apiInstance.healthControllerCheckV0();
    System.out.println("Service is healthy: " + result);
} catch (ApiException e) {
    System.err.println("Health check failed: " + e.getMessage());
}
Returns: HealthResponseDto Throws: ApiException - if the API call fails

healthControllerPublicHealthCheckV0()

Public health check endpoint (no authentication required).
PublicHealthResponseDto status = apiInstance.healthControllerPublicHealthCheckV0();
System.out.println("Service status: " + status.getStatus());
Returns: PublicHealthResponseDto Throws: ApiException - if the API call fails

App Balances

Query your application’s stablecoin balances.

Methods

balanceControllerGetAllBalances()

Get all stablecoin balances for your application.
import org.openapitools.client.api.AppBalancesApi;
import org.openapitools.client.model.*;

ApiClient defaultClient = Configuration.getDefaultApiClient();
AppBalancesApi apiInstance = new AppBalancesApi(defaultClient);

try {
    AllBalancesResponse balances = apiInstance.balanceControllerGetAllBalances();
    System.out.println("USDC Balance: " + balances.getUsdc());
    System.out.println("EURC Balance: " + balances.getEurc());
} catch (ApiException e) {
    System.err.println("Exception: " + e.getMessage());
}
Returns: AllBalancesResponse Throws: ApiException - if the API call fails

balanceControllerGetUSDCBalance()

Get USDC balance only.
AggregatedBalanceResponse usdcBalance = apiInstance.balanceControllerGetUSDCBalance();
System.out.println("USDC: " + usdcBalance.getAmount());
Returns: AggregatedBalanceResponse Throws: ApiException - if the API call fails

balanceControllerGetEURCBalance()

Get EURC balance only.
AggregatedBalanceResponse eurcBalance = apiInstance.balanceControllerGetEURCBalance();
System.out.println("EURC: " + eurcBalance.getAmount());
Returns: AggregatedBalanceResponse Throws: ApiException - if the API call fails

Customers

Manage customer records and KYC information.

Methods

customerControllerCreate(CreateCustomerDto)

Create a new customer.
import org.openapitools.client.api.CustomersApi;
import org.openapitools.client.model.*;

ApiClient defaultClient = Configuration.getDefaultApiClient();
CustomersApi apiInstance = new CustomersApi(defaultClient);

try {
    CreateCustomerDto customerDto = new CreateCustomerDto()
        .firstName("John")
        .lastName("Doe")
        .email("john.doe@example.com")
        .type(CustomerType.INDIVIDUAL)
        .country("US");
    
    Object customer = apiInstance.customerControllerCreate(customerDto);
    System.out.println("Customer created: " + customer);
} catch (ApiException e) {
    System.err.println("Exception: " + e.getMessage());
}
Parameters:
  • createCustomerDto: CreateCustomerDto - Customer details
Returns: Object Throws: ApiException - if the API call fails

customerControllerFindAll(Integer, Integer, String)

Get all customers with optional filters.
try {
    Integer page = 1;
    Integer limit = 20;
    String status = "ACTIVE";
    
    Object customers = apiInstance.customerControllerFindAll(page, limit, status);
    System.out.println("Customers: " + customers);
} catch (ApiException e) {
    System.err.println("Exception: " + e.getMessage());
}
Parameters:
  • page: Integer - Page number (optional, default: 1)
  • limit: Integer - Items per page (optional, default: 20)
  • status: String - Filter by status (optional)
Returns: Object Throws: ApiException - if the API call fails

customerControllerFindOne(String)

Get a customer by ID.
String customerId = "customer-id-here";
Object customer = apiInstance.customerControllerFindOne(customerId);
System.out.println("Customer: " + customer);
Parameters:
  • id: String - Customer ID (required)
Returns: Object Throws: ApiException - if the API call fails

customerControllerUpdate(String, UpdateCustomerDto)

Update a customer’s information.
UpdateCustomerDto updateDto = new UpdateCustomerDto()
    .phone("+1234567890")
    .address("123 Main St");

Object updated = apiInstance.customerControllerUpdate("customer-id-here", updateDto);
System.out.println("Customer updated: " + updated);
Parameters:
  • id: String - Customer ID (required)
  • updateCustomerDto: UpdateCustomerDto - Fields to update
Returns: Object Throws: ApiException - if the API call fails

Exchange Rates

Get real-time currency exchange rates.

Methods

exchangeRateControllerGetExchangeRate(String, String)

Get exchange rate between any two supported currencies.
import org.openapitools.client.api.ExchangeRatesApi;
import org.openapitools.client.model.*;

ApiClient defaultClient = Configuration.getDefaultApiClient();
ExchangeRatesApi apiInstance = new ExchangeRatesApi(defaultClient);

try {
    String from = "USD";
    String to = "EUR";
    
    ExchangeRateResponseDto rate = apiInstance.exchangeRateControllerGetExchangeRate(from, to);
    System.out.println("1 USD = " + rate.getRate() + " EUR");
    System.out.println("Rate expires at: " + rate.getExpiresAt());
} catch (ApiException e) {
    System.err.println("Exception: " + e.getMessage());
}
Parameters:
  • from: String - Source currency code (optional)
  • to: String - Target currency code (optional)
Returns: ExchangeRateResponseDto Throws: ApiException - if the API call fails

exchangeRateControllerGetUSDToEURRate()

Get USD to EUR exchange rate.
ExchangeRateResponseDto usdToEur = apiInstance.exchangeRateControllerGetUSDToEURRate();
System.out.println("USD to EUR: " + usdToEur.getRate());
Returns: ExchangeRateResponseDto Throws: ApiException - if the API call fails

exchangeRateControllerGetEURToUSDRate()

Get EUR to USD exchange rate.
ExchangeRateResponseDto eurToUsd = apiInstance.exchangeRateControllerGetEURToUSDRate();
System.out.println("EUR to USD: " + eurToUsd.getRate());
Returns: ExchangeRateResponseDto Throws: ApiException - if the API call fails

Invoices

Create and manage invoices for your customers.

Methods

invoiceControllerCreate(CreateInvoiceDto)

Create a new invoice.
import org.openapitools.client.api.InvoicesApi;
import org.openapitools.client.model.*;
import java.util.Arrays;
import java.time.LocalDate;

ApiClient defaultClient = Configuration.getDefaultApiClient();
InvoicesApi apiInstance = new InvoicesApi(defaultClient);

try {
    InvoiceProductDto product = new InvoiceProductDto()
        .description("Premium Subscription")
        .quantity(1)
        .price(new BigDecimal("99.99"))
        .currency("USD");
    
    CreateInvoiceDto invoiceDto = new CreateInvoiceDto()
        .customerId("customer-id")
        .items(Arrays.asList(product))
        .dueDate(LocalDate.parse("2024-12-31"));
    
    Object invoice = apiInstance.invoiceControllerCreate(invoiceDto);
    System.out.println("Invoice created: " + invoice);
} catch (ApiException e) {
    System.err.println("Exception: " + e.getMessage());
}
Parameters:
  • createInvoiceDto: CreateInvoiceDto - Invoice details
Returns: Object Throws: ApiException - if the API call fails

invoiceControllerFindAll(Integer, Integer, String)

Get all invoices.
Integer page = 1;
Integer limit = 50;
String status = "UNPAID";

Object invoices = apiInstance.invoiceControllerFindAll(page, limit, status);
System.out.println("Invoices: " + invoices);
Parameters:
  • page: Integer - Page number (optional)
  • limit: Integer - Items per page (optional)
  • status: String - Filter by status (optional)
Returns: Object Throws: ApiException - if the API call fails

invoiceControllerFindOne(String)

Get an invoice by ID.
Object invoice = apiInstance.invoiceControllerFindOne("invoice-id");
System.out.println("Invoice: " + invoice);
Parameters:
  • id: String - Invoice ID (required)
Returns: Object Throws: ApiException - if the API call fails

invoiceControllerUpdate(String, Object)

Update an invoice.
// Note: Use appropriate DTO for update
Object updated = apiInstance.invoiceControllerUpdate("invoice-id", updateDto);
System.out.println("Invoice updated: " + updated);
Parameters:
  • id: String - Invoice ID (required)
  • updateInvoiceDto: Object - Fields to update
Returns: Object Throws: ApiException - if the API call fails

Liquidation Addresses

Manage cryptocurrency liquidation addresses for customers.

Methods

liquidationAddressControllerCreateLiquidationAddress(String, CreateLiquidationAddressDto)

Create a new liquidation address for a customer.
import org.openapitools.client.api.LiquidationAddressesApi;
import org.openapitools.client.model.*;

ApiClient defaultClient = Configuration.getDefaultApiClient();
LiquidationAddressesApi apiInstance = new LiquidationAddressesApi(defaultClient);

try {
    CreateLiquidationAddressDto addressDto = new CreateLiquidationAddressDto()
        .network("solana")
        .currency("usdc");
    
    LiquidationAddressResponseDto address = apiInstance
        .liquidationAddressControllerCreateLiquidationAddress("customer-id", addressDto);
    
    System.out.println("Liquidation address: " + address.getAddress());
    System.out.println("Network: " + address.getNetwork());
} catch (ApiException e) {
    System.err.println("Exception: " + e.getMessage());
}
Parameters:
  • customerId: String - Customer ID (required)
  • createLiquidationAddressDto: CreateLiquidationAddressDto - Address details
Returns: LiquidationAddressResponseDto Throws: ApiException - if the API call fails

liquidationAddressControllerGetLiquidationAddresses(String)

Get all liquidation addresses for a customer.
Object addresses = apiInstance.liquidationAddressControllerGetLiquidationAddresses("customer-id");
System.out.println("Addresses: " + addresses);
Parameters:
  • customerId: String - Customer ID (required)
Returns: Object Throws: ApiException - if the API call fails

liquidationAddressControllerGetLiquidationAddress(String, String)

Get a specific liquidation address.
LiquidationAddressResponseDto address = apiInstance
    .liquidationAddressControllerGetLiquidationAddress("customer-id", "address-id");

System.out.println("Address: " + address.getAddress());
Parameters:
  • customerId: String - Customer ID (required)
  • liquidationAddressId: String - Address ID (required)
Returns: LiquidationAddressResponseDto Throws: ApiException - if the API call fails

Payment Intents

Create payment intents for bank and stablecoin payments.

Methods

paymentIntentControllerCreateBankPaymentIntent(CreateBankPaymentIntentDto)

Create a bank payment intent.
import org.openapitools.client.api.PaymentIntentsApi;
import org.openapitools.client.model.*;

ApiClient defaultClient = Configuration.getDefaultApiClient();
PaymentIntentsApi apiInstance = new PaymentIntentsApi(defaultClient);

try {
    CreateBankPaymentIntentDto intentDto = new CreateBankPaymentIntentDto()
        .customerId("customer-id")
        .amount(new BigDecimal("1000.00"))
        .currency("USD")
        .paymentRail("wire");
    
    Object intent = apiInstance.paymentIntentControllerCreateBankPaymentIntent(intentDto);
    System.out.println("Payment intent: " + intent);
} catch (ApiException e) {
    System.err.println("Exception: " + e.getMessage());
}
Parameters:
  • createBankPaymentIntentDto: CreateBankPaymentIntentDto - Intent details
Returns: Object Throws: ApiException - if the API call fails

paymentIntentControllerCreateStablePaymentIntent(CreateStablePaymentIntentDto)

Create a stablecoin payment intent.
CreateStablePaymentIntentDto stableIntentDto = new CreateStablePaymentIntentDto()
    .customerId("customer-id")
    .amount(new BigDecimal("500.00"))
    .currency("usdc")
    .network("solana");

Object stableIntent = apiInstance.paymentIntentControllerCreateStablePaymentIntent(stableIntentDto);
System.out.println("Stable intent: " + stableIntent);
Parameters:
  • createStablePaymentIntentDto: CreateStablePaymentIntentDto - Intent details
Returns: Object Throws: ApiException - if the API call fails
Generate and manage payment links for easy customer payments.

Methods

paymentLinksControllerCreate(CreatePaymentLinkDto)

Create a new payment link.
import org.openapitools.client.api.PaymentLinksApi;
import org.openapitools.client.model.*;
import java.util.Arrays;

ApiClient defaultClient = Configuration.getDefaultApiClient();
PaymentLinksApi apiInstance = new PaymentLinksApi(defaultClient);

try {
    PaymentLinkProductDto product = new PaymentLinkProductDto()
        .name("Premium Plan")
        .quantity(1)
        .price(new BigDecimal("99.99"));
    
    CreatePaymentLinkDto linkDto = new CreatePaymentLinkDto()
        .name("Product Purchase")
        .amount(new BigDecimal("99.99"))
        .currency("USD")
        .products(Arrays.asList(product));
    
    Object link = apiInstance.paymentLinksControllerCreate(linkDto);
    System.out.println("Payment link created: " + link);
} catch (ApiException e) {
    System.err.println("Exception: " + e.getMessage());
}
Parameters:
  • createPaymentLinkDto: CreatePaymentLinkDto - Link details
Returns: Object Throws: ApiException - if the API call fails

paymentLinksControllerFindAll(Integer, Integer, Boolean)

Get all payment links.
Integer page = 1;
Integer limit = 20;
Boolean active = true;

Object links = apiInstance.paymentLinksControllerFindAll(page, limit, active);
System.out.println("Payment links: " + links);
Parameters:
  • page: Integer - Page number (optional)
  • limit: Integer - Items per page (optional)
  • active: Boolean - Filter by active status (optional)
Returns: Object Throws: ApiException - if the API call fails

paymentLinksControllerFindOne(String)

Get a payment link by ID.
Object link = apiInstance.paymentLinksControllerFindOne("link-id");
System.out.println("Link: " + link);
Parameters:
  • id: String - Payment link ID (required)
Returns: Object Throws: ApiException - if the API call fails

paymentLinksControllerUpdate(String, Object)

Update a payment link.
Object updated = apiInstance.paymentLinksControllerUpdate("link-id", updateDto);
System.out.println("Link updated: " + updated);
Parameters:
  • id: String - Payment link ID (required)
  • updatePaymentLinkDto: Object - Fields to update
Returns: Object Throws: ApiException - if the API call fails

Products

Manage your product catalog.

Methods

productControllerCreate(Object)

Create a new product.
import org.openapitools.client.api.ProductsApi;

ApiClient defaultClient = Configuration.getDefaultApiClient();
ProductsApi apiInstance = new ProductsApi(defaultClient);

try {
    // Create product DTO with required fields
    Object productDto = new Object(); // Use appropriate DTO
    
    Object product = apiInstance.productControllerCreate(productDto);
    System.out.println("Product created: " + product);
} catch (ApiException e) {
    System.err.println("Exception: " + e.getMessage());
}
Parameters:
  • createProductDto: Object - Product details
Returns: Object Throws: ApiException - if the API call fails

productControllerFindAll(String, Boolean)

Get all products.
String category = "subscriptions";
Boolean active = true;

Object products = apiInstance.productControllerFindAll(category, active);
System.out.println("Products: " + products);
Parameters:
  • category: String - Filter by category (optional)
  • active: Boolean - Filter by active status (optional)
Returns: Object Throws: ApiException - if the API call fails

productControllerFindOne(String)

Get a product by ID.
Object product = apiInstance.productControllerFindOne("product-id");
System.out.println("Product: " + product);
Parameters:
  • id: String - Product ID (required)
Returns: Object Throws: ApiException - if the API call fails

productControllerUpdate(String, Object)

Update a product.
Object updated = apiInstance.productControllerUpdate("product-id", updateDto);
System.out.println("Product updated: " + updated);
Parameters:
  • id: String - Product ID (required)
  • updateProductDto: Object - Fields to update
Returns: Object Throws: ApiException - if the API call fails

productControllerRemove(String)

Delete a product.
apiInstance.productControllerRemove("product-id");
System.out.println("Product deleted");
Parameters:
  • id: String - Product ID (required)
Returns: void Throws: ApiException - if the API call fails

productControllerUploadImage(String, List<File>)

Upload images for a product.
import java.io.File;
import java.util.Arrays;

List<File> images = Arrays.asList(
    new File("/path/to/image1.jpg"),
    new File("/path/to/image2.jpg")
);

Object product = apiInstance.productControllerUploadImage("product-id", images);
System.out.println("Images uploaded: " + product);
Parameters:
  • id: String - Product ID (required)
  • images: List<File> - Image files
Returns: Object Throws: ApiException - if the API call fails

Taxes

Configure and manage tax settings.

Methods

taxControllerCreate(CreateTaxDto)

Create a new tax configuration.
import org.openapitools.client.api.TaxesApi;
import org.openapitools.client.model.*;

ApiClient defaultClient = Configuration.getDefaultApiClient();
TaxesApi apiInstance = new TaxesApi(defaultClient);

try {
    CreateTaxDto taxDto = new CreateTaxDto()
        .name("Sales Tax")
        .percentage(new BigDecimal("8.5"))
        .country("US")
        .state("CA");
    
    TaxControllerCreate201Response tax = apiInstance.taxControllerCreate(taxDto);
    System.out.println("Tax created: " + tax);
} catch (ApiException e) {
    System.err.println("Exception: " + e.getMessage());
}
Parameters:
  • createTaxDto: CreateTaxDto - Tax details
Returns: TaxControllerCreate201Response Throws: ApiException - if the API call fails

taxControllerFindAll(String)

Get all tax configurations.
String country = "US";
Object taxes = apiInstance.taxControllerFindAll(country);
System.out.println("Taxes: " + taxes);
Parameters:
  • country: String - Filter by country (optional)
Returns: Object Throws: ApiException - if the API call fails

taxControllerFindOne(String)

Get a tax configuration by ID.
Object tax = apiInstance.taxControllerFindOne("tax-id");
System.out.println("Tax: " + tax);
Parameters:
  • id: String - Tax ID (required)
Returns: Object Throws: ApiException - if the API call fails

taxControllerUpdate(String, UpdateTaxDto)

Update a tax configuration.
UpdateTaxDto updateDto = new UpdateTaxDto()
    .percentage(new BigDecimal("9.0"));

Object updated = apiInstance.taxControllerUpdate("tax-id", updateDto);
System.out.println("Tax updated: " + updated);
Parameters:
  • id: String - Tax ID (required)
  • updateTaxDto: UpdateTaxDto - Fields to update
Returns: Object Throws: ApiException - if the API call fails

taxControllerRemove(String)

Delete a tax configuration.
apiInstance.taxControllerRemove("tax-id");
System.out.println("Tax deleted");
Parameters:
  • id: String - Tax ID (required)
Returns: void Throws: ApiException - if the API call fails

Test Payments

Process test payments in sandbox environment.

Methods

testPaymentControllerCreatePaymentV0(PaymentRequestDto)

Create a test payment.
import org.openapitools.client.api.TestPaymentsApi;
import org.openapitools.client.model.*;

ApiClient defaultClient = Configuration.getDefaultApiClient();
TestPaymentsApi apiInstance = new TestPaymentsApi(defaultClient);

try {
    PaymentRequestDto paymentDto = new PaymentRequestDto()
        .amount(new BigDecimal("100.00"))
        .currency("USD")
        .customerId("test-customer-id")
        .idempotencyKey("unique-key-123");
    
    PaymentResponseDto payment = apiInstance.testPaymentControllerCreatePaymentV0(paymentDto);
    System.out.println("Test payment: " + payment.getId());
    System.out.println("Status: " + payment.getStatus());
} catch (ApiException e) {
    System.err.println("Exception: " + e.getMessage());
}
Parameters:
  • paymentRequestDto: PaymentRequestDto - Payment details
Returns: PaymentResponseDto Throws: ApiException - if the API call fails

testPaymentControllerGetPaymentV0(String)

Get test payment details by ID.
PaymentResponseDto payment = apiInstance.testPaymentControllerGetPaymentV0("payment-id");
System.out.println("Payment status: " + payment.getStatus());
Parameters:
  • id: String - Payment ID (required)
Returns: PaymentResponseDto Throws: ApiException - if the API call fails

testPaymentControllerRefundPaymentV0(String, BigDecimal)

Refund a test payment.
BigDecimal refundAmount = new BigDecimal("50.00");
RefundResponseDto refund = apiInstance.testPaymentControllerRefundPaymentV0("payment-id", refundAmount);
System.out.println("Refund processed: " + refund.getId());
Parameters:
  • id: String - Payment ID (required)
  • refundAmount: BigDecimal - Amount to refund (optional, defaults to full amount)
Returns: RefundResponseDto Throws: ApiException - if the API call fails

Transfers

Initiate and manage fund transfers between different payment rails.

Methods

transferControllerCreateDirectBankTransfer(CreateDirectBankTransferDto)

Create a direct bank transfer.
import org.openapitools.client.api.TransfersApi;
import org.openapitools.client.model.*;
import java.math.BigDecimal;

ApiClient defaultClient = Configuration.getDefaultApiClient();
TransfersApi apiInstance = new TransfersApi(defaultClient);

try {
    CreateDirectBankTransferDto transferDto = new CreateDirectBankTransferDto()
        .walletId("wallet-id")
        .paymentRail("wire")
        .sourceCurrency("usd")
        .destinationCurrency("usdc")
        .amount(new BigDecimal("1000.00"));
    
    Object transfer = apiInstance.transferControllerCreateDirectBankTransfer(transferDto);
    System.out.println("Transfer created: " + transfer);
} catch (ApiException e) {
    System.err.println("Exception: " + e.getMessage());
}
Parameters:
  • createDirectBankTransferDto: CreateDirectBankTransferDto - Transfer details
Returns: Object Throws: ApiException - if the API call fails See also: Direct Bank Transfer Guide

transferControllerCreateDirectWalletTransfer(CreateDirectWalletTransferDto)

Create a direct wallet transfer.
CreateDirectWalletTransferDto transferDto = new CreateDirectWalletTransferDto()
    .walletId("wallet-id")
    .network("solana")
    .stableCoinCurrency("usdc")
    .amount(new BigDecimal("500.00"));

Object transfer = apiInstance.transferControllerCreateDirectWalletTransfer(transferDto);
System.out.println("Transfer created: " + transfer);
Parameters:
  • createDirectWalletTransferDto: CreateDirectWalletTransferDto - Transfer details
Returns: Object Throws: ApiException - if the API call fails See also: Direct Wallet Transfer Guide

transferControllerCreateExternalBankTransfer(CreateExternalBankTransferDto)

Create an external bank transfer (from your wallet to external bank).
CreateExternalBankTransferDto transferDto = new CreateExternalBankTransferDto()
    .sourceWalletId("wallet-id")
    .destinationBankAccountId("bank-account-id")
    .amount(new BigDecimal("1000.00"))
    .currency("USD");

Object transfer = apiInstance.transferControllerCreateExternalBankTransfer(transferDto);
System.out.println("External bank transfer: " + transfer);
Parameters:
  • createExternalBankTransferDto: CreateExternalBankTransferDto - Transfer details
Returns: Object Throws: ApiException - if the API call fails

transferControllerCreateExternalStablecoinTransfer(CreateExternalStablecoinTransferDto)

Create an external stablecoin transfer (from your wallet to external wallet).
CreateExternalStablecoinTransferDto transferDto = new CreateExternalStablecoinTransferDto()
    .sourceWalletId("wallet-id")
    .destinationAddress("0x742d35Cc6Ff82a8C2D8D1Da9da17c7eDfD5bE0a3")
    .network("ethereum")
    .currency("usdc")
    .amount(new BigDecimal("250.00"));

Object transfer = apiInstance.transferControllerCreateExternalStablecoinTransfer(transferDto);
System.out.println("External stablecoin transfer: " + transfer);
Parameters:
  • createExternalStablecoinTransferDto: CreateExternalStablecoinTransferDto - Transfer details
Returns: Object Throws: ApiException - if the API call fails

transferControllerCreateStablecoinConversion(CreateStablecoinConversionDto)

Convert between different stablecoins or networks.
CreateStablecoinConversionDto conversionDto = new CreateStablecoinConversionDto()
    .sourceWalletId("wallet-id")
    .destinationWalletId("wallet-id")
    .sourceNetwork("ethereum")
    .destinationNetwork("solana")
    .sourceCurrency("usdc")
    .destinationCurrency("usdc")
    .amount(new BigDecimal("1000.00"));

Object conversion = apiInstance.transferControllerCreateStablecoinConversion(conversionDto);
System.out.println("Conversion ID: " + conversion);
Parameters:
  • createStablecoinConversionDto: CreateStablecoinConversionDto - Conversion details
Returns: Object Throws: ApiException - if the API call fails See also: Stablecoin Conversion Guide

Wallets

Manage wallets and query balances.

Methods

walletControllerGetWallets()

Get all wallets for your application.
import org.openapitools.client.api.WalletsApi;

ApiClient defaultClient = Configuration.getDefaultApiClient();
WalletsApi apiInstance = new WalletsApi(defaultClient);

try {
    apiInstance.walletControllerGetWallets();
    System.out.println("Wallets retrieved successfully");
} catch (ApiException e) {
    System.err.println("Exception: " + e.getMessage());
}
Returns: void Throws: ApiException - if the API call fails
The response contains wallet IDs that you can use for transfers and other operations. In a future SDK version, this will return typed wallet objects.

Webhooks

Configure webhooks to receive real-time event notifications.

Methods

webhookControllerCreate(CreateWebhookDto)

Create a new webhook.
import org.openapitools.client.api.WebhooksApi;
import org.openapitools.client.model.*;

ApiClient defaultClient = Configuration.getDefaultApiClient();
WebhooksApi apiInstance = new WebhooksApi(defaultClient);

try {
    CreateWebhookDto webhookDto = new CreateWebhookDto()
        .url("https://your-app.com/webhooks/devdraft")
        .name("Production Webhook")
        .isActive(true)
        .encrypted(false);
    
    WebhookResponseDto webhook = apiInstance.webhookControllerCreate(webhookDto);
    System.out.println("Webhook ID: " + webhook.getId());
    System.out.println("Signing secret: " + webhook.getSigningSecret());
} catch (ApiException e) {
    System.err.println("Exception: " + e.getMessage());
}
Parameters:
  • createWebhookDto: CreateWebhookDto - Webhook configuration
Returns: WebhookResponseDto Throws: ApiException - if the API call fails See also: Webhooks Overview

webhookControllerFindAll(Integer, Integer, Boolean)

Get all webhooks.
Integer page = 1;
Integer limit = 20;
Boolean active = true;

Object webhooks = apiInstance.webhookControllerFindAll(page, limit, active);
System.out.println("Webhooks: " + webhooks);
Parameters:
  • page: Integer - Page number (optional)
  • limit: Integer - Items per page (optional)
  • active: Boolean - Filter by active status (optional)
Returns: Object Throws: ApiException - if the API call fails

webhookControllerFindOne(String)

Get a webhook by ID.
WebhookResponseDto webhook = apiInstance.webhookControllerFindOne("webhook-id");

System.out.println("Webhook: " + webhook.getName());
System.out.println("URL: " + webhook.getUrl());
Parameters:
  • id: String - Webhook ID (required)
Returns: WebhookResponseDto Throws: ApiException - if the API call fails

webhookControllerUpdate(String, UpdateWebhookDto)

Update a webhook.
UpdateWebhookDto updateDto = new UpdateWebhookDto()
    .url("https://your-app.com/webhooks/new-endpoint")
    .isActive(true);

WebhookResponseDto updated = apiInstance.webhookControllerUpdate("webhook-id", updateDto);
System.out.println("Webhook updated: " + updated.getId());
Parameters:
  • id: String - Webhook ID (required)
  • updateWebhookDto: UpdateWebhookDto - Fields to update
Returns: WebhookResponseDto Throws: ApiException - if the API call fails

webhookControllerRemove(String)

Delete a webhook.
apiInstance.webhookControllerRemove("webhook-id");
System.out.println("Webhook deleted");
Parameters:
  • id: String - Webhook ID (required)
Returns: void Throws: ApiException - if the API call fails

Error Handling

All SDK methods throw ApiException when API calls fail. Handle them appropriately:
import org.openapitools.client.ApiException;

try {
    Object transfer = transfersApi.transferControllerCreateDirectWalletTransfer(transferDto);
    System.out.println("Transfer created: " + transfer);
} catch (ApiException e) {
    // Get status code
    int statusCode = e.getCode();
    
    switch (statusCode) {
        case 400:
            System.err.println("Invalid request: " + e.getMessage());
            break;
        case 401:
            System.err.println("Authentication failed - check your API credentials");
            break;
        case 404:
            System.err.println("Resource not found: " + e.getMessage());
            break;
        case 422:
            System.err.println("Validation error: " + e.getMessage());
            break;
        case 429:
            System.err.println("Rate limited - please retry later");
            break;
        default:
            System.err.println("API error (" + statusCode + "): " + e.getMessage());
    }
    
    // Access response body for more details
    System.err.println("Response body: " + e.getResponseBody());
    
    // Access response headers
    System.err.println("Response headers: " + e.getResponseHeaders());
    
    // Print stack trace for debugging
    e.printStackTrace();
} catch (Exception e) {
    System.err.println("Unexpected error: " + e.getMessage());
    e.printStackTrace();
}

Best Practices

1

Use Environment Variables

Store credentials in environment variables or configuration files.
public class DevdraftConfig {
    private static ApiClient client;
    
    public static ApiClient getClient() {
        if (client == null) {
            client = Configuration.getDefaultApiClient();
            client.setBasePath("https://api.devdraft.ai");
            
            // Configure authentication
            ApiKeyAuth clientKey = (ApiKeyAuth) client.getAuthentication("x-client-key");
            clientKey.setApiKey(System.getenv("DEVDRAFT_CLIENT_KEY"));
            
            ApiKeyAuth clientSecret = (ApiKeyAuth) client.getAuthentication("x-client-secret");
            clientSecret.setApiKey(System.getenv("DEVDRAFT_CLIENT_SECRET"));
        }
        return client;
    }
}

// Usage
TransfersApi transfersApi = new TransfersApi(DevdraftConfig.getClient());
2

Implement Proper Exception Handling

Always wrap API calls in try-catch blocks with specific error handling.
public class TransferService {
    private final TransfersApi transfersApi;
    
    public TransferService(ApiClient client) {
        this.transfersApi = new TransfersApi(client);
    }
    
    public Object createTransfer(BigDecimal amount) throws ApiException {
        CreateDirectWalletTransferDto dto = new CreateDirectWalletTransferDto()
            .walletId("wallet-id")
            .network("solana")
            .stableCoinCurrency("usdc")
            .amount(amount);
        
        try {
            return transfersApi.transferControllerCreateDirectWalletTransfer(dto);
        } catch (ApiException e) {
            // Log the error
            System.err.println("Transfer creation failed: " + e.getMessage());
            throw e;
        }
    }
}
3

Use BigDecimal for Currency Amounts

Always use BigDecimal for monetary values to avoid floating-point precision issues.
// Good: Using BigDecimal
BigDecimal amount = new BigDecimal("100.50");

// Bad: Using double (can lose precision)
double amount = 100.50;
4

Leverage Java Streams

Use Java Streams for collection operations when processing API responses.
// Example with filtering customers
List<Object> customers = (List<Object>) customersApi.customerControllerFindAll(null, null, null);

// Process with streams
customers.stream()
    .filter(customer -> /* filter condition */)
    .map(customer -> /* transform */)
    .forEach(System.out::println);
5

Implement Logging

Use a logging framework like SLF4J or Log4j2.
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class TransferService {
    private static final Logger logger = LoggerFactory.getLogger(TransferService.class);
    private final TransfersApi transfersApi;
    
    public Object createTransfer(BigDecimal amount) {
        logger.info("Creating transfer for amount: {}", amount);
        
        try {
            CreateDirectWalletTransferDto dto = new CreateDirectWalletTransferDto()
                .walletId("wallet-id")
                .network("solana")
                .stableCoinCurrency("usdc")
                .amount(amount);
            
            Object transfer = transfersApi.transferControllerCreateDirectWalletTransfer(dto);
            logger.info("Transfer created successfully");
            return transfer;
        } catch (ApiException e) {
            logger.error("Transfer creation failed: {}", e.getMessage(), e);
            throw new RuntimeException("Failed to create transfer", e);
        }
    }
}
6

Use Dependency Injection

Integrate with Spring or other DI frameworks for better testability.
import org.springframework.stereotype.Service;

@Service
public class PaymentService {
    private final TransfersApi transfersApi;
    private final WebhooksApi webhooksApi;
    
    public PaymentService(ApiClient apiClient) {
        this.transfersApi = new TransfersApi(apiClient);
        this.webhooksApi = new WebhooksApi(apiClient);
    }
    
    // Service methods...
}

Testing with JUnit 5

Example JUnit test for SDK integration:
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.openapitools.client.*;
import org.openapitools.client.api.WebhooksApi;
import org.openapitools.client.model.*;

import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.*;

@ExtendWith(MockitoExtension.class)
class WebhookServiceTest {
    
    @Mock
    private WebhooksApi webhooksApi;
    
    private WebhookService webhookService;
    
    @BeforeEach
    void setUp() {
        webhookService = new WebhookService(webhooksApi);
    }
    
    @Test
    void testCreateWebhook_Success() throws ApiException {
        // Arrange
        CreateWebhookDto webhookDto = new CreateWebhookDto()
            .url("https://test.example.com/webhook")
            .name("Test Webhook")
            .isActive(true)
            .encrypted(false);
        
        WebhookResponseDto expectedWebhook = new WebhookResponseDto()
            .id("webhook-123")
            .name("Test Webhook")
            .isActive(true);
        
        when(webhooksApi.webhookControllerCreate(any(CreateWebhookDto.class)))
            .thenReturn(expectedWebhook);
        
        // Act
        WebhookResponseDto result = webhookService.createWebhook(webhookDto);
        
        // Assert
        assertNotNull(result);
        assertEquals("webhook-123", result.getId());
        assertEquals("Test Webhook", result.getName());
        assertTrue(result.getIsActive());
        
        verify(webhooksApi, times(1)).webhookControllerCreate(any(CreateWebhookDto.class));
    }
    
    @Test
    void testCreateWebhook_ApiException() throws ApiException {
        // Arrange
        CreateWebhookDto webhookDto = new CreateWebhookDto()
            .url("invalid-url")
            .name("Invalid Webhook")
            .isActive(true);
        
        when(webhooksApi.webhookControllerCreate(any(CreateWebhookDto.class)))
            .thenThrow(new ApiException(400, "Invalid URL"));
        
        // Act & Assert
        ApiException exception = assertThrows(ApiException.class, () -> {
            webhookService.createWebhook(webhookDto);
        });
        
        assertEquals(400, exception.getCode());
        assertTrue(exception.getMessage().contains("Invalid URL"));
    }
}

Spring Boot Integration

Configuration

Create a configuration class for Spring Boot applications:
import org.openapitools.client.*;
import org.openapitools.client.auth.ApiKeyAuth;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class DevdraftConfig {
    
    @Value("${devdraft.client.key}")
    private String clientKey;
    
    @Value("${devdraft.client.secret}")
    private String clientSecret;
    
    @Value("${devdraft.api.url:https://api.devdraft.ai}")
    private String apiUrl;
    
    @Bean
    public ApiClient devdraftApiClient() {
        ApiClient client = Configuration.getDefaultApiClient();
        client.setBasePath(apiUrl);
        
        // Configure authentication
        ApiKeyAuth keyAuth = (ApiKeyAuth) client.getAuthentication("x-client-key");
        keyAuth.setApiKey(clientKey);
        
        ApiKeyAuth secretAuth = (ApiKeyAuth) client.getAuthentication("x-client-secret");
        secretAuth.setApiKey(clientSecret);
        
        return client;
    }
}

Application Properties

# application.properties
devdraft.client.key=${DEVDRAFT_CLIENT_KEY}
devdraft.client.secret=${DEVDRAFT_CLIENT_SECRET}
devdraft.api.url=https://api.devdraft.ai

Service Layer

Create service classes for clean separation:
import org.openapitools.client.ApiClient;
import org.openapitools.client.ApiException;
import org.openapitools.client.api.TransfersApi;
import org.openapitools.client.api.WebhooksApi;
import org.openapitools.client.model.*;
import org.springframework.stereotype.Service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.math.BigDecimal;

@Service
public class DevdraftService {
    private static final Logger logger = LoggerFactory.getLogger(DevdraftService.class);
    
    private final TransfersApi transfersApi;
    private final WebhooksApi webhooksApi;
    
    public DevdraftService(ApiClient apiClient) {
        this.transfersApi = new TransfersApi(apiClient);
        this.webhooksApi = new WebhooksApi(apiClient);
    }
    
    public Object createTransfer(String walletId, BigDecimal amount) throws ApiException {
        logger.info("Creating transfer for wallet: {}, amount: {}", walletId, amount);
        
        CreateDirectWalletTransferDto dto = new CreateDirectWalletTransferDto()
            .walletId(walletId)
            .network("solana")
            .stableCoinCurrency("usdc")
            .amount(amount);
        
        try {
            Object transfer = transfersApi.transferControllerCreateDirectWalletTransfer(dto);
            logger.info("Transfer created successfully");
            return transfer;
        } catch (ApiException e) {
            logger.error("Failed to create transfer: {}", e.getMessage(), e);
            throw e;
        }
    }
    
    public WebhookResponseDto createWebhook(String url, String name) throws ApiException {
        logger.info("Creating webhook: {}", name);
        
        CreateWebhookDto dto = new CreateWebhookDto()
            .url(url)
            .name(name)
            .isActive(true)
            .encrypted(false);
        
        try {
            WebhookResponseDto webhook = webhooksApi.webhookControllerCreate(dto);
            logger.info("Webhook created: {}", webhook.getId());
            return webhook;
        } catch (ApiException e) {
            logger.error("Failed to create webhook: {}", e.getMessage(), e);
            throw e;
        }
    }
}

REST Controller

Use the service in your Spring Boot controllers:
import org.openapitools.client.ApiException;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/api/transfers")
public class TransferController {
    
    private final DevdraftService devdraftService;
    
    public TransferController(DevdraftService devdraftService) {
        this.devdraftService = devdraftService;
    }
    
    @PostMapping
    public ResponseEntity<Map<String, Object>> createTransfer(
            @RequestParam String walletId,
            @RequestParam BigDecimal amount) {
        
        try {
            Object transfer = devdraftService.createTransfer(walletId, amount);
            
            Map<String, Object> response = new HashMap<>();
            response.put("success", true);
            response.put("transfer", transfer);
            
            return ResponseEntity.ok(response);
        } catch (ApiException e) {
            Map<String, Object> errorResponse = new HashMap<>();
            errorResponse.put("success", false);
            errorResponse.put("error", e.getMessage());
            
            return ResponseEntity
                .status(e.getCode())
                .body(errorResponse);
        } catch (Exception e) {
            Map<String, Object> errorResponse = new HashMap<>();
            errorResponse.put("success", false);
            errorResponse.put("error", "Internal server error");
            
            return ResponseEntity
                .status(HttpStatus.INTERNAL_SERVER_ERROR)
                .body(errorResponse);
        }
    }
}

Global Exception Handler

Handle API exceptions globally:
import org.openapitools.client.ApiException;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

import java.util.HashMap;
import java.util.Map;

@ControllerAdvice
public class GlobalExceptionHandler {
    
    @ExceptionHandler(ApiException.class)
    public ResponseEntity<Map<String, Object>> handleApiException(ApiException e) {
        Map<String, Object> response = new HashMap<>();
        response.put("error", e.getMessage());
        response.put("statusCode", e.getCode());
        response.put("responseBody", e.getResponseBody());
        
        return ResponseEntity.status(e.getCode()).body(response);
    }
    
    @ExceptionHandler(Exception.class)
    public ResponseEntity<Map<String, Object>> handleGenericException(Exception e) {
        Map<String, Object> response = new HashMap<>();
        response.put("error", "Internal server error");
        response.put("message", e.getMessage());
        
        return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response);
    }
}

Next Steps

SDK Quickstart

Complete integration guide with examples

Transfers

Learn about initiating transfers

Webhooks

Set up webhook notifications

API Reference

Complete REST API documentation