from __future__ import annotations
from collections.abc import Callable
from dataclasses import dataclass, field
from kiota_abstractions.serialization import Parsable, ParseNode, SerializationWriter
from typing import Any, Optional, TYPE_CHECKING, Union

if TYPE_CHECKING:
    from .users_import_post_request_body_users_products import UsersImportPostRequestBody_users_products

@dataclass
class UsersImportPostRequestBody_users(Parsable):
    # The ID of the company that the user is representing in the project. To obtain a list of all company IDs associated with a project, call `GET projects/:projectId/companies </en/docs/acc/v1/reference/http/projects-:project_id-companies-GET/>`_.
    company_id: Optional[str] = None
    # The email of the user.Max length: 255
    email: Optional[str] = None
    # The first name of the user.Max length: 255
    first_name: Optional[str] = None
    # The last name of the user.Max length: 255
    last_name: Optional[str] = None
    # Information about the products activated in the specified project for this imported user.
    products: Optional[list[UsersImportPostRequestBody_users_products]] = None
    # A list of the IDs of the user's roles in the project.To obtain role IDs for this parameter, you can call `GET projects/:projectId/users </en/docs/acc/v1/reference/http/admin-projects-projectId-users-GET/>`_ endpoint or `GET projects/:projectId/users/:userId </en/docs/acc/v1/reference/http/admin-projects-projectId-users-userId-GET/>`_ and inspect the ``roleId`` field in the response.
    role_ids: Optional[list[str]] = None
    # Not relevant
    user_id: Optional[str] = None
    
    @staticmethod
    def create_from_discriminator_value(parse_node: ParseNode) -> UsersImportPostRequestBody_users:
        """
        Creates a new instance of the appropriate class based on discriminator value
        param parse_node: The parse node to use to read the discriminator value and create the object
        Returns: UsersImportPostRequestBody_users
        """
        if parse_node is None:
            raise TypeError("parse_node cannot be null.")
        return UsersImportPostRequestBody_users()
    
    def get_field_deserializers(self,) -> dict[str, Callable[[ParseNode], None]]:
        """
        The deserialization information for the current model
        Returns: dict[str, Callable[[ParseNode], None]]
        """
        from .users_import_post_request_body_users_products import UsersImportPostRequestBody_users_products

        from .users_import_post_request_body_users_products import UsersImportPostRequestBody_users_products

        fields: dict[str, Callable[[Any], None]] = {
            "companyId": lambda n : setattr(self, 'company_id', n.get_str_value()),
            "email": lambda n : setattr(self, 'email', n.get_str_value()),
            "firstName": lambda n : setattr(self, 'first_name', n.get_str_value()),
            "lastName": lambda n : setattr(self, 'last_name', n.get_str_value()),
            "products": lambda n : setattr(self, 'products', n.get_collection_of_object_values(UsersImportPostRequestBody_users_products)),
            "roleIds": lambda n : setattr(self, 'role_ids', n.get_collection_of_primitive_values(str)),
            "userId": lambda n : setattr(self, 'user_id', n.get_str_value()),
        }
        return fields
    
    def serialize(self,writer: SerializationWriter) -> None:
        """
        Serializes information the current object
        param writer: Serialization writer to use to serialize this model
        Returns: None
        """
        if writer is None:
            raise TypeError("writer cannot be null.")
        writer.write_str_value("companyId", self.company_id)
        writer.write_str_value("email", self.email)
        writer.write_str_value("firstName", self.first_name)
        writer.write_str_value("lastName", self.last_name)
        writer.write_collection_of_object_values("products", self.products)
        writer.write_collection_of_primitive_values("roleIds", self.role_ids)
        writer.write_str_value("userId", self.user_id)
    

