Documentation Index
Fetch the complete documentation index at: https://mintlify.com/zitadel/client-ruby/llms.txt
Use this file to discover all available pages before exploring further.
What are Models?
Models in the Zitadel Ruby SDK are Ruby classes that represent data structures returned from or sent to the Zitadel API. They provide a structured way to work with Zitadel resources such as users, organizations, and applications. All model classes are located in theZitadel::Client::Models module and are automatically generated from the Zitadel OpenAPI specification.
How Models Work
Models provide several key features:Attribute Accessors
Each model exposes attributes as Ruby attr_accessors, allowing you to read and write properties using standard Ruby syntax:Initialization from Hash
Models can be initialized from a hash of attributes:JSON Mapping
Models automatically handle conversion between Ruby naming conventions (snake_case) and JSON naming conventions (camelCase):- Ruby:
user_id,preferred_login_name - JSON:
userId,preferredLoginName
Serialization and Deserialization
Converting to Hash/JSON
Models provide methods to convert to Ruby hashes and JSON:Building from API Response
The SDK automatically deserializes API responses into model objects:Manual Deserialization
You can also manually deserialize data:Type Safety
Each model defines its attribute types through theopenapi_types method:
Nested Models
Many models contain nested model objects. For example,UserServiceUser can contain a UserServiceHumanUser object:
Common Patterns
Checking User Type
Working with Arrays
Many models contain array attributes:Handling Timestamps
Timestamp fields are automatically parsed into RubyTime objects:
Model Categories
The SDK includes models organized by resource type:- User Models - User, HumanUser, MachineUser, profile, email, phone, etc.
- Organization Models - Organization, Domain, and organization-related structures
- Application Models - Application, OIDC, API, and SAML configurations
Error Handling
Models validate input during initialization:Best Practices
- Use type information - Check the
openapi_typesto understand expected data types - Handle nil values - Not all attributes are always present; check for nil before accessing nested objects
- Use build_from_hash - When working with raw API data, use
build_from_hashfor proper type conversion - Leverage attribute mapping - Let the SDK handle JSON naming conversions automatically
- Check nullable attributes - Use
openapi_nullableto see which attributes can be nil
Next Steps
- Explore User Models for user-related data structures
- Learn about Organization Models for organization resources
- Review Application Models for application configurations