/*
1Backend

AI-native microservices platform.

API version: 0.8.2
Contact: sales@singulatron.com
*/

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

package openapi

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

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

// UserSvcEnroll struct for UserSvcEnroll
type UserSvcEnroll struct {
	// App of the enroll. Use `*` to match all apps, such as when bootstrapping in services.
	AppId string `json:"appId"`
	// ContactId is the the recipient of the enroll. If the user is already registered, the role is assigned immediately; otherwise, it is applied upon registration.
	ContactId *string `json:"contactId,omitempty"`
	CreatedAt string `json:"createdAt"`
	// CreatedBy contains the ID of the user who created the Enroll.
	CreatedBy *string `json:"createdBy,omitempty"`
	DeletedAt *string `json:"deletedAt,omitempty"`
	Id string `json:"id"`
	InternalId *string `json:"internalId,omitempty"`
	// Role specifies the role to be assigned to the ContactId. Callers can only assign roles they own, identified by their service slug (e.g., if \"my-service\" creates an enroll, the role must be \"my-service:admin\"). Dynamic organization roles can also be assigned (e.g., \"user-svc:org:{%orgId}:admin\" or \"user-svc:org:{%orgId}:user\"), but in this case, the caller must be an admin of the target organization.
	Role string `json:"role"`
	UpdatedAt string `json:"updatedAt"`
	// UserId is the recipient of the enroll. If the user is already registered, the role is assigned immediately; otherwise, it is applied upon registration.
	UserId *string `json:"userId,omitempty"`
}

type _UserSvcEnroll UserSvcEnroll

// NewUserSvcEnroll instantiates a new UserSvcEnroll 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 NewUserSvcEnroll(appId string, createdAt string, id string, role string, updatedAt string) *UserSvcEnroll {
	this := UserSvcEnroll{}
	this.AppId = appId
	this.CreatedAt = createdAt
	this.Id = id
	this.Role = role
	this.UpdatedAt = updatedAt
	return &this
}

// NewUserSvcEnrollWithDefaults instantiates a new UserSvcEnroll 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 NewUserSvcEnrollWithDefaults() *UserSvcEnroll {
	this := UserSvcEnroll{}
	return &this
}

// GetAppId returns the AppId field value
func (o *UserSvcEnroll) GetAppId() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.AppId
}

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

// SetAppId sets field value
func (o *UserSvcEnroll) SetAppId(v string) {
	o.AppId = v
}

// GetContactId returns the ContactId field value if set, zero value otherwise.
func (o *UserSvcEnroll) GetContactId() string {
	if o == nil || IsNil(o.ContactId) {
		var ret string
		return ret
	}
	return *o.ContactId
}

// GetContactIdOk returns a tuple with the ContactId field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *UserSvcEnroll) GetContactIdOk() (*string, bool) {
	if o == nil || IsNil(o.ContactId) {
		return nil, false
	}
	return o.ContactId, true
}

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

	return false
}

// SetContactId gets a reference to the given string and assigns it to the ContactId field.
func (o *UserSvcEnroll) SetContactId(v string) {
	o.ContactId = &v
}

// GetCreatedAt returns the CreatedAt field value
func (o *UserSvcEnroll) GetCreatedAt() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.CreatedAt
}

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

// SetCreatedAt sets field value
func (o *UserSvcEnroll) SetCreatedAt(v string) {
	o.CreatedAt = v
}

// GetCreatedBy returns the CreatedBy field value if set, zero value otherwise.
func (o *UserSvcEnroll) GetCreatedBy() string {
	if o == nil || IsNil(o.CreatedBy) {
		var ret string
		return ret
	}
	return *o.CreatedBy
}

// GetCreatedByOk returns a tuple with the CreatedBy field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *UserSvcEnroll) GetCreatedByOk() (*string, bool) {
	if o == nil || IsNil(o.CreatedBy) {
		return nil, false
	}
	return o.CreatedBy, true
}

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

	return false
}

// SetCreatedBy gets a reference to the given string and assigns it to the CreatedBy field.
func (o *UserSvcEnroll) SetCreatedBy(v string) {
	o.CreatedBy = &v
}

// GetDeletedAt returns the DeletedAt field value if set, zero value otherwise.
func (o *UserSvcEnroll) GetDeletedAt() string {
	if o == nil || IsNil(o.DeletedAt) {
		var ret string
		return ret
	}
	return *o.DeletedAt
}

