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

// UserSvcToken struct for UserSvcToken
type UserSvcToken struct {
	// Active tokens contain the most up-to-date information. When a user's role changes—due to role assignment, organization creation/assignment, etc.—all existing tokens are marked inactive. Active tokens are reused during login, while inactive tokens that have been recently refreshed (being used still) are kept for further refreshing (unless `OB_TOKEN_AUTO_REFRESH_OFF` is set to true, old tokens can be refreshed indefinitely.)  Active tokens contain the most up-to-date information. When a user's role changes—due to role assignment, organization creation/assignment, etc.—all existing tokens are marked inactive. Active tokens are reused during login, while inactive tokens that have been recently refreshed (see `lastRefreshedAt` field) and are still in use are retained for further refreshing. (Unless `OB_TOKEN_AUTO_REFRESH_OFF` is set to true, in which case old tokens can be refreshed indefinitely.)
	Active *bool `json:"active,omitempty"`
	App *UserSvcApp `json:"app,omitempty"`
	AppId string `json:"appId"`
	CreatedAt string `json:"createdAt"`
	DeletedAt *string `json:"deletedAt,omitempty"`
	// The device the token is associated with. This in combination with LastRefreshedAt can be used to determine if the token is still in use, and lets us prune unused tokens.
	Device string `json:"device"`
	ExpiresAt string `json:"expiresAt"`
	Id string `json:"id"`
	InternalId *string `json:"internalId,omitempty"`
	// The last time the token was refreshed. This is used to determine if the token is still in use.
	LastRefreshedAt *string `json:"lastRefreshedAt,omitempty"`
	// Token is a signed JWT used to authenticate the user without querying the User Svc. You can verify it using the public key at `/user-svc/public-key`.  The token is just a JSON object with fields like: - \"oui\": the user ID (e.g., \"usr_dC4K75Cbp6\") - \"olu\": the user slug (e.g., \"test-user-slug-0\") - \"oro\": a list of roles, such as:   - \"user-svc:user\"   - \"user-svc:org:{org_dC4K7NNDCG}:user\"
	Token string `json:"token"`
	UpdatedAt string `json:"updatedAt"`
	UserId string `json:"userId"`
}

type _UserSvcToken UserSvcToken

// NewUserSvcToken instantiates a new UserSvcToken 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 NewUserSvcToken(appId string, createdAt string, device string, expiresAt string, id string, token string, updatedAt string, userId string) *UserSvcToken {
	this := UserSvcToken{}
	this.AppId = appId
	this.CreatedAt = createdAt
	this.Device = device
	this.ExpiresAt = expiresAt
	this.Id = id
	this.Token = token
	this.UpdatedAt = updatedAt
	this.UserId = userId
	return &this
}

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

// GetActive returns the Active field value if set, zero value otherwise.
func (o *UserSvcToken) GetActive() bool {
	if o == nil || IsNil(o.Active) {
		var ret bool
		return ret
	}
	return *o.Active
}

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

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

	return false
}

// SetActive gets a reference to the given bool and assigns it to the Active field.
func (o *UserSvcToken) SetActive(v bool) {
	o.Active = &v
}

// GetApp returns the App field value if set, zero value otherwise.
func (o *UserSvcToken) GetApp() UserSvcApp {
	if o == nil || IsNil(o.App) {
		var ret UserSvcApp
		return ret
	}
	return *o.App
}

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

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

	return false
}

// SetApp gets a reference to the given UserSvcApp and assigns it to the App field.
func (o *UserSvcToken) SetApp(v UserSvcApp) {
	o.App = &v
}

// GetAppId returns the AppId field value
func (o *UserSvcToken) 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 *UserSvcToken) GetAppIdOk() (*string, bool) {
	if o == nil {
		return nil, false
	}
	return &o.AppId, true
}

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

// GetCreatedAt returns the CreatedAt field value
func (o *UserSvcToken) 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 *UserSvcToken) GetCreatedAtOk() (*string, bool) {
	if o == nil {
		return nil, false
	}
	return &o.CreatedAt, true
}

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

