model_game_news_item.go•6.31 kB
/*
GameBrain API
GameBrain API
API version: 1.0.1
Contact: mail@gamebrain.co
*/
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
package gamebrain
import (
"encoding/json"
"bytes"
"fmt"
)
// checks if the GameNewsItem type satisfies the MappedNullable interface at compile time
var _ MappedNullable = &GameNewsItem{}
// GameNewsItem struct for GameNewsItem
type GameNewsItem struct {
Title string `json:"title"`
Url string `json:"url"`
Source string `json:"source"`
Image *string `json:"image,omitempty"`
Published string `json:"published"`
}
type _GameNewsItem GameNewsItem
// NewGameNewsItem instantiates a new GameNewsItem 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 NewGameNewsItem(title string, url string, source string, published string) *GameNewsItem {
this := GameNewsItem{}
this.Title = title
this.Url = url
this.Source = source
this.Published = published
return &this
}
// NewGameNewsItemWithDefaults instantiates a new GameNewsItem 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 NewGameNewsItemWithDefaults() *GameNewsItem {
this := GameNewsItem{}
return &this
}
// GetTitle returns the Title field value
func (o *GameNewsItem) GetTitle() string {
if o == nil {
var ret string
return ret
}
return o.Title
}
// GetTitleOk returns a tuple with the Title field value
// and a boolean to check if the value has been set.
func (o *GameNewsItem) GetTitleOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Title, true
}
// SetTitle sets field value
func (o *GameNewsItem) SetTitle(v string) {
o.Title = v
}
// GetUrl returns the Url field value
func (o *GameNewsItem) GetUrl() string {
if o == nil {
var ret string
return ret
}
return o.Url
}
// GetUrlOk returns a tuple with the Url field value
// and a boolean to check if the value has been set.
func (o *GameNewsItem) GetUrlOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Url, true
}
// SetUrl sets field value
func (o *GameNewsItem) SetUrl(v string) {
o.Url = v
}
// GetSource returns the Source field value
func (o *GameNewsItem) GetSource() string {
if o == nil {
var ret string
return ret
}
return o.Source
}
// GetSourceOk returns a tuple with the Source field value
// and a boolean to check if the value has been set.
func (o *GameNewsItem) GetSourceOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Source, true
}
// SetSource sets field value
func (o *GameNewsItem) SetSource(v string) {
o.Source = v
}
// GetImage returns the Image field value if set, zero value otherwise.
func (o *GameNewsItem) GetImage() string {
if o == nil || IsNil(o.Image) {
var ret string
return ret
}
return *o.Image
}
// GetImageOk returns a tuple with the Image field value if set, nil otherwise
// and a boolean to check if the value has been set.
func (o *GameNewsItem) GetImageOk() (*string, bool) {
if o == nil || IsNil(o.Image) {
return nil, false
}
return o.Image, true
}
// HasImage returns a boolean if a field has been set.
func (o *GameNewsItem) HasImage() bool {
if o != nil && !IsNil(o.Image) {
return true
}
return false
}
// SetImage gets a reference to the given string and assigns it to the Image field.
func (o *GameNewsItem) SetImage(v string) {
o.Image = &v
}
// GetPublished returns the Published field value
func (o *GameNewsItem) GetPublished() string {
if o == nil {
var ret string
return ret
}
return o.Published
}
// GetPublishedOk returns a tuple with the Published field value
// and a boolean to check if the value has been set.
func (o *GameNewsItem) GetPublishedOk() (*string, bool) {
if o == nil {
return nil, false
}
return &o.Published, true
}
// SetPublished sets field value
func (o *GameNewsItem) SetPublished(v string) {
o.Published = v
}
func (o GameNewsItem) MarshalJSON() ([]byte, error) {
toSerialize,err := o.ToMap()
if err != nil {
return []byte{}, err
}
return json.Marshal(toSerialize)
}
func (o GameNewsItem) ToMap() (map[string]interface{}, error) {
toSerialize := map[string]interface{}{}
toSerialize["title"] = o.Title
toSerialize["url"] = o.Url
toSerialize["source"] = o.Source
if !IsNil(o.Image) {
toSerialize["image"] = o.Image
}
toSerialize["published"] = o.Published
return toSerialize, nil
}
func (o *GameNewsItem) 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{
"title",
"url",
"source",
"published",
}
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)
}
}
varGameNewsItem := _GameNewsItem{}
decoder := json.NewDecoder(bytes.NewReader(data))
decoder.DisallowUnknownFields()
err = decoder.Decode(&varGameNewsItem)
if err != nil {
return err
}
*o = GameNewsItem(varGameNewsItem)
return err
}
type NullableGameNewsItem struct {
value *GameNewsItem
isSet bool
}
func (v NullableGameNewsItem) Get() *GameNewsItem {
return v.value
}
func (v *NullableGameNewsItem) Set(val *GameNewsItem) {
v.value = val
v.isSet = true
}
func (v NullableGameNewsItem) IsSet() bool {
return v.isSet
}
func (v *NullableGameNewsItem) Unset() {
v.value = nil
v.isSet = false
}
func NewNullableGameNewsItem(val *GameNewsItem) *NullableGameNewsItem {
return &NullableGameNewsItem{value: val, isSet: true}
}
func (v NullableGameNewsItem) MarshalJSON() ([]byte, error) {
return json.Marshal(v.value)
}
func (v *NullableGameNewsItem) UnmarshalJSON(src []byte) error {
v.isSet = true
return json.Unmarshal(src, &v.value)
}