// GetDeletedAtOk returns a tuple with the DeletedAt field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *UserSvcEnroll) GetDeletedAtOk() (*string, bool) {
	if o == nil || IsNil(o.DeletedAt) {
		return nil, false
	}
	return o.DeletedAt, true
}

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

	return false
}

// SetDeletedAt gets a reference to the given string and assigns it to the DeletedAt field.
func (o *UserSvcEnroll) SetDeletedAt(v string) {
	o.DeletedAt = &v
}

// GetId returns the Id field value
func (o *UserSvcEnroll) GetId() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Id
}

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

// SetId sets field value
func (o *UserSvcEnroll) SetId(v string) {
	o.Id = v
}

// GetInternalId returns the InternalId field value if set, zero value otherwise.
func (o *UserSvcEnroll) GetInternalId() string {
	if o == nil || IsNil(o.InternalId) {
		var ret string
		return ret
	}
	return *o.InternalId
}

// GetInternalIdOk returns a tuple with the InternalId field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *UserSvcEnroll) GetInternalIdOk() (*string, bool) {
	if o == nil || IsNil(o.InternalId) {
		return nil, false
	}
	return o.InternalId, true
}

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

	return false
}

// SetInternalId gets a reference to the given string and assigns it to the InternalId field.
func (o *UserSvcEnroll) SetInternalId(v string) {
	o.InternalId = &v
}

// GetRole returns the Role field value
func (o *UserSvcEnroll) 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 *UserSvcEnroll) GetRoleOk() (*string, bool) {
	if o == nil {
		return nil, false
	}
	return &o.Role, true
}

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

// GetUpdatedAt returns the UpdatedAt field value
func (o *UserSvcEnroll) GetUpdatedAt() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.UpdatedAt
}

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

// SetUpdatedAt sets field value
func (o *UserSvcEnroll) SetUpdatedAt(v string) {
	o.UpdatedAt = v
}

// GetUserId returns the UserId field value if set, zero value otherwise.
func (o *UserSvcEnroll) GetUserId() string {
	if o == nil || IsNil(o.UserId) {
		var ret string
		return ret
	}
	return *o.UserId
}

// GetUserIdOk returns a tuple with the UserId field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *UserSvcEnroll) GetUserIdOk() (*string, bool) {
	if o == nil || IsNil(o.UserId) {
		return nil, false
	}
	return o.UserId, true
}

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

	return false
}

// SetUserId gets a reference to the given string and assigns it to the UserId field.
func (o *UserSvcEnroll) SetUserId(v string) {
	o.UserId = &v
}

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

func (o UserSvcEnroll) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["appId"] = o.AppId
	if !IsNil(o.ContactId) {
		toSerialize["contactId"] = o.ContactId
	}
	toSerialize["createdAt"] = o.CreatedAt
	if !IsNil(o.CreatedBy) {
		toSerialize["createdBy"] = o.CreatedBy
	}
	if !IsNil(o.DeletedAt) {
		toSerialize["deletedAt"] = o.DeletedAt
	}
	toSerialize["id"] = o.Id
	if !IsNil(o.InternalId) {
		toSerialize["internalId"] = o.InternalId
	}
	toSerialize["role"] = o.Role
	toSerialize["updatedAt"] = o.UpdatedAt
	if !IsNil(o.UserId) {
		toSerialize["userId"] = o.UserId
	}
	return toSerialize, nil
}

func (o *UserSvcEnroll) 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{
		"appId",
		"createdAt",
		"id",
		"role",
		"updatedAt",
	}

	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)
		}
	}

	varUserSvcEnroll := _UserSvcEnroll{}

	decoder := json.NewDecoder(bytes.NewReader(data))
	decoder.DisallowUnknownFields()
	err = decoder.Decode(&varUserSvcEnroll)

	if err != nil {
		return err
	}

	*o = UserSvcEnroll(varUserSvcEnroll)

	return err
}

type NullableUserSvcEnroll struct {
	value *UserSvcEnroll
	isSet bool
}

func (v NullableUserSvcEnroll) Get() *UserSvcEnroll {
	return v.value
}

func (v *NullableUserSvcEnroll) Set(val *UserSvcEnroll) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableUserSvcEnroll(val *UserSvcEnroll) *NullableUserSvcEnroll {
	return &NullableUserSvcEnroll{value: val, isSet: true}
}

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

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