// GetDeletedAt returns the DeletedAt field value if set, zero value otherwise.
func (o *UserSvcToken) 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 *UserSvcToken) 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 *UserSvcToken) 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 *UserSvcToken) SetDeletedAt(v string) {
	o.DeletedAt = &v
}

// GetDevice returns the Device field value
func (o *UserSvcToken) GetDevice() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Device
}

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

// SetDevice sets field value
func (o *UserSvcToken) SetDevice(v string) {
	o.Device = v
}

// GetExpiresAt returns the ExpiresAt field value
func (o *UserSvcToken) GetExpiresAt() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.ExpiresAt
}

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

// SetExpiresAt sets field value
func (o *UserSvcToken) SetExpiresAt(v string) {
	o.ExpiresAt = v
}

// GetId returns the Id field value
func (o *UserSvcToken) 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 *UserSvcToken) GetIdOk() (*string, bool) {
	if o == nil {
		return nil, false
	}
	return &o.Id, true
}

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

// GetInternalId returns the InternalId field value if set, zero value otherwise.
func (o *UserSvcToken) 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 *UserSvcToken) 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 *UserSvcToken) 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 *UserSvcToken) SetInternalId(v string) {
	o.InternalId = &v
}

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

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

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

	return false
}

// SetLastRefreshedAt gets a reference to the given string and assigns it to the LastRefreshedAt field.
func (o *UserSvcToken) SetLastRefreshedAt(v string) {
	o.LastRefreshedAt = &v
}

// GetToken returns the Token field value
func (o *UserSvcToken) GetToken() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Token
}

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

// SetToken sets field value
func (o *UserSvcToken) SetToken(v string) {
	o.Token = v
}

// GetUpdatedAt returns the UpdatedAt field value
func (o *UserSvcToken) 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 *UserSvcToken) GetUpdatedAtOk() (*string, bool) {
	if o == nil {
		return nil, false
	}
	return &o.UpdatedAt, true
}

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

// GetUserId returns the UserId field value
func (o *UserSvcToken) GetUserId() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.UserId
}

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

// SetUserId sets field value
func (o *UserSvcToken) SetUserId(v string) {
	o.UserId = v
}

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

func (o UserSvcToken) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	if !IsNil(o.Active) {
		toSerialize["active"] = o.Active
	}
	if !IsNil(o.App) {
		toSerialize["app"] = o.App
	}
	toSerialize["appId"] = o.AppId
	toSerialize["createdAt"] = o.CreatedAt
	if !IsNil(o.DeletedAt) {
		toSerialize["deletedAt"] = o.DeletedAt
	}
	toSerialize["device"] = o.Device
	toSerialize["expiresAt"] = o.ExpiresAt
	toSerialize["id"] = o.Id
	if !IsNil(o.InternalId) {
		toSerialize["internalId"] = o.InternalId
	}
	if !IsNil(o.LastRefreshedAt) {
		toSerialize["lastRefreshedAt"] = o.LastRefreshedAt
	}
	toSerialize["token"] = o.Token
	toSerialize["updatedAt"] = o.UpdatedAt
	toSerialize["userId"] = o.UserId
	return toSerialize, nil
}

func (o *UserSvcToken) 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",
		"device",
		"expiresAt",
		"id",
		"token",
		"updatedAt",
		"userId",
	}

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

	varUserSvcToken := _UserSvcToken{}

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

	if err != nil {
		return err
	}

	*o = UserSvcToken(varUserSvcToken)

	return err
}

type NullableUserSvcToken struct {
	value *UserSvcToken
	isSet bool
}

func (v NullableUserSvcToken) Get() *UserSvcToken {
	return v.value
}

func (v *NullableUserSvcToken) Set(val *UserSvcToken) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableUserSvcToken(val *UserSvcToken) *NullableUserSvcToken {
	return &NullableUserSvcToken{value: val, isSet: true}
}

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

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


