Files
portal/openapi/model_card.go
2026-08-04 15:28:33 +02:00

347 lines
7.7 KiB
Go

/*
FastAPI
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
API version: 0.1.0
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package openapi
import (
"encoding/json"
"bytes"
"fmt"
)
// checks if the Card type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &Card{}
// Card struct for Card
type Card struct {
Id NullableInt32 `json:"id,omitempty"`
Key string `json:"key"`
CardSerial string `json:"card_serial"`
Enabled *bool `json:"enabled,omitempty"`
Name string `json:"name"`
GroupId NullableInt32 `json:"group_id,omitempty"`
}
type _Card Card
// NewCard instantiates a new Card 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 NewCard(key string, cardSerial string, name string) *Card {
this := Card{}
this.Key = key
this.CardSerial = cardSerial
var enabled bool = true
this.Enabled = &enabled
this.Name = name
return &this
}
// NewCardWithDefaults instantiates a new Card 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 NewCardWithDefaults() *Card {
this := Card{}
var enabled bool = true
this.Enabled = &enabled
return &this
}
// GetId returns the Id field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *Card) GetId() int32 {
if o == nil || IsNil(o.Id.Get()) {
var ret int32
return ret
}
return *o.Id.Get()
}
// GetIdOk returns a tuple with the Id field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *Card) GetIdOk() (*int32, bool) {
if o == nil {
return nil, false
}
return o.Id.Get(), o.Id.IsSet()
}
// HasId returns a boolean if a field has been set.
func (o *Card) HasId() bool {
if o != nil && o.Id.IsSet() {
return true
}
return false
}
// SetId gets a reference to the given NullableInt32 and assigns it to the Id field.
func (o *Card) SetId(v int32) {
o.Id.Set(&v)
}
// SetIdNil sets the value for Id to be an explicit nil
func (o *Card) SetIdNil() {
o.Id.Set(nil)
}
// UnsetId ensures that no value is present for Id, not even an explicit nil
func (o *Card) UnsetId() {
o.Id.Unset()
}
// GetKey returns the Key field value
func (o *Card) GetKey() string {
if o == nil {
var ret string
return ret
}
return o.Key
}
// GetKeyOk returns a tuple with the Key field value
// and a boolean to check if the value has been set.
func (o *Card) GetKeyOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Key, true
}
// SetKey sets field value
func (o *Card) SetKey(v string) {
o.Key = v
}
// GetCardSerial returns the CardSerial field value
func (o *Card) GetCardSerial() string {
if o == nil {
var ret string
return ret
}
return o.CardSerial
}
// GetCardSerialOk returns a tuple with the CardSerial field value
// and a boolean to check if the value has been set.
func (o *Card) GetCardSerialOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.CardSerial, true
}
// SetCardSerial sets field value
func (o *Card) SetCardSerial(v string) {
o.CardSerial = v
}
// GetEnabled returns the Enabled field value if set, zero value otherwise.
func (o *Card) GetEnabled() bool {
if o == nil || IsNil(o.Enabled) {
var ret bool
return ret
}
return *o.Enabled
}
// GetEnabledOk returns a tuple with the Enabled field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *Card) GetEnabledOk() (*bool, bool) {
if o == nil || IsNil(o.Enabled) {
return nil, false
}
return o.Enabled, true
}
// HasEnabled returns a boolean if a field has been set.
func (o *Card) HasEnabled() bool {
if o != nil && !IsNil(o.Enabled) {
return true
}
return false
}
// SetEnabled gets a reference to the given bool and assigns it to the Enabled field.
func (o *Card) SetEnabled(v bool) {
o.Enabled = &v
}
// GetName returns the Name field value
func (o *Card) GetName() string {
if o == nil {
var ret string
return ret
}
return o.Name
}
// GetNameOk returns a tuple with the Name field value
// and a boolean to check if the value has been set.
func (o *Card) GetNameOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Name, true
}
// SetName sets field value
func (o *Card) SetName(v string) {
o.Name = v
}
// GetGroupId returns the GroupId field value if set, zero value otherwise (both if not set or set to explicit null).
func (o *Card) GetGroupId() int32 {
if o == nil || IsNil(o.GroupId.Get()) {
var ret int32
return ret
}
return *o.GroupId.Get()
}
// GetGroupIdOk returns a tuple with the GroupId field value if set, nil otherwise
// and a boolean to check if the value has been set.
// NOTE: If the value is an explicit nil, `nil, true` will be returned
func (o *Card) GetGroupIdOk() (*int32, bool) {
if o == nil {
return nil, false
}
return o.GroupId.Get(), o.GroupId.IsSet()
}
// HasGroupId returns a boolean if a field has been set.
func (o *Card) HasGroupId() bool {
if o != nil && o.GroupId.IsSet() {
return true
}
return false
}
// SetGroupId gets a reference to the given NullableInt32 and assigns it to the GroupId field.
func (o *Card) SetGroupId(v int32) {
o.GroupId.Set(&v)
}
// SetGroupIdNil sets the value for GroupId to be an explicit nil
func (o *Card) SetGroupIdNil() {
o.GroupId.Set(nil)
}
// UnsetGroupId ensures that no value is present for GroupId, not even an explicit nil
func (o *Card) UnsetGroupId() {
o.GroupId.Unset()
}
func (o Card) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o Card) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
if o.Id.IsSet() {
toSerialize["id"] = o.Id.Get()
}
toSerialize["key"] = o.Key
toSerialize["card_serial"] = o.CardSerial
if !IsNil(o.Enabled) {
toSerialize["enabled"] = o.Enabled
}
toSerialize["name"] = o.Name
if o.GroupId.IsSet() {
toSerialize["group_id"] = o.GroupId.Get()
}
return toSerialize, nil
}
func (o *Card) 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{
"key",
"card_serial",
"name",
}
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)
}
}
varCard := _Card{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varCard)
if err != nil {
return err
}
*o = Card(varCard)
return err
}
type NullableCard struct {
value *Card
isSet bool
}
func (v NullableCard) Get() *Card {
return v.value
}
func (v *NullableCard) Set(val *Card) {
v.value = val
v.isSet = true
}
func (v NullableCard) IsSet() bool {
return v.isSet
}
func (v *NullableCard) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableCard(val *Card) *NullableCard {
return &NullableCard{value: val, isSet: true}
}
func (v NullableCard) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableCard) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}