/*
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 UserSvcReadSelfResponse type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &UserSvcReadSelfResponse{}

// UserSvcReadSelfResponse struct for UserSvcReadSelfResponse
type UserSvcReadSelfResponse struct {
	// Active organization of the caller user, if it has any.
	ActiveOrganizationId *string `json:"activeOrganizationId,omitempty"`
	// Contacts of the caller user.
	Contacts []UserSvcContact `json:"contacts,omitempty"`
	// Organizations of the caller user.
	Organizations []UserSvcOrganization `json:"organizations,omitempty"`
	// Roles the token has that made this request.
	Roles []string `json:"roles,omitempty"`
	TokenCount int32 `json:"tokenCount"`
	// The user who made the request.
	User UserSvcUser `json:"user"`
}

type _UserSvcReadSelfResponse UserSvcReadSelfResponse

// NewUserSvcReadSelfResponse instantiates a new UserSvcReadSelfResponse 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 NewUserSvcReadSelfResponse(tokenCount int32, user UserSvcUser) *UserSvcReadSelfResponse {
	this := UserSvcReadSelfResponse{}
	this.TokenCount = tokenCount
	this.User = user
	return &this
}

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

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

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

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

	return false
}

// SetActiveOrganizationId gets a reference to the given string and assigns it to the ActiveOrganizationId field.
func (o *UserSvcReadSelfResponse) SetActiveOrganizationId(v string) {
	o.ActiveOrganizationId = &v
}

// GetContacts returns the Contacts field value if set, zero value otherwise.
func (o *UserSvcReadSelfResponse) GetContacts() []UserSvcContact {
	if o == nil || IsNil(o.Contacts) {
		var ret []UserSvcContact
		return ret
	}
	return o.Contacts
}

// GetContactsOk returns a tuple with the Contacts field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *UserSvcReadSelfResponse) GetContactsOk() ([]UserSvcContact, bool) {
	if o == nil || IsNil(o.Contacts) {
		return nil, false
	}
	return o.Contacts, true
}

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

	return false
}

// SetContacts gets a reference to the given []UserSvcContact and assigns it to the Contacts field.
func (o *UserSvcReadSelfResponse) SetContacts(v []UserSvcContact) {
	o.Contacts = v
}

// GetOrganizations returns the Organizations field value if set, zero value otherwise.
func (o *UserSvcReadSelfResponse) GetOrganizations() []UserSvcOrganization {
	if o == nil || IsNil(o.Organizations) {
		var ret []UserSvcOrganization
		return ret
	}
	return o.Organizations
}

// GetOrganizationsOk returns a tuple with the Organizations field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *UserSvcReadSelfResponse) GetOrganizationsOk() ([]UserSvcOrganization, bool) {
	if o == nil || IsNil(o.Organizations) {
		return nil, false
	}
	return o.Organizations, true
}

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

	return false
}

// SetOrganizations gets a reference to the given []UserSvcOrganization and assigns it to the Organizations field.
func (o *UserSvcReadSelfResponse) SetOrganizations(v []UserSvcOrganization) {
	o.Organizations = v
}

// GetRoles returns the Roles field value if set, zero value otherwise.
func (o *UserSvcReadSelfResponse) GetRoles() []string {
	if o == nil || IsNil(o.Roles) {
		var ret []string
		return ret
	}
	return o.Roles
}

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

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

	return false
}

// SetRoles gets a reference to the given []string and assigns it to the Roles field.
func (o *UserSvcReadSelfResponse) SetRoles(v []string) {
	o.Roles = v
}

// GetTokenCount returns the TokenCount field value
func (o *UserSvcReadSelfResponse) GetTokenCount() int32 {
	if o == nil {
		var ret int32
		return ret
	}

	return o.TokenCount
}

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

// SetTokenCount sets field value
func (o *UserSvcReadSelfResponse) SetTokenCount(v int32) {
	o.TokenCount = v
}

// GetUser returns the User field value
func (o *UserSvcReadSelfResponse) GetUser() UserSvcUser {
	if o == nil {
		var ret UserSvcUser
		return ret
	}

	return o.User
}

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

// SetUser sets field value
func (o *UserSvcReadSelfResponse) SetUser(v UserSvcUser) {
	o.User = v
}

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

func (o UserSvcReadSelfResponse) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	if !IsNil(o.ActiveOrganizationId) {
		toSerialize["activeOrganizationId"] = o.ActiveOrganizationId
	}
	if !IsNil(o.Contacts) {
		toSerialize["contacts"] = o.Contacts
	}
	if !IsNil(o.Organizations) {
		toSerialize["organizations"] = o.Organizations
	}
	if !IsNil(o.Roles) {
		toSerialize["roles"] = o.Roles
	}
	toSerialize["tokenCount"] = o.TokenCount
	toSerialize["user"] = o.User
	return toSerialize, nil
}

func (o *UserSvcReadSelfResponse) 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{
		"tokenCount",
		"user",
	}

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

	varUserSvcReadSelfResponse := _UserSvcReadSelfResponse{}

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

	if err != nil {
		return err
	}

	*o = UserSvcReadSelfResponse(varUserSvcReadSelfResponse)

	return err
}

type NullableUserSvcReadSelfResponse struct {
	value *UserSvcReadSelfResponse
	isSet bool
}

func (v NullableUserSvcReadSelfResponse) Get() *UserSvcReadSelfResponse {
	return v.value
}

func (v *NullableUserSvcReadSelfResponse) Set(val *UserSvcReadSelfResponse) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableUserSvcReadSelfResponse(val *UserSvcReadSelfResponse) *NullableUserSvcReadSelfResponse {
	return &NullableUserSvcReadSelfResponse{value: val, isSet: true}
}

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

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


