/*
authentik

Making authentication simple.

API version: 2026.5.0-rc1
Contact: hello@goauthentik.io
*/

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

package api

import (
	"encoding/json"
	"fmt"
)

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

// TelegramChallengeResponseRequest Base class for all challenge responses
type TelegramChallengeResponseRequest struct {
	Id                   int32   `json:"id"`
	FirstName            *string `json:"first_name,omitempty"`
	LastName             *string `json:"last_name,omitempty"`
	Username             *string `json:"username,omitempty"`
	PhotoUrl             *string `json:"photo_url,omitempty"`
	AuthDate             int32   `json:"auth_date"`
	Hash                 string  `json:"hash"`
	Component            *string `json:"component,omitempty"`
	AdditionalProperties map[string]interface{}
}

type _TelegramChallengeResponseRequest TelegramChallengeResponseRequest

// NewTelegramChallengeResponseRequest instantiates a new TelegramChallengeResponseRequest 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 NewTelegramChallengeResponseRequest(id int32, authDate int32, hash string) *TelegramChallengeResponseRequest {
	this := TelegramChallengeResponseRequest{}
	this.Id = id
	this.AuthDate = authDate
	this.Hash = hash
	var component string = "ak-source-telegram"
	this.Component = &component
	return &this
}

// NewTelegramChallengeResponseRequestWithDefaults instantiates a new TelegramChallengeResponseRequest 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 NewTelegramChallengeResponseRequestWithDefaults() *TelegramChallengeResponseRequest {
	this := TelegramChallengeResponseRequest{}
	var component string = "ak-source-telegram"
	this.Component = &component
	return &this
}

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

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

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

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

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

	return false
}

// SetFirstName gets a reference to the given string and assigns it to the FirstName field.
func (o *TelegramChallengeResponseRequest) SetFirstName(v string) {
	o.FirstName = &v
}

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

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

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

	return false
}

// SetLastName gets a reference to the given string and assigns it to the LastName field.
func (o *TelegramChallengeResponseRequest) SetLastName(v string) {
	o.LastName = &v
}

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

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

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

	return false
}

// SetUsername gets a reference to the given string and assigns it to the Username field.
func (o *TelegramChallengeResponseRequest) SetUsername(v string) {
	o.Username = &v
}

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

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

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

	return false
}

// SetPhotoUrl gets a reference to the given string and assigns it to the PhotoUrl field.
func (o *TelegramChallengeResponseRequest) SetPhotoUrl(v string) {
	o.PhotoUrl = &v
}

// GetAuthDate returns the AuthDate field value
func (o *TelegramChallengeResponseRequest) GetAuthDate() int32 {
	if o == nil {
		var ret int32
		return ret
	}

	return o.AuthDate
}

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

// SetAuthDate sets field value
func (o *TelegramChallengeResponseRequest) SetAuthDate(v int32) {
	o.AuthDate = v
}

// GetHash returns the Hash field value
func (o *TelegramChallengeResponseRequest) GetHash() string {
	if o == nil {
		var ret string
		return ret
	}

	return o.Hash
}

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

// SetHash sets field value
func (o *TelegramChallengeResponseRequest) SetHash(v string) {
	o.Hash = v
}

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

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

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

	return false
}

// SetComponent gets a reference to the given string and assigns it to the Component field.
func (o *TelegramChallengeResponseRequest) SetComponent(v string) {
	o.Component = &v
}

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

func (o TelegramChallengeResponseRequest) ToMap() (map[string]interface{}, error) {
	toSerialize := map[string]interface{}{}
	toSerialize["id"] = o.Id
	if !IsNil(o.FirstName) {
		toSerialize["first_name"] = o.FirstName
	}
	if !IsNil(o.LastName) {
		toSerialize["last_name"] = o.LastName
	}
	if !IsNil(o.Username) {
		toSerialize["username"] = o.Username
	}
	if !IsNil(o.PhotoUrl) {
		toSerialize["photo_url"] = o.PhotoUrl
	}
	toSerialize["auth_date"] = o.AuthDate
	toSerialize["hash"] = o.Hash
	if !IsNil(o.Component) {
		toSerialize["component"] = o.Component
	}

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

	return toSerialize, nil
}

func (o *TelegramChallengeResponseRequest) 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{
		"id",
		"auth_date",
		"hash",
	}

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

	varTelegramChallengeResponseRequest := _TelegramChallengeResponseRequest{}

	err = json.Unmarshal(data, &varTelegramChallengeResponseRequest)

	if err != nil {
		return err
	}

	*o = TelegramChallengeResponseRequest(varTelegramChallengeResponseRequest)

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

	if err = json.Unmarshal(data, &additionalProperties); err == nil {
		delete(additionalProperties, "id")
		delete(additionalProperties, "first_name")
		delete(additionalProperties, "last_name")
		delete(additionalProperties, "username")
		delete(additionalProperties, "photo_url")
		delete(additionalProperties, "auth_date")
		delete(additionalProperties, "hash")
		delete(additionalProperties, "component")
		o.AdditionalProperties = additionalProperties
	}

	return err
}

type NullableTelegramChallengeResponseRequest struct {
	value *TelegramChallengeResponseRequest
	isSet bool
}

func (v NullableTelegramChallengeResponseRequest) Get() *TelegramChallengeResponseRequest {
	return v.value
}

func (v *NullableTelegramChallengeResponseRequest) Set(val *TelegramChallengeResponseRequest) {
	v.value = val
	v.isSet = true
}

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

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

func NewNullableTelegramChallengeResponseRequest(val *TelegramChallengeResponseRequest) *NullableTelegramChallengeResponseRequest {
	return &NullableTelegramChallengeResponseRequest{value: val, isSet: true}
}

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

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