diff --git a/algolia/recommend/model_highlight_result.go b/algolia/recommend/model_highlight_result.go index 7e973f82c..410944238 100644 --- a/algolia/recommend/model_highlight_result.go +++ b/algolia/recommend/model_highlight_result.go @@ -10,10 +10,9 @@ import ( // HighlightResult - struct for HighlightResult. type HighlightResult struct { - HighlightResultOption *HighlightResultOption - ArrayOfHighlightResultOption *[]HighlightResultOption - MapmapOfStringHighlightResult *map[string]HighlightResult - MapmapOfStringHighlightResultOption *map[string]HighlightResultOption + HighlightResultOption *HighlightResultOption + ArrayOfHighlightResult *[]HighlightResult + MapmapOfStringHighlightResult *map[string]HighlightResult } // HighlightResultOptionAsHighlightResult is a convenience function that returns HighlightResultOption wrapped in HighlightResult. @@ -30,17 +29,10 @@ func MapmapOfStringHighlightResultAsHighlightResult(v map[string]HighlightResult } } -// map[string]HighlightResultOptionAsHighlightResult is a convenience function that returns map[string]HighlightResultOption wrapped in HighlightResult. -func MapmapOfStringHighlightResultOptionAsHighlightResult(v map[string]HighlightResultOption) *HighlightResult { +// []HighlightResultAsHighlightResult is a convenience function that returns []HighlightResult wrapped in HighlightResult. +func ArrayOfHighlightResultAsHighlightResult(v []HighlightResult) *HighlightResult { return &HighlightResult{ - MapmapOfStringHighlightResultOption: &v, - } -} - -// []HighlightResultOptionAsHighlightResult is a convenience function that returns []HighlightResultOption wrapped in HighlightResult. -func ArrayOfHighlightResultOptionAsHighlightResult(v []HighlightResultOption) *HighlightResult { - return &HighlightResult{ - ArrayOfHighlightResultOption: &v, + ArrayOfHighlightResult: &v, } } @@ -66,19 +58,12 @@ func (dst *HighlightResult) UnmarshalJSON(data []byte) error { } else { dst.MapmapOfStringHighlightResult = nil } - // try to unmarshal data into MapmapOfStringHighlightResultOption - err = newStrictDecoder(data).Decode(&dst.MapmapOfStringHighlightResultOption) - if err == nil && validateStruct(dst.MapmapOfStringHighlightResultOption) == nil { + // try to unmarshal data into ArrayOfHighlightResult + err = newStrictDecoder(data).Decode(&dst.ArrayOfHighlightResult) + if err == nil && validateStruct(dst.ArrayOfHighlightResult) == nil { return nil // found the correct type } else { - dst.MapmapOfStringHighlightResultOption = nil - } - // try to unmarshal data into ArrayOfHighlightResultOption - err = newStrictDecoder(data).Decode(&dst.ArrayOfHighlightResultOption) - if err == nil && validateStruct(dst.ArrayOfHighlightResultOption) == nil { - return nil // found the correct type - } else { - dst.ArrayOfHighlightResultOption = nil + dst.ArrayOfHighlightResult = nil } return fmt.Errorf("Data failed to match schemas in oneOf(HighlightResult)") @@ -95,10 +80,10 @@ func (src HighlightResult) MarshalJSON() ([]byte, error) { return serialized, nil } - if src.ArrayOfHighlightResultOption != nil { - serialized, err := json.Marshal(&src.ArrayOfHighlightResultOption) + if src.ArrayOfHighlightResult != nil { + serialized, err := json.Marshal(&src.ArrayOfHighlightResult) if err != nil { - return nil, fmt.Errorf("failed to unmarshal one of ArrayOfHighlightResultOption of HighlightResult: %w", err) + return nil, fmt.Errorf("failed to unmarshal one of ArrayOfHighlightResult of HighlightResult: %w", err) } return serialized, nil @@ -113,15 +98,6 @@ func (src HighlightResult) MarshalJSON() ([]byte, error) { return serialized, nil } - if src.MapmapOfStringHighlightResultOption != nil { - serialized, err := json.Marshal(&src.MapmapOfStringHighlightResultOption) - if err != nil { - return nil, fmt.Errorf("failed to unmarshal one of MapmapOfStringHighlightResultOption of HighlightResult: %w", err) - } - - return serialized, nil - } - return nil, nil // no data in oneOf schemas } @@ -131,18 +107,14 @@ func (obj HighlightResult) GetActualInstance() any { return *obj.HighlightResultOption } - if obj.ArrayOfHighlightResultOption != nil { - return *obj.ArrayOfHighlightResultOption + if obj.ArrayOfHighlightResult != nil { + return *obj.ArrayOfHighlightResult } if obj.MapmapOfStringHighlightResult != nil { return *obj.MapmapOfStringHighlightResult } - if obj.MapmapOfStringHighlightResultOption != nil { - return *obj.MapmapOfStringHighlightResultOption - } - // all schemas are nil return nil } diff --git a/algolia/recommend/model_recommendations_results.go b/algolia/recommend/model_recommendations_results.go index 1333e77ce..882fed476 100644 --- a/algolia/recommend/model_recommendations_results.go +++ b/algolia/recommend/model_recommendations_results.go @@ -59,13 +59,13 @@ type RecommendationsResults struct { // Whether automatic events collection is enabled for the application. AutomaticInsights *bool `json:"_automaticInsights,omitempty"` // Page of search results to retrieve. - Page int32 `json:"page"` + Page *int32 `json:"page,omitempty"` // Number of results (hits). - NbHits int32 `json:"nbHits"` + NbHits *int32 `json:"nbHits,omitempty"` // Number of pages of results. - NbPages int32 `json:"nbPages"` + NbPages *int32 `json:"nbPages,omitempty"` // Number of hits per page. - HitsPerPage int32 `json:"hitsPerPage"` + HitsPerPage *int32 `json:"hitsPerPage,omitempty"` Hits []RecommendationsHit `json:"hits"` } @@ -215,17 +215,37 @@ func WithRecommendationsResultsAutomaticInsights(val bool) RecommendationsResult } } +func WithRecommendationsResultsPage(val int32) RecommendationsResultsOption { + return func(f *RecommendationsResults) { + f.Page = &val + } +} + +func WithRecommendationsResultsNbHits(val int32) RecommendationsResultsOption { + return func(f *RecommendationsResults) { + f.NbHits = &val + } +} + +func WithRecommendationsResultsNbPages(val int32) RecommendationsResultsOption { + return func(f *RecommendationsResults) { + f.NbPages = &val + } +} + +func WithRecommendationsResultsHitsPerPage(val int32) RecommendationsResultsOption { + return func(f *RecommendationsResults) { + f.HitsPerPage = &val + } +} + // NewRecommendationsResults instantiates a new RecommendationsResults 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 NewRecommendationsResults(processingTimeMS int32, page int32, nbHits int32, nbPages int32, hitsPerPage int32, hits []RecommendationsHit, opts ...RecommendationsResultsOption) *RecommendationsResults { +func NewRecommendationsResults(processingTimeMS int32, hits []RecommendationsHit, opts ...RecommendationsResultsOption) *RecommendationsResults { this := &RecommendationsResults{} this.ProcessingTimeMS = processingTimeMS - this.Page = page - this.NbHits = nbHits - this.NbPages = nbPages - this.HitsPerPage = hitsPerPage this.Hits = hits for _, opt := range opts { opt(this) @@ -1064,103 +1084,135 @@ func (o *RecommendationsResults) SetAutomaticInsights(v bool) *RecommendationsRe return o } -// GetPage returns the Page field value. +// GetPage returns the Page field value if set, zero value otherwise. func (o *RecommendationsResults) GetPage() int32 { - if o == nil { + if o == nil || o.Page == nil { var ret int32 return ret } - - return o.Page + return *o.Page } -// GetPageOk returns a tuple with the Page field value +// GetPageOk returns a tuple with the Page field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *RecommendationsResults) GetPageOk() (*int32, bool) { - if o == nil { + if o == nil || o.Page == nil { return nil, false } - return &o.Page, true + return o.Page, true +} + +// HasPage returns a boolean if a field has been set. +func (o *RecommendationsResults) HasPage() bool { + if o != nil && o.Page != nil { + return true + } + + return false } -// SetPage sets field value. +// SetPage gets a reference to the given int32 and assigns it to the Page field. func (o *RecommendationsResults) SetPage(v int32) *RecommendationsResults { - o.Page = v + o.Page = &v return o } -// GetNbHits returns the NbHits field value. +// GetNbHits returns the NbHits field value if set, zero value otherwise. func (o *RecommendationsResults) GetNbHits() int32 { - if o == nil { + if o == nil || o.NbHits == nil { var ret int32 return ret } - - return o.NbHits + return *o.NbHits } -// GetNbHitsOk returns a tuple with the NbHits field value +// GetNbHitsOk returns a tuple with the NbHits field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *RecommendationsResults) GetNbHitsOk() (*int32, bool) { - if o == nil { + if o == nil || o.NbHits == nil { return nil, false } - return &o.NbHits, true + return o.NbHits, true } -// SetNbHits sets field value. +// HasNbHits returns a boolean if a field has been set. +func (o *RecommendationsResults) HasNbHits() bool { + if o != nil && o.NbHits != nil { + return true + } + + return false +} + +// SetNbHits gets a reference to the given int32 and assigns it to the NbHits field. func (o *RecommendationsResults) SetNbHits(v int32) *RecommendationsResults { - o.NbHits = v + o.NbHits = &v return o } -// GetNbPages returns the NbPages field value. +// GetNbPages returns the NbPages field value if set, zero value otherwise. func (o *RecommendationsResults) GetNbPages() int32 { - if o == nil { + if o == nil || o.NbPages == nil { var ret int32 return ret } - - return o.NbPages + return *o.NbPages } -// GetNbPagesOk returns a tuple with the NbPages field value +// GetNbPagesOk returns a tuple with the NbPages field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *RecommendationsResults) GetNbPagesOk() (*int32, bool) { - if o == nil { + if o == nil || o.NbPages == nil { return nil, false } - return &o.NbPages, true + return o.NbPages, true +} + +// HasNbPages returns a boolean if a field has been set. +func (o *RecommendationsResults) HasNbPages() bool { + if o != nil && o.NbPages != nil { + return true + } + + return false } -// SetNbPages sets field value. +// SetNbPages gets a reference to the given int32 and assigns it to the NbPages field. func (o *RecommendationsResults) SetNbPages(v int32) *RecommendationsResults { - o.NbPages = v + o.NbPages = &v return o } -// GetHitsPerPage returns the HitsPerPage field value. +// GetHitsPerPage returns the HitsPerPage field value if set, zero value otherwise. func (o *RecommendationsResults) GetHitsPerPage() int32 { - if o == nil { + if o == nil || o.HitsPerPage == nil { var ret int32 return ret } - - return o.HitsPerPage + return *o.HitsPerPage } -// GetHitsPerPageOk returns a tuple with the HitsPerPage field value +// GetHitsPerPageOk returns a tuple with the HitsPerPage field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *RecommendationsResults) GetHitsPerPageOk() (*int32, bool) { - if o == nil { + if o == nil || o.HitsPerPage == nil { return nil, false } - return &o.HitsPerPage, true + return o.HitsPerPage, true +} + +// HasHitsPerPage returns a boolean if a field has been set. +func (o *RecommendationsResults) HasHitsPerPage() bool { + if o != nil && o.HitsPerPage != nil { + return true + } + + return false } -// SetHitsPerPage sets field value. +// SetHitsPerPage gets a reference to the given int32 and assigns it to the HitsPerPage field. func (o *RecommendationsResults) SetHitsPerPage(v int32) *RecommendationsResults { - o.HitsPerPage = v + o.HitsPerPage = &v return o } @@ -1266,16 +1318,16 @@ func (o RecommendationsResults) MarshalJSON() ([]byte, error) { if o.AutomaticInsights != nil { toSerialize["_automaticInsights"] = o.AutomaticInsights } - if true { + if o.Page != nil { toSerialize["page"] = o.Page } - if true { + if o.NbHits != nil { toSerialize["nbHits"] = o.NbHits } - if true { + if o.NbPages != nil { toSerialize["nbPages"] = o.NbPages } - if true { + if o.HitsPerPage != nil { toSerialize["hitsPerPage"] = o.HitsPerPage } if true { diff --git a/algolia/recommend/model_snippet_result.go b/algolia/recommend/model_snippet_result.go index 41de505b9..9febb6694 100644 --- a/algolia/recommend/model_snippet_result.go +++ b/algolia/recommend/model_snippet_result.go @@ -10,10 +10,9 @@ import ( // SnippetResult - struct for SnippetResult. type SnippetResult struct { - SnippetResultOption *SnippetResultOption - ArrayOfSnippetResultOption *[]SnippetResultOption - MapmapOfStringSnippetResult *map[string]SnippetResult - MapmapOfStringSnippetResultOption *map[string]SnippetResultOption + SnippetResultOption *SnippetResultOption + ArrayOfSnippetResult *[]SnippetResult + MapmapOfStringSnippetResult *map[string]SnippetResult } // SnippetResultOptionAsSnippetResult is a convenience function that returns SnippetResultOption wrapped in SnippetResult. @@ -30,17 +29,10 @@ func MapmapOfStringSnippetResultAsSnippetResult(v map[string]SnippetResult) *Sni } } -// map[string]SnippetResultOptionAsSnippetResult is a convenience function that returns map[string]SnippetResultOption wrapped in SnippetResult. -func MapmapOfStringSnippetResultOptionAsSnippetResult(v map[string]SnippetResultOption) *SnippetResult { +// []SnippetResultAsSnippetResult is a convenience function that returns []SnippetResult wrapped in SnippetResult. +func ArrayOfSnippetResultAsSnippetResult(v []SnippetResult) *SnippetResult { return &SnippetResult{ - MapmapOfStringSnippetResultOption: &v, - } -} - -// []SnippetResultOptionAsSnippetResult is a convenience function that returns []SnippetResultOption wrapped in SnippetResult. -func ArrayOfSnippetResultOptionAsSnippetResult(v []SnippetResultOption) *SnippetResult { - return &SnippetResult{ - ArrayOfSnippetResultOption: &v, + ArrayOfSnippetResult: &v, } } @@ -66,19 +58,12 @@ func (dst *SnippetResult) UnmarshalJSON(data []byte) error { } else { dst.MapmapOfStringSnippetResult = nil } - // try to unmarshal data into MapmapOfStringSnippetResultOption - err = newStrictDecoder(data).Decode(&dst.MapmapOfStringSnippetResultOption) - if err == nil && validateStruct(dst.MapmapOfStringSnippetResultOption) == nil { + // try to unmarshal data into ArrayOfSnippetResult + err = newStrictDecoder(data).Decode(&dst.ArrayOfSnippetResult) + if err == nil && validateStruct(dst.ArrayOfSnippetResult) == nil { return nil // found the correct type } else { - dst.MapmapOfStringSnippetResultOption = nil - } - // try to unmarshal data into ArrayOfSnippetResultOption - err = newStrictDecoder(data).Decode(&dst.ArrayOfSnippetResultOption) - if err == nil && validateStruct(dst.ArrayOfSnippetResultOption) == nil { - return nil // found the correct type - } else { - dst.ArrayOfSnippetResultOption = nil + dst.ArrayOfSnippetResult = nil } return fmt.Errorf("Data failed to match schemas in oneOf(SnippetResult)") @@ -95,10 +80,10 @@ func (src SnippetResult) MarshalJSON() ([]byte, error) { return serialized, nil } - if src.ArrayOfSnippetResultOption != nil { - serialized, err := json.Marshal(&src.ArrayOfSnippetResultOption) + if src.ArrayOfSnippetResult != nil { + serialized, err := json.Marshal(&src.ArrayOfSnippetResult) if err != nil { - return nil, fmt.Errorf("failed to unmarshal one of ArrayOfSnippetResultOption of SnippetResult: %w", err) + return nil, fmt.Errorf("failed to unmarshal one of ArrayOfSnippetResult of SnippetResult: %w", err) } return serialized, nil @@ -113,15 +98,6 @@ func (src SnippetResult) MarshalJSON() ([]byte, error) { return serialized, nil } - if src.MapmapOfStringSnippetResultOption != nil { - serialized, err := json.Marshal(&src.MapmapOfStringSnippetResultOption) - if err != nil { - return nil, fmt.Errorf("failed to unmarshal one of MapmapOfStringSnippetResultOption of SnippetResult: %w", err) - } - - return serialized, nil - } - return nil, nil // no data in oneOf schemas } @@ -131,18 +107,14 @@ func (obj SnippetResult) GetActualInstance() any { return *obj.SnippetResultOption } - if obj.ArrayOfSnippetResultOption != nil { - return *obj.ArrayOfSnippetResultOption + if obj.ArrayOfSnippetResult != nil { + return *obj.ArrayOfSnippetResult } if obj.MapmapOfStringSnippetResult != nil { return *obj.MapmapOfStringSnippetResult } - if obj.MapmapOfStringSnippetResultOption != nil { - return *obj.MapmapOfStringSnippetResultOption - } - // all schemas are nil return nil } diff --git a/algolia/search/model_highlight_result.go b/algolia/search/model_highlight_result.go index 10a793a97..a37d2f925 100644 --- a/algolia/search/model_highlight_result.go +++ b/algolia/search/model_highlight_result.go @@ -10,10 +10,9 @@ import ( // HighlightResult - struct for HighlightResult. type HighlightResult struct { - HighlightResultOption *HighlightResultOption - ArrayOfHighlightResultOption *[]HighlightResultOption - MapmapOfStringHighlightResult *map[string]HighlightResult - MapmapOfStringHighlightResultOption *map[string]HighlightResultOption + HighlightResultOption *HighlightResultOption + ArrayOfHighlightResult *[]HighlightResult + MapmapOfStringHighlightResult *map[string]HighlightResult } // HighlightResultOptionAsHighlightResult is a convenience function that returns HighlightResultOption wrapped in HighlightResult. @@ -30,17 +29,10 @@ func MapmapOfStringHighlightResultAsHighlightResult(v map[string]HighlightResult } } -// map[string]HighlightResultOptionAsHighlightResult is a convenience function that returns map[string]HighlightResultOption wrapped in HighlightResult. -func MapmapOfStringHighlightResultOptionAsHighlightResult(v map[string]HighlightResultOption) *HighlightResult { +// []HighlightResultAsHighlightResult is a convenience function that returns []HighlightResult wrapped in HighlightResult. +func ArrayOfHighlightResultAsHighlightResult(v []HighlightResult) *HighlightResult { return &HighlightResult{ - MapmapOfStringHighlightResultOption: &v, - } -} - -// []HighlightResultOptionAsHighlightResult is a convenience function that returns []HighlightResultOption wrapped in HighlightResult. -func ArrayOfHighlightResultOptionAsHighlightResult(v []HighlightResultOption) *HighlightResult { - return &HighlightResult{ - ArrayOfHighlightResultOption: &v, + ArrayOfHighlightResult: &v, } } @@ -66,19 +58,12 @@ func (dst *HighlightResult) UnmarshalJSON(data []byte) error { } else { dst.MapmapOfStringHighlightResult = nil } - // try to unmarshal data into MapmapOfStringHighlightResultOption - err = newStrictDecoder(data).Decode(&dst.MapmapOfStringHighlightResultOption) - if err == nil && validateStruct(dst.MapmapOfStringHighlightResultOption) == nil { + // try to unmarshal data into ArrayOfHighlightResult + err = newStrictDecoder(data).Decode(&dst.ArrayOfHighlightResult) + if err == nil && validateStruct(dst.ArrayOfHighlightResult) == nil { return nil // found the correct type } else { - dst.MapmapOfStringHighlightResultOption = nil - } - // try to unmarshal data into ArrayOfHighlightResultOption - err = newStrictDecoder(data).Decode(&dst.ArrayOfHighlightResultOption) - if err == nil && validateStruct(dst.ArrayOfHighlightResultOption) == nil { - return nil // found the correct type - } else { - dst.ArrayOfHighlightResultOption = nil + dst.ArrayOfHighlightResult = nil } return fmt.Errorf("Data failed to match schemas in oneOf(HighlightResult)") @@ -95,10 +80,10 @@ func (src HighlightResult) MarshalJSON() ([]byte, error) { return serialized, nil } - if src.ArrayOfHighlightResultOption != nil { - serialized, err := json.Marshal(&src.ArrayOfHighlightResultOption) + if src.ArrayOfHighlightResult != nil { + serialized, err := json.Marshal(&src.ArrayOfHighlightResult) if err != nil { - return nil, fmt.Errorf("failed to unmarshal one of ArrayOfHighlightResultOption of HighlightResult: %w", err) + return nil, fmt.Errorf("failed to unmarshal one of ArrayOfHighlightResult of HighlightResult: %w", err) } return serialized, nil @@ -113,15 +98,6 @@ func (src HighlightResult) MarshalJSON() ([]byte, error) { return serialized, nil } - if src.MapmapOfStringHighlightResultOption != nil { - serialized, err := json.Marshal(&src.MapmapOfStringHighlightResultOption) - if err != nil { - return nil, fmt.Errorf("failed to unmarshal one of MapmapOfStringHighlightResultOption of HighlightResult: %w", err) - } - - return serialized, nil - } - return nil, nil // no data in oneOf schemas } @@ -131,18 +107,14 @@ func (obj HighlightResult) GetActualInstance() any { return *obj.HighlightResultOption } - if obj.ArrayOfHighlightResultOption != nil { - return *obj.ArrayOfHighlightResultOption + if obj.ArrayOfHighlightResult != nil { + return *obj.ArrayOfHighlightResult } if obj.MapmapOfStringHighlightResult != nil { return *obj.MapmapOfStringHighlightResult } - if obj.MapmapOfStringHighlightResultOption != nil { - return *obj.MapmapOfStringHighlightResultOption - } - // all schemas are nil return nil } diff --git a/algolia/search/model_search_response.go b/algolia/search/model_search_response.go index 383e81f66..0b9fa6270 100644 --- a/algolia/search/model_search_response.go +++ b/algolia/search/model_search_response.go @@ -59,13 +59,13 @@ type SearchResponse struct { // Whether automatic events collection is enabled for the application. AutomaticInsights *bool `json:"_automaticInsights,omitempty"` // Page of search results to retrieve. - Page int32 `json:"page"` + Page *int32 `json:"page,omitempty"` // Number of results (hits). - NbHits int32 `json:"nbHits"` + NbHits *int32 `json:"nbHits,omitempty"` // Number of pages of results. - NbPages int32 `json:"nbPages"` + NbPages *int32 `json:"nbPages,omitempty"` // Number of hits per page. - HitsPerPage int32 `json:"hitsPerPage"` + HitsPerPage *int32 `json:"hitsPerPage,omitempty"` // Search results (hits). Hits are records from your index that match the search criteria, augmented with additional attributes, such as, for highlighting. Hits []Hit `json:"hits"` // Search query. @@ -223,17 +223,37 @@ func WithSearchResponseAutomaticInsights(val bool) SearchResponseOption { } } +func WithSearchResponsePage(val int32) SearchResponseOption { + return func(f *SearchResponse) { + f.Page = &val + } +} + +func WithSearchResponseNbHits(val int32) SearchResponseOption { + return func(f *SearchResponse) { + f.NbHits = &val + } +} + +func WithSearchResponseNbPages(val int32) SearchResponseOption { + return func(f *SearchResponse) { + f.NbPages = &val + } +} + +func WithSearchResponseHitsPerPage(val int32) SearchResponseOption { + return func(f *SearchResponse) { + f.HitsPerPage = &val + } +} + // NewSearchResponse instantiates a new SearchResponse 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 NewSearchResponse(processingTimeMS int32, page int32, nbHits int32, nbPages int32, hitsPerPage int32, hits []Hit, query string, params string, opts ...SearchResponseOption) *SearchResponse { +func NewSearchResponse(processingTimeMS int32, hits []Hit, query string, params string, opts ...SearchResponseOption) *SearchResponse { this := &SearchResponse{} this.ProcessingTimeMS = processingTimeMS - this.Page = page - this.NbHits = nbHits - this.NbPages = nbPages - this.HitsPerPage = hitsPerPage this.Hits = hits this.Query = query this.Params = params @@ -1074,103 +1094,135 @@ func (o *SearchResponse) SetAutomaticInsights(v bool) *SearchResponse { return o } -// GetPage returns the Page field value. +// GetPage returns the Page field value if set, zero value otherwise. func (o *SearchResponse) GetPage() int32 { - if o == nil { + if o == nil || o.Page == nil { var ret int32 return ret } - - return o.Page + return *o.Page } -// GetPageOk returns a tuple with the Page field value +// GetPageOk returns a tuple with the Page field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *SearchResponse) GetPageOk() (*int32, bool) { - if o == nil { + if o == nil || o.Page == nil { return nil, false } - return &o.Page, true + return o.Page, true +} + +// HasPage returns a boolean if a field has been set. +func (o *SearchResponse) HasPage() bool { + if o != nil && o.Page != nil { + return true + } + + return false } -// SetPage sets field value. +// SetPage gets a reference to the given int32 and assigns it to the Page field. func (o *SearchResponse) SetPage(v int32) *SearchResponse { - o.Page = v + o.Page = &v return o } -// GetNbHits returns the NbHits field value. +// GetNbHits returns the NbHits field value if set, zero value otherwise. func (o *SearchResponse) GetNbHits() int32 { - if o == nil { + if o == nil || o.NbHits == nil { var ret int32 return ret } - - return o.NbHits + return *o.NbHits } -// GetNbHitsOk returns a tuple with the NbHits field value +// GetNbHitsOk returns a tuple with the NbHits field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *SearchResponse) GetNbHitsOk() (*int32, bool) { - if o == nil { + if o == nil || o.NbHits == nil { return nil, false } - return &o.NbHits, true + return o.NbHits, true } -// SetNbHits sets field value. +// HasNbHits returns a boolean if a field has been set. +func (o *SearchResponse) HasNbHits() bool { + if o != nil && o.NbHits != nil { + return true + } + + return false +} + +// SetNbHits gets a reference to the given int32 and assigns it to the NbHits field. func (o *SearchResponse) SetNbHits(v int32) *SearchResponse { - o.NbHits = v + o.NbHits = &v return o } -// GetNbPages returns the NbPages field value. +// GetNbPages returns the NbPages field value if set, zero value otherwise. func (o *SearchResponse) GetNbPages() int32 { - if o == nil { + if o == nil || o.NbPages == nil { var ret int32 return ret } - - return o.NbPages + return *o.NbPages } -// GetNbPagesOk returns a tuple with the NbPages field value +// GetNbPagesOk returns a tuple with the NbPages field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *SearchResponse) GetNbPagesOk() (*int32, bool) { - if o == nil { + if o == nil || o.NbPages == nil { return nil, false } - return &o.NbPages, true + return o.NbPages, true +} + +// HasNbPages returns a boolean if a field has been set. +func (o *SearchResponse) HasNbPages() bool { + if o != nil && o.NbPages != nil { + return true + } + + return false } -// SetNbPages sets field value. +// SetNbPages gets a reference to the given int32 and assigns it to the NbPages field. func (o *SearchResponse) SetNbPages(v int32) *SearchResponse { - o.NbPages = v + o.NbPages = &v return o } -// GetHitsPerPage returns the HitsPerPage field value. +// GetHitsPerPage returns the HitsPerPage field value if set, zero value otherwise. func (o *SearchResponse) GetHitsPerPage() int32 { - if o == nil { + if o == nil || o.HitsPerPage == nil { var ret int32 return ret } - - return o.HitsPerPage + return *o.HitsPerPage } -// GetHitsPerPageOk returns a tuple with the HitsPerPage field value +// GetHitsPerPageOk returns a tuple with the HitsPerPage field value if set, nil otherwise // and a boolean to check if the value has been set. func (o *SearchResponse) GetHitsPerPageOk() (*int32, bool) { - if o == nil { + if o == nil || o.HitsPerPage == nil { return nil, false } - return &o.HitsPerPage, true + return o.HitsPerPage, true +} + +// HasHitsPerPage returns a boolean if a field has been set. +func (o *SearchResponse) HasHitsPerPage() bool { + if o != nil && o.HitsPerPage != nil { + return true + } + + return false } -// SetHitsPerPage sets field value. +// SetHitsPerPage gets a reference to the given int32 and assigns it to the HitsPerPage field. func (o *SearchResponse) SetHitsPerPage(v int32) *SearchResponse { - o.HitsPerPage = v + o.HitsPerPage = &v return o } @@ -1336,16 +1388,16 @@ func (o SearchResponse) MarshalJSON() ([]byte, error) { if o.AutomaticInsights != nil { toSerialize["_automaticInsights"] = o.AutomaticInsights } - if true { + if o.Page != nil { toSerialize["page"] = o.Page } - if true { + if o.NbHits != nil { toSerialize["nbHits"] = o.NbHits } - if true { + if o.NbPages != nil { toSerialize["nbPages"] = o.NbPages } - if true { + if o.HitsPerPage != nil { toSerialize["hitsPerPage"] = o.HitsPerPage } if true { diff --git a/algolia/search/model_snippet_result.go b/algolia/search/model_snippet_result.go index f27cfc4a8..da5c6a9a8 100644 --- a/algolia/search/model_snippet_result.go +++ b/algolia/search/model_snippet_result.go @@ -10,10 +10,9 @@ import ( // SnippetResult - struct for SnippetResult. type SnippetResult struct { - SnippetResultOption *SnippetResultOption - ArrayOfSnippetResultOption *[]SnippetResultOption - MapmapOfStringSnippetResult *map[string]SnippetResult - MapmapOfStringSnippetResultOption *map[string]SnippetResultOption + SnippetResultOption *SnippetResultOption + ArrayOfSnippetResult *[]SnippetResult + MapmapOfStringSnippetResult *map[string]SnippetResult } // SnippetResultOptionAsSnippetResult is a convenience function that returns SnippetResultOption wrapped in SnippetResult. @@ -30,17 +29,10 @@ func MapmapOfStringSnippetResultAsSnippetResult(v map[string]SnippetResult) *Sni } } -// map[string]SnippetResultOptionAsSnippetResult is a convenience function that returns map[string]SnippetResultOption wrapped in SnippetResult. -func MapmapOfStringSnippetResultOptionAsSnippetResult(v map[string]SnippetResultOption) *SnippetResult { +// []SnippetResultAsSnippetResult is a convenience function that returns []SnippetResult wrapped in SnippetResult. +func ArrayOfSnippetResultAsSnippetResult(v []SnippetResult) *SnippetResult { return &SnippetResult{ - MapmapOfStringSnippetResultOption: &v, - } -} - -// []SnippetResultOptionAsSnippetResult is a convenience function that returns []SnippetResultOption wrapped in SnippetResult. -func ArrayOfSnippetResultOptionAsSnippetResult(v []SnippetResultOption) *SnippetResult { - return &SnippetResult{ - ArrayOfSnippetResultOption: &v, + ArrayOfSnippetResult: &v, } } @@ -66,19 +58,12 @@ func (dst *SnippetResult) UnmarshalJSON(data []byte) error { } else { dst.MapmapOfStringSnippetResult = nil } - // try to unmarshal data into MapmapOfStringSnippetResultOption - err = newStrictDecoder(data).Decode(&dst.MapmapOfStringSnippetResultOption) - if err == nil && validateStruct(dst.MapmapOfStringSnippetResultOption) == nil { + // try to unmarshal data into ArrayOfSnippetResult + err = newStrictDecoder(data).Decode(&dst.ArrayOfSnippetResult) + if err == nil && validateStruct(dst.ArrayOfSnippetResult) == nil { return nil // found the correct type } else { - dst.MapmapOfStringSnippetResultOption = nil - } - // try to unmarshal data into ArrayOfSnippetResultOption - err = newStrictDecoder(data).Decode(&dst.ArrayOfSnippetResultOption) - if err == nil && validateStruct(dst.ArrayOfSnippetResultOption) == nil { - return nil // found the correct type - } else { - dst.ArrayOfSnippetResultOption = nil + dst.ArrayOfSnippetResult = nil } return fmt.Errorf("Data failed to match schemas in oneOf(SnippetResult)") @@ -95,10 +80,10 @@ func (src SnippetResult) MarshalJSON() ([]byte, error) { return serialized, nil } - if src.ArrayOfSnippetResultOption != nil { - serialized, err := json.Marshal(&src.ArrayOfSnippetResultOption) + if src.ArrayOfSnippetResult != nil { + serialized, err := json.Marshal(&src.ArrayOfSnippetResult) if err != nil { - return nil, fmt.Errorf("failed to unmarshal one of ArrayOfSnippetResultOption of SnippetResult: %w", err) + return nil, fmt.Errorf("failed to unmarshal one of ArrayOfSnippetResult of SnippetResult: %w", err) } return serialized, nil @@ -113,15 +98,6 @@ func (src SnippetResult) MarshalJSON() ([]byte, error) { return serialized, nil } - if src.MapmapOfStringSnippetResultOption != nil { - serialized, err := json.Marshal(&src.MapmapOfStringSnippetResultOption) - if err != nil { - return nil, fmt.Errorf("failed to unmarshal one of MapmapOfStringSnippetResultOption of SnippetResult: %w", err) - } - - return serialized, nil - } - return nil, nil // no data in oneOf schemas } @@ -131,18 +107,14 @@ func (obj SnippetResult) GetActualInstance() any { return *obj.SnippetResultOption } - if obj.ArrayOfSnippetResultOption != nil { - return *obj.ArrayOfSnippetResultOption + if obj.ArrayOfSnippetResult != nil { + return *obj.ArrayOfSnippetResult } if obj.MapmapOfStringSnippetResult != nil { return *obj.MapmapOfStringSnippetResult } - if obj.MapmapOfStringSnippetResultOption != nil { - return *obj.MapmapOfStringSnippetResultOption - } - // all schemas are nil return nil }