devdraft
Advanced tools
@@ -21,5 +21,5 @@ # -*- encoding: utf-8 -*- | ||
| s.platform = Gem::Platform::RUBY | ||
| s.authors = ["Swagger-Codegen"] | ||
| s.email = [""] | ||
| s.homepage = "https://github.com/swagger-api/swagger-codegen" | ||
| s.authors = ["Devdraft Engineer"] | ||
| s.email = ["engineering@devdraft.ai"] | ||
| s.homepage = "https://github.com/devdraftengineer/devdraft-sdk-ruby" | ||
| s.summary = "Devdraft Payment & Business Management API Ruby Gem" | ||
@@ -26,0 +26,0 @@ s.description = " A comprehensive payment processing and business management API that enables seamless integration of cryptocurrency and traditional payment methods. " |
+52
-17
@@ -14,4 +14,7 @@ #!/usr/bin/env ruby | ||
| Devdraft.configure do |config| | ||
| # Set your API key (required for authenticated endpoints) | ||
| config.api_key['api_key'] = 'YOUR_API_KEY' | ||
| # Set your authentication headers (required for authenticated endpoints) | ||
| config.default_headers = { | ||
| 'x-client-key' => 'YOUR_CLIENT_KEY', | ||
| 'x-secret-key' => 'YOUR_SECRET_KEY' | ||
| } | ||
@@ -45,17 +48,20 @@ # Optional: Set a custom base URL if needed | ||
| # Example 2: List Customers | ||
| def list_customers | ||
| puts "\n=== List Customers Example ===" | ||
| # Example 2: Create Customer | ||
| def create_customer | ||
| puts "\n=== Create Customer Example ===" | ||
| api_instance = Devdraft::CustomersApi.new | ||
| begin | ||
| # List customers with pagination | ||
| result = api_instance.customers_controller_list_v0( | ||
| page: 1, | ||
| limit: 10 | ||
| # Create a new customer | ||
| customer_data = Devdraft::CreateCustomerDto.new( | ||
| email: 'customer@example.com', | ||
| name: 'John Doe', | ||
| status: 'active' | ||
| ) | ||
| puts "Customers Response:" | ||
| result = api_instance.customer_controller_create(customer_data) | ||
| puts "Customer Created:" | ||
| puts result.inspect | ||
| rescue => e | ||
| puts "Error listing customers: #{e}" | ||
| puts "Error creating customer: #{e}" | ||
| end | ||
@@ -72,9 +78,16 @@ end | ||
| payment_link = Devdraft::CreatePaymentLinkDto.new( | ||
| amount: 100.00, | ||
| amount: 99.99, | ||
| currency: 'USD', | ||
| description: 'Test Payment Link', | ||
| expires_at: (Time.now + 86400).iso8601 # 24 hours from now | ||
| 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 | ||
| ) | ||
| ] | ||
| ) | ||
| result = api_instance.payment_links_controller_create_v0(payment_link) | ||
| result = api_instance.payment_links_controller_create(payment_link) | ||
| puts "Payment Link Created:" | ||
@@ -87,12 +100,34 @@ puts result.inspect | ||
| # Example 4: Check Balance | ||
| def check_balance | ||
| puts "\n=== Check Balance Example ===" | ||
| api_instance = Devdraft::AppBalancesApi.new | ||
| begin | ||
| # Get all balances | ||
| balances = api_instance.balance_controller_get_all_balances | ||
| puts "All Balances:" | ||
| puts balances.inspect | ||
| # Get specific currency balance | ||
| usdc_balance = api_instance.balance_controller_get_usdc_balance | ||
| puts "\nUSDC Balance:" | ||
| puts usdc_balance.inspect | ||
| rescue => e | ||
| puts "Error checking balance: #{e}" | ||
| end | ||
| end | ||
| # Run examples | ||
| puts "Devdraft Ruby SDK Examples" | ||
| puts "==========================" | ||
| puts "Make sure to set your API key in the configuration block above." | ||
| puts "Make sure to set your client key and secret key in the configuration block above." | ||
| puts "You can generate these keys from https://console.devdraft.ai under App Settings." | ||
| puts "Running examples..." | ||
| check_health | ||
| list_customers | ||
| create_customer | ||
| create_payment_link | ||
| check_balance | ||
| puts "\nExamples completed!" |
@@ -13,3 +13,3 @@ =begin | ||
| module Devdraft | ||
| VERSION = '1.0.1' | ||
| VERSION = '1.0.2' | ||
| end |
+91
-24
@@ -32,4 +32,7 @@ # Devdraft Ruby SDK | ||
| Devdraft.configure do |config| | ||
| # Set your API key (required for authenticated endpoints) | ||
| config.api_key['api_key'] = 'YOUR_API_KEY' | ||
| # Set your authentication headers (required for authenticated endpoints) | ||
| config.default_headers = { | ||
| 'x-client-key' => 'YOUR_CLIENT_KEY', | ||
| 'x-secret-key' => 'YOUR_SECRET_KEY' | ||
| } | ||
@@ -44,45 +47,109 @@ # Optional: Set a custom base URL if needed | ||
| You can generate your client key and secret key from the [Devdraft Console](https://console.devdraft.ai) under App Settings. | ||
| ### Examples | ||
| #### Health Check | ||
| #### Basic Setup | ||
| ```ruby | ||
| api_instance = Devdraft::APIHealthApi.new | ||
| require 'devdraft' | ||
| # Public health check (no auth required) | ||
| result = api_instance.health_controller_public_health_check_v0 | ||
| puts result.inspect | ||
| # Authenticated health check | ||
| result = api_instance.health_controller_check_v0 | ||
| puts result.inspect | ||
| # 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 | ||
| ``` | ||
| #### List Customers | ||
| You can generate your client key and secret key from the [Devdraft Console](https://console.devdraft.ai) under App Settings. | ||
| #### Create a Customer | ||
| ```ruby | ||
| api_instance = Devdraft::CustomersApi.new | ||
| # List customers with pagination | ||
| result = api_instance.customers_controller_list_v0( | ||
| page: 1, | ||
| limit: 10 | ||
| # Create a new customer | ||
| customer_data = Devdraft::CreateCustomerDto.new( | ||
| email: 'customer@example.com', | ||
| name: 'John Doe', | ||
| status: 'active' | ||
| ) | ||
| puts result.inspect | ||
| 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 Payment Link | ||
| #### Create a Payment Link | ||
| ```ruby | ||
| api_instance = Devdraft::PaymentLinksApi.new | ||
| # Create a payment link | ||
| # Create a payment link for a product | ||
| payment_link = Devdraft::CreatePaymentLinkDto.new( | ||
| amount: 100.00, | ||
| amount: 99.99, | ||
| currency: 'USD', | ||
| description: 'Test Payment Link', | ||
| expires_at: (Time.now + 86400).iso8601 # 24 hours from now | ||
| 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 | ||
| ) | ||
| ] | ||
| ) | ||
| result = api_instance.payment_links_controller_create_v0(payment_link) | ||
| puts result.inspect | ||
| 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 | ||
| ```ruby | ||
| 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 | ||
| ```ruby | ||
| 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 | ||
@@ -89,0 +156,0 @@ |