...

Source file src/github.com/Azure/azure-sdk-for-go/services/cognitiveservices/v1.0/customimagesearch/models.go

Documentation: github.com/Azure/azure-sdk-for-go/services/cognitiveservices/v1.0/customimagesearch

     1  package customimagesearch
     2  
     3  // Copyright (c) Microsoft Corporation. All rights reserved.
     4  // Licensed under the MIT License. See License.txt in the project root for license information.
     5  //
     6  // Code generated by Microsoft (R) AutoRest Code Generator.
     7  // Changes may cause incorrect behavior and will be lost if the code is regenerated.
     8  
     9  import (
    10  	"encoding/json"
    11  	"github.com/Azure/go-autorest/autorest"
    12  )
    13  
    14  // The package's fully qualified name.
    15  const fqdn = "github.com/Azure/azure-sdk-for-go/services/cognitiveservices/v1.0/customimagesearch"
    16  
    17  // BasicAnswer defines an answer.
    18  type BasicAnswer interface {
    19  	AsImages() (*Images, bool)
    20  	AsSearchResultsAnswer() (*SearchResultsAnswer, bool)
    21  	AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool)
    22  	AsAnswer() (*Answer, bool)
    23  }
    24  
    25  // Answer defines an answer.
    26  type Answer struct {
    27  	// ReadLink - READ-ONLY; The URL that returns this resource.
    28  	ReadLink *string `json:"readLink,omitempty"`
    29  	// WebSearchURL - READ-ONLY; The URL To Bing's search result for this item.
    30  	WebSearchURL *string `json:"webSearchUrl,omitempty"`
    31  	// ID - READ-ONLY; A String identifier.
    32  	ID *string `json:"id,omitempty"`
    33  	// Type - Possible values include: 'TypeResponseBase', 'TypeImageObject', 'TypeImages', 'TypeSearchResultsAnswer', 'TypeAnswer', 'TypeMediaObject', 'TypeResponse', 'TypeThing', 'TypeCreativeWork', 'TypeIdentifiable', 'TypeErrorResponse', 'TypeWebPage'
    34  	Type Type `json:"_type,omitempty"`
    35  }
    36  
    37  func unmarshalBasicAnswer(body []byte) (BasicAnswer, error) {
    38  	var m map[string]interface{}
    39  	err := json.Unmarshal(body, &m)
    40  	if err != nil {
    41  		return nil, err
    42  	}
    43  
    44  	switch m["_type"] {
    45  	case string(TypeImages):
    46  		var i Images
    47  		err := json.Unmarshal(body, &i)
    48  		return i, err
    49  	case string(TypeSearchResultsAnswer):
    50  		var sra SearchResultsAnswer
    51  		err := json.Unmarshal(body, &sra)
    52  		return sra, err
    53  	default:
    54  		var a Answer
    55  		err := json.Unmarshal(body, &a)
    56  		return a, err
    57  	}
    58  }
    59  func unmarshalBasicAnswerArray(body []byte) ([]BasicAnswer, error) {
    60  	var rawMessages []*json.RawMessage
    61  	err := json.Unmarshal(body, &rawMessages)
    62  	if err != nil {
    63  		return nil, err
    64  	}
    65  
    66  	aArray := make([]BasicAnswer, len(rawMessages))
    67  
    68  	for index, rawMessage := range rawMessages {
    69  		a, err := unmarshalBasicAnswer(*rawMessage)
    70  		if err != nil {
    71  			return nil, err
    72  		}
    73  		aArray[index] = a
    74  	}
    75  	return aArray, nil
    76  }
    77  
    78  // MarshalJSON is the custom marshaler for Answer.
    79  func (a Answer) MarshalJSON() ([]byte, error) {
    80  	a.Type = TypeAnswer
    81  	objectMap := make(map[string]interface{})
    82  	if a.Type != "" {
    83  		objectMap["_type"] = a.Type
    84  	}
    85  	return json.Marshal(objectMap)
    86  }
    87  
    88  // AsImageObject is the BasicResponseBase implementation for Answer.
    89  func (a Answer) AsImageObject() (*ImageObject, bool) {
    90  	return nil, false
    91  }
    92  
    93  // AsImages is the BasicResponseBase implementation for Answer.
    94  func (a Answer) AsImages() (*Images, bool) {
    95  	return nil, false
    96  }
    97  
    98  // AsSearchResultsAnswer is the BasicResponseBase implementation for Answer.
    99  func (a Answer) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) {
   100  	return nil, false
   101  }
   102  
   103  // AsBasicSearchResultsAnswer is the BasicResponseBase implementation for Answer.
   104  func (a Answer) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) {
   105  	return nil, false
   106  }
   107  
   108  // AsAnswer is the BasicResponseBase implementation for Answer.
   109  func (a Answer) AsAnswer() (*Answer, bool) {
   110  	return &a, true
   111  }
   112  
   113  // AsBasicAnswer is the BasicResponseBase implementation for Answer.
   114  func (a Answer) AsBasicAnswer() (BasicAnswer, bool) {
   115  	return &a, true
   116  }
   117  
   118  // AsMediaObject is the BasicResponseBase implementation for Answer.
   119  func (a Answer) AsMediaObject() (*MediaObject, bool) {
   120  	return nil, false
   121  }
   122  
   123  // AsBasicMediaObject is the BasicResponseBase implementation for Answer.
   124  func (a Answer) AsBasicMediaObject() (BasicMediaObject, bool) {
   125  	return nil, false
   126  }
   127  
   128  // AsResponse is the BasicResponseBase implementation for Answer.
   129  func (a Answer) AsResponse() (*Response, bool) {
   130  	return nil, false
   131  }
   132  
   133  // AsBasicResponse is the BasicResponseBase implementation for Answer.
   134  func (a Answer) AsBasicResponse() (BasicResponse, bool) {
   135  	return &a, true
   136  }
   137  
   138  // AsThing is the BasicResponseBase implementation for Answer.
   139  func (a Answer) AsThing() (*Thing, bool) {
   140  	return nil, false
   141  }
   142  
   143  // AsBasicThing is the BasicResponseBase implementation for Answer.
   144  func (a Answer) AsBasicThing() (BasicThing, bool) {
   145  	return nil, false
   146  }
   147  
   148  // AsCreativeWork is the BasicResponseBase implementation for Answer.
   149  func (a Answer) AsCreativeWork() (*CreativeWork, bool) {
   150  	return nil, false
   151  }
   152  
   153  // AsBasicCreativeWork is the BasicResponseBase implementation for Answer.
   154  func (a Answer) AsBasicCreativeWork() (BasicCreativeWork, bool) {
   155  	return nil, false
   156  }
   157  
   158  // AsIdentifiable is the BasicResponseBase implementation for Answer.
   159  func (a Answer) AsIdentifiable() (*Identifiable, bool) {
   160  	return nil, false
   161  }
   162  
   163  // AsBasicIdentifiable is the BasicResponseBase implementation for Answer.
   164  func (a Answer) AsBasicIdentifiable() (BasicIdentifiable, bool) {
   165  	return &a, true
   166  }
   167  
   168  // AsErrorResponse is the BasicResponseBase implementation for Answer.
   169  func (a Answer) AsErrorResponse() (*ErrorResponse, bool) {
   170  	return nil, false
   171  }
   172  
   173  // AsWebPage is the BasicResponseBase implementation for Answer.
   174  func (a Answer) AsWebPage() (*WebPage, bool) {
   175  	return nil, false
   176  }
   177  
   178  // AsResponseBase is the BasicResponseBase implementation for Answer.
   179  func (a Answer) AsResponseBase() (*ResponseBase, bool) {
   180  	return nil, false
   181  }
   182  
   183  // AsBasicResponseBase is the BasicResponseBase implementation for Answer.
   184  func (a Answer) AsBasicResponseBase() (BasicResponseBase, bool) {
   185  	return &a, true
   186  }
   187  
   188  // BasicCreativeWork the most generic kind of creative work, including books, movies, photographs, software programs,
   189  // etc.
   190  type BasicCreativeWork interface {
   191  	AsImageObject() (*ImageObject, bool)
   192  	AsMediaObject() (*MediaObject, bool)
   193  	AsBasicMediaObject() (BasicMediaObject, bool)
   194  	AsWebPage() (*WebPage, bool)
   195  	AsCreativeWork() (*CreativeWork, bool)
   196  }
   197  
   198  // CreativeWork the most generic kind of creative work, including books, movies, photographs, software
   199  // programs, etc.
   200  type CreativeWork struct {
   201  	// ThumbnailURL - READ-ONLY; The URL to a thumbnail of the item.
   202  	ThumbnailURL *string `json:"thumbnailUrl,omitempty"`
   203  	// Provider - READ-ONLY; The source of the creative work.
   204  	Provider *[]BasicThing `json:"provider,omitempty"`
   205  	// Text - READ-ONLY; Text content of this creative work
   206  	Text *string `json:"text,omitempty"`
   207  	// Name - READ-ONLY; The name of the thing represented by this object.
   208  	Name *string `json:"name,omitempty"`
   209  	// URL - READ-ONLY; The URL to get more information about the thing represented by this object.
   210  	URL *string `json:"url,omitempty"`
   211  	// Image - READ-ONLY; An image of the item.
   212  	Image *ImageObject `json:"image,omitempty"`
   213  	// Description - READ-ONLY; A short description of the item.
   214  	Description *string `json:"description,omitempty"`
   215  	// AlternateName - READ-ONLY; An alias for the item
   216  	AlternateName *string `json:"alternateName,omitempty"`
   217  	// BingID - READ-ONLY; An ID that uniquely identifies this item.
   218  	BingID *string `json:"bingId,omitempty"`
   219  	// ReadLink - READ-ONLY; The URL that returns this resource.
   220  	ReadLink *string `json:"readLink,omitempty"`
   221  	// WebSearchURL - READ-ONLY; The URL To Bing's search result for this item.
   222  	WebSearchURL *string `json:"webSearchUrl,omitempty"`
   223  	// ID - READ-ONLY; A String identifier.
   224  	ID *string `json:"id,omitempty"`
   225  	// Type - Possible values include: 'TypeResponseBase', 'TypeImageObject', 'TypeImages', 'TypeSearchResultsAnswer', 'TypeAnswer', 'TypeMediaObject', 'TypeResponse', 'TypeThing', 'TypeCreativeWork', 'TypeIdentifiable', 'TypeErrorResponse', 'TypeWebPage'
   226  	Type Type `json:"_type,omitempty"`
   227  }
   228  
   229  func unmarshalBasicCreativeWork(body []byte) (BasicCreativeWork, error) {
   230  	var m map[string]interface{}
   231  	err := json.Unmarshal(body, &m)
   232  	if err != nil {
   233  		return nil, err
   234  	}
   235  
   236  	switch m["_type"] {
   237  	case string(TypeImageObject):
   238  		var ioVar ImageObject
   239  		err := json.Unmarshal(body, &ioVar)
   240  		return ioVar, err
   241  	case string(TypeMediaObject):
   242  		var mo MediaObject
   243  		err := json.Unmarshal(body, &mo)
   244  		return mo, err
   245  	case string(TypeWebPage):
   246  		var wp WebPage
   247  		err := json.Unmarshal(body, &wp)
   248  		return wp, err
   249  	default:
   250  		var cw CreativeWork
   251  		err := json.Unmarshal(body, &cw)
   252  		return cw, err
   253  	}
   254  }
   255  func unmarshalBasicCreativeWorkArray(body []byte) ([]BasicCreativeWork, error) {
   256  	var rawMessages []*json.RawMessage
   257  	err := json.Unmarshal(body, &rawMessages)
   258  	if err != nil {
   259  		return nil, err
   260  	}
   261  
   262  	cwArray := make([]BasicCreativeWork, len(rawMessages))
   263  
   264  	for index, rawMessage := range rawMessages {
   265  		cw, err := unmarshalBasicCreativeWork(*rawMessage)
   266  		if err != nil {
   267  			return nil, err
   268  		}
   269  		cwArray[index] = cw
   270  	}
   271  	return cwArray, nil
   272  }
   273  
   274  // MarshalJSON is the custom marshaler for CreativeWork.
   275  func (cw CreativeWork) MarshalJSON() ([]byte, error) {
   276  	cw.Type = TypeCreativeWork
   277  	objectMap := make(map[string]interface{})
   278  	if cw.Type != "" {
   279  		objectMap["_type"] = cw.Type
   280  	}
   281  	return json.Marshal(objectMap)
   282  }
   283  
   284  // AsImageObject is the BasicResponseBase implementation for CreativeWork.
   285  func (cw CreativeWork) AsImageObject() (*ImageObject, bool) {
   286  	return nil, false
   287  }
   288  
   289  // AsImages is the BasicResponseBase implementation for CreativeWork.
   290  func (cw CreativeWork) AsImages() (*Images, bool) {
   291  	return nil, false
   292  }
   293  
   294  // AsSearchResultsAnswer is the BasicResponseBase implementation for CreativeWork.
   295  func (cw CreativeWork) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) {
   296  	return nil, false
   297  }
   298  
   299  // AsBasicSearchResultsAnswer is the BasicResponseBase implementation for CreativeWork.
   300  func (cw CreativeWork) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) {
   301  	return nil, false
   302  }
   303  
   304  // AsAnswer is the BasicResponseBase implementation for CreativeWork.
   305  func (cw CreativeWork) AsAnswer() (*Answer, bool) {
   306  	return nil, false
   307  }
   308  
   309  // AsBasicAnswer is the BasicResponseBase implementation for CreativeWork.
   310  func (cw CreativeWork) AsBasicAnswer() (BasicAnswer, bool) {
   311  	return nil, false
   312  }
   313  
   314  // AsMediaObject is the BasicResponseBase implementation for CreativeWork.
   315  func (cw CreativeWork) AsMediaObject() (*MediaObject, bool) {
   316  	return nil, false
   317  }
   318  
   319  // AsBasicMediaObject is the BasicResponseBase implementation for CreativeWork.
   320  func (cw CreativeWork) AsBasicMediaObject() (BasicMediaObject, bool) {
   321  	return nil, false
   322  }
   323  
   324  // AsResponse is the BasicResponseBase implementation for CreativeWork.
   325  func (cw CreativeWork) AsResponse() (*Response, bool) {
   326  	return nil, false
   327  }
   328  
   329  // AsBasicResponse is the BasicResponseBase implementation for CreativeWork.
   330  func (cw CreativeWork) AsBasicResponse() (BasicResponse, bool) {
   331  	return &cw, true
   332  }
   333  
   334  // AsThing is the BasicResponseBase implementation for CreativeWork.
   335  func (cw CreativeWork) AsThing() (*Thing, bool) {
   336  	return nil, false
   337  }
   338  
   339  // AsBasicThing is the BasicResponseBase implementation for CreativeWork.
   340  func (cw CreativeWork) AsBasicThing() (BasicThing, bool) {
   341  	return &cw, true
   342  }
   343  
   344  // AsCreativeWork is the BasicResponseBase implementation for CreativeWork.
   345  func (cw CreativeWork) AsCreativeWork() (*CreativeWork, bool) {
   346  	return &cw, true
   347  }
   348  
   349  // AsBasicCreativeWork is the BasicResponseBase implementation for CreativeWork.
   350  func (cw CreativeWork) AsBasicCreativeWork() (BasicCreativeWork, bool) {
   351  	return &cw, true
   352  }
   353  
   354  // AsIdentifiable is the BasicResponseBase implementation for CreativeWork.
   355  func (cw CreativeWork) AsIdentifiable() (*Identifiable, bool) {
   356  	return nil, false
   357  }
   358  
   359  // AsBasicIdentifiable is the BasicResponseBase implementation for CreativeWork.
   360  func (cw CreativeWork) AsBasicIdentifiable() (BasicIdentifiable, bool) {
   361  	return &cw, true
   362  }
   363  
   364  // AsErrorResponse is the BasicResponseBase implementation for CreativeWork.
   365  func (cw CreativeWork) AsErrorResponse() (*ErrorResponse, bool) {
   366  	return nil, false
   367  }
   368  
   369  // AsWebPage is the BasicResponseBase implementation for CreativeWork.
   370  func (cw CreativeWork) AsWebPage() (*WebPage, bool) {
   371  	return nil, false
   372  }
   373  
   374  // AsResponseBase is the BasicResponseBase implementation for CreativeWork.
   375  func (cw CreativeWork) AsResponseBase() (*ResponseBase, bool) {
   376  	return nil, false
   377  }
   378  
   379  // AsBasicResponseBase is the BasicResponseBase implementation for CreativeWork.
   380  func (cw CreativeWork) AsBasicResponseBase() (BasicResponseBase, bool) {
   381  	return &cw, true
   382  }
   383  
   384  // UnmarshalJSON is the custom unmarshaler for CreativeWork struct.
   385  func (cw *CreativeWork) UnmarshalJSON(body []byte) error {
   386  	var m map[string]*json.RawMessage
   387  	err := json.Unmarshal(body, &m)
   388  	if err != nil {
   389  		return err
   390  	}
   391  	for k, v := range m {
   392  		switch k {
   393  		case "thumbnailUrl":
   394  			if v != nil {
   395  				var thumbnailURL string
   396  				err = json.Unmarshal(*v, &thumbnailURL)
   397  				if err != nil {
   398  					return err
   399  				}
   400  				cw.ThumbnailURL = &thumbnailURL
   401  			}
   402  		case "provider":
   403  			if v != nil {
   404  				provider, err := unmarshalBasicThingArray(*v)
   405  				if err != nil {
   406  					return err
   407  				}
   408  				cw.Provider = &provider
   409  			}
   410  		case "text":
   411  			if v != nil {
   412  				var textVar string
   413  				err = json.Unmarshal(*v, &textVar)
   414  				if err != nil {
   415  					return err
   416  				}
   417  				cw.Text = &textVar
   418  			}
   419  		case "name":
   420  			if v != nil {
   421  				var name string
   422  				err = json.Unmarshal(*v, &name)
   423  				if err != nil {
   424  					return err
   425  				}
   426  				cw.Name = &name
   427  			}
   428  		case "url":
   429  			if v != nil {
   430  				var URL string
   431  				err = json.Unmarshal(*v, &URL)
   432  				if err != nil {
   433  					return err
   434  				}
   435  				cw.URL = &URL
   436  			}
   437  		case "image":
   438  			if v != nil {
   439  				var imageVar ImageObject
   440  				err = json.Unmarshal(*v, &imageVar)
   441  				if err != nil {
   442  					return err
   443  				}
   444  				cw.Image = &imageVar
   445  			}
   446  		case "description":
   447  			if v != nil {
   448  				var description string
   449  				err = json.Unmarshal(*v, &description)
   450  				if err != nil {
   451  					return err
   452  				}
   453  				cw.Description = &description
   454  			}
   455  		case "alternateName":
   456  			if v != nil {
   457  				var alternateName string
   458  				err = json.Unmarshal(*v, &alternateName)
   459  				if err != nil {
   460  					return err
   461  				}
   462  				cw.AlternateName = &alternateName
   463  			}
   464  		case "bingId":
   465  			if v != nil {
   466  				var bingID string
   467  				err = json.Unmarshal(*v, &bingID)
   468  				if err != nil {
   469  					return err
   470  				}
   471  				cw.BingID = &bingID
   472  			}
   473  		case "readLink":
   474  			if v != nil {
   475  				var readLink string
   476  				err = json.Unmarshal(*v, &readLink)
   477  				if err != nil {
   478  					return err
   479  				}
   480  				cw.ReadLink = &readLink
   481  			}
   482  		case "webSearchUrl":
   483  			if v != nil {
   484  				var webSearchURL string
   485  				err = json.Unmarshal(*v, &webSearchURL)
   486  				if err != nil {
   487  					return err
   488  				}
   489  				cw.WebSearchURL = &webSearchURL
   490  			}
   491  		case "id":
   492  			if v != nil {
   493  				var ID string
   494  				err = json.Unmarshal(*v, &ID)
   495  				if err != nil {
   496  					return err
   497  				}
   498  				cw.ID = &ID
   499  			}
   500  		case "_type":
   501  			if v != nil {
   502  				var typeVar Type
   503  				err = json.Unmarshal(*v, &typeVar)
   504  				if err != nil {
   505  					return err
   506  				}
   507  				cw.Type = typeVar
   508  			}
   509  		}
   510  	}
   511  
   512  	return nil
   513  }
   514  
   515  // Error defines the error that occurred.
   516  type Error struct {
   517  	// Code - The error code that identifies the category of error. Possible values include: 'None', 'ServerError', 'InvalidRequest', 'RateLimitExceeded', 'InvalidAuthorization', 'InsufficientAuthorization'
   518  	Code ErrorCode `json:"code,omitempty"`
   519  	// SubCode - READ-ONLY; The error code that further helps to identify the error. Possible values include: 'UnexpectedError', 'ResourceError', 'NotImplemented', 'ParameterMissing', 'ParameterInvalidValue', 'HTTPNotAllowed', 'Blocked', 'AuthorizationMissing', 'AuthorizationRedundancy', 'AuthorizationDisabled', 'AuthorizationExpired'
   520  	SubCode ErrorSubCode `json:"subCode,omitempty"`
   521  	// Message - A description of the error.
   522  	Message *string `json:"message,omitempty"`
   523  	// MoreDetails - READ-ONLY; A description that provides additional information about the error.
   524  	MoreDetails *string `json:"moreDetails,omitempty"`
   525  	// Parameter - READ-ONLY; The parameter in the request that caused the error.
   526  	Parameter *string `json:"parameter,omitempty"`
   527  	// Value - READ-ONLY; The parameter's value in the request that was not valid.
   528  	Value *string `json:"value,omitempty"`
   529  }
   530  
   531  // MarshalJSON is the custom marshaler for Error.
   532  func (e Error) MarshalJSON() ([]byte, error) {
   533  	objectMap := make(map[string]interface{})
   534  	if e.Code != "" {
   535  		objectMap["code"] = e.Code
   536  	}
   537  	if e.Message != nil {
   538  		objectMap["message"] = e.Message
   539  	}
   540  	return json.Marshal(objectMap)
   541  }
   542  
   543  // ErrorResponse the top-level response that represents a failed request.
   544  type ErrorResponse struct {
   545  	// Errors - A list of errors that describe the reasons why the request failed.
   546  	Errors *[]Error `json:"errors,omitempty"`
   547  	// ReadLink - READ-ONLY; The URL that returns this resource.
   548  	ReadLink *string `json:"readLink,omitempty"`
   549  	// WebSearchURL - READ-ONLY; The URL To Bing's search result for this item.
   550  	WebSearchURL *string `json:"webSearchUrl,omitempty"`
   551  	// ID - READ-ONLY; A String identifier.
   552  	ID *string `json:"id,omitempty"`
   553  	// Type - Possible values include: 'TypeResponseBase', 'TypeImageObject', 'TypeImages', 'TypeSearchResultsAnswer', 'TypeAnswer', 'TypeMediaObject', 'TypeResponse', 'TypeThing', 'TypeCreativeWork', 'TypeIdentifiable', 'TypeErrorResponse', 'TypeWebPage'
   554  	Type Type `json:"_type,omitempty"`
   555  }
   556  
   557  // MarshalJSON is the custom marshaler for ErrorResponse.
   558  func (er ErrorResponse) MarshalJSON() ([]byte, error) {
   559  	er.Type = TypeErrorResponse
   560  	objectMap := make(map[string]interface{})
   561  	if er.Errors != nil {
   562  		objectMap["errors"] = er.Errors
   563  	}
   564  	if er.Type != "" {
   565  		objectMap["_type"] = er.Type
   566  	}
   567  	return json.Marshal(objectMap)
   568  }
   569  
   570  // AsImageObject is the BasicResponseBase implementation for ErrorResponse.
   571  func (er ErrorResponse) AsImageObject() (*ImageObject, bool) {
   572  	return nil, false
   573  }
   574  
   575  // AsImages is the BasicResponseBase implementation for ErrorResponse.
   576  func (er ErrorResponse) AsImages() (*Images, bool) {
   577  	return nil, false
   578  }
   579  
   580  // AsSearchResultsAnswer is the BasicResponseBase implementation for ErrorResponse.
   581  func (er ErrorResponse) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) {
   582  	return nil, false
   583  }
   584  
   585  // AsBasicSearchResultsAnswer is the BasicResponseBase implementation for ErrorResponse.
   586  func (er ErrorResponse) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) {
   587  	return nil, false
   588  }
   589  
   590  // AsAnswer is the BasicResponseBase implementation for ErrorResponse.
   591  func (er ErrorResponse) AsAnswer() (*Answer, bool) {
   592  	return nil, false
   593  }
   594  
   595  // AsBasicAnswer is the BasicResponseBase implementation for ErrorResponse.
   596  func (er ErrorResponse) AsBasicAnswer() (BasicAnswer, bool) {
   597  	return nil, false
   598  }
   599  
   600  // AsMediaObject is the BasicResponseBase implementation for ErrorResponse.
   601  func (er ErrorResponse) AsMediaObject() (*MediaObject, bool) {
   602  	return nil, false
   603  }
   604  
   605  // AsBasicMediaObject is the BasicResponseBase implementation for ErrorResponse.
   606  func (er ErrorResponse) AsBasicMediaObject() (BasicMediaObject, bool) {
   607  	return nil, false
   608  }
   609  
   610  // AsResponse is the BasicResponseBase implementation for ErrorResponse.
   611  func (er ErrorResponse) AsResponse() (*Response, bool) {
   612  	return nil, false
   613  }
   614  
   615  // AsBasicResponse is the BasicResponseBase implementation for ErrorResponse.
   616  func (er ErrorResponse) AsBasicResponse() (BasicResponse, bool) {
   617  	return &er, true
   618  }
   619  
   620  // AsThing is the BasicResponseBase implementation for ErrorResponse.
   621  func (er ErrorResponse) AsThing() (*Thing, bool) {
   622  	return nil, false
   623  }
   624  
   625  // AsBasicThing is the BasicResponseBase implementation for ErrorResponse.
   626  func (er ErrorResponse) AsBasicThing() (BasicThing, bool) {
   627  	return nil, false
   628  }
   629  
   630  // AsCreativeWork is the BasicResponseBase implementation for ErrorResponse.
   631  func (er ErrorResponse) AsCreativeWork() (*CreativeWork, bool) {
   632  	return nil, false
   633  }
   634  
   635  // AsBasicCreativeWork is the BasicResponseBase implementation for ErrorResponse.
   636  func (er ErrorResponse) AsBasicCreativeWork() (BasicCreativeWork, bool) {
   637  	return nil, false
   638  }
   639  
   640  // AsIdentifiable is the BasicResponseBase implementation for ErrorResponse.
   641  func (er ErrorResponse) AsIdentifiable() (*Identifiable, bool) {
   642  	return nil, false
   643  }
   644  
   645  // AsBasicIdentifiable is the BasicResponseBase implementation for ErrorResponse.
   646  func (er ErrorResponse) AsBasicIdentifiable() (BasicIdentifiable, bool) {
   647  	return &er, true
   648  }
   649  
   650  // AsErrorResponse is the BasicResponseBase implementation for ErrorResponse.
   651  func (er ErrorResponse) AsErrorResponse() (*ErrorResponse, bool) {
   652  	return &er, true
   653  }
   654  
   655  // AsWebPage is the BasicResponseBase implementation for ErrorResponse.
   656  func (er ErrorResponse) AsWebPage() (*WebPage, bool) {
   657  	return nil, false
   658  }
   659  
   660  // AsResponseBase is the BasicResponseBase implementation for ErrorResponse.
   661  func (er ErrorResponse) AsResponseBase() (*ResponseBase, bool) {
   662  	return nil, false
   663  }
   664  
   665  // AsBasicResponseBase is the BasicResponseBase implementation for ErrorResponse.
   666  func (er ErrorResponse) AsBasicResponseBase() (BasicResponseBase, bool) {
   667  	return &er, true
   668  }
   669  
   670  // BasicIdentifiable defines the identity of a resource.
   671  type BasicIdentifiable interface {
   672  	AsImageObject() (*ImageObject, bool)
   673  	AsImages() (*Images, bool)
   674  	AsSearchResultsAnswer() (*SearchResultsAnswer, bool)
   675  	AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool)
   676  	AsAnswer() (*Answer, bool)
   677  	AsBasicAnswer() (BasicAnswer, bool)
   678  	AsMediaObject() (*MediaObject, bool)
   679  	AsBasicMediaObject() (BasicMediaObject, bool)
   680  	AsResponse() (*Response, bool)
   681  	AsBasicResponse() (BasicResponse, bool)
   682  	AsThing() (*Thing, bool)
   683  	AsBasicThing() (BasicThing, bool)
   684  	AsCreativeWork() (*CreativeWork, bool)
   685  	AsBasicCreativeWork() (BasicCreativeWork, bool)
   686  	AsErrorResponse() (*ErrorResponse, bool)
   687  	AsWebPage() (*WebPage, bool)
   688  	AsIdentifiable() (*Identifiable, bool)
   689  }
   690  
   691  // Identifiable defines the identity of a resource.
   692  type Identifiable struct {
   693  	// ID - READ-ONLY; A String identifier.
   694  	ID *string `json:"id,omitempty"`
   695  	// Type - Possible values include: 'TypeResponseBase', 'TypeImageObject', 'TypeImages', 'TypeSearchResultsAnswer', 'TypeAnswer', 'TypeMediaObject', 'TypeResponse', 'TypeThing', 'TypeCreativeWork', 'TypeIdentifiable', 'TypeErrorResponse', 'TypeWebPage'
   696  	Type Type `json:"_type,omitempty"`
   697  }
   698  
   699  func unmarshalBasicIdentifiable(body []byte) (BasicIdentifiable, error) {
   700  	var m map[string]interface{}
   701  	err := json.Unmarshal(body, &m)
   702  	if err != nil {
   703  		return nil, err
   704  	}
   705  
   706  	switch m["_type"] {
   707  	case string(TypeImageObject):
   708  		var ioVar ImageObject
   709  		err := json.Unmarshal(body, &ioVar)
   710  		return ioVar, err
   711  	case string(TypeImages):
   712  		var i Images
   713  		err := json.Unmarshal(body, &i)
   714  		return i, err
   715  	case string(TypeSearchResultsAnswer):
   716  		var sra SearchResultsAnswer
   717  		err := json.Unmarshal(body, &sra)
   718  		return sra, err
   719  	case string(TypeAnswer):
   720  		var a Answer
   721  		err := json.Unmarshal(body, &a)
   722  		return a, err
   723  	case string(TypeMediaObject):
   724  		var mo MediaObject
   725  		err := json.Unmarshal(body, &mo)
   726  		return mo, err
   727  	case string(TypeResponse):
   728  		var r Response
   729  		err := json.Unmarshal(body, &r)
   730  		return r, err
   731  	case string(TypeThing):
   732  		var t Thing
   733  		err := json.Unmarshal(body, &t)
   734  		return t, err
   735  	case string(TypeCreativeWork):
   736  		var cw CreativeWork
   737  		err := json.Unmarshal(body, &cw)
   738  		return cw, err
   739  	case string(TypeErrorResponse):
   740  		var er ErrorResponse
   741  		err := json.Unmarshal(body, &er)
   742  		return er, err
   743  	case string(TypeWebPage):
   744  		var wp WebPage
   745  		err := json.Unmarshal(body, &wp)
   746  		return wp, err
   747  	default:
   748  		var i Identifiable
   749  		err := json.Unmarshal(body, &i)
   750  		return i, err
   751  	}
   752  }
   753  func unmarshalBasicIdentifiableArray(body []byte) ([]BasicIdentifiable, error) {
   754  	var rawMessages []*json.RawMessage
   755  	err := json.Unmarshal(body, &rawMessages)
   756  	if err != nil {
   757  		return nil, err
   758  	}
   759  
   760  	iArray := make([]BasicIdentifiable, len(rawMessages))
   761  
   762  	for index, rawMessage := range rawMessages {
   763  		i, err := unmarshalBasicIdentifiable(*rawMessage)
   764  		if err != nil {
   765  			return nil, err
   766  		}
   767  		iArray[index] = i
   768  	}
   769  	return iArray, nil
   770  }
   771  
   772  // MarshalJSON is the custom marshaler for Identifiable.
   773  func (i Identifiable) MarshalJSON() ([]byte, error) {
   774  	i.Type = TypeIdentifiable
   775  	objectMap := make(map[string]interface{})
   776  	if i.Type != "" {
   777  		objectMap["_type"] = i.Type
   778  	}
   779  	return json.Marshal(objectMap)
   780  }
   781  
   782  // AsImageObject is the BasicResponseBase implementation for Identifiable.
   783  func (i Identifiable) AsImageObject() (*ImageObject, bool) {
   784  	return nil, false
   785  }
   786  
   787  // AsImages is the BasicResponseBase implementation for Identifiable.
   788  func (i Identifiable) AsImages() (*Images, bool) {
   789  	return nil, false
   790  }
   791  
   792  // AsSearchResultsAnswer is the BasicResponseBase implementation for Identifiable.
   793  func (i Identifiable) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) {
   794  	return nil, false
   795  }
   796  
   797  // AsBasicSearchResultsAnswer is the BasicResponseBase implementation for Identifiable.
   798  func (i Identifiable) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) {
   799  	return nil, false
   800  }
   801  
   802  // AsAnswer is the BasicResponseBase implementation for Identifiable.
   803  func (i Identifiable) AsAnswer() (*Answer, bool) {
   804  	return nil, false
   805  }
   806  
   807  // AsBasicAnswer is the BasicResponseBase implementation for Identifiable.
   808  func (i Identifiable) AsBasicAnswer() (BasicAnswer, bool) {
   809  	return nil, false
   810  }
   811  
   812  // AsMediaObject is the BasicResponseBase implementation for Identifiable.
   813  func (i Identifiable) AsMediaObject() (*MediaObject, bool) {
   814  	return nil, false
   815  }
   816  
   817  // AsBasicMediaObject is the BasicResponseBase implementation for Identifiable.
   818  func (i Identifiable) AsBasicMediaObject() (BasicMediaObject, bool) {
   819  	return nil, false
   820  }
   821  
   822  // AsResponse is the BasicResponseBase implementation for Identifiable.
   823  func (i Identifiable) AsResponse() (*Response, bool) {
   824  	return nil, false
   825  }
   826  
   827  // AsBasicResponse is the BasicResponseBase implementation for Identifiable.
   828  func (i Identifiable) AsBasicResponse() (BasicResponse, bool) {
   829  	return nil, false
   830  }
   831  
   832  // AsThing is the BasicResponseBase implementation for Identifiable.
   833  func (i Identifiable) AsThing() (*Thing, bool) {
   834  	return nil, false
   835  }
   836  
   837  // AsBasicThing is the BasicResponseBase implementation for Identifiable.
   838  func (i Identifiable) AsBasicThing() (BasicThing, bool) {
   839  	return nil, false
   840  }
   841  
   842  // AsCreativeWork is the BasicResponseBase implementation for Identifiable.
   843  func (i Identifiable) AsCreativeWork() (*CreativeWork, bool) {
   844  	return nil, false
   845  }
   846  
   847  // AsBasicCreativeWork is the BasicResponseBase implementation for Identifiable.
   848  func (i Identifiable) AsBasicCreativeWork() (BasicCreativeWork, bool) {
   849  	return nil, false
   850  }
   851  
   852  // AsIdentifiable is the BasicResponseBase implementation for Identifiable.
   853  func (i Identifiable) AsIdentifiable() (*Identifiable, bool) {
   854  	return &i, true
   855  }
   856  
   857  // AsBasicIdentifiable is the BasicResponseBase implementation for Identifiable.
   858  func (i Identifiable) AsBasicIdentifiable() (BasicIdentifiable, bool) {
   859  	return &i, true
   860  }
   861  
   862  // AsErrorResponse is the BasicResponseBase implementation for Identifiable.
   863  func (i Identifiable) AsErrorResponse() (*ErrorResponse, bool) {
   864  	return nil, false
   865  }
   866  
   867  // AsWebPage is the BasicResponseBase implementation for Identifiable.
   868  func (i Identifiable) AsWebPage() (*WebPage, bool) {
   869  	return nil, false
   870  }
   871  
   872  // AsResponseBase is the BasicResponseBase implementation for Identifiable.
   873  func (i Identifiable) AsResponseBase() (*ResponseBase, bool) {
   874  	return nil, false
   875  }
   876  
   877  // AsBasicResponseBase is the BasicResponseBase implementation for Identifiable.
   878  func (i Identifiable) AsBasicResponseBase() (BasicResponseBase, bool) {
   879  	return &i, true
   880  }
   881  
   882  // ImageObject defines an image
   883  type ImageObject struct {
   884  	// Thumbnail - READ-ONLY; The URL to a thumbnail of the image
   885  	Thumbnail *ImageObject `json:"thumbnail,omitempty"`
   886  	// ImageInsightsToken - READ-ONLY; The token that you use in a subsequent call to the Image Search API to get additional information about the image. For information about using this token, see the insightsToken query parameter.
   887  	ImageInsightsToken *string `json:"imageInsightsToken,omitempty"`
   888  	// ImageID - READ-ONLY; Unique Id for the image
   889  	ImageID *string `json:"imageId,omitempty"`
   890  	// AccentColor - READ-ONLY; A three-byte hexadecimal number that represents the color that dominates the image. Use the color as the temporary background in your client until the image is loaded.
   891  	AccentColor *string `json:"accentColor,omitempty"`
   892  	// VisualWords - READ-ONLY; Visual representation of the image. Used for getting more sizes
   893  	VisualWords *string `json:"visualWords,omitempty"`
   894  	// ContentURL - READ-ONLY; Original URL to retrieve the source (file) for the media object (e.g the source URL for the image).
   895  	ContentURL *string `json:"contentUrl,omitempty"`
   896  	// HostPageURL - READ-ONLY; URL of the page that hosts the media object.
   897  	HostPageURL *string `json:"hostPageUrl,omitempty"`
   898  	// ContentSize - READ-ONLY; Size of the media object content (use format "value unit" e.g "1024 B").
   899  	ContentSize *string `json:"contentSize,omitempty"`
   900  	// EncodingFormat - READ-ONLY; Encoding format (e.g mp3, mp4, jpeg, etc).
   901  	EncodingFormat *string `json:"encodingFormat,omitempty"`
   902  	// HostPageDisplayURL - READ-ONLY; Display URL of the page that hosts the media object.
   903  	HostPageDisplayURL *string `json:"hostPageDisplayUrl,omitempty"`
   904  	// Width - READ-ONLY; The width of the media object, in pixels.
   905  	Width *int32 `json:"width,omitempty"`
   906  	// Height - READ-ONLY; The height of the media object, in pixels.
   907  	Height *int32 `json:"height,omitempty"`
   908  	// ThumbnailURL - READ-ONLY; The URL to a thumbnail of the item.
   909  	ThumbnailURL *string `json:"thumbnailUrl,omitempty"`
   910  	// Provider - READ-ONLY; The source of the creative work.
   911  	Provider *[]BasicThing `json:"provider,omitempty"`
   912  	// Text - READ-ONLY; Text content of this creative work
   913  	Text *string `json:"text,omitempty"`
   914  	// Name - READ-ONLY; The name of the thing represented by this object.
   915  	Name *string `json:"name,omitempty"`
   916  	// URL - READ-ONLY; The URL to get more information about the thing represented by this object.
   917  	URL *string `json:"url,omitempty"`
   918  	// Image - READ-ONLY; An image of the item.
   919  	Image *ImageObject `json:"image,omitempty"`
   920  	// Description - READ-ONLY; A short description of the item.
   921  	Description *string `json:"description,omitempty"`
   922  	// AlternateName - READ-ONLY; An alias for the item
   923  	AlternateName *string `json:"alternateName,omitempty"`
   924  	// BingID - READ-ONLY; An ID that uniquely identifies this item.
   925  	BingID *string `json:"bingId,omitempty"`
   926  	// ReadLink - READ-ONLY; The URL that returns this resource.
   927  	ReadLink *string `json:"readLink,omitempty"`
   928  	// WebSearchURL - READ-ONLY; The URL To Bing's search result for this item.
   929  	WebSearchURL *string `json:"webSearchUrl,omitempty"`
   930  	// ID - READ-ONLY; A String identifier.
   931  	ID *string `json:"id,omitempty"`
   932  	// Type - Possible values include: 'TypeResponseBase', 'TypeImageObject', 'TypeImages', 'TypeSearchResultsAnswer', 'TypeAnswer', 'TypeMediaObject', 'TypeResponse', 'TypeThing', 'TypeCreativeWork', 'TypeIdentifiable', 'TypeErrorResponse', 'TypeWebPage'
   933  	Type Type `json:"_type,omitempty"`
   934  }
   935  
   936  // MarshalJSON is the custom marshaler for ImageObject.
   937  func (ioVar ImageObject) MarshalJSON() ([]byte, error) {
   938  	ioVar.Type = TypeImageObject
   939  	objectMap := make(map[string]interface{})
   940  	if ioVar.Type != "" {
   941  		objectMap["_type"] = ioVar.Type
   942  	}
   943  	return json.Marshal(objectMap)
   944  }
   945  
   946  // AsImageObject is the BasicResponseBase implementation for ImageObject.
   947  func (ioVar ImageObject) AsImageObject() (*ImageObject, bool) {
   948  	return &ioVar, true
   949  }
   950  
   951  // AsImages is the BasicResponseBase implementation for ImageObject.
   952  func (ioVar ImageObject) AsImages() (*Images, bool) {
   953  	return nil, false
   954  }
   955  
   956  // AsSearchResultsAnswer is the BasicResponseBase implementation for ImageObject.
   957  func (ioVar ImageObject) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) {
   958  	return nil, false
   959  }
   960  
   961  // AsBasicSearchResultsAnswer is the BasicResponseBase implementation for ImageObject.
   962  func (ioVar ImageObject) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) {
   963  	return nil, false
   964  }
   965  
   966  // AsAnswer is the BasicResponseBase implementation for ImageObject.
   967  func (ioVar ImageObject) AsAnswer() (*Answer, bool) {
   968  	return nil, false
   969  }
   970  
   971  // AsBasicAnswer is the BasicResponseBase implementation for ImageObject.
   972  func (ioVar ImageObject) AsBasicAnswer() (BasicAnswer, bool) {
   973  	return nil, false
   974  }
   975  
   976  // AsMediaObject is the BasicResponseBase implementation for ImageObject.
   977  func (ioVar ImageObject) AsMediaObject() (*MediaObject, bool) {
   978  	return nil, false
   979  }
   980  
   981  // AsBasicMediaObject is the BasicResponseBase implementation for ImageObject.
   982  func (ioVar ImageObject) AsBasicMediaObject() (BasicMediaObject, bool) {
   983  	return &ioVar, true
   984  }
   985  
   986  // AsResponse is the BasicResponseBase implementation for ImageObject.
   987  func (ioVar ImageObject) AsResponse() (*Response, bool) {
   988  	return nil, false
   989  }
   990  
   991  // AsBasicResponse is the BasicResponseBase implementation for ImageObject.
   992  func (ioVar ImageObject) AsBasicResponse() (BasicResponse, bool) {
   993  	return &ioVar, true
   994  }
   995  
   996  // AsThing is the BasicResponseBase implementation for ImageObject.
   997  func (ioVar ImageObject) AsThing() (*Thing, bool) {
   998  	return nil, false
   999  }
  1000  
  1001  // AsBasicThing is the BasicResponseBase implementation for ImageObject.
  1002  func (ioVar ImageObject) AsBasicThing() (BasicThing, bool) {
  1003  	return &ioVar, true
  1004  }
  1005  
  1006  // AsCreativeWork is the BasicResponseBase implementation for ImageObject.
  1007  func (ioVar ImageObject) AsCreativeWork() (*CreativeWork, bool) {
  1008  	return nil, false
  1009  }
  1010  
  1011  // AsBasicCreativeWork is the BasicResponseBase implementation for ImageObject.
  1012  func (ioVar ImageObject) AsBasicCreativeWork() (BasicCreativeWork, bool) {
  1013  	return &ioVar, true
  1014  }
  1015  
  1016  // AsIdentifiable is the BasicResponseBase implementation for ImageObject.
  1017  func (ioVar ImageObject) AsIdentifiable() (*Identifiable, bool) {
  1018  	return nil, false
  1019  }
  1020  
  1021  // AsBasicIdentifiable is the BasicResponseBase implementation for ImageObject.
  1022  func (ioVar ImageObject) AsBasicIdentifiable() (BasicIdentifiable, bool) {
  1023  	return &ioVar, true
  1024  }
  1025  
  1026  // AsErrorResponse is the BasicResponseBase implementation for ImageObject.
  1027  func (ioVar ImageObject) AsErrorResponse() (*ErrorResponse, bool) {
  1028  	return nil, false
  1029  }
  1030  
  1031  // AsWebPage is the BasicResponseBase implementation for ImageObject.
  1032  func (ioVar ImageObject) AsWebPage() (*WebPage, bool) {
  1033  	return nil, false
  1034  }
  1035  
  1036  // AsResponseBase is the BasicResponseBase implementation for ImageObject.
  1037  func (ioVar ImageObject) AsResponseBase() (*ResponseBase, bool) {
  1038  	return nil, false
  1039  }
  1040  
  1041  // AsBasicResponseBase is the BasicResponseBase implementation for ImageObject.
  1042  func (ioVar ImageObject) AsBasicResponseBase() (BasicResponseBase, bool) {
  1043  	return &ioVar, true
  1044  }
  1045  
  1046  // UnmarshalJSON is the custom unmarshaler for ImageObject struct.
  1047  func (ioVar *ImageObject) UnmarshalJSON(body []byte) error {
  1048  	var m map[string]*json.RawMessage
  1049  	err := json.Unmarshal(body, &m)
  1050  	if err != nil {
  1051  		return err
  1052  	}
  1053  	for k, v := range m {
  1054  		switch k {
  1055  		case "thumbnail":
  1056  			if v != nil {
  1057  				var thumbnail ImageObject
  1058  				err = json.Unmarshal(*v, &thumbnail)
  1059  				if err != nil {
  1060  					return err
  1061  				}
  1062  				ioVar.Thumbnail = &thumbnail
  1063  			}
  1064  		case "imageInsightsToken":
  1065  			if v != nil {
  1066  				var imageInsightsToken string
  1067  				err = json.Unmarshal(*v, &imageInsightsToken)
  1068  				if err != nil {
  1069  					return err
  1070  				}
  1071  				ioVar.ImageInsightsToken = &imageInsightsToken
  1072  			}
  1073  		case "imageId":
  1074  			if v != nil {
  1075  				var imageID string
  1076  				err = json.Unmarshal(*v, &imageID)
  1077  				if err != nil {
  1078  					return err
  1079  				}
  1080  				ioVar.ImageID = &imageID
  1081  			}
  1082  		case "accentColor":
  1083  			if v != nil {
  1084  				var accentColor string
  1085  				err = json.Unmarshal(*v, &accentColor)
  1086  				if err != nil {
  1087  					return err
  1088  				}
  1089  				ioVar.AccentColor = &accentColor
  1090  			}
  1091  		case "visualWords":
  1092  			if v != nil {
  1093  				var visualWords string
  1094  				err = json.Unmarshal(*v, &visualWords)
  1095  				if err != nil {
  1096  					return err
  1097  				}
  1098  				ioVar.VisualWords = &visualWords
  1099  			}
  1100  		case "contentUrl":
  1101  			if v != nil {
  1102  				var contentURL string
  1103  				err = json.Unmarshal(*v, &contentURL)
  1104  				if err != nil {
  1105  					return err
  1106  				}
  1107  				ioVar.ContentURL = &contentURL
  1108  			}
  1109  		case "hostPageUrl":
  1110  			if v != nil {
  1111  				var hostPageURL string
  1112  				err = json.Unmarshal(*v, &hostPageURL)
  1113  				if err != nil {
  1114  					return err
  1115  				}
  1116  				ioVar.HostPageURL = &hostPageURL
  1117  			}
  1118  		case "contentSize":
  1119  			if v != nil {
  1120  				var contentSize string
  1121  				err = json.Unmarshal(*v, &contentSize)
  1122  				if err != nil {
  1123  					return err
  1124  				}
  1125  				ioVar.ContentSize = &contentSize
  1126  			}
  1127  		case "encodingFormat":
  1128  			if v != nil {
  1129  				var encodingFormat string
  1130  				err = json.Unmarshal(*v, &encodingFormat)
  1131  				if err != nil {
  1132  					return err
  1133  				}
  1134  				ioVar.EncodingFormat = &encodingFormat
  1135  			}
  1136  		case "hostPageDisplayUrl":
  1137  			if v != nil {
  1138  				var hostPageDisplayURL string
  1139  				err = json.Unmarshal(*v, &hostPageDisplayURL)
  1140  				if err != nil {
  1141  					return err
  1142  				}
  1143  				ioVar.HostPageDisplayURL = &hostPageDisplayURL
  1144  			}
  1145  		case "width":
  1146  			if v != nil {
  1147  				var width int32
  1148  				err = json.Unmarshal(*v, &width)
  1149  				if err != nil {
  1150  					return err
  1151  				}
  1152  				ioVar.Width = &width
  1153  			}
  1154  		case "height":
  1155  			if v != nil {
  1156  				var height int32
  1157  				err = json.Unmarshal(*v, &height)
  1158  				if err != nil {
  1159  					return err
  1160  				}
  1161  				ioVar.Height = &height
  1162  			}
  1163  		case "thumbnailUrl":
  1164  			if v != nil {
  1165  				var thumbnailURL string
  1166  				err = json.Unmarshal(*v, &thumbnailURL)
  1167  				if err != nil {
  1168  					return err
  1169  				}
  1170  				ioVar.ThumbnailURL = &thumbnailURL
  1171  			}
  1172  		case "provider":
  1173  			if v != nil {
  1174  				provider, err := unmarshalBasicThingArray(*v)
  1175  				if err != nil {
  1176  					return err
  1177  				}
  1178  				ioVar.Provider = &provider
  1179  			}
  1180  		case "text":
  1181  			if v != nil {
  1182  				var textVar string
  1183  				err = json.Unmarshal(*v, &textVar)
  1184  				if err != nil {
  1185  					return err
  1186  				}
  1187  				ioVar.Text = &textVar
  1188  			}
  1189  		case "name":
  1190  			if v != nil {
  1191  				var name string
  1192  				err = json.Unmarshal(*v, &name)
  1193  				if err != nil {
  1194  					return err
  1195  				}
  1196  				ioVar.Name = &name
  1197  			}
  1198  		case "url":
  1199  			if v != nil {
  1200  				var URL string
  1201  				err = json.Unmarshal(*v, &URL)
  1202  				if err != nil {
  1203  					return err
  1204  				}
  1205  				ioVar.URL = &URL
  1206  			}
  1207  		case "image":
  1208  			if v != nil {
  1209  				var imageVar ImageObject
  1210  				err = json.Unmarshal(*v, &imageVar)
  1211  				if err != nil {
  1212  					return err
  1213  				}
  1214  				ioVar.Image = &imageVar
  1215  			}
  1216  		case "description":
  1217  			if v != nil {
  1218  				var description string
  1219  				err = json.Unmarshal(*v, &description)
  1220  				if err != nil {
  1221  					return err
  1222  				}
  1223  				ioVar.Description = &description
  1224  			}
  1225  		case "alternateName":
  1226  			if v != nil {
  1227  				var alternateName string
  1228  				err = json.Unmarshal(*v, &alternateName)
  1229  				if err != nil {
  1230  					return err
  1231  				}
  1232  				ioVar.AlternateName = &alternateName
  1233  			}
  1234  		case "bingId":
  1235  			if v != nil {
  1236  				var bingID string
  1237  				err = json.Unmarshal(*v, &bingID)
  1238  				if err != nil {
  1239  					return err
  1240  				}
  1241  				ioVar.BingID = &bingID
  1242  			}
  1243  		case "readLink":
  1244  			if v != nil {
  1245  				var readLink string
  1246  				err = json.Unmarshal(*v, &readLink)
  1247  				if err != nil {
  1248  					return err
  1249  				}
  1250  				ioVar.ReadLink = &readLink
  1251  			}
  1252  		case "webSearchUrl":
  1253  			if v != nil {
  1254  				var webSearchURL string
  1255  				err = json.Unmarshal(*v, &webSearchURL)
  1256  				if err != nil {
  1257  					return err
  1258  				}
  1259  				ioVar.WebSearchURL = &webSearchURL
  1260  			}
  1261  		case "id":
  1262  			if v != nil {
  1263  				var ID string
  1264  				err = json.Unmarshal(*v, &ID)
  1265  				if err != nil {
  1266  					return err
  1267  				}
  1268  				ioVar.ID = &ID
  1269  			}
  1270  		case "_type":
  1271  			if v != nil {
  1272  				var typeVar Type
  1273  				err = json.Unmarshal(*v, &typeVar)
  1274  				if err != nil {
  1275  					return err
  1276  				}
  1277  				ioVar.Type = typeVar
  1278  			}
  1279  		}
  1280  	}
  1281  
  1282  	return nil
  1283  }
  1284  
  1285  // Images defines an image answer
  1286  type Images struct {
  1287  	autorest.Response `json:"-"`
  1288  	// NextOffset - READ-ONLY; Used as part of deduping. Tells client the next offset that client should use in the next pagination request
  1289  	NextOffset *int32 `json:"nextOffset,omitempty"`
  1290  	// Value - A list of image objects that are relevant to the query. If there are no results, the List is empty.
  1291  	Value *[]ImageObject `json:"value,omitempty"`
  1292  	// TotalEstimatedMatches - READ-ONLY; The estimated number of webpages that are relevant to the query. Use this number along with the count and offset query parameters to page the results.
  1293  	TotalEstimatedMatches *int64 `json:"totalEstimatedMatches,omitempty"`
  1294  	// ReadLink - READ-ONLY; The URL that returns this resource.
  1295  	ReadLink *string `json:"readLink,omitempty"`
  1296  	// WebSearchURL - READ-ONLY; The URL To Bing's search result for this item.
  1297  	WebSearchURL *string `json:"webSearchUrl,omitempty"`
  1298  	// ID - READ-ONLY; A String identifier.
  1299  	ID *string `json:"id,omitempty"`
  1300  	// Type - Possible values include: 'TypeResponseBase', 'TypeImageObject', 'TypeImages', 'TypeSearchResultsAnswer', 'TypeAnswer', 'TypeMediaObject', 'TypeResponse', 'TypeThing', 'TypeCreativeWork', 'TypeIdentifiable', 'TypeErrorResponse', 'TypeWebPage'
  1301  	Type Type `json:"_type,omitempty"`
  1302  }
  1303  
  1304  // MarshalJSON is the custom marshaler for Images.
  1305  func (i Images) MarshalJSON() ([]byte, error) {
  1306  	i.Type = TypeImages
  1307  	objectMap := make(map[string]interface{})
  1308  	if i.Value != nil {
  1309  		objectMap["value"] = i.Value
  1310  	}
  1311  	if i.Type != "" {
  1312  		objectMap["_type"] = i.Type
  1313  	}
  1314  	return json.Marshal(objectMap)
  1315  }
  1316  
  1317  // AsImageObject is the BasicResponseBase implementation for Images.
  1318  func (i Images) AsImageObject() (*ImageObject, bool) {
  1319  	return nil, false
  1320  }
  1321  
  1322  // AsImages is the BasicResponseBase implementation for Images.
  1323  func (i Images) AsImages() (*Images, bool) {
  1324  	return &i, true
  1325  }
  1326  
  1327  // AsSearchResultsAnswer is the BasicResponseBase implementation for Images.
  1328  func (i Images) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) {
  1329  	return nil, false
  1330  }
  1331  
  1332  // AsBasicSearchResultsAnswer is the BasicResponseBase implementation for Images.
  1333  func (i Images) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) {
  1334  	return &i, true
  1335  }
  1336  
  1337  // AsAnswer is the BasicResponseBase implementation for Images.
  1338  func (i Images) AsAnswer() (*Answer, bool) {
  1339  	return nil, false
  1340  }
  1341  
  1342  // AsBasicAnswer is the BasicResponseBase implementation for Images.
  1343  func (i Images) AsBasicAnswer() (BasicAnswer, bool) {
  1344  	return &i, true
  1345  }
  1346  
  1347  // AsMediaObject is the BasicResponseBase implementation for Images.
  1348  func (i Images) AsMediaObject() (*MediaObject, bool) {
  1349  	return nil, false
  1350  }
  1351  
  1352  // AsBasicMediaObject is the BasicResponseBase implementation for Images.
  1353  func (i Images) AsBasicMediaObject() (BasicMediaObject, bool) {
  1354  	return nil, false
  1355  }
  1356  
  1357  // AsResponse is the BasicResponseBase implementation for Images.
  1358  func (i Images) AsResponse() (*Response, bool) {
  1359  	return nil, false
  1360  }
  1361  
  1362  // AsBasicResponse is the BasicResponseBase implementation for Images.
  1363  func (i Images) AsBasicResponse() (BasicResponse, bool) {
  1364  	return &i, true
  1365  }
  1366  
  1367  // AsThing is the BasicResponseBase implementation for Images.
  1368  func (i Images) AsThing() (*Thing, bool) {
  1369  	return nil, false
  1370  }
  1371  
  1372  // AsBasicThing is the BasicResponseBase implementation for Images.
  1373  func (i Images) AsBasicThing() (BasicThing, bool) {
  1374  	return nil, false
  1375  }
  1376  
  1377  // AsCreativeWork is the BasicResponseBase implementation for Images.
  1378  func (i Images) AsCreativeWork() (*CreativeWork, bool) {
  1379  	return nil, false
  1380  }
  1381  
  1382  // AsBasicCreativeWork is the BasicResponseBase implementation for Images.
  1383  func (i Images) AsBasicCreativeWork() (BasicCreativeWork, bool) {
  1384  	return nil, false
  1385  }
  1386  
  1387  // AsIdentifiable is the BasicResponseBase implementation for Images.
  1388  func (i Images) AsIdentifiable() (*Identifiable, bool) {
  1389  	return nil, false
  1390  }
  1391  
  1392  // AsBasicIdentifiable is the BasicResponseBase implementation for Images.
  1393  func (i Images) AsBasicIdentifiable() (BasicIdentifiable, bool) {
  1394  	return &i, true
  1395  }
  1396  
  1397  // AsErrorResponse is the BasicResponseBase implementation for Images.
  1398  func (i Images) AsErrorResponse() (*ErrorResponse, bool) {
  1399  	return nil, false
  1400  }
  1401  
  1402  // AsWebPage is the BasicResponseBase implementation for Images.
  1403  func (i Images) AsWebPage() (*WebPage, bool) {
  1404  	return nil, false
  1405  }
  1406  
  1407  // AsResponseBase is the BasicResponseBase implementation for Images.
  1408  func (i Images) AsResponseBase() (*ResponseBase, bool) {
  1409  	return nil, false
  1410  }
  1411  
  1412  // AsBasicResponseBase is the BasicResponseBase implementation for Images.
  1413  func (i Images) AsBasicResponseBase() (BasicResponseBase, bool) {
  1414  	return &i, true
  1415  }
  1416  
  1417  // BasicMediaObject defines a media object.
  1418  type BasicMediaObject interface {
  1419  	AsImageObject() (*ImageObject, bool)
  1420  	AsMediaObject() (*MediaObject, bool)
  1421  }
  1422  
  1423  // MediaObject defines a media object.
  1424  type MediaObject struct {
  1425  	// ContentURL - READ-ONLY; Original URL to retrieve the source (file) for the media object (e.g the source URL for the image).
  1426  	ContentURL *string `json:"contentUrl,omitempty"`
  1427  	// HostPageURL - READ-ONLY; URL of the page that hosts the media object.
  1428  	HostPageURL *string `json:"hostPageUrl,omitempty"`
  1429  	// ContentSize - READ-ONLY; Size of the media object content (use format "value unit" e.g "1024 B").
  1430  	ContentSize *string `json:"contentSize,omitempty"`
  1431  	// EncodingFormat - READ-ONLY; Encoding format (e.g mp3, mp4, jpeg, etc).
  1432  	EncodingFormat *string `json:"encodingFormat,omitempty"`
  1433  	// HostPageDisplayURL - READ-ONLY; Display URL of the page that hosts the media object.
  1434  	HostPageDisplayURL *string `json:"hostPageDisplayUrl,omitempty"`
  1435  	// Width - READ-ONLY; The width of the media object, in pixels.
  1436  	Width *int32 `json:"width,omitempty"`
  1437  	// Height - READ-ONLY; The height of the media object, in pixels.
  1438  	Height *int32 `json:"height,omitempty"`
  1439  	// ThumbnailURL - READ-ONLY; The URL to a thumbnail of the item.
  1440  	ThumbnailURL *string `json:"thumbnailUrl,omitempty"`
  1441  	// Provider - READ-ONLY; The source of the creative work.
  1442  	Provider *[]BasicThing `json:"provider,omitempty"`
  1443  	// Text - READ-ONLY; Text content of this creative work
  1444  	Text *string `json:"text,omitempty"`
  1445  	// Name - READ-ONLY; The name of the thing represented by this object.
  1446  	Name *string `json:"name,omitempty"`
  1447  	// URL - READ-ONLY; The URL to get more information about the thing represented by this object.
  1448  	URL *string `json:"url,omitempty"`
  1449  	// Image - READ-ONLY; An image of the item.
  1450  	Image *ImageObject `json:"image,omitempty"`
  1451  	// Description - READ-ONLY; A short description of the item.
  1452  	Description *string `json:"description,omitempty"`
  1453  	// AlternateName - READ-ONLY; An alias for the item
  1454  	AlternateName *string `json:"alternateName,omitempty"`
  1455  	// BingID - READ-ONLY; An ID that uniquely identifies this item.
  1456  	BingID *string `json:"bingId,omitempty"`
  1457  	// ReadLink - READ-ONLY; The URL that returns this resource.
  1458  	ReadLink *string `json:"readLink,omitempty"`
  1459  	// WebSearchURL - READ-ONLY; The URL To Bing's search result for this item.
  1460  	WebSearchURL *string `json:"webSearchUrl,omitempty"`
  1461  	// ID - READ-ONLY; A String identifier.
  1462  	ID *string `json:"id,omitempty"`
  1463  	// Type - Possible values include: 'TypeResponseBase', 'TypeImageObject', 'TypeImages', 'TypeSearchResultsAnswer', 'TypeAnswer', 'TypeMediaObject', 'TypeResponse', 'TypeThing', 'TypeCreativeWork', 'TypeIdentifiable', 'TypeErrorResponse', 'TypeWebPage'
  1464  	Type Type `json:"_type,omitempty"`
  1465  }
  1466  
  1467  func unmarshalBasicMediaObject(body []byte) (BasicMediaObject, error) {
  1468  	var m map[string]interface{}
  1469  	err := json.Unmarshal(body, &m)
  1470  	if err != nil {
  1471  		return nil, err
  1472  	}
  1473  
  1474  	switch m["_type"] {
  1475  	case string(TypeImageObject):
  1476  		var ioVar ImageObject
  1477  		err := json.Unmarshal(body, &ioVar)
  1478  		return ioVar, err
  1479  	default:
  1480  		var mo MediaObject
  1481  		err := json.Unmarshal(body, &mo)
  1482  		return mo, err
  1483  	}
  1484  }
  1485  func unmarshalBasicMediaObjectArray(body []byte) ([]BasicMediaObject, error) {
  1486  	var rawMessages []*json.RawMessage
  1487  	err := json.Unmarshal(body, &rawMessages)
  1488  	if err != nil {
  1489  		return nil, err
  1490  	}
  1491  
  1492  	moArray := make([]BasicMediaObject, len(rawMessages))
  1493  
  1494  	for index, rawMessage := range rawMessages {
  1495  		mo, err := unmarshalBasicMediaObject(*rawMessage)
  1496  		if err != nil {
  1497  			return nil, err
  1498  		}
  1499  		moArray[index] = mo
  1500  	}
  1501  	return moArray, nil
  1502  }
  1503  
  1504  // MarshalJSON is the custom marshaler for MediaObject.
  1505  func (mo MediaObject) MarshalJSON() ([]byte, error) {
  1506  	mo.Type = TypeMediaObject
  1507  	objectMap := make(map[string]interface{})
  1508  	if mo.Type != "" {
  1509  		objectMap["_type"] = mo.Type
  1510  	}
  1511  	return json.Marshal(objectMap)
  1512  }
  1513  
  1514  // AsImageObject is the BasicResponseBase implementation for MediaObject.
  1515  func (mo MediaObject) AsImageObject() (*ImageObject, bool) {
  1516  	return nil, false
  1517  }
  1518  
  1519  // AsImages is the BasicResponseBase implementation for MediaObject.
  1520  func (mo MediaObject) AsImages() (*Images, bool) {
  1521  	return nil, false
  1522  }
  1523  
  1524  // AsSearchResultsAnswer is the BasicResponseBase implementation for MediaObject.
  1525  func (mo MediaObject) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) {
  1526  	return nil, false
  1527  }
  1528  
  1529  // AsBasicSearchResultsAnswer is the BasicResponseBase implementation for MediaObject.
  1530  func (mo MediaObject) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) {
  1531  	return nil, false
  1532  }
  1533  
  1534  // AsAnswer is the BasicResponseBase implementation for MediaObject.
  1535  func (mo MediaObject) AsAnswer() (*Answer, bool) {
  1536  	return nil, false
  1537  }
  1538  
  1539  // AsBasicAnswer is the BasicResponseBase implementation for MediaObject.
  1540  func (mo MediaObject) AsBasicAnswer() (BasicAnswer, bool) {
  1541  	return nil, false
  1542  }
  1543  
  1544  // AsMediaObject is the BasicResponseBase implementation for MediaObject.
  1545  func (mo MediaObject) AsMediaObject() (*MediaObject, bool) {
  1546  	return &mo, true
  1547  }
  1548  
  1549  // AsBasicMediaObject is the BasicResponseBase implementation for MediaObject.
  1550  func (mo MediaObject) AsBasicMediaObject() (BasicMediaObject, bool) {
  1551  	return &mo, true
  1552  }
  1553  
  1554  // AsResponse is the BasicResponseBase implementation for MediaObject.
  1555  func (mo MediaObject) AsResponse() (*Response, bool) {
  1556  	return nil, false
  1557  }
  1558  
  1559  // AsBasicResponse is the BasicResponseBase implementation for MediaObject.
  1560  func (mo MediaObject) AsBasicResponse() (BasicResponse, bool) {
  1561  	return &mo, true
  1562  }
  1563  
  1564  // AsThing is the BasicResponseBase implementation for MediaObject.
  1565  func (mo MediaObject) AsThing() (*Thing, bool) {
  1566  	return nil, false
  1567  }
  1568  
  1569  // AsBasicThing is the BasicResponseBase implementation for MediaObject.
  1570  func (mo MediaObject) AsBasicThing() (BasicThing, bool) {
  1571  	return &mo, true
  1572  }
  1573  
  1574  // AsCreativeWork is the BasicResponseBase implementation for MediaObject.
  1575  func (mo MediaObject) AsCreativeWork() (*CreativeWork, bool) {
  1576  	return nil, false
  1577  }
  1578  
  1579  // AsBasicCreativeWork is the BasicResponseBase implementation for MediaObject.
  1580  func (mo MediaObject) AsBasicCreativeWork() (BasicCreativeWork, bool) {
  1581  	return &mo, true
  1582  }
  1583  
  1584  // AsIdentifiable is the BasicResponseBase implementation for MediaObject.
  1585  func (mo MediaObject) AsIdentifiable() (*Identifiable, bool) {
  1586  	return nil, false
  1587  }
  1588  
  1589  // AsBasicIdentifiable is the BasicResponseBase implementation for MediaObject.
  1590  func (mo MediaObject) AsBasicIdentifiable() (BasicIdentifiable, bool) {
  1591  	return &mo, true
  1592  }
  1593  
  1594  // AsErrorResponse is the BasicResponseBase implementation for MediaObject.
  1595  func (mo MediaObject) AsErrorResponse() (*ErrorResponse, bool) {
  1596  	return nil, false
  1597  }
  1598  
  1599  // AsWebPage is the BasicResponseBase implementation for MediaObject.
  1600  func (mo MediaObject) AsWebPage() (*WebPage, bool) {
  1601  	return nil, false
  1602  }
  1603  
  1604  // AsResponseBase is the BasicResponseBase implementation for MediaObject.
  1605  func (mo MediaObject) AsResponseBase() (*ResponseBase, bool) {
  1606  	return nil, false
  1607  }
  1608  
  1609  // AsBasicResponseBase is the BasicResponseBase implementation for MediaObject.
  1610  func (mo MediaObject) AsBasicResponseBase() (BasicResponseBase, bool) {
  1611  	return &mo, true
  1612  }
  1613  
  1614  // UnmarshalJSON is the custom unmarshaler for MediaObject struct.
  1615  func (mo *MediaObject) UnmarshalJSON(body []byte) error {
  1616  	var m map[string]*json.RawMessage
  1617  	err := json.Unmarshal(body, &m)
  1618  	if err != nil {
  1619  		return err
  1620  	}
  1621  	for k, v := range m {
  1622  		switch k {
  1623  		case "contentUrl":
  1624  			if v != nil {
  1625  				var contentURL string
  1626  				err = json.Unmarshal(*v, &contentURL)
  1627  				if err != nil {
  1628  					return err
  1629  				}
  1630  				mo.ContentURL = &contentURL
  1631  			}
  1632  		case "hostPageUrl":
  1633  			if v != nil {
  1634  				var hostPageURL string
  1635  				err = json.Unmarshal(*v, &hostPageURL)
  1636  				if err != nil {
  1637  					return err
  1638  				}
  1639  				mo.HostPageURL = &hostPageURL
  1640  			}
  1641  		case "contentSize":
  1642  			if v != nil {
  1643  				var contentSize string
  1644  				err = json.Unmarshal(*v, &contentSize)
  1645  				if err != nil {
  1646  					return err
  1647  				}
  1648  				mo.ContentSize = &contentSize
  1649  			}
  1650  		case "encodingFormat":
  1651  			if v != nil {
  1652  				var encodingFormat string
  1653  				err = json.Unmarshal(*v, &encodingFormat)
  1654  				if err != nil {
  1655  					return err
  1656  				}
  1657  				mo.EncodingFormat = &encodingFormat
  1658  			}
  1659  		case "hostPageDisplayUrl":
  1660  			if v != nil {
  1661  				var hostPageDisplayURL string
  1662  				err = json.Unmarshal(*v, &hostPageDisplayURL)
  1663  				if err != nil {
  1664  					return err
  1665  				}
  1666  				mo.HostPageDisplayURL = &hostPageDisplayURL
  1667  			}
  1668  		case "width":
  1669  			if v != nil {
  1670  				var width int32
  1671  				err = json.Unmarshal(*v, &width)
  1672  				if err != nil {
  1673  					return err
  1674  				}
  1675  				mo.Width = &width
  1676  			}
  1677  		case "height":
  1678  			if v != nil {
  1679  				var height int32
  1680  				err = json.Unmarshal(*v, &height)
  1681  				if err != nil {
  1682  					return err
  1683  				}
  1684  				mo.Height = &height
  1685  			}
  1686  		case "thumbnailUrl":
  1687  			if v != nil {
  1688  				var thumbnailURL string
  1689  				err = json.Unmarshal(*v, &thumbnailURL)
  1690  				if err != nil {
  1691  					return err
  1692  				}
  1693  				mo.ThumbnailURL = &thumbnailURL
  1694  			}
  1695  		case "provider":
  1696  			if v != nil {
  1697  				provider, err := unmarshalBasicThingArray(*v)
  1698  				if err != nil {
  1699  					return err
  1700  				}
  1701  				mo.Provider = &provider
  1702  			}
  1703  		case "text":
  1704  			if v != nil {
  1705  				var textVar string
  1706  				err = json.Unmarshal(*v, &textVar)
  1707  				if err != nil {
  1708  					return err
  1709  				}
  1710  				mo.Text = &textVar
  1711  			}
  1712  		case "name":
  1713  			if v != nil {
  1714  				var name string
  1715  				err = json.Unmarshal(*v, &name)
  1716  				if err != nil {
  1717  					return err
  1718  				}
  1719  				mo.Name = &name
  1720  			}
  1721  		case "url":
  1722  			if v != nil {
  1723  				var URL string
  1724  				err = json.Unmarshal(*v, &URL)
  1725  				if err != nil {
  1726  					return err
  1727  				}
  1728  				mo.URL = &URL
  1729  			}
  1730  		case "image":
  1731  			if v != nil {
  1732  				var imageVar ImageObject
  1733  				err = json.Unmarshal(*v, &imageVar)
  1734  				if err != nil {
  1735  					return err
  1736  				}
  1737  				mo.Image = &imageVar
  1738  			}
  1739  		case "description":
  1740  			if v != nil {
  1741  				var description string
  1742  				err = json.Unmarshal(*v, &description)
  1743  				if err != nil {
  1744  					return err
  1745  				}
  1746  				mo.Description = &description
  1747  			}
  1748  		case "alternateName":
  1749  			if v != nil {
  1750  				var alternateName string
  1751  				err = json.Unmarshal(*v, &alternateName)
  1752  				if err != nil {
  1753  					return err
  1754  				}
  1755  				mo.AlternateName = &alternateName
  1756  			}
  1757  		case "bingId":
  1758  			if v != nil {
  1759  				var bingID string
  1760  				err = json.Unmarshal(*v, &bingID)
  1761  				if err != nil {
  1762  					return err
  1763  				}
  1764  				mo.BingID = &bingID
  1765  			}
  1766  		case "readLink":
  1767  			if v != nil {
  1768  				var readLink string
  1769  				err = json.Unmarshal(*v, &readLink)
  1770  				if err != nil {
  1771  					return err
  1772  				}
  1773  				mo.ReadLink = &readLink
  1774  			}
  1775  		case "webSearchUrl":
  1776  			if v != nil {
  1777  				var webSearchURL string
  1778  				err = json.Unmarshal(*v, &webSearchURL)
  1779  				if err != nil {
  1780  					return err
  1781  				}
  1782  				mo.WebSearchURL = &webSearchURL
  1783  			}
  1784  		case "id":
  1785  			if v != nil {
  1786  				var ID string
  1787  				err = json.Unmarshal(*v, &ID)
  1788  				if err != nil {
  1789  					return err
  1790  				}
  1791  				mo.ID = &ID
  1792  			}
  1793  		case "_type":
  1794  			if v != nil {
  1795  				var typeVar Type
  1796  				err = json.Unmarshal(*v, &typeVar)
  1797  				if err != nil {
  1798  					return err
  1799  				}
  1800  				mo.Type = typeVar
  1801  			}
  1802  		}
  1803  	}
  1804  
  1805  	return nil
  1806  }
  1807  
  1808  // Query defines a search query.
  1809  type Query struct {
  1810  	// Text - The query string. Use this string as the query term in a new search request.
  1811  	Text *string `json:"text,omitempty"`
  1812  	// DisplayText - READ-ONLY; The display version of the query term. This version of the query term may contain special characters that highlight the search term found in the query string. The string contains the highlighting characters only if the query enabled hit highlighting
  1813  	DisplayText *string `json:"displayText,omitempty"`
  1814  	// WebSearchURL - READ-ONLY; The URL that takes the user to the Bing search results page for the query.Only related search results include this field.
  1815  	WebSearchURL *string `json:"webSearchUrl,omitempty"`
  1816  	// SearchLink - READ-ONLY; The URL that you use to get the results of the related search. Before using the URL, you must append query parameters as appropriate and include the Ocp-Apim-Subscription-Key header. Use this URL if you're displaying the results in your own user interface. Otherwise, use the webSearchUrl URL.
  1817  	SearchLink *string `json:"searchLink,omitempty"`
  1818  	// Thumbnail - READ-ONLY; The URL to a thumbnail of a related image.
  1819  	Thumbnail *ImageObject `json:"thumbnail,omitempty"`
  1820  }
  1821  
  1822  // MarshalJSON is the custom marshaler for Query.
  1823  func (q Query) MarshalJSON() ([]byte, error) {
  1824  	objectMap := make(map[string]interface{})
  1825  	if q.Text != nil {
  1826  		objectMap["text"] = q.Text
  1827  	}
  1828  	return json.Marshal(objectMap)
  1829  }
  1830  
  1831  // BasicResponse defines a response. All schemas that could be returned at the root of a response should inherit from
  1832  // this
  1833  type BasicResponse interface {
  1834  	AsImageObject() (*ImageObject, bool)
  1835  	AsImages() (*Images, bool)
  1836  	AsSearchResultsAnswer() (*SearchResultsAnswer, bool)
  1837  	AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool)
  1838  	AsAnswer() (*Answer, bool)
  1839  	AsBasicAnswer() (BasicAnswer, bool)
  1840  	AsMediaObject() (*MediaObject, bool)
  1841  	AsBasicMediaObject() (BasicMediaObject, bool)
  1842  	AsThing() (*Thing, bool)
  1843  	AsBasicThing() (BasicThing, bool)
  1844  	AsCreativeWork() (*CreativeWork, bool)
  1845  	AsBasicCreativeWork() (BasicCreativeWork, bool)
  1846  	AsErrorResponse() (*ErrorResponse, bool)
  1847  	AsWebPage() (*WebPage, bool)
  1848  	AsResponse() (*Response, bool)
  1849  }
  1850  
  1851  // Response defines a response. All schemas that could be returned at the root of a response should inherit
  1852  // from this
  1853  type Response struct {
  1854  	// ReadLink - READ-ONLY; The URL that returns this resource.
  1855  	ReadLink *string `json:"readLink,omitempty"`
  1856  	// WebSearchURL - READ-ONLY; The URL To Bing's search result for this item.
  1857  	WebSearchURL *string `json:"webSearchUrl,omitempty"`
  1858  	// ID - READ-ONLY; A String identifier.
  1859  	ID *string `json:"id,omitempty"`
  1860  	// Type - Possible values include: 'TypeResponseBase', 'TypeImageObject', 'TypeImages', 'TypeSearchResultsAnswer', 'TypeAnswer', 'TypeMediaObject', 'TypeResponse', 'TypeThing', 'TypeCreativeWork', 'TypeIdentifiable', 'TypeErrorResponse', 'TypeWebPage'
  1861  	Type Type `json:"_type,omitempty"`
  1862  }
  1863  
  1864  func unmarshalBasicResponse(body []byte) (BasicResponse, error) {
  1865  	var m map[string]interface{}
  1866  	err := json.Unmarshal(body, &m)
  1867  	if err != nil {
  1868  		return nil, err
  1869  	}
  1870  
  1871  	switch m["_type"] {
  1872  	case string(TypeImageObject):
  1873  		var ioVar ImageObject
  1874  		err := json.Unmarshal(body, &ioVar)
  1875  		return ioVar, err
  1876  	case string(TypeImages):
  1877  		var i Images
  1878  		err := json.Unmarshal(body, &i)
  1879  		return i, err
  1880  	case string(TypeSearchResultsAnswer):
  1881  		var sra SearchResultsAnswer
  1882  		err := json.Unmarshal(body, &sra)
  1883  		return sra, err
  1884  	case string(TypeAnswer):
  1885  		var a Answer
  1886  		err := json.Unmarshal(body, &a)
  1887  		return a, err
  1888  	case string(TypeMediaObject):
  1889  		var mo MediaObject
  1890  		err := json.Unmarshal(body, &mo)
  1891  		return mo, err
  1892  	case string(TypeThing):
  1893  		var t Thing
  1894  		err := json.Unmarshal(body, &t)
  1895  		return t, err
  1896  	case string(TypeCreativeWork):
  1897  		var cw CreativeWork
  1898  		err := json.Unmarshal(body, &cw)
  1899  		return cw, err
  1900  	case string(TypeErrorResponse):
  1901  		var er ErrorResponse
  1902  		err := json.Unmarshal(body, &er)
  1903  		return er, err
  1904  	case string(TypeWebPage):
  1905  		var wp WebPage
  1906  		err := json.Unmarshal(body, &wp)
  1907  		return wp, err
  1908  	default:
  1909  		var r Response
  1910  		err := json.Unmarshal(body, &r)
  1911  		return r, err
  1912  	}
  1913  }
  1914  func unmarshalBasicResponseArray(body []byte) ([]BasicResponse, error) {
  1915  	var rawMessages []*json.RawMessage
  1916  	err := json.Unmarshal(body, &rawMessages)
  1917  	if err != nil {
  1918  		return nil, err
  1919  	}
  1920  
  1921  	rArray := make([]BasicResponse, len(rawMessages))
  1922  
  1923  	for index, rawMessage := range rawMessages {
  1924  		r, err := unmarshalBasicResponse(*rawMessage)
  1925  		if err != nil {
  1926  			return nil, err
  1927  		}
  1928  		rArray[index] = r
  1929  	}
  1930  	return rArray, nil
  1931  }
  1932  
  1933  // MarshalJSON is the custom marshaler for Response.
  1934  func (r Response) MarshalJSON() ([]byte, error) {
  1935  	r.Type = TypeResponse
  1936  	objectMap := make(map[string]interface{})
  1937  	if r.Type != "" {
  1938  		objectMap["_type"] = r.Type
  1939  	}
  1940  	return json.Marshal(objectMap)
  1941  }
  1942  
  1943  // AsImageObject is the BasicResponseBase implementation for Response.
  1944  func (r Response) AsImageObject() (*ImageObject, bool) {
  1945  	return nil, false
  1946  }
  1947  
  1948  // AsImages is the BasicResponseBase implementation for Response.
  1949  func (r Response) AsImages() (*Images, bool) {
  1950  	return nil, false
  1951  }
  1952  
  1953  // AsSearchResultsAnswer is the BasicResponseBase implementation for Response.
  1954  func (r Response) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) {
  1955  	return nil, false
  1956  }
  1957  
  1958  // AsBasicSearchResultsAnswer is the BasicResponseBase implementation for Response.
  1959  func (r Response) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) {
  1960  	return nil, false
  1961  }
  1962  
  1963  // AsAnswer is the BasicResponseBase implementation for Response.
  1964  func (r Response) AsAnswer() (*Answer, bool) {
  1965  	return nil, false
  1966  }
  1967  
  1968  // AsBasicAnswer is the BasicResponseBase implementation for Response.
  1969  func (r Response) AsBasicAnswer() (BasicAnswer, bool) {
  1970  	return nil, false
  1971  }
  1972  
  1973  // AsMediaObject is the BasicResponseBase implementation for Response.
  1974  func (r Response) AsMediaObject() (*MediaObject, bool) {
  1975  	return nil, false
  1976  }
  1977  
  1978  // AsBasicMediaObject is the BasicResponseBase implementation for Response.
  1979  func (r Response) AsBasicMediaObject() (BasicMediaObject, bool) {
  1980  	return nil, false
  1981  }
  1982  
  1983  // AsResponse is the BasicResponseBase implementation for Response.
  1984  func (r Response) AsResponse() (*Response, bool) {
  1985  	return &r, true
  1986  }
  1987  
  1988  // AsBasicResponse is the BasicResponseBase implementation for Response.
  1989  func (r Response) AsBasicResponse() (BasicResponse, bool) {
  1990  	return &r, true
  1991  }
  1992  
  1993  // AsThing is the BasicResponseBase implementation for Response.
  1994  func (r Response) AsThing() (*Thing, bool) {
  1995  	return nil, false
  1996  }
  1997  
  1998  // AsBasicThing is the BasicResponseBase implementation for Response.
  1999  func (r Response) AsBasicThing() (BasicThing, bool) {
  2000  	return nil, false
  2001  }
  2002  
  2003  // AsCreativeWork is the BasicResponseBase implementation for Response.
  2004  func (r Response) AsCreativeWork() (*CreativeWork, bool) {
  2005  	return nil, false
  2006  }
  2007  
  2008  // AsBasicCreativeWork is the BasicResponseBase implementation for Response.
  2009  func (r Response) AsBasicCreativeWork() (BasicCreativeWork, bool) {
  2010  	return nil, false
  2011  }
  2012  
  2013  // AsIdentifiable is the BasicResponseBase implementation for Response.
  2014  func (r Response) AsIdentifiable() (*Identifiable, bool) {
  2015  	return nil, false
  2016  }
  2017  
  2018  // AsBasicIdentifiable is the BasicResponseBase implementation for Response.
  2019  func (r Response) AsBasicIdentifiable() (BasicIdentifiable, bool) {
  2020  	return &r, true
  2021  }
  2022  
  2023  // AsErrorResponse is the BasicResponseBase implementation for Response.
  2024  func (r Response) AsErrorResponse() (*ErrorResponse, bool) {
  2025  	return nil, false
  2026  }
  2027  
  2028  // AsWebPage is the BasicResponseBase implementation for Response.
  2029  func (r Response) AsWebPage() (*WebPage, bool) {
  2030  	return nil, false
  2031  }
  2032  
  2033  // AsResponseBase is the BasicResponseBase implementation for Response.
  2034  func (r Response) AsResponseBase() (*ResponseBase, bool) {
  2035  	return nil, false
  2036  }
  2037  
  2038  // AsBasicResponseBase is the BasicResponseBase implementation for Response.
  2039  func (r Response) AsBasicResponseBase() (BasicResponseBase, bool) {
  2040  	return &r, true
  2041  }
  2042  
  2043  // BasicResponseBase response base
  2044  type BasicResponseBase interface {
  2045  	AsImageObject() (*ImageObject, bool)
  2046  	AsImages() (*Images, bool)
  2047  	AsSearchResultsAnswer() (*SearchResultsAnswer, bool)
  2048  	AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool)
  2049  	AsAnswer() (*Answer, bool)
  2050  	AsBasicAnswer() (BasicAnswer, bool)
  2051  	AsMediaObject() (*MediaObject, bool)
  2052  	AsBasicMediaObject() (BasicMediaObject, bool)
  2053  	AsResponse() (*Response, bool)
  2054  	AsBasicResponse() (BasicResponse, bool)
  2055  	AsThing() (*Thing, bool)
  2056  	AsBasicThing() (BasicThing, bool)
  2057  	AsCreativeWork() (*CreativeWork, bool)
  2058  	AsBasicCreativeWork() (BasicCreativeWork, bool)
  2059  	AsIdentifiable() (*Identifiable, bool)
  2060  	AsBasicIdentifiable() (BasicIdentifiable, bool)
  2061  	AsErrorResponse() (*ErrorResponse, bool)
  2062  	AsWebPage() (*WebPage, bool)
  2063  	AsResponseBase() (*ResponseBase, bool)
  2064  }
  2065  
  2066  // ResponseBase response base
  2067  type ResponseBase struct {
  2068  	// Type - Possible values include: 'TypeResponseBase', 'TypeImageObject', 'TypeImages', 'TypeSearchResultsAnswer', 'TypeAnswer', 'TypeMediaObject', 'TypeResponse', 'TypeThing', 'TypeCreativeWork', 'TypeIdentifiable', 'TypeErrorResponse', 'TypeWebPage'
  2069  	Type Type `json:"_type,omitempty"`
  2070  }
  2071  
  2072  func unmarshalBasicResponseBase(body []byte) (BasicResponseBase, error) {
  2073  	var m map[string]interface{}
  2074  	err := json.Unmarshal(body, &m)
  2075  	if err != nil {
  2076  		return nil, err
  2077  	}
  2078  
  2079  	switch m["_type"] {
  2080  	case string(TypeImageObject):
  2081  		var ioVar ImageObject
  2082  		err := json.Unmarshal(body, &ioVar)
  2083  		return ioVar, err
  2084  	case string(TypeImages):
  2085  		var i Images
  2086  		err := json.Unmarshal(body, &i)
  2087  		return i, err
  2088  	case string(TypeSearchResultsAnswer):
  2089  		var sra SearchResultsAnswer
  2090  		err := json.Unmarshal(body, &sra)
  2091  		return sra, err
  2092  	case string(TypeAnswer):
  2093  		var a Answer
  2094  		err := json.Unmarshal(body, &a)
  2095  		return a, err
  2096  	case string(TypeMediaObject):
  2097  		var mo MediaObject
  2098  		err := json.Unmarshal(body, &mo)
  2099  		return mo, err
  2100  	case string(TypeResponse):
  2101  		var r Response
  2102  		err := json.Unmarshal(body, &r)
  2103  		return r, err
  2104  	case string(TypeThing):
  2105  		var t Thing
  2106  		err := json.Unmarshal(body, &t)
  2107  		return t, err
  2108  	case string(TypeCreativeWork):
  2109  		var cw CreativeWork
  2110  		err := json.Unmarshal(body, &cw)
  2111  		return cw, err
  2112  	case string(TypeIdentifiable):
  2113  		var i Identifiable
  2114  		err := json.Unmarshal(body, &i)
  2115  		return i, err
  2116  	case string(TypeErrorResponse):
  2117  		var er ErrorResponse
  2118  		err := json.Unmarshal(body, &er)
  2119  		return er, err
  2120  	case string(TypeWebPage):
  2121  		var wp WebPage
  2122  		err := json.Unmarshal(body, &wp)
  2123  		return wp, err
  2124  	default:
  2125  		var rb ResponseBase
  2126  		err := json.Unmarshal(body, &rb)
  2127  		return rb, err
  2128  	}
  2129  }
  2130  func unmarshalBasicResponseBaseArray(body []byte) ([]BasicResponseBase, error) {
  2131  	var rawMessages []*json.RawMessage
  2132  	err := json.Unmarshal(body, &rawMessages)
  2133  	if err != nil {
  2134  		return nil, err
  2135  	}
  2136  
  2137  	rbArray := make([]BasicResponseBase, len(rawMessages))
  2138  
  2139  	for index, rawMessage := range rawMessages {
  2140  		rb, err := unmarshalBasicResponseBase(*rawMessage)
  2141  		if err != nil {
  2142  			return nil, err
  2143  		}
  2144  		rbArray[index] = rb
  2145  	}
  2146  	return rbArray, nil
  2147  }
  2148  
  2149  // MarshalJSON is the custom marshaler for ResponseBase.
  2150  func (rb ResponseBase) MarshalJSON() ([]byte, error) {
  2151  	rb.Type = TypeResponseBase
  2152  	objectMap := make(map[string]interface{})
  2153  	if rb.Type != "" {
  2154  		objectMap["_type"] = rb.Type
  2155  	}
  2156  	return json.Marshal(objectMap)
  2157  }
  2158  
  2159  // AsImageObject is the BasicResponseBase implementation for ResponseBase.
  2160  func (rb ResponseBase) AsImageObject() (*ImageObject, bool) {
  2161  	return nil, false
  2162  }
  2163  
  2164  // AsImages is the BasicResponseBase implementation for ResponseBase.
  2165  func (rb ResponseBase) AsImages() (*Images, bool) {
  2166  	return nil, false
  2167  }
  2168  
  2169  // AsSearchResultsAnswer is the BasicResponseBase implementation for ResponseBase.
  2170  func (rb ResponseBase) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) {
  2171  	return nil, false
  2172  }
  2173  
  2174  // AsBasicSearchResultsAnswer is the BasicResponseBase implementation for ResponseBase.
  2175  func (rb ResponseBase) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) {
  2176  	return nil, false
  2177  }
  2178  
  2179  // AsAnswer is the BasicResponseBase implementation for ResponseBase.
  2180  func (rb ResponseBase) AsAnswer() (*Answer, bool) {
  2181  	return nil, false
  2182  }
  2183  
  2184  // AsBasicAnswer is the BasicResponseBase implementation for ResponseBase.
  2185  func (rb ResponseBase) AsBasicAnswer() (BasicAnswer, bool) {
  2186  	return nil, false
  2187  }
  2188  
  2189  // AsMediaObject is the BasicResponseBase implementation for ResponseBase.
  2190  func (rb ResponseBase) AsMediaObject() (*MediaObject, bool) {
  2191  	return nil, false
  2192  }
  2193  
  2194  // AsBasicMediaObject is the BasicResponseBase implementation for ResponseBase.
  2195  func (rb ResponseBase) AsBasicMediaObject() (BasicMediaObject, bool) {
  2196  	return nil, false
  2197  }
  2198  
  2199  // AsResponse is the BasicResponseBase implementation for ResponseBase.
  2200  func (rb ResponseBase) AsResponse() (*Response, bool) {
  2201  	return nil, false
  2202  }
  2203  
  2204  // AsBasicResponse is the BasicResponseBase implementation for ResponseBase.
  2205  func (rb ResponseBase) AsBasicResponse() (BasicResponse, bool) {
  2206  	return nil, false
  2207  }
  2208  
  2209  // AsThing is the BasicResponseBase implementation for ResponseBase.
  2210  func (rb ResponseBase) AsThing() (*Thing, bool) {
  2211  	return nil, false
  2212  }
  2213  
  2214  // AsBasicThing is the BasicResponseBase implementation for ResponseBase.
  2215  func (rb ResponseBase) AsBasicThing() (BasicThing, bool) {
  2216  	return nil, false
  2217  }
  2218  
  2219  // AsCreativeWork is the BasicResponseBase implementation for ResponseBase.
  2220  func (rb ResponseBase) AsCreativeWork() (*CreativeWork, bool) {
  2221  	return nil, false
  2222  }
  2223  
  2224  // AsBasicCreativeWork is the BasicResponseBase implementation for ResponseBase.
  2225  func (rb ResponseBase) AsBasicCreativeWork() (BasicCreativeWork, bool) {
  2226  	return nil, false
  2227  }
  2228  
  2229  // AsIdentifiable is the BasicResponseBase implementation for ResponseBase.
  2230  func (rb ResponseBase) AsIdentifiable() (*Identifiable, bool) {
  2231  	return nil, false
  2232  }
  2233  
  2234  // AsBasicIdentifiable is the BasicResponseBase implementation for ResponseBase.
  2235  func (rb ResponseBase) AsBasicIdentifiable() (BasicIdentifiable, bool) {
  2236  	return nil, false
  2237  }
  2238  
  2239  // AsErrorResponse is the BasicResponseBase implementation for ResponseBase.
  2240  func (rb ResponseBase) AsErrorResponse() (*ErrorResponse, bool) {
  2241  	return nil, false
  2242  }
  2243  
  2244  // AsWebPage is the BasicResponseBase implementation for ResponseBase.
  2245  func (rb ResponseBase) AsWebPage() (*WebPage, bool) {
  2246  	return nil, false
  2247  }
  2248  
  2249  // AsResponseBase is the BasicResponseBase implementation for ResponseBase.
  2250  func (rb ResponseBase) AsResponseBase() (*ResponseBase, bool) {
  2251  	return &rb, true
  2252  }
  2253  
  2254  // AsBasicResponseBase is the BasicResponseBase implementation for ResponseBase.
  2255  func (rb ResponseBase) AsBasicResponseBase() (BasicResponseBase, bool) {
  2256  	return &rb, true
  2257  }
  2258  
  2259  // BasicSearchResultsAnswer defines a search result answer.
  2260  type BasicSearchResultsAnswer interface {
  2261  	AsImages() (*Images, bool)
  2262  	AsSearchResultsAnswer() (*SearchResultsAnswer, bool)
  2263  }
  2264  
  2265  // SearchResultsAnswer defines a search result answer.
  2266  type SearchResultsAnswer struct {
  2267  	// TotalEstimatedMatches - READ-ONLY; The estimated number of webpages that are relevant to the query. Use this number along with the count and offset query parameters to page the results.
  2268  	TotalEstimatedMatches *int64 `json:"totalEstimatedMatches,omitempty"`
  2269  	// ReadLink - READ-ONLY; The URL that returns this resource.
  2270  	ReadLink *string `json:"readLink,omitempty"`
  2271  	// WebSearchURL - READ-ONLY; The URL To Bing's search result for this item.
  2272  	WebSearchURL *string `json:"webSearchUrl,omitempty"`
  2273  	// ID - READ-ONLY; A String identifier.
  2274  	ID *string `json:"id,omitempty"`
  2275  	// Type - Possible values include: 'TypeResponseBase', 'TypeImageObject', 'TypeImages', 'TypeSearchResultsAnswer', 'TypeAnswer', 'TypeMediaObject', 'TypeResponse', 'TypeThing', 'TypeCreativeWork', 'TypeIdentifiable', 'TypeErrorResponse', 'TypeWebPage'
  2276  	Type Type `json:"_type,omitempty"`
  2277  }
  2278  
  2279  func unmarshalBasicSearchResultsAnswer(body []byte) (BasicSearchResultsAnswer, error) {
  2280  	var m map[string]interface{}
  2281  	err := json.Unmarshal(body, &m)
  2282  	if err != nil {
  2283  		return nil, err
  2284  	}
  2285  
  2286  	switch m["_type"] {
  2287  	case string(TypeImages):
  2288  		var i Images
  2289  		err := json.Unmarshal(body, &i)
  2290  		return i, err
  2291  	default:
  2292  		var sra SearchResultsAnswer
  2293  		err := json.Unmarshal(body, &sra)
  2294  		return sra, err
  2295  	}
  2296  }
  2297  func unmarshalBasicSearchResultsAnswerArray(body []byte) ([]BasicSearchResultsAnswer, error) {
  2298  	var rawMessages []*json.RawMessage
  2299  	err := json.Unmarshal(body, &rawMessages)
  2300  	if err != nil {
  2301  		return nil, err
  2302  	}
  2303  
  2304  	sraArray := make([]BasicSearchResultsAnswer, len(rawMessages))
  2305  
  2306  	for index, rawMessage := range rawMessages {
  2307  		sra, err := unmarshalBasicSearchResultsAnswer(*rawMessage)
  2308  		if err != nil {
  2309  			return nil, err
  2310  		}
  2311  		sraArray[index] = sra
  2312  	}
  2313  	return sraArray, nil
  2314  }
  2315  
  2316  // MarshalJSON is the custom marshaler for SearchResultsAnswer.
  2317  func (sra SearchResultsAnswer) MarshalJSON() ([]byte, error) {
  2318  	sra.Type = TypeSearchResultsAnswer
  2319  	objectMap := make(map[string]interface{})
  2320  	if sra.Type != "" {
  2321  		objectMap["_type"] = sra.Type
  2322  	}
  2323  	return json.Marshal(objectMap)
  2324  }
  2325  
  2326  // AsImageObject is the BasicResponseBase implementation for SearchResultsAnswer.
  2327  func (sra SearchResultsAnswer) AsImageObject() (*ImageObject, bool) {
  2328  	return nil, false
  2329  }
  2330  
  2331  // AsImages is the BasicResponseBase implementation for SearchResultsAnswer.
  2332  func (sra SearchResultsAnswer) AsImages() (*Images, bool) {
  2333  	return nil, false
  2334  }
  2335  
  2336  // AsSearchResultsAnswer is the BasicResponseBase implementation for SearchResultsAnswer.
  2337  func (sra SearchResultsAnswer) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) {
  2338  	return &sra, true
  2339  }
  2340  
  2341  // AsBasicSearchResultsAnswer is the BasicResponseBase implementation for SearchResultsAnswer.
  2342  func (sra SearchResultsAnswer) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) {
  2343  	return &sra, true
  2344  }
  2345  
  2346  // AsAnswer is the BasicResponseBase implementation for SearchResultsAnswer.
  2347  func (sra SearchResultsAnswer) AsAnswer() (*Answer, bool) {
  2348  	return nil, false
  2349  }
  2350  
  2351  // AsBasicAnswer is the BasicResponseBase implementation for SearchResultsAnswer.
  2352  func (sra SearchResultsAnswer) AsBasicAnswer() (BasicAnswer, bool) {
  2353  	return &sra, true
  2354  }
  2355  
  2356  // AsMediaObject is the BasicResponseBase implementation for SearchResultsAnswer.
  2357  func (sra SearchResultsAnswer) AsMediaObject() (*MediaObject, bool) {
  2358  	return nil, false
  2359  }
  2360  
  2361  // AsBasicMediaObject is the BasicResponseBase implementation for SearchResultsAnswer.
  2362  func (sra SearchResultsAnswer) AsBasicMediaObject() (BasicMediaObject, bool) {
  2363  	return nil, false
  2364  }
  2365  
  2366  // AsResponse is the BasicResponseBase implementation for SearchResultsAnswer.
  2367  func (sra SearchResultsAnswer) AsResponse() (*Response, bool) {
  2368  	return nil, false
  2369  }
  2370  
  2371  // AsBasicResponse is the BasicResponseBase implementation for SearchResultsAnswer.
  2372  func (sra SearchResultsAnswer) AsBasicResponse() (BasicResponse, bool) {
  2373  	return &sra, true
  2374  }
  2375  
  2376  // AsThing is the BasicResponseBase implementation for SearchResultsAnswer.
  2377  func (sra SearchResultsAnswer) AsThing() (*Thing, bool) {
  2378  	return nil, false
  2379  }
  2380  
  2381  // AsBasicThing is the BasicResponseBase implementation for SearchResultsAnswer.
  2382  func (sra SearchResultsAnswer) AsBasicThing() (BasicThing, bool) {
  2383  	return nil, false
  2384  }
  2385  
  2386  // AsCreativeWork is the BasicResponseBase implementation for SearchResultsAnswer.
  2387  func (sra SearchResultsAnswer) AsCreativeWork() (*CreativeWork, bool) {
  2388  	return nil, false
  2389  }
  2390  
  2391  // AsBasicCreativeWork is the BasicResponseBase implementation for SearchResultsAnswer.
  2392  func (sra SearchResultsAnswer) AsBasicCreativeWork() (BasicCreativeWork, bool) {
  2393  	return nil, false
  2394  }
  2395  
  2396  // AsIdentifiable is the BasicResponseBase implementation for SearchResultsAnswer.
  2397  func (sra SearchResultsAnswer) AsIdentifiable() (*Identifiable, bool) {
  2398  	return nil, false
  2399  }
  2400  
  2401  // AsBasicIdentifiable is the BasicResponseBase implementation for SearchResultsAnswer.
  2402  func (sra SearchResultsAnswer) AsBasicIdentifiable() (BasicIdentifiable, bool) {
  2403  	return &sra, true
  2404  }
  2405  
  2406  // AsErrorResponse is the BasicResponseBase implementation for SearchResultsAnswer.
  2407  func (sra SearchResultsAnswer) AsErrorResponse() (*ErrorResponse, bool) {
  2408  	return nil, false
  2409  }
  2410  
  2411  // AsWebPage is the BasicResponseBase implementation for SearchResultsAnswer.
  2412  func (sra SearchResultsAnswer) AsWebPage() (*WebPage, bool) {
  2413  	return nil, false
  2414  }
  2415  
  2416  // AsResponseBase is the BasicResponseBase implementation for SearchResultsAnswer.
  2417  func (sra SearchResultsAnswer) AsResponseBase() (*ResponseBase, bool) {
  2418  	return nil, false
  2419  }
  2420  
  2421  // AsBasicResponseBase is the BasicResponseBase implementation for SearchResultsAnswer.
  2422  func (sra SearchResultsAnswer) AsBasicResponseBase() (BasicResponseBase, bool) {
  2423  	return &sra, true
  2424  }
  2425  
  2426  // BasicThing defines a thing.
  2427  type BasicThing interface {
  2428  	AsImageObject() (*ImageObject, bool)
  2429  	AsMediaObject() (*MediaObject, bool)
  2430  	AsBasicMediaObject() (BasicMediaObject, bool)
  2431  	AsCreativeWork() (*CreativeWork, bool)
  2432  	AsBasicCreativeWork() (BasicCreativeWork, bool)
  2433  	AsWebPage() (*WebPage, bool)
  2434  	AsThing() (*Thing, bool)
  2435  }
  2436  
  2437  // Thing defines a thing.
  2438  type Thing struct {
  2439  	// Name - READ-ONLY; The name of the thing represented by this object.
  2440  	Name *string `json:"name,omitempty"`
  2441  	// URL - READ-ONLY; The URL to get more information about the thing represented by this object.
  2442  	URL *string `json:"url,omitempty"`
  2443  	// Image - READ-ONLY; An image of the item.
  2444  	Image *ImageObject `json:"image,omitempty"`
  2445  	// Description - READ-ONLY; A short description of the item.
  2446  	Description *string `json:"description,omitempty"`
  2447  	// AlternateName - READ-ONLY; An alias for the item
  2448  	AlternateName *string `json:"alternateName,omitempty"`
  2449  	// BingID - READ-ONLY; An ID that uniquely identifies this item.
  2450  	BingID *string `json:"bingId,omitempty"`
  2451  	// ReadLink - READ-ONLY; The URL that returns this resource.
  2452  	ReadLink *string `json:"readLink,omitempty"`
  2453  	// WebSearchURL - READ-ONLY; The URL To Bing's search result for this item.
  2454  	WebSearchURL *string `json:"webSearchUrl,omitempty"`
  2455  	// ID - READ-ONLY; A String identifier.
  2456  	ID *string `json:"id,omitempty"`
  2457  	// Type - Possible values include: 'TypeResponseBase', 'TypeImageObject', 'TypeImages', 'TypeSearchResultsAnswer', 'TypeAnswer', 'TypeMediaObject', 'TypeResponse', 'TypeThing', 'TypeCreativeWork', 'TypeIdentifiable', 'TypeErrorResponse', 'TypeWebPage'
  2458  	Type Type `json:"_type,omitempty"`
  2459  }
  2460  
  2461  func unmarshalBasicThing(body []byte) (BasicThing, error) {
  2462  	var m map[string]interface{}
  2463  	err := json.Unmarshal(body, &m)
  2464  	if err != nil {
  2465  		return nil, err
  2466  	}
  2467  
  2468  	switch m["_type"] {
  2469  	case string(TypeImageObject):
  2470  		var ioVar ImageObject
  2471  		err := json.Unmarshal(body, &ioVar)
  2472  		return ioVar, err
  2473  	case string(TypeMediaObject):
  2474  		var mo MediaObject
  2475  		err := json.Unmarshal(body, &mo)
  2476  		return mo, err
  2477  	case string(TypeCreativeWork):
  2478  		var cw CreativeWork
  2479  		err := json.Unmarshal(body, &cw)
  2480  		return cw, err
  2481  	case string(TypeWebPage):
  2482  		var wp WebPage
  2483  		err := json.Unmarshal(body, &wp)
  2484  		return wp, err
  2485  	default:
  2486  		var t Thing
  2487  		err := json.Unmarshal(body, &t)
  2488  		return t, err
  2489  	}
  2490  }
  2491  func unmarshalBasicThingArray(body []byte) ([]BasicThing, error) {
  2492  	var rawMessages []*json.RawMessage
  2493  	err := json.Unmarshal(body, &rawMessages)
  2494  	if err != nil {
  2495  		return nil, err
  2496  	}
  2497  
  2498  	tArray := make([]BasicThing, len(rawMessages))
  2499  
  2500  	for index, rawMessage := range rawMessages {
  2501  		t, err := unmarshalBasicThing(*rawMessage)
  2502  		if err != nil {
  2503  			return nil, err
  2504  		}
  2505  		tArray[index] = t
  2506  	}
  2507  	return tArray, nil
  2508  }
  2509  
  2510  // MarshalJSON is the custom marshaler for Thing.
  2511  func (t Thing) MarshalJSON() ([]byte, error) {
  2512  	t.Type = TypeThing
  2513  	objectMap := make(map[string]interface{})
  2514  	if t.Type != "" {
  2515  		objectMap["_type"] = t.Type
  2516  	}
  2517  	return json.Marshal(objectMap)
  2518  }
  2519  
  2520  // AsImageObject is the BasicResponseBase implementation for Thing.
  2521  func (t Thing) AsImageObject() (*ImageObject, bool) {
  2522  	return nil, false
  2523  }
  2524  
  2525  // AsImages is the BasicResponseBase implementation for Thing.
  2526  func (t Thing) AsImages() (*Images, bool) {
  2527  	return nil, false
  2528  }
  2529  
  2530  // AsSearchResultsAnswer is the BasicResponseBase implementation for Thing.
  2531  func (t Thing) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) {
  2532  	return nil, false
  2533  }
  2534  
  2535  // AsBasicSearchResultsAnswer is the BasicResponseBase implementation for Thing.
  2536  func (t Thing) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) {
  2537  	return nil, false
  2538  }
  2539  
  2540  // AsAnswer is the BasicResponseBase implementation for Thing.
  2541  func (t Thing) AsAnswer() (*Answer, bool) {
  2542  	return nil, false
  2543  }
  2544  
  2545  // AsBasicAnswer is the BasicResponseBase implementation for Thing.
  2546  func (t Thing) AsBasicAnswer() (BasicAnswer, bool) {
  2547  	return nil, false
  2548  }
  2549  
  2550  // AsMediaObject is the BasicResponseBase implementation for Thing.
  2551  func (t Thing) AsMediaObject() (*MediaObject, bool) {
  2552  	return nil, false
  2553  }
  2554  
  2555  // AsBasicMediaObject is the BasicResponseBase implementation for Thing.
  2556  func (t Thing) AsBasicMediaObject() (BasicMediaObject, bool) {
  2557  	return nil, false
  2558  }
  2559  
  2560  // AsResponse is the BasicResponseBase implementation for Thing.
  2561  func (t Thing) AsResponse() (*Response, bool) {
  2562  	return nil, false
  2563  }
  2564  
  2565  // AsBasicResponse is the BasicResponseBase implementation for Thing.
  2566  func (t Thing) AsBasicResponse() (BasicResponse, bool) {
  2567  	return &t, true
  2568  }
  2569  
  2570  // AsThing is the BasicResponseBase implementation for Thing.
  2571  func (t Thing) AsThing() (*Thing, bool) {
  2572  	return &t, true
  2573  }
  2574  
  2575  // AsBasicThing is the BasicResponseBase implementation for Thing.
  2576  func (t Thing) AsBasicThing() (BasicThing, bool) {
  2577  	return &t, true
  2578  }
  2579  
  2580  // AsCreativeWork is the BasicResponseBase implementation for Thing.
  2581  func (t Thing) AsCreativeWork() (*CreativeWork, bool) {
  2582  	return nil, false
  2583  }
  2584  
  2585  // AsBasicCreativeWork is the BasicResponseBase implementation for Thing.
  2586  func (t Thing) AsBasicCreativeWork() (BasicCreativeWork, bool) {
  2587  	return nil, false
  2588  }
  2589  
  2590  // AsIdentifiable is the BasicResponseBase implementation for Thing.
  2591  func (t Thing) AsIdentifiable() (*Identifiable, bool) {
  2592  	return nil, false
  2593  }
  2594  
  2595  // AsBasicIdentifiable is the BasicResponseBase implementation for Thing.
  2596  func (t Thing) AsBasicIdentifiable() (BasicIdentifiable, bool) {
  2597  	return &t, true
  2598  }
  2599  
  2600  // AsErrorResponse is the BasicResponseBase implementation for Thing.
  2601  func (t Thing) AsErrorResponse() (*ErrorResponse, bool) {
  2602  	return nil, false
  2603  }
  2604  
  2605  // AsWebPage is the BasicResponseBase implementation for Thing.
  2606  func (t Thing) AsWebPage() (*WebPage, bool) {
  2607  	return nil, false
  2608  }
  2609  
  2610  // AsResponseBase is the BasicResponseBase implementation for Thing.
  2611  func (t Thing) AsResponseBase() (*ResponseBase, bool) {
  2612  	return nil, false
  2613  }
  2614  
  2615  // AsBasicResponseBase is the BasicResponseBase implementation for Thing.
  2616  func (t Thing) AsBasicResponseBase() (BasicResponseBase, bool) {
  2617  	return &t, true
  2618  }
  2619  
  2620  // WebPage defines a webpage that is relevant to the query.
  2621  type WebPage struct {
  2622  	// ThumbnailURL - READ-ONLY; The URL to a thumbnail of the item.
  2623  	ThumbnailURL *string `json:"thumbnailUrl,omitempty"`
  2624  	// Provider - READ-ONLY; The source of the creative work.
  2625  	Provider *[]BasicThing `json:"provider,omitempty"`
  2626  	// Text - READ-ONLY; Text content of this creative work
  2627  	Text *string `json:"text,omitempty"`
  2628  	// Name - READ-ONLY; The name of the thing represented by this object.
  2629  	Name *string `json:"name,omitempty"`
  2630  	// URL - READ-ONLY; The URL to get more information about the thing represented by this object.
  2631  	URL *string `json:"url,omitempty"`
  2632  	// Image - READ-ONLY; An image of the item.
  2633  	Image *ImageObject `json:"image,omitempty"`
  2634  	// Description - READ-ONLY; A short description of the item.
  2635  	Description *string `json:"description,omitempty"`
  2636  	// AlternateName - READ-ONLY; An alias for the item
  2637  	AlternateName *string `json:"alternateName,omitempty"`
  2638  	// BingID - READ-ONLY; An ID that uniquely identifies this item.
  2639  	BingID *string `json:"bingId,omitempty"`
  2640  	// ReadLink - READ-ONLY; The URL that returns this resource.
  2641  	ReadLink *string `json:"readLink,omitempty"`
  2642  	// WebSearchURL - READ-ONLY; The URL To Bing's search result for this item.
  2643  	WebSearchURL *string `json:"webSearchUrl,omitempty"`
  2644  	// ID - READ-ONLY; A String identifier.
  2645  	ID *string `json:"id,omitempty"`
  2646  	// Type - Possible values include: 'TypeResponseBase', 'TypeImageObject', 'TypeImages', 'TypeSearchResultsAnswer', 'TypeAnswer', 'TypeMediaObject', 'TypeResponse', 'TypeThing', 'TypeCreativeWork', 'TypeIdentifiable', 'TypeErrorResponse', 'TypeWebPage'
  2647  	Type Type `json:"_type,omitempty"`
  2648  }
  2649  
  2650  // MarshalJSON is the custom marshaler for WebPage.
  2651  func (wp WebPage) MarshalJSON() ([]byte, error) {
  2652  	wp.Type = TypeWebPage
  2653  	objectMap := make(map[string]interface{})
  2654  	if wp.Type != "" {
  2655  		objectMap["_type"] = wp.Type
  2656  	}
  2657  	return json.Marshal(objectMap)
  2658  }
  2659  
  2660  // AsImageObject is the BasicResponseBase implementation for WebPage.
  2661  func (wp WebPage) AsImageObject() (*ImageObject, bool) {
  2662  	return nil, false
  2663  }
  2664  
  2665  // AsImages is the BasicResponseBase implementation for WebPage.
  2666  func (wp WebPage) AsImages() (*Images, bool) {
  2667  	return nil, false
  2668  }
  2669  
  2670  // AsSearchResultsAnswer is the BasicResponseBase implementation for WebPage.
  2671  func (wp WebPage) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) {
  2672  	return nil, false
  2673  }
  2674  
  2675  // AsBasicSearchResultsAnswer is the BasicResponseBase implementation for WebPage.
  2676  func (wp WebPage) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) {
  2677  	return nil, false
  2678  }
  2679  
  2680  // AsAnswer is the BasicResponseBase implementation for WebPage.
  2681  func (wp WebPage) AsAnswer() (*Answer, bool) {
  2682  	return nil, false
  2683  }
  2684  
  2685  // AsBasicAnswer is the BasicResponseBase implementation for WebPage.
  2686  func (wp WebPage) AsBasicAnswer() (BasicAnswer, bool) {
  2687  	return nil, false
  2688  }
  2689  
  2690  // AsMediaObject is the BasicResponseBase implementation for WebPage.
  2691  func (wp WebPage) AsMediaObject() (*MediaObject, bool) {
  2692  	return nil, false
  2693  }
  2694  
  2695  // AsBasicMediaObject is the BasicResponseBase implementation for WebPage.
  2696  func (wp WebPage) AsBasicMediaObject() (BasicMediaObject, bool) {
  2697  	return nil, false
  2698  }
  2699  
  2700  // AsResponse is the BasicResponseBase implementation for WebPage.
  2701  func (wp WebPage) AsResponse() (*Response, bool) {
  2702  	return nil, false
  2703  }
  2704  
  2705  // AsBasicResponse is the BasicResponseBase implementation for WebPage.
  2706  func (wp WebPage) AsBasicResponse() (BasicResponse, bool) {
  2707  	return &wp, true
  2708  }
  2709  
  2710  // AsThing is the BasicResponseBase implementation for WebPage.
  2711  func (wp WebPage) AsThing() (*Thing, bool) {
  2712  	return nil, false
  2713  }
  2714  
  2715  // AsBasicThing is the BasicResponseBase implementation for WebPage.
  2716  func (wp WebPage) AsBasicThing() (BasicThing, bool) {
  2717  	return &wp, true
  2718  }
  2719  
  2720  // AsCreativeWork is the BasicResponseBase implementation for WebPage.
  2721  func (wp WebPage) AsCreativeWork() (*CreativeWork, bool) {
  2722  	return nil, false
  2723  }
  2724  
  2725  // AsBasicCreativeWork is the BasicResponseBase implementation for WebPage.
  2726  func (wp WebPage) AsBasicCreativeWork() (BasicCreativeWork, bool) {
  2727  	return &wp, true
  2728  }
  2729  
  2730  // AsIdentifiable is the BasicResponseBase implementation for WebPage.
  2731  func (wp WebPage) AsIdentifiable() (*Identifiable, bool) {
  2732  	return nil, false
  2733  }
  2734  
  2735  // AsBasicIdentifiable is the BasicResponseBase implementation for WebPage.
  2736  func (wp WebPage) AsBasicIdentifiable() (BasicIdentifiable, bool) {
  2737  	return &wp, true
  2738  }
  2739  
  2740  // AsErrorResponse is the BasicResponseBase implementation for WebPage.
  2741  func (wp WebPage) AsErrorResponse() (*ErrorResponse, bool) {
  2742  	return nil, false
  2743  }
  2744  
  2745  // AsWebPage is the BasicResponseBase implementation for WebPage.
  2746  func (wp WebPage) AsWebPage() (*WebPage, bool) {
  2747  	return &wp, true
  2748  }
  2749  
  2750  // AsResponseBase is the BasicResponseBase implementation for WebPage.
  2751  func (wp WebPage) AsResponseBase() (*ResponseBase, bool) {
  2752  	return nil, false
  2753  }
  2754  
  2755  // AsBasicResponseBase is the BasicResponseBase implementation for WebPage.
  2756  func (wp WebPage) AsBasicResponseBase() (BasicResponseBase, bool) {
  2757  	return &wp, true
  2758  }
  2759  
  2760  // UnmarshalJSON is the custom unmarshaler for WebPage struct.
  2761  func (wp *WebPage) UnmarshalJSON(body []byte) error {
  2762  	var m map[string]*json.RawMessage
  2763  	err := json.Unmarshal(body, &m)
  2764  	if err != nil {
  2765  		return err
  2766  	}
  2767  	for k, v := range m {
  2768  		switch k {
  2769  		case "thumbnailUrl":
  2770  			if v != nil {
  2771  				var thumbnailURL string
  2772  				err = json.Unmarshal(*v, &thumbnailURL)
  2773  				if err != nil {
  2774  					return err
  2775  				}
  2776  				wp.ThumbnailURL = &thumbnailURL
  2777  			}
  2778  		case "provider":
  2779  			if v != nil {
  2780  				provider, err := unmarshalBasicThingArray(*v)
  2781  				if err != nil {
  2782  					return err
  2783  				}
  2784  				wp.Provider = &provider
  2785  			}
  2786  		case "text":
  2787  			if v != nil {
  2788  				var textVar string
  2789  				err = json.Unmarshal(*v, &textVar)
  2790  				if err != nil {
  2791  					return err
  2792  				}
  2793  				wp.Text = &textVar
  2794  			}
  2795  		case "name":
  2796  			if v != nil {
  2797  				var name string
  2798  				err = json.Unmarshal(*v, &name)
  2799  				if err != nil {
  2800  					return err
  2801  				}
  2802  				wp.Name = &name
  2803  			}
  2804  		case "url":
  2805  			if v != nil {
  2806  				var URL string
  2807  				err = json.Unmarshal(*v, &URL)
  2808  				if err != nil {
  2809  					return err
  2810  				}
  2811  				wp.URL = &URL
  2812  			}
  2813  		case "image":
  2814  			if v != nil {
  2815  				var imageVar ImageObject
  2816  				err = json.Unmarshal(*v, &imageVar)
  2817  				if err != nil {
  2818  					return err
  2819  				}
  2820  				wp.Image = &imageVar
  2821  			}
  2822  		case "description":
  2823  			if v != nil {
  2824  				var description string
  2825  				err = json.Unmarshal(*v, &description)
  2826  				if err != nil {
  2827  					return err
  2828  				}
  2829  				wp.Description = &description
  2830  			}
  2831  		case "alternateName":
  2832  			if v != nil {
  2833  				var alternateName string
  2834  				err = json.Unmarshal(*v, &alternateName)
  2835  				if err != nil {
  2836  					return err
  2837  				}
  2838  				wp.AlternateName = &alternateName
  2839  			}
  2840  		case "bingId":
  2841  			if v != nil {
  2842  				var bingID string
  2843  				err = json.Unmarshal(*v, &bingID)
  2844  				if err != nil {
  2845  					return err
  2846  				}
  2847  				wp.BingID = &bingID
  2848  			}
  2849  		case "readLink":
  2850  			if v != nil {
  2851  				var readLink string
  2852  				err = json.Unmarshal(*v, &readLink)
  2853  				if err != nil {
  2854  					return err
  2855  				}
  2856  				wp.ReadLink = &readLink
  2857  			}
  2858  		case "webSearchUrl":
  2859  			if v != nil {
  2860  				var webSearchURL string
  2861  				err = json.Unmarshal(*v, &webSearchURL)
  2862  				if err != nil {
  2863  					return err
  2864  				}
  2865  				wp.WebSearchURL = &webSearchURL
  2866  			}
  2867  		case "id":
  2868  			if v != nil {
  2869  				var ID string
  2870  				err = json.Unmarshal(*v, &ID)
  2871  				if err != nil {
  2872  					return err
  2873  				}
  2874  				wp.ID = &ID
  2875  			}
  2876  		case "_type":
  2877  			if v != nil {
  2878  				var typeVar Type
  2879  				err = json.Unmarshal(*v, &typeVar)
  2880  				if err != nil {
  2881  					return err
  2882  				}
  2883  				wp.Type = typeVar
  2884  			}
  2885  		}
  2886  	}
  2887  
  2888  	return nil
  2889  }
  2890  

View as plain text