/*
Daytona

Daytona AI platform API Docs

API version: 1.0
Contact: support@daytona.com
*/

// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.

package apiclient

import (
	"encoding/json"
	"time"
	"fmt"
)

// checks if the CreateOrganizationInvitation type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &CreateOrganizationInvitation{}

// CreateOrganizationInvitation struct for CreateOrganizationInvitation
type CreateOrganizationInvitation struct {
	// Email address of the invitee
	Email string `json:"email"`
	// Organization member role for the invitee
	Role string `json:"role"`
	// Array of assigned role IDs for the invitee
	AssignedRoleIds []string `json:"assignedRoleIds"`
	// Expiration date of the invitation
	ExpiresAt *time.Time `json:"expiresAt,omitempty"`
	AdditionalProperties map[string]interface{}
}

type _CreateOrganizationInvitation CreateOrganizationInvitation

// NewCreateOrganizationInvitation instantiates a new CreateOrganizationInvitation object
// This constructor will assign default values to properties that have it defined,
// and makes sure properties required by API are set, but the set of arguments
// will change when the set of required properties is changed
func NewCreateOrganizationInvitation(email string, role string, assignedRoleIds []string) *CreateOrganizationInvitation {
	this := CreateOrganizationInvitation{}
	this.Email = email
	this.Role = role
	this.AssignedRoleIds = assignedRoleIds
	return &this
}

// NewCreateOrganizationInvitationWithDefaults instantiates a new CreateOrganizationInvitation object
// This constructor will only assign default values to properties that have it defined,
// but it doesn't guarantee that properties required by API are set
func NewCreateOrganizationInvitationWithDefaults() *CreateOrganizationInvitation {
	this := CreateOrganizationInvitation{}
	var role string = "member"
	this.Role = role
	return &this
}

// GetEmail returns the Email field value
func (o *CreateOrganizationInvitation) GetEmail() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Email
}

// GetEmailOk returns a tuple with the Email field value
// and a boolean to check if the value has been set.
func (o *CreateOrganizationInvitation) GetEmailOk() (*string, bool) {
	if o == nil {
		return nil, false
	}
	return &o.Email, true
}

// SetEmail sets field value
func (o *CreateOrganizationInvitation) SetEmail(v string) {
	o.Email = v
}

// GetRole returns the Role field value
func (o *CreateOrganizationInvitation) GetRole() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Role
}

// GetRoleOk returns a tuple with the Role field value
// and a boolean to check if the value has been set.
func (o *CreateOrganizationInvitation) GetRoleOk() (*string, bool) {
	if o == nil {
		return nil, false
	}
	return &o.Role, true
}

// SetRole sets field value
func (o *CreateOrganizationInvitation) SetRole(v string) {
	o.Role = v
}

// GetAssignedRoleIds returns the AssignedRoleIds field value
func (o *CreateOrganizationInvitation) GetAssignedRoleIds() []string {
	if o == nil {
		var ret []string
		return ret
	}

	return o.AssignedRoleIds
}

// GetAssignedRoleIdsOk returns a tuple with the AssignedRoleIds field value
// and a boolean to check if the value has been set.
func (o *CreateOrganizationInvitation) GetAssignedRoleIdsOk() ([]string, bool) {
	if o == nil {
		return nil, false
	}
	return o.AssignedRoleIds, true
}

// SetAssignedRoleIds sets field value
func (o *CreateOrganizationInvitation) SetAssignedRoleIds(v []string) {
	o.AssignedRoleIds = v
}

// GetExpiresAt returns the ExpiresAt field value if set, zero value otherwise.
func (o *CreateOrganizationInvitation) GetExpiresAt() time.Time {
	if o == nil || IsNil(o.ExpiresAt) {
		var ret time.Time
		return ret
	}
	return *o.ExpiresAt
}

// GetExpiresAtOk returns a tuple with the ExpiresAt field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *CreateOrganizationInvitation) GetExpiresAtOk() (*time.Time, bool) {
	if o == nil || IsNil(o.ExpiresAt) {
		return nil, false
	}
	return o.ExpiresAt, true
}

// HasExpiresAt returns a boolean if a field has been set.
func (o *CreateOrganizationInvitation) HasExpiresAt() bool {
	if o != nil && !IsNil(o.ExpiresAt) {
		return true
	}

	return false
}

// SetExpiresAt gets a reference to the given time.Time and assigns it to the ExpiresAt field.
func (o *CreateOrganizationInvitation) SetExpiresAt(v time.Time) {
	o.ExpiresAt = &v
}

func (o CreateOrganizationInvitation) MarshalJSON() ([]byte, error) {
	toSerialize,err := o.ToMap()
	if err != nil {
		return []byte{}, err
	}
	return json.Marshal(toSerialize)
}

func (o CreateOrganizationInvitation) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["email"] = o.Email
	toSerialize["role"] = o.Role
	toSerialize["assignedRoleIds"] = o.AssignedRoleIds
	if !IsNil(o.ExpiresAt) {
		toSerialize["expiresAt"] = o.ExpiresAt
	}

	for key, value := range o.AdditionalProperties {
		toSerialize[key] = value
	}

	return toSerialize, nil
}

func (o *CreateOrganizationInvitation) UnmarshalJSON(data []byte) (err error) {
	// This validates that all required properties are included in the JSON object
	// by unmarshalling the object into a generic map with string keys and checking
	// that every required field exists as a key in the generic map.
	requiredProperties := []string{
		"email",
		"role",
		"assignedRoleIds",
	}

	allProperties := make(map[string]interface{})

	err = json.Unmarshal(data, &allProperties)

	if err != nil {
		return err;
	}

	for _, requiredProperty := range(requiredProperties) {
		if _, exists := allProperties[requiredProperty]; !exists {
			return fmt.Errorf("no value given for required property %v", requiredProperty)
		}
	}

	varCreateOrganizationInvitation := _CreateOrganizationInvitation{}

	err = json.Unmarshal(data, &varCreateOrganizationInvitation)

	if err != nil {
		return err
	}

	*o = CreateOrganizationInvitation(varCreateOrganizationInvitation)

	additionalProperties := make(map[string]interface{})

	if err = json.Unmarshal(data, &additionalProperties); err == nil {
		delete(additionalProperties, "email")
		delete(additionalProperties, "role")
		delete(additionalProperties, "assignedRoleIds")
		delete(additionalProperties, "expiresAt")
		o.AdditionalProperties = additionalProperties
	}

	return err
}

type NullableCreateOrganizationInvitation struct {
	value *CreateOrganizationInvitation
	isSet bool
}

func (v NullableCreateOrganizationInvitation) Get() *CreateOrganizationInvitation {
	return v.value
}

func (v *NullableCreateOrganizationInvitation) Set(val *CreateOrganizationInvitation) {
	v.value = val
	v.isSet = true
}

func (v NullableCreateOrganizationInvitation) IsSet() bool {
	return v.isSet
}

func (v *NullableCreateOrganizationInvitation) Unset() {
	v.value = nil
	v.isSet = false
}

func NewNullableCreateOrganizationInvitation(val *CreateOrganizationInvitation) *NullableCreateOrganizationInvitation {
	return &NullableCreateOrganizationInvitation{value: val, isSet: true}
}

func (v NullableCreateOrganizationInvitation) MarshalJSON() ([]byte, error) {
	return json.Marshal(v.value)
}

func (v *NullableCreateOrganizationInvitation) UnmarshalJSON(src []byte) error {
	v.isSet = true
	return json.Unmarshal(src, &v.value)
}


