Documentation
¶
Overview ¶
Package main provides a comprehensive example of using the Midaz Go SDK.
Complete Workflow Example ¶
This example demonstrates a complete workflow using the Midaz Go SDK, including: - Creating organizations - Creating ledgers - Creating assets - Creating accounts - Performing transactions - Creating segments and portfolios - Listing accounts - Updating and retrieving organizations
Server Requirements ¶
IMPORTANT: This example requires a running Midaz server and does NOT run in mock mode. To start the server locally, run the following command from the project root:
make up
This will start all necessary services using Docker Compose. The server does not include an OAuth2 layer in local development mode, so you can use any string as the authentication token.
Environment Configuration ¶
The example uses the SDK's config package to load configuration from environment variables. You can set these variables in a .env file:
MIDAZ_AUTH_TOKEN=example-auth-token MIDAZ_ENVIRONMENT=local # Can be local, development, or production MIDAZ_ONBOARDING_URL=http://localhost:3000/v1 # Optional override MIDAZ_TRANSACTION_URL=http://localhost:3001/v1 # Optional override MIDAZ_DEBUG=true # Optional, enables detailed API logging
Workflow Steps ¶
The example follows these steps: 1. Organization Creation - Creates a new organization 2. Ledger Creation - Creates a ledger within the organization 3. Asset Creation - Creates a USD asset 4. Account Creation - Creates customer and merchant accounts 5. Transaction Execution - Transfers funds between accounts using DSL 6. Segment Creation - Creates a segment for account categorization 7. Portfolio Creation - Creates a portfolio for account grouping 8. Account Listing - Lists all accounts in the ledger 9. Organization Update - Updates the organization details 10. Organization Retrieval - Retrieves the updated organization
Error Handling ¶
The example includes comprehensive error handling to demonstrate best practices for working with the Midaz API. Each step checks for errors and provides meaningful error messages to help with troubleshooting.