Devdraft Ruby SDK
A Ruby client library for the Devdraft Payment & Business Management API.
Installation
Add this line to your application's Gemfile:
gem 'devdraft', '~> 1.0.1'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install devdraft
Usage
Basic Setup
require 'devdraft'
# Configure the SDK
Devdraft.configure do |config|
# Set your authentication headers (required for authenticated endpoints)
config.default_headers = {
'x-client-key' => 'YOUR_CLIENT_KEY',
'x-secret-key' => 'YOUR_SECRET_KEY'
}
# Optional: Set a custom base URL if needed
# config.base_url = 'https://api.devdraft.com'
# Optional: Enable debug logging
config.debugging = true
end
You can generate your client key and secret key from the Devdraft Console under App Settings.
Examples
Basic Setup
require 'devdraft'
# Configure the SDK
Devdraft.configure do |config|
# Set your authentication headers (required for authenticated endpoints)
config.default_headers = {
'x-client-key' => 'YOUR_CLIENT_KEY',
'x-secret-key' => 'YOUR_SECRET_KEY'
}
# Optional: Set a custom base URL if needed
# config.base_url = 'https://api.devdraft.com'
# Optional: Enable debug logging
config.debugging = true
end
You can generate your client key and secret key from the Devdraft Console under App Settings.
Create a Customer
api_instance = Devdraft::CustomersApi.new
# Create a new customer
customer_data = Devdraft::CreateCustomerDto.new(
email: 'customer@example.com',
name: 'John Doe',
status: 'active'
)
begin
result = api_instance.customer_controller_create(customer_data)
puts "Customer created: #{result.inspect}"
rescue Devdraft::ApiError => e
puts "Error creating customer: #{e.response_body}"
end
Create a Payment Link
api_instance = Devdraft::PaymentLinksApi.new
# Create a payment link for a product
payment_link = Devdraft::CreatePaymentLinkDto.new(
amount: 99.99,
currency: 'USD',
description: 'Premium Subscription',
expires_at: (Time.now + 7.days).iso8601, # Expires in 7 days
products: [
Devdraft::PaymentLinkProductDto.new(
name: 'Premium Plan',
quantity: 1,
price: 99.99
)
]
)
begin
result = api_instance.payment_links_controller_create(payment_link)
puts "Payment link created: #{result.inspect}"
rescue Devdraft::ApiError => e
puts "Error creating payment link: #{e.response_body}"
end
Check Balance
api_instance = Devdraft::AppBalancesApi.new
begin
# Get all balances
balances = api_instance.balance_controller_get_all_balances
puts "All balances: #{balances.inspect}"
# Get specific currency balance
usdc_balance = api_instance.balance_controller_get_usdc_balance
puts "USDC balance: #{usdc_balance.inspect}"
rescue Devdraft::ApiError => e
puts "Error checking balance: #{e.response_body}"
end
Create a Webhook
api_instance = Devdraft::WebhooksApi.new
webhook = Devdraft::CreateWebhookDto.new(
url: 'https://your-domain.com/webhooks',
events: ['payment.created', 'payment.completed'],
description: 'Payment notifications'
)
begin
result = api_instance.webhook_controller_create(webhook)
puts "Webhook created: #{result.inspect}"
rescue Devdraft::ApiError => e
puts "Error creating webhook: #{e.response_body}"
end
Available APIs
The SDK provides access to the following APIs:
-
APIHealthApi
: Health check endpoints -
AppBalancesApi
: Balance management -
CustomersApi
: Customer management -
ExchangeRatesApi
: Exchange rate information -
InvoicesApi
: Invoice management -
LiquidationAddressesApi
: Liquidation address management -
PaymentIntentsApi
: Payment intent management -
PaymentLinksApi
: Payment link management -
ProductsApi
: Product management -
TaxesApi
: Tax management -
TestPaymentsApi
: Test payment endpoints -
TransfersApi
: Transfer management -
WalletsApi
: Wallet management -
WebhooksApi
: Webhook management
Development
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests.
Contributing
Bug reports and pull requests are welcome on GitHub.
License
The gem is available as open source under the terms of the Unlicense.
Documentation for API Endpoints
All URIs are relative to https://api.devdraft.ai
Class | Method | HTTP request | Description |
---|---|---|---|
DevDraftAI::APIHealthApi | health_controller_check_v0 | GET /api/v0/health | Authenticated health check endpoint |
DevDraftAI::APIHealthApi | health_controller_public_health_check_v0 | GET /api/v0/health/public | Public health check endpoint |
DevDraftAI::AppBalancesApi | balance_controller_get_all_balances | GET /api/v0/balance | Get all stablecoin balances for an app |
DevDraftAI::AppBalancesApi | balance_controller_get_eurc_balance | GET /api/v0/balance/eurc | Get EURC balance for an app |
DevDraftAI::AppBalancesApi | balance_controller_get_usdc_balance | GET /api/v0/balance/usdc | Get USDC balance for an app |
DevDraftAI::CustomersApi | customer_controller_create | POST /api/v0/customers | Create a new customer |
DevDraftAI::CustomersApi | customer_controller_find_all | GET /api/v0/customers | Get all customers with filters |
DevDraftAI::CustomersApi | customer_controller_find_one | GET /api/v0/customers/{id} | Get a customer by ID |
DevDraftAI::CustomersApi | customer_controller_update | PATCH /api/v0/customers/{id} | Update a customer |
DevDraftAI::ExchangeRatesApi | exchange_rate_controller_get_eurto_usd_rate | GET /api/v0/exchange-rate/eur-to-usd | Get EUR to USD exchange rate |
DevDraftAI::ExchangeRatesApi | exchange_rate_controller_get_exchange_rate | GET /api/v0/exchange-rate | Get exchange rate between specified currencies |
DevDraftAI::ExchangeRatesApi | exchange_rate_controller_get_usdto_eur_rate | GET /api/v0/exchange-rate/usd-to-eur | Get USD to EUR exchange rate |
DevDraftAI::InvoicesApi | invoice_controller_create | POST /api/v0/invoices | Create a new invoice |
DevDraftAI::InvoicesApi | invoice_controller_find_all | GET /api/v0/invoices | Get all invoices |
DevDraftAI::InvoicesApi | invoice_controller_find_one | GET /api/v0/invoices/{id} | Get an invoice by ID |
DevDraftAI::InvoicesApi | invoice_controller_update | PUT /api/v0/invoices/{id} | Update an invoice |
DevDraftAI::LiquidationAddressesApi | liquidation_address_controller_create_liquidation_address | POST /api/v0/customers/{customerId}/liquidation_addresses | Create a new liquidation address for a customer |
DevDraftAI::LiquidationAddressesApi | liquidation_address_controller_get_liquidation_address | GET /api/v0/customers/{customerId}/liquidation_addresses/{liquidationAddressId} | Get a specific liquidation address |
DevDraftAI::LiquidationAddressesApi | liquidation_address_controller_get_liquidation_addresses | GET /api/v0/customers/{customerId}/liquidation_addresses | Get all liquidation addresses for a customer |
DevDraftAI::PaymentIntentsApi | payment_intent_controller_create_bank_payment_intent | POST /api/v0/payment-intents/bank | Create a bank payment intent |
DevDraftAI::PaymentIntentsApi | payment_intent_controller_create_stable_payment_intent | POST /api/v0/payment-intents/stablecoin | Create a stable payment intent |
DevDraftAI::PaymentLinksApi | payment_links_controller_create | POST /api/v0/payment-links | Create a new payment link |
DevDraftAI::PaymentLinksApi | payment_links_controller_find_all | GET /api/v0/payment-links | Get all payment links |
DevDraftAI::PaymentLinksApi | payment_links_controller_find_one | GET /api/v0/payment-links/{id} | Get a payment link by ID |
DevDraftAI::PaymentLinksApi | payment_links_controller_update | PUT /api/v0/payment-links/{id} | Update a payment link |
DevDraftAI::ProductsApi | product_controller_create | POST /api/v0/products | Create a new product |
DevDraftAI::ProductsApi | product_controller_find_all | GET /api/v0/products | Get all products |
DevDraftAI::ProductsApi | product_controller_find_one | GET /api/v0/products/{id} | Get a product by ID |
DevDraftAI::ProductsApi | product_controller_remove | DELETE /api/v0/products/{id} | Delete a product |
DevDraftAI::ProductsApi | product_controller_update | PUT /api/v0/products/{id} | Update a product |
DevDraftAI::ProductsApi | product_controller_upload_image | POST /api/v0/products/{id}/images | Upload images for a product |
DevDraftAI::TaxesApi | tax_controller_create | POST /api/v0/taxes | Create a new tax |
DevDraftAI::TaxesApi | tax_controller_find_all | GET /api/v0/taxes | Get all taxes |
DevDraftAI::TaxesApi | tax_controller_find_one | GET /api/v0/taxes/{id} | Get a tax by ID |
DevDraftAI::TaxesApi | tax_controller_remove | DELETE /api/v0/taxes/{id} | Delete a tax |
DevDraftAI::TaxesApi | tax_controller_update | PUT /api/v0/taxes/{id} | Update a tax |
DevDraftAI::TestPaymentsApi | test_payment_controller_create_payment_v0 | POST /api/v0/test-payment | Process a test payment |
DevDraftAI::TestPaymentsApi | test_payment_controller_get_payment_v0 | GET /api/v0/test-payment/{id} | Get payment details by ID |
DevDraftAI::TestPaymentsApi | test_payment_controller_refund_payment_v0 | POST /api/v0/test-payment/{id}/refund | Refund a payment |
DevDraftAI::TransfersApi | transfer_controller_create_direct_bank_transfer | POST /api/v0/transfers/direct-bank | Create a direct bank transfer |
DevDraftAI::TransfersApi | transfer_controller_create_direct_wallet_transfer | POST /api/v0/transfers/direct-wallet | Create a direct wallet transfer |
DevDraftAI::TransfersApi | transfer_controller_create_stablecoin_conversion | POST /api/v0/transfers/stablecoin-conversion | Create a stablecoin conversion |
DevDraftAI::WalletsApi | wallet_controller_get_wallets | GET /api/v0/wallets | Get wallets for an app |
DevDraftAI::WebhooksApi | webhook_controller_create | POST /api/v0/webhooks | Create a new webhook |
DevDraftAI::WebhooksApi | webhook_controller_find_all | GET /api/v0/webhooks | Get all webhooks |
DevDraftAI::WebhooksApi | webhook_controller_find_one | GET /api/v0/webhooks/{id} | Get a webhook by id |
DevDraftAI::WebhooksApi | webhook_controller_remove | DELETE /api/v0/webhooks/{id} | Delete a webhook |
DevDraftAI::WebhooksApi | webhook_controller_update | PATCH /api/v0/webhooks/{id} | Update a webhook |
Documentation for Models
- DevDraftAI::AggregatedBalanceResponse
- DevDraftAI::AllBalancesResponse
- DevDraftAI::AllOfAllBalancesResponseEurc
- DevDraftAI::AllOfAllBalancesResponseUsdc
- DevDraftAI::AllOfCreateBankPaymentIntentDtoDestinationCurrency
- DevDraftAI::AllOfCreateBankPaymentIntentDtoDestinationNetwork
- DevDraftAI::AllOfCreateBankPaymentIntentDtoSourceCurrency
- DevDraftAI::AllOfCreateBankPaymentIntentDtoSourcePaymentRail
- DevDraftAI::AllOfCreateCustomerDtoStatus
- DevDraftAI::AllOfCreateLiquidationAddressDtoDestinationCurrency
- DevDraftAI::AllOfCreateLiquidationAddressDtoDestinationPaymentRail
- DevDraftAI::AllOfCreateStablePaymentIntentDtoDestinationCurrency
- DevDraftAI::AllOfCreateStablePaymentIntentDtoDestinationNetwork
- DevDraftAI::AllOfCreateStablePaymentIntentDtoSourceCurrency
- DevDraftAI::AllOfCreateStablePaymentIntentDtoSourceNetwork
- DevDraftAI::AllOfUpdateCustomerDtoStatus
- DevDraftAI::BridgePaymentRail
- DevDraftAI::CreateBankPaymentIntentDto
- DevDraftAI::CreateCustomerDto
- DevDraftAI::CreateDirectBankTransferDto
- DevDraftAI::CreateDirectWalletTransferDto
- DevDraftAI::CreateInvoiceDto
- DevDraftAI::CreateLiquidationAddressDto
- DevDraftAI::CreatePaymentLinkDto
- DevDraftAI::CreateProductDto
- DevDraftAI::CreateStablePaymentIntentDto
- DevDraftAI::CreateStablecoinConversionDto
- DevDraftAI::CreateTaxInput
- DevDraftAI::CreateWebhookDto
- DevDraftAI::CustomerStatus
- DevDraftAI::DestinationCurrency
- DevDraftAI::ExchangeRateResponseDto
- DevDraftAI::FiatCurrency
- DevDraftAI::HealthResponseDto
- DevDraftAI::InvoiceProductDto
- DevDraftAI::LiquidationAddressResponseDto
- DevDraftAI::PaymentLinkProductDto
- DevDraftAI::PaymentRequestDto
- DevDraftAI::PaymentResponseDto
- DevDraftAI::PublicHealthResponseDto
- DevDraftAI::RefundResponseDto
- DevDraftAI::StableCoinCurrency
- DevDraftAI::UpdateCustomerDto
- DevDraftAI::UpdatePaymentLinkDto
- DevDraftAI::UpdatePreferenceInput
- DevDraftAI::UpdateProductDto
- DevDraftAI::UpdateTaxInput
- DevDraftAI::UpdateWebhookDto
- DevDraftAI::WebhookResponseDto
Documentation for Authorization
idempotency-key
- Type: API key
- API key parameter name: idempotency-key
- Location: HTTP header
x-client-key
- Type: API key
- API key parameter name: x-client-key
- Location: HTTP header
x-client-secret
- Type: API key
- API key parameter name: x-client-secret
- Location: HTTP header