...

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

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

     1  package customsearch
     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/customsearch"
    16  
    17  // BasicAnswer ...
    18  type BasicAnswer interface {
    19  	AsWebWebAnswer() (*WebWebAnswer, bool)
    20  	AsSearchResultsAnswer() (*SearchResultsAnswer, bool)
    21  	AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool)
    22  	AsAnswer() (*Answer, bool)
    23  }
    24  
    25  // Answer ...
    26  type Answer struct {
    27  	// FollowUpQueries - READ-ONLY
    28  	FollowUpQueries *[]Query `json:"followUpQueries,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', 'TypeWebPage', 'TypeWebWebAnswer', 'TypeSearchResponse', 'TypeResponse', 'TypeSearchResultsAnswer', 'TypeIdentifiable', 'TypeErrorResponse', 'TypeAnswer', 'TypeThing', 'TypeCreativeWork'
    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(TypeWebWebAnswer):
    46  		var wwa WebWebAnswer
    47  		err := json.Unmarshal(body, &wwa)
    48  		return wwa, 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  // AsWebPage is the BasicResponseBase implementation for Answer.
    89  func (a Answer) AsWebPage() (*WebPage, bool) {
    90  	return nil, false
    91  }
    92  
    93  // AsWebWebAnswer is the BasicResponseBase implementation for Answer.
    94  func (a Answer) AsWebWebAnswer() (*WebWebAnswer, bool) {
    95  	return nil, false
    96  }
    97  
    98  // AsSearchResponse is the BasicResponseBase implementation for Answer.
    99  func (a Answer) AsSearchResponse() (*SearchResponse, bool) {
   100  	return nil, false
   101  }
   102  
   103  // AsResponse is the BasicResponseBase implementation for Answer.
   104  func (a Answer) AsResponse() (*Response, bool) {
   105  	return nil, false
   106  }
   107  
   108  // AsBasicResponse is the BasicResponseBase implementation for Answer.
   109  func (a Answer) AsBasicResponse() (BasicResponse, bool) {
   110  	return &a, true
   111  }
   112  
   113  // AsSearchResultsAnswer is the BasicResponseBase implementation for Answer.
   114  func (a Answer) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) {
   115  	return nil, false
   116  }
   117  
   118  // AsBasicSearchResultsAnswer is the BasicResponseBase implementation for Answer.
   119  func (a Answer) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) {
   120  	return nil, false
   121  }
   122  
   123  // AsIdentifiable is the BasicResponseBase implementation for Answer.
   124  func (a Answer) AsIdentifiable() (*Identifiable, bool) {
   125  	return nil, false
   126  }
   127  
   128  // AsBasicIdentifiable is the BasicResponseBase implementation for Answer.
   129  func (a Answer) AsBasicIdentifiable() (BasicIdentifiable, bool) {
   130  	return &a, true
   131  }
   132  
   133  // AsErrorResponse is the BasicResponseBase implementation for Answer.
   134  func (a Answer) AsErrorResponse() (*ErrorResponse, bool) {
   135  	return nil, false
   136  }
   137  
   138  // AsAnswer is the BasicResponseBase implementation for Answer.
   139  func (a Answer) AsAnswer() (*Answer, bool) {
   140  	return &a, true
   141  }
   142  
   143  // AsBasicAnswer is the BasicResponseBase implementation for Answer.
   144  func (a Answer) AsBasicAnswer() (BasicAnswer, bool) {
   145  	return &a, true
   146  }
   147  
   148  // AsThing is the BasicResponseBase implementation for Answer.
   149  func (a Answer) AsThing() (*Thing, bool) {
   150  	return nil, false
   151  }
   152  
   153  // AsBasicThing is the BasicResponseBase implementation for Answer.
   154  func (a Answer) AsBasicThing() (BasicThing, bool) {
   155  	return nil, false
   156  }
   157  
   158  // AsCreativeWork is the BasicResponseBase implementation for Answer.
   159  func (a Answer) AsCreativeWork() (*CreativeWork, bool) {
   160  	return nil, false
   161  }
   162  
   163  // AsBasicCreativeWork is the BasicResponseBase implementation for Answer.
   164  func (a Answer) AsBasicCreativeWork() (BasicCreativeWork, bool) {
   165  	return nil, false
   166  }
   167  
   168  // AsResponseBase is the BasicResponseBase implementation for Answer.
   169  func (a Answer) AsResponseBase() (*ResponseBase, bool) {
   170  	return nil, false
   171  }
   172  
   173  // AsBasicResponseBase is the BasicResponseBase implementation for Answer.
   174  func (a Answer) AsBasicResponseBase() (BasicResponseBase, bool) {
   175  	return &a, true
   176  }
   177  
   178  // BasicCreativeWork ...
   179  type BasicCreativeWork interface {
   180  	AsWebPage() (*WebPage, bool)
   181  	AsCreativeWork() (*CreativeWork, bool)
   182  }
   183  
   184  // CreativeWork ...
   185  type CreativeWork struct {
   186  	// ThumbnailURL - READ-ONLY; The URL to a thumbnail of the item.
   187  	ThumbnailURL *string `json:"thumbnailUrl,omitempty"`
   188  	// Provider - READ-ONLY; The source of the creative work.
   189  	Provider *[]BasicThing `json:"provider,omitempty"`
   190  	// Text - READ-ONLY
   191  	Text *string `json:"text,omitempty"`
   192  	// Name - READ-ONLY; The name of the thing represented by this object.
   193  	Name *string `json:"name,omitempty"`
   194  	// URL - READ-ONLY; The URL to get more information about the thing represented by this object.
   195  	URL *string `json:"url,omitempty"`
   196  	// Description - READ-ONLY; A short description of the item.
   197  	Description *string `json:"description,omitempty"`
   198  	// BingID - READ-ONLY; An ID that uniquely identifies this item.
   199  	BingID *string `json:"bingId,omitempty"`
   200  	// WebSearchURL - READ-ONLY; The URL To Bing's search result for this item.
   201  	WebSearchURL *string `json:"webSearchUrl,omitempty"`
   202  	// ID - READ-ONLY; A String identifier.
   203  	ID *string `json:"id,omitempty"`
   204  	// Type - Possible values include: 'TypeResponseBase', 'TypeWebPage', 'TypeWebWebAnswer', 'TypeSearchResponse', 'TypeResponse', 'TypeSearchResultsAnswer', 'TypeIdentifiable', 'TypeErrorResponse', 'TypeAnswer', 'TypeThing', 'TypeCreativeWork'
   205  	Type Type `json:"_type,omitempty"`
   206  }
   207  
   208  func unmarshalBasicCreativeWork(body []byte) (BasicCreativeWork, error) {
   209  	var m map[string]interface{}
   210  	err := json.Unmarshal(body, &m)
   211  	if err != nil {
   212  		return nil, err
   213  	}
   214  
   215  	switch m["_type"] {
   216  	case string(TypeWebPage):
   217  		var wp WebPage
   218  		err := json.Unmarshal(body, &wp)
   219  		return wp, err
   220  	default:
   221  		var cw CreativeWork
   222  		err := json.Unmarshal(body, &cw)
   223  		return cw, err
   224  	}
   225  }
   226  func unmarshalBasicCreativeWorkArray(body []byte) ([]BasicCreativeWork, error) {
   227  	var rawMessages []*json.RawMessage
   228  	err := json.Unmarshal(body, &rawMessages)
   229  	if err != nil {
   230  		return nil, err
   231  	}
   232  
   233  	cwArray := make([]BasicCreativeWork, len(rawMessages))
   234  
   235  	for index, rawMessage := range rawMessages {
   236  		cw, err := unmarshalBasicCreativeWork(*rawMessage)
   237  		if err != nil {
   238  			return nil, err
   239  		}
   240  		cwArray[index] = cw
   241  	}
   242  	return cwArray, nil
   243  }
   244  
   245  // MarshalJSON is the custom marshaler for CreativeWork.
   246  func (cw CreativeWork) MarshalJSON() ([]byte, error) {
   247  	cw.Type = TypeCreativeWork
   248  	objectMap := make(map[string]interface{})
   249  	if cw.Type != "" {
   250  		objectMap["_type"] = cw.Type
   251  	}
   252  	return json.Marshal(objectMap)
   253  }
   254  
   255  // AsWebPage is the BasicResponseBase implementation for CreativeWork.
   256  func (cw CreativeWork) AsWebPage() (*WebPage, bool) {
   257  	return nil, false
   258  }
   259  
   260  // AsWebWebAnswer is the BasicResponseBase implementation for CreativeWork.
   261  func (cw CreativeWork) AsWebWebAnswer() (*WebWebAnswer, bool) {
   262  	return nil, false
   263  }
   264  
   265  // AsSearchResponse is the BasicResponseBase implementation for CreativeWork.
   266  func (cw CreativeWork) AsSearchResponse() (*SearchResponse, bool) {
   267  	return nil, false
   268  }
   269  
   270  // AsResponse is the BasicResponseBase implementation for CreativeWork.
   271  func (cw CreativeWork) AsResponse() (*Response, bool) {
   272  	return nil, false
   273  }
   274  
   275  // AsBasicResponse is the BasicResponseBase implementation for CreativeWork.
   276  func (cw CreativeWork) AsBasicResponse() (BasicResponse, bool) {
   277  	return &cw, true
   278  }
   279  
   280  // AsSearchResultsAnswer is the BasicResponseBase implementation for CreativeWork.
   281  func (cw CreativeWork) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) {
   282  	return nil, false
   283  }
   284  
   285  // AsBasicSearchResultsAnswer is the BasicResponseBase implementation for CreativeWork.
   286  func (cw CreativeWork) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) {
   287  	return nil, false
   288  }
   289  
   290  // AsIdentifiable is the BasicResponseBase implementation for CreativeWork.
   291  func (cw CreativeWork) AsIdentifiable() (*Identifiable, bool) {
   292  	return nil, false
   293  }
   294  
   295  // AsBasicIdentifiable is the BasicResponseBase implementation for CreativeWork.
   296  func (cw CreativeWork) AsBasicIdentifiable() (BasicIdentifiable, bool) {
   297  	return &cw, true
   298  }
   299  
   300  // AsErrorResponse is the BasicResponseBase implementation for CreativeWork.
   301  func (cw CreativeWork) AsErrorResponse() (*ErrorResponse, bool) {
   302  	return nil, false
   303  }
   304  
   305  // AsAnswer is the BasicResponseBase implementation for CreativeWork.
   306  func (cw CreativeWork) AsAnswer() (*Answer, bool) {
   307  	return nil, false
   308  }
   309  
   310  // AsBasicAnswer is the BasicResponseBase implementation for CreativeWork.
   311  func (cw CreativeWork) AsBasicAnswer() (BasicAnswer, bool) {
   312  	return nil, false
   313  }
   314  
   315  // AsThing is the BasicResponseBase implementation for CreativeWork.
   316  func (cw CreativeWork) AsThing() (*Thing, bool) {
   317  	return nil, false
   318  }
   319  
   320  // AsBasicThing is the BasicResponseBase implementation for CreativeWork.
   321  func (cw CreativeWork) AsBasicThing() (BasicThing, bool) {
   322  	return &cw, true
   323  }
   324  
   325  // AsCreativeWork is the BasicResponseBase implementation for CreativeWork.
   326  func (cw CreativeWork) AsCreativeWork() (*CreativeWork, bool) {
   327  	return &cw, true
   328  }
   329  
   330  // AsBasicCreativeWork is the BasicResponseBase implementation for CreativeWork.
   331  func (cw CreativeWork) AsBasicCreativeWork() (BasicCreativeWork, bool) {
   332  	return &cw, true
   333  }
   334  
   335  // AsResponseBase is the BasicResponseBase implementation for CreativeWork.
   336  func (cw CreativeWork) AsResponseBase() (*ResponseBase, bool) {
   337  	return nil, false
   338  }
   339  
   340  // AsBasicResponseBase is the BasicResponseBase implementation for CreativeWork.
   341  func (cw CreativeWork) AsBasicResponseBase() (BasicResponseBase, bool) {
   342  	return &cw, true
   343  }
   344  
   345  // UnmarshalJSON is the custom unmarshaler for CreativeWork struct.
   346  func (cw *CreativeWork) UnmarshalJSON(body []byte) error {
   347  	var m map[string]*json.RawMessage
   348  	err := json.Unmarshal(body, &m)
   349  	if err != nil {
   350  		return err
   351  	}
   352  	for k, v := range m {
   353  		switch k {
   354  		case "thumbnailUrl":
   355  			if v != nil {
   356  				var thumbnailURL string
   357  				err = json.Unmarshal(*v, &thumbnailURL)
   358  				if err != nil {
   359  					return err
   360  				}
   361  				cw.ThumbnailURL = &thumbnailURL
   362  			}
   363  		case "provider":
   364  			if v != nil {
   365  				provider, err := unmarshalBasicThingArray(*v)
   366  				if err != nil {
   367  					return err
   368  				}
   369  				cw.Provider = &provider
   370  			}
   371  		case "text":
   372  			if v != nil {
   373  				var textVar string
   374  				err = json.Unmarshal(*v, &textVar)
   375  				if err != nil {
   376  					return err
   377  				}
   378  				cw.Text = &textVar
   379  			}
   380  		case "name":
   381  			if v != nil {
   382  				var name string
   383  				err = json.Unmarshal(*v, &name)
   384  				if err != nil {
   385  					return err
   386  				}
   387  				cw.Name = &name
   388  			}
   389  		case "url":
   390  			if v != nil {
   391  				var URL string
   392  				err = json.Unmarshal(*v, &URL)
   393  				if err != nil {
   394  					return err
   395  				}
   396  				cw.URL = &URL
   397  			}
   398  		case "description":
   399  			if v != nil {
   400  				var description string
   401  				err = json.Unmarshal(*v, &description)
   402  				if err != nil {
   403  					return err
   404  				}
   405  				cw.Description = &description
   406  			}
   407  		case "bingId":
   408  			if v != nil {
   409  				var bingID string
   410  				err = json.Unmarshal(*v, &bingID)
   411  				if err != nil {
   412  					return err
   413  				}
   414  				cw.BingID = &bingID
   415  			}
   416  		case "webSearchUrl":
   417  			if v != nil {
   418  				var webSearchURL string
   419  				err = json.Unmarshal(*v, &webSearchURL)
   420  				if err != nil {
   421  					return err
   422  				}
   423  				cw.WebSearchURL = &webSearchURL
   424  			}
   425  		case "id":
   426  			if v != nil {
   427  				var ID string
   428  				err = json.Unmarshal(*v, &ID)
   429  				if err != nil {
   430  					return err
   431  				}
   432  				cw.ID = &ID
   433  			}
   434  		case "_type":
   435  			if v != nil {
   436  				var typeVar Type
   437  				err = json.Unmarshal(*v, &typeVar)
   438  				if err != nil {
   439  					return err
   440  				}
   441  				cw.Type = typeVar
   442  			}
   443  		}
   444  	}
   445  
   446  	return nil
   447  }
   448  
   449  // Error defines the error that occurred.
   450  type Error struct {
   451  	// Code - The error code that identifies the category of error. Possible values include: 'None', 'ServerError', 'InvalidRequest', 'RateLimitExceeded', 'InvalidAuthorization', 'InsufficientAuthorization'
   452  	Code ErrorCode `json:"code,omitempty"`
   453  	// 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'
   454  	SubCode ErrorSubCode `json:"subCode,omitempty"`
   455  	// Message - A description of the error.
   456  	Message *string `json:"message,omitempty"`
   457  	// MoreDetails - READ-ONLY; A description that provides additional information about the error.
   458  	MoreDetails *string `json:"moreDetails,omitempty"`
   459  	// Parameter - READ-ONLY; The parameter in the request that caused the error.
   460  	Parameter *string `json:"parameter,omitempty"`
   461  	// Value - READ-ONLY; The parameter's value in the request that was not valid.
   462  	Value *string `json:"value,omitempty"`
   463  }
   464  
   465  // MarshalJSON is the custom marshaler for Error.
   466  func (e Error) MarshalJSON() ([]byte, error) {
   467  	objectMap := make(map[string]interface{})
   468  	if e.Code != "" {
   469  		objectMap["code"] = e.Code
   470  	}
   471  	if e.Message != nil {
   472  		objectMap["message"] = e.Message
   473  	}
   474  	return json.Marshal(objectMap)
   475  }
   476  
   477  // ErrorResponse the top-level response that represents a failed request.
   478  type ErrorResponse struct {
   479  	// Errors - A list of errors that describe the reasons why the request failed.
   480  	Errors *[]Error `json:"errors,omitempty"`
   481  	// WebSearchURL - READ-ONLY; The URL To Bing's search result for this item.
   482  	WebSearchURL *string `json:"webSearchUrl,omitempty"`
   483  	// ID - READ-ONLY; A String identifier.
   484  	ID *string `json:"id,omitempty"`
   485  	// Type - Possible values include: 'TypeResponseBase', 'TypeWebPage', 'TypeWebWebAnswer', 'TypeSearchResponse', 'TypeResponse', 'TypeSearchResultsAnswer', 'TypeIdentifiable', 'TypeErrorResponse', 'TypeAnswer', 'TypeThing', 'TypeCreativeWork'
   486  	Type Type `json:"_type,omitempty"`
   487  }
   488  
   489  // MarshalJSON is the custom marshaler for ErrorResponse.
   490  func (er ErrorResponse) MarshalJSON() ([]byte, error) {
   491  	er.Type = TypeErrorResponse
   492  	objectMap := make(map[string]interface{})
   493  	if er.Errors != nil {
   494  		objectMap["errors"] = er.Errors
   495  	}
   496  	if er.Type != "" {
   497  		objectMap["_type"] = er.Type
   498  	}
   499  	return json.Marshal(objectMap)
   500  }
   501  
   502  // AsWebPage is the BasicResponseBase implementation for ErrorResponse.
   503  func (er ErrorResponse) AsWebPage() (*WebPage, bool) {
   504  	return nil, false
   505  }
   506  
   507  // AsWebWebAnswer is the BasicResponseBase implementation for ErrorResponse.
   508  func (er ErrorResponse) AsWebWebAnswer() (*WebWebAnswer, bool) {
   509  	return nil, false
   510  }
   511  
   512  // AsSearchResponse is the BasicResponseBase implementation for ErrorResponse.
   513  func (er ErrorResponse) AsSearchResponse() (*SearchResponse, bool) {
   514  	return nil, false
   515  }
   516  
   517  // AsResponse is the BasicResponseBase implementation for ErrorResponse.
   518  func (er ErrorResponse) AsResponse() (*Response, bool) {
   519  	return nil, false
   520  }
   521  
   522  // AsBasicResponse is the BasicResponseBase implementation for ErrorResponse.
   523  func (er ErrorResponse) AsBasicResponse() (BasicResponse, bool) {
   524  	return &er, true
   525  }
   526  
   527  // AsSearchResultsAnswer is the BasicResponseBase implementation for ErrorResponse.
   528  func (er ErrorResponse) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) {
   529  	return nil, false
   530  }
   531  
   532  // AsBasicSearchResultsAnswer is the BasicResponseBase implementation for ErrorResponse.
   533  func (er ErrorResponse) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) {
   534  	return nil, false
   535  }
   536  
   537  // AsIdentifiable is the BasicResponseBase implementation for ErrorResponse.
   538  func (er ErrorResponse) AsIdentifiable() (*Identifiable, bool) {
   539  	return nil, false
   540  }
   541  
   542  // AsBasicIdentifiable is the BasicResponseBase implementation for ErrorResponse.
   543  func (er ErrorResponse) AsBasicIdentifiable() (BasicIdentifiable, bool) {
   544  	return &er, true
   545  }
   546  
   547  // AsErrorResponse is the BasicResponseBase implementation for ErrorResponse.
   548  func (er ErrorResponse) AsErrorResponse() (*ErrorResponse, bool) {
   549  	return &er, true
   550  }
   551  
   552  // AsAnswer is the BasicResponseBase implementation for ErrorResponse.
   553  func (er ErrorResponse) AsAnswer() (*Answer, bool) {
   554  	return nil, false
   555  }
   556  
   557  // AsBasicAnswer is the BasicResponseBase implementation for ErrorResponse.
   558  func (er ErrorResponse) AsBasicAnswer() (BasicAnswer, bool) {
   559  	return nil, false
   560  }
   561  
   562  // AsThing is the BasicResponseBase implementation for ErrorResponse.
   563  func (er ErrorResponse) AsThing() (*Thing, bool) {
   564  	return nil, false
   565  }
   566  
   567  // AsBasicThing is the BasicResponseBase implementation for ErrorResponse.
   568  func (er ErrorResponse) AsBasicThing() (BasicThing, bool) {
   569  	return nil, false
   570  }
   571  
   572  // AsCreativeWork is the BasicResponseBase implementation for ErrorResponse.
   573  func (er ErrorResponse) AsCreativeWork() (*CreativeWork, bool) {
   574  	return nil, false
   575  }
   576  
   577  // AsBasicCreativeWork is the BasicResponseBase implementation for ErrorResponse.
   578  func (er ErrorResponse) AsBasicCreativeWork() (BasicCreativeWork, bool) {
   579  	return nil, false
   580  }
   581  
   582  // AsResponseBase is the BasicResponseBase implementation for ErrorResponse.
   583  func (er ErrorResponse) AsResponseBase() (*ResponseBase, bool) {
   584  	return nil, false
   585  }
   586  
   587  // AsBasicResponseBase is the BasicResponseBase implementation for ErrorResponse.
   588  func (er ErrorResponse) AsBasicResponseBase() (BasicResponseBase, bool) {
   589  	return &er, true
   590  }
   591  
   592  // BasicIdentifiable defines the identity of a resource.
   593  type BasicIdentifiable interface {
   594  	AsWebPage() (*WebPage, bool)
   595  	AsWebWebAnswer() (*WebWebAnswer, bool)
   596  	AsSearchResponse() (*SearchResponse, bool)
   597  	AsResponse() (*Response, bool)
   598  	AsBasicResponse() (BasicResponse, bool)
   599  	AsSearchResultsAnswer() (*SearchResultsAnswer, bool)
   600  	AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool)
   601  	AsErrorResponse() (*ErrorResponse, bool)
   602  	AsAnswer() (*Answer, bool)
   603  	AsBasicAnswer() (BasicAnswer, bool)
   604  	AsThing() (*Thing, bool)
   605  	AsBasicThing() (BasicThing, bool)
   606  	AsCreativeWork() (*CreativeWork, bool)
   607  	AsBasicCreativeWork() (BasicCreativeWork, bool)
   608  	AsIdentifiable() (*Identifiable, bool)
   609  }
   610  
   611  // Identifiable defines the identity of a resource.
   612  type Identifiable struct {
   613  	// ID - READ-ONLY; A String identifier.
   614  	ID *string `json:"id,omitempty"`
   615  	// Type - Possible values include: 'TypeResponseBase', 'TypeWebPage', 'TypeWebWebAnswer', 'TypeSearchResponse', 'TypeResponse', 'TypeSearchResultsAnswer', 'TypeIdentifiable', 'TypeErrorResponse', 'TypeAnswer', 'TypeThing', 'TypeCreativeWork'
   616  	Type Type `json:"_type,omitempty"`
   617  }
   618  
   619  func unmarshalBasicIdentifiable(body []byte) (BasicIdentifiable, error) {
   620  	var m map[string]interface{}
   621  	err := json.Unmarshal(body, &m)
   622  	if err != nil {
   623  		return nil, err
   624  	}
   625  
   626  	switch m["_type"] {
   627  	case string(TypeWebPage):
   628  		var wp WebPage
   629  		err := json.Unmarshal(body, &wp)
   630  		return wp, err
   631  	case string(TypeWebWebAnswer):
   632  		var wwa WebWebAnswer
   633  		err := json.Unmarshal(body, &wwa)
   634  		return wwa, err
   635  	case string(TypeSearchResponse):
   636  		var sr SearchResponse
   637  		err := json.Unmarshal(body, &sr)
   638  		return sr, err
   639  	case string(TypeResponse):
   640  		var r Response
   641  		err := json.Unmarshal(body, &r)
   642  		return r, err
   643  	case string(TypeSearchResultsAnswer):
   644  		var sra SearchResultsAnswer
   645  		err := json.Unmarshal(body, &sra)
   646  		return sra, err
   647  	case string(TypeErrorResponse):
   648  		var er ErrorResponse
   649  		err := json.Unmarshal(body, &er)
   650  		return er, err
   651  	case string(TypeAnswer):
   652  		var a Answer
   653  		err := json.Unmarshal(body, &a)
   654  		return a, err
   655  	case string(TypeThing):
   656  		var t Thing
   657  		err := json.Unmarshal(body, &t)
   658  		return t, err
   659  	case string(TypeCreativeWork):
   660  		var cw CreativeWork
   661  		err := json.Unmarshal(body, &cw)
   662  		return cw, err
   663  	default:
   664  		var i Identifiable
   665  		err := json.Unmarshal(body, &i)
   666  		return i, err
   667  	}
   668  }
   669  func unmarshalBasicIdentifiableArray(body []byte) ([]BasicIdentifiable, error) {
   670  	var rawMessages []*json.RawMessage
   671  	err := json.Unmarshal(body, &rawMessages)
   672  	if err != nil {
   673  		return nil, err
   674  	}
   675  
   676  	iArray := make([]BasicIdentifiable, len(rawMessages))
   677  
   678  	for index, rawMessage := range rawMessages {
   679  		i, err := unmarshalBasicIdentifiable(*rawMessage)
   680  		if err != nil {
   681  			return nil, err
   682  		}
   683  		iArray[index] = i
   684  	}
   685  	return iArray, nil
   686  }
   687  
   688  // MarshalJSON is the custom marshaler for Identifiable.
   689  func (i Identifiable) MarshalJSON() ([]byte, error) {
   690  	i.Type = TypeIdentifiable
   691  	objectMap := make(map[string]interface{})
   692  	if i.Type != "" {
   693  		objectMap["_type"] = i.Type
   694  	}
   695  	return json.Marshal(objectMap)
   696  }
   697  
   698  // AsWebPage is the BasicResponseBase implementation for Identifiable.
   699  func (i Identifiable) AsWebPage() (*WebPage, bool) {
   700  	return nil, false
   701  }
   702  
   703  // AsWebWebAnswer is the BasicResponseBase implementation for Identifiable.
   704  func (i Identifiable) AsWebWebAnswer() (*WebWebAnswer, bool) {
   705  	return nil, false
   706  }
   707  
   708  // AsSearchResponse is the BasicResponseBase implementation for Identifiable.
   709  func (i Identifiable) AsSearchResponse() (*SearchResponse, bool) {
   710  	return nil, false
   711  }
   712  
   713  // AsResponse is the BasicResponseBase implementation for Identifiable.
   714  func (i Identifiable) AsResponse() (*Response, bool) {
   715  	return nil, false
   716  }
   717  
   718  // AsBasicResponse is the BasicResponseBase implementation for Identifiable.
   719  func (i Identifiable) AsBasicResponse() (BasicResponse, bool) {
   720  	return nil, false
   721  }
   722  
   723  // AsSearchResultsAnswer is the BasicResponseBase implementation for Identifiable.
   724  func (i Identifiable) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) {
   725  	return nil, false
   726  }
   727  
   728  // AsBasicSearchResultsAnswer is the BasicResponseBase implementation for Identifiable.
   729  func (i Identifiable) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) {
   730  	return nil, false
   731  }
   732  
   733  // AsIdentifiable is the BasicResponseBase implementation for Identifiable.
   734  func (i Identifiable) AsIdentifiable() (*Identifiable, bool) {
   735  	return &i, true
   736  }
   737  
   738  // AsBasicIdentifiable is the BasicResponseBase implementation for Identifiable.
   739  func (i Identifiable) AsBasicIdentifiable() (BasicIdentifiable, bool) {
   740  	return &i, true
   741  }
   742  
   743  // AsErrorResponse is the BasicResponseBase implementation for Identifiable.
   744  func (i Identifiable) AsErrorResponse() (*ErrorResponse, bool) {
   745  	return nil, false
   746  }
   747  
   748  // AsAnswer is the BasicResponseBase implementation for Identifiable.
   749  func (i Identifiable) AsAnswer() (*Answer, bool) {
   750  	return nil, false
   751  }
   752  
   753  // AsBasicAnswer is the BasicResponseBase implementation for Identifiable.
   754  func (i Identifiable) AsBasicAnswer() (BasicAnswer, bool) {
   755  	return nil, false
   756  }
   757  
   758  // AsThing is the BasicResponseBase implementation for Identifiable.
   759  func (i Identifiable) AsThing() (*Thing, bool) {
   760  	return nil, false
   761  }
   762  
   763  // AsBasicThing is the BasicResponseBase implementation for Identifiable.
   764  func (i Identifiable) AsBasicThing() (BasicThing, bool) {
   765  	return nil, false
   766  }
   767  
   768  // AsCreativeWork is the BasicResponseBase implementation for Identifiable.
   769  func (i Identifiable) AsCreativeWork() (*CreativeWork, bool) {
   770  	return nil, false
   771  }
   772  
   773  // AsBasicCreativeWork is the BasicResponseBase implementation for Identifiable.
   774  func (i Identifiable) AsBasicCreativeWork() (BasicCreativeWork, bool) {
   775  	return nil, false
   776  }
   777  
   778  // AsResponseBase is the BasicResponseBase implementation for Identifiable.
   779  func (i Identifiable) AsResponseBase() (*ResponseBase, bool) {
   780  	return nil, false
   781  }
   782  
   783  // AsBasicResponseBase is the BasicResponseBase implementation for Identifiable.
   784  func (i Identifiable) AsBasicResponseBase() (BasicResponseBase, bool) {
   785  	return &i, true
   786  }
   787  
   788  // Query defines a search query.
   789  type Query struct {
   790  	// Text - The query string. Use this string as the query term in a new search request.
   791  	Text *string `json:"text,omitempty"`
   792  	// 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
   793  	DisplayText *string `json:"displayText,omitempty"`
   794  	// 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.
   795  	WebSearchURL *string `json:"webSearchUrl,omitempty"`
   796  	// SearchLink - READ-ONLY
   797  	SearchLink *string `json:"searchLink,omitempty"`
   798  }
   799  
   800  // MarshalJSON is the custom marshaler for Query.
   801  func (q Query) MarshalJSON() ([]byte, error) {
   802  	objectMap := make(map[string]interface{})
   803  	if q.Text != nil {
   804  		objectMap["text"] = q.Text
   805  	}
   806  	return json.Marshal(objectMap)
   807  }
   808  
   809  // QueryContext defines the query context that Bing used for the request.
   810  type QueryContext struct {
   811  	// OriginalQuery - The query string as specified in the request.
   812  	OriginalQuery *string `json:"originalQuery,omitempty"`
   813  	// AlteredQuery - READ-ONLY; The query string used by Bing to perform the query. Bing uses the altered query string if the original query string contained spelling mistakes. For example, if the query string is "saling downwind", the altered query string will be "sailing downwind". This field is included only if the original query string contains a spelling mistake.
   814  	AlteredQuery *string `json:"alteredQuery,omitempty"`
   815  	// AlterationOverrideQuery - READ-ONLY; The query string to use to force Bing to use the original string. For example, if the query string is "saling downwind", the override query string will be "+saling downwind". Remember to encode the query string which results in "%2Bsaling+downwind". This field is included only if the original query string contains a spelling mistake.
   816  	AlterationOverrideQuery *string `json:"alterationOverrideQuery,omitempty"`
   817  	// AdultIntent - READ-ONLY; A Boolean value that indicates whether the specified query has adult intent. The value is true if the query has adult intent; otherwise, false.
   818  	AdultIntent *bool `json:"adultIntent,omitempty"`
   819  }
   820  
   821  // MarshalJSON is the custom marshaler for QueryContext.
   822  func (qc QueryContext) MarshalJSON() ([]byte, error) {
   823  	objectMap := make(map[string]interface{})
   824  	if qc.OriginalQuery != nil {
   825  		objectMap["originalQuery"] = qc.OriginalQuery
   826  	}
   827  	return json.Marshal(objectMap)
   828  }
   829  
   830  // BasicResponse defines a response. All schemas that could be returned at the root of a response should inherit from
   831  // this
   832  type BasicResponse interface {
   833  	AsWebPage() (*WebPage, bool)
   834  	AsWebWebAnswer() (*WebWebAnswer, bool)
   835  	AsSearchResponse() (*SearchResponse, bool)
   836  	AsSearchResultsAnswer() (*SearchResultsAnswer, bool)
   837  	AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool)
   838  	AsErrorResponse() (*ErrorResponse, bool)
   839  	AsAnswer() (*Answer, bool)
   840  	AsBasicAnswer() (BasicAnswer, bool)
   841  	AsThing() (*Thing, bool)
   842  	AsBasicThing() (BasicThing, bool)
   843  	AsCreativeWork() (*CreativeWork, bool)
   844  	AsBasicCreativeWork() (BasicCreativeWork, bool)
   845  	AsResponse() (*Response, bool)
   846  }
   847  
   848  // Response defines a response. All schemas that could be returned at the root of a response should inherit
   849  // from this
   850  type Response struct {
   851  	// WebSearchURL - READ-ONLY; The URL To Bing's search result for this item.
   852  	WebSearchURL *string `json:"webSearchUrl,omitempty"`
   853  	// ID - READ-ONLY; A String identifier.
   854  	ID *string `json:"id,omitempty"`
   855  	// Type - Possible values include: 'TypeResponseBase', 'TypeWebPage', 'TypeWebWebAnswer', 'TypeSearchResponse', 'TypeResponse', 'TypeSearchResultsAnswer', 'TypeIdentifiable', 'TypeErrorResponse', 'TypeAnswer', 'TypeThing', 'TypeCreativeWork'
   856  	Type Type `json:"_type,omitempty"`
   857  }
   858  
   859  func unmarshalBasicResponse(body []byte) (BasicResponse, error) {
   860  	var m map[string]interface{}
   861  	err := json.Unmarshal(body, &m)
   862  	if err != nil {
   863  		return nil, err
   864  	}
   865  
   866  	switch m["_type"] {
   867  	case string(TypeWebPage):
   868  		var wp WebPage
   869  		err := json.Unmarshal(body, &wp)
   870  		return wp, err
   871  	case string(TypeWebWebAnswer):
   872  		var wwa WebWebAnswer
   873  		err := json.Unmarshal(body, &wwa)
   874  		return wwa, err
   875  	case string(TypeSearchResponse):
   876  		var sr SearchResponse
   877  		err := json.Unmarshal(body, &sr)
   878  		return sr, err
   879  	case string(TypeSearchResultsAnswer):
   880  		var sra SearchResultsAnswer
   881  		err := json.Unmarshal(body, &sra)
   882  		return sra, err
   883  	case string(TypeErrorResponse):
   884  		var er ErrorResponse
   885  		err := json.Unmarshal(body, &er)
   886  		return er, err
   887  	case string(TypeAnswer):
   888  		var a Answer
   889  		err := json.Unmarshal(body, &a)
   890  		return a, err
   891  	case string(TypeThing):
   892  		var t Thing
   893  		err := json.Unmarshal(body, &t)
   894  		return t, err
   895  	case string(TypeCreativeWork):
   896  		var cw CreativeWork
   897  		err := json.Unmarshal(body, &cw)
   898  		return cw, err
   899  	default:
   900  		var r Response
   901  		err := json.Unmarshal(body, &r)
   902  		return r, err
   903  	}
   904  }
   905  func unmarshalBasicResponseArray(body []byte) ([]BasicResponse, error) {
   906  	var rawMessages []*json.RawMessage
   907  	err := json.Unmarshal(body, &rawMessages)
   908  	if err != nil {
   909  		return nil, err
   910  	}
   911  
   912  	rArray := make([]BasicResponse, len(rawMessages))
   913  
   914  	for index, rawMessage := range rawMessages {
   915  		r, err := unmarshalBasicResponse(*rawMessage)
   916  		if err != nil {
   917  			return nil, err
   918  		}
   919  		rArray[index] = r
   920  	}
   921  	return rArray, nil
   922  }
   923  
   924  // MarshalJSON is the custom marshaler for Response.
   925  func (r Response) MarshalJSON() ([]byte, error) {
   926  	r.Type = TypeResponse
   927  	objectMap := make(map[string]interface{})
   928  	if r.Type != "" {
   929  		objectMap["_type"] = r.Type
   930  	}
   931  	return json.Marshal(objectMap)
   932  }
   933  
   934  // AsWebPage is the BasicResponseBase implementation for Response.
   935  func (r Response) AsWebPage() (*WebPage, bool) {
   936  	return nil, false
   937  }
   938  
   939  // AsWebWebAnswer is the BasicResponseBase implementation for Response.
   940  func (r Response) AsWebWebAnswer() (*WebWebAnswer, bool) {
   941  	return nil, false
   942  }
   943  
   944  // AsSearchResponse is the BasicResponseBase implementation for Response.
   945  func (r Response) AsSearchResponse() (*SearchResponse, bool) {
   946  	return nil, false
   947  }
   948  
   949  // AsResponse is the BasicResponseBase implementation for Response.
   950  func (r Response) AsResponse() (*Response, bool) {
   951  	return &r, true
   952  }
   953  
   954  // AsBasicResponse is the BasicResponseBase implementation for Response.
   955  func (r Response) AsBasicResponse() (BasicResponse, bool) {
   956  	return &r, true
   957  }
   958  
   959  // AsSearchResultsAnswer is the BasicResponseBase implementation for Response.
   960  func (r Response) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) {
   961  	return nil, false
   962  }
   963  
   964  // AsBasicSearchResultsAnswer is the BasicResponseBase implementation for Response.
   965  func (r Response) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) {
   966  	return nil, false
   967  }
   968  
   969  // AsIdentifiable is the BasicResponseBase implementation for Response.
   970  func (r Response) AsIdentifiable() (*Identifiable, bool) {
   971  	return nil, false
   972  }
   973  
   974  // AsBasicIdentifiable is the BasicResponseBase implementation for Response.
   975  func (r Response) AsBasicIdentifiable() (BasicIdentifiable, bool) {
   976  	return &r, true
   977  }
   978  
   979  // AsErrorResponse is the BasicResponseBase implementation for Response.
   980  func (r Response) AsErrorResponse() (*ErrorResponse, bool) {
   981  	return nil, false
   982  }
   983  
   984  // AsAnswer is the BasicResponseBase implementation for Response.
   985  func (r Response) AsAnswer() (*Answer, bool) {
   986  	return nil, false
   987  }
   988  
   989  // AsBasicAnswer is the BasicResponseBase implementation for Response.
   990  func (r Response) AsBasicAnswer() (BasicAnswer, bool) {
   991  	return nil, false
   992  }
   993  
   994  // AsThing is the BasicResponseBase implementation for Response.
   995  func (r Response) AsThing() (*Thing, bool) {
   996  	return nil, false
   997  }
   998  
   999  // AsBasicThing is the BasicResponseBase implementation for Response.
  1000  func (r Response) AsBasicThing() (BasicThing, bool) {
  1001  	return nil, false
  1002  }
  1003  
  1004  // AsCreativeWork is the BasicResponseBase implementation for Response.
  1005  func (r Response) AsCreativeWork() (*CreativeWork, bool) {
  1006  	return nil, false
  1007  }
  1008  
  1009  // AsBasicCreativeWork is the BasicResponseBase implementation for Response.
  1010  func (r Response) AsBasicCreativeWork() (BasicCreativeWork, bool) {
  1011  	return nil, false
  1012  }
  1013  
  1014  // AsResponseBase is the BasicResponseBase implementation for Response.
  1015  func (r Response) AsResponseBase() (*ResponseBase, bool) {
  1016  	return nil, false
  1017  }
  1018  
  1019  // AsBasicResponseBase is the BasicResponseBase implementation for Response.
  1020  func (r Response) AsBasicResponseBase() (BasicResponseBase, bool) {
  1021  	return &r, true
  1022  }
  1023  
  1024  // BasicResponseBase ...
  1025  type BasicResponseBase interface {
  1026  	AsWebPage() (*WebPage, bool)
  1027  	AsWebWebAnswer() (*WebWebAnswer, bool)
  1028  	AsSearchResponse() (*SearchResponse, bool)
  1029  	AsResponse() (*Response, bool)
  1030  	AsBasicResponse() (BasicResponse, bool)
  1031  	AsSearchResultsAnswer() (*SearchResultsAnswer, bool)
  1032  	AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool)
  1033  	AsIdentifiable() (*Identifiable, bool)
  1034  	AsBasicIdentifiable() (BasicIdentifiable, bool)
  1035  	AsErrorResponse() (*ErrorResponse, bool)
  1036  	AsAnswer() (*Answer, bool)
  1037  	AsBasicAnswer() (BasicAnswer, bool)
  1038  	AsThing() (*Thing, bool)
  1039  	AsBasicThing() (BasicThing, bool)
  1040  	AsCreativeWork() (*CreativeWork, bool)
  1041  	AsBasicCreativeWork() (BasicCreativeWork, bool)
  1042  	AsResponseBase() (*ResponseBase, bool)
  1043  }
  1044  
  1045  // ResponseBase ...
  1046  type ResponseBase struct {
  1047  	// Type - Possible values include: 'TypeResponseBase', 'TypeWebPage', 'TypeWebWebAnswer', 'TypeSearchResponse', 'TypeResponse', 'TypeSearchResultsAnswer', 'TypeIdentifiable', 'TypeErrorResponse', 'TypeAnswer', 'TypeThing', 'TypeCreativeWork'
  1048  	Type Type `json:"_type,omitempty"`
  1049  }
  1050  
  1051  func unmarshalBasicResponseBase(body []byte) (BasicResponseBase, error) {
  1052  	var m map[string]interface{}
  1053  	err := json.Unmarshal(body, &m)
  1054  	if err != nil {
  1055  		return nil, err
  1056  	}
  1057  
  1058  	switch m["_type"] {
  1059  	case string(TypeWebPage):
  1060  		var wp WebPage
  1061  		err := json.Unmarshal(body, &wp)
  1062  		return wp, err
  1063  	case string(TypeWebWebAnswer):
  1064  		var wwa WebWebAnswer
  1065  		err := json.Unmarshal(body, &wwa)
  1066  		return wwa, err
  1067  	case string(TypeSearchResponse):
  1068  		var sr SearchResponse
  1069  		err := json.Unmarshal(body, &sr)
  1070  		return sr, err
  1071  	case string(TypeResponse):
  1072  		var r Response
  1073  		err := json.Unmarshal(body, &r)
  1074  		return r, err
  1075  	case string(TypeSearchResultsAnswer):
  1076  		var sra SearchResultsAnswer
  1077  		err := json.Unmarshal(body, &sra)
  1078  		return sra, err
  1079  	case string(TypeIdentifiable):
  1080  		var i Identifiable
  1081  		err := json.Unmarshal(body, &i)
  1082  		return i, err
  1083  	case string(TypeErrorResponse):
  1084  		var er ErrorResponse
  1085  		err := json.Unmarshal(body, &er)
  1086  		return er, err
  1087  	case string(TypeAnswer):
  1088  		var a Answer
  1089  		err := json.Unmarshal(body, &a)
  1090  		return a, err
  1091  	case string(TypeThing):
  1092  		var t Thing
  1093  		err := json.Unmarshal(body, &t)
  1094  		return t, err
  1095  	case string(TypeCreativeWork):
  1096  		var cw CreativeWork
  1097  		err := json.Unmarshal(body, &cw)
  1098  		return cw, err
  1099  	default:
  1100  		var rb ResponseBase
  1101  		err := json.Unmarshal(body, &rb)
  1102  		return rb, err
  1103  	}
  1104  }
  1105  func unmarshalBasicResponseBaseArray(body []byte) ([]BasicResponseBase, error) {
  1106  	var rawMessages []*json.RawMessage
  1107  	err := json.Unmarshal(body, &rawMessages)
  1108  	if err != nil {
  1109  		return nil, err
  1110  	}
  1111  
  1112  	rbArray := make([]BasicResponseBase, len(rawMessages))
  1113  
  1114  	for index, rawMessage := range rawMessages {
  1115  		rb, err := unmarshalBasicResponseBase(*rawMessage)
  1116  		if err != nil {
  1117  			return nil, err
  1118  		}
  1119  		rbArray[index] = rb
  1120  	}
  1121  	return rbArray, nil
  1122  }
  1123  
  1124  // MarshalJSON is the custom marshaler for ResponseBase.
  1125  func (rb ResponseBase) MarshalJSON() ([]byte, error) {
  1126  	rb.Type = TypeResponseBase
  1127  	objectMap := make(map[string]interface{})
  1128  	if rb.Type != "" {
  1129  		objectMap["_type"] = rb.Type
  1130  	}
  1131  	return json.Marshal(objectMap)
  1132  }
  1133  
  1134  // AsWebPage is the BasicResponseBase implementation for ResponseBase.
  1135  func (rb ResponseBase) AsWebPage() (*WebPage, bool) {
  1136  	return nil, false
  1137  }
  1138  
  1139  // AsWebWebAnswer is the BasicResponseBase implementation for ResponseBase.
  1140  func (rb ResponseBase) AsWebWebAnswer() (*WebWebAnswer, bool) {
  1141  	return nil, false
  1142  }
  1143  
  1144  // AsSearchResponse is the BasicResponseBase implementation for ResponseBase.
  1145  func (rb ResponseBase) AsSearchResponse() (*SearchResponse, bool) {
  1146  	return nil, false
  1147  }
  1148  
  1149  // AsResponse is the BasicResponseBase implementation for ResponseBase.
  1150  func (rb ResponseBase) AsResponse() (*Response, bool) {
  1151  	return nil, false
  1152  }
  1153  
  1154  // AsBasicResponse is the BasicResponseBase implementation for ResponseBase.
  1155  func (rb ResponseBase) AsBasicResponse() (BasicResponse, bool) {
  1156  	return nil, false
  1157  }
  1158  
  1159  // AsSearchResultsAnswer is the BasicResponseBase implementation for ResponseBase.
  1160  func (rb ResponseBase) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) {
  1161  	return nil, false
  1162  }
  1163  
  1164  // AsBasicSearchResultsAnswer is the BasicResponseBase implementation for ResponseBase.
  1165  func (rb ResponseBase) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) {
  1166  	return nil, false
  1167  }
  1168  
  1169  // AsIdentifiable is the BasicResponseBase implementation for ResponseBase.
  1170  func (rb ResponseBase) AsIdentifiable() (*Identifiable, bool) {
  1171  	return nil, false
  1172  }
  1173  
  1174  // AsBasicIdentifiable is the BasicResponseBase implementation for ResponseBase.
  1175  func (rb ResponseBase) AsBasicIdentifiable() (BasicIdentifiable, bool) {
  1176  	return nil, false
  1177  }
  1178  
  1179  // AsErrorResponse is the BasicResponseBase implementation for ResponseBase.
  1180  func (rb ResponseBase) AsErrorResponse() (*ErrorResponse, bool) {
  1181  	return nil, false
  1182  }
  1183  
  1184  // AsAnswer is the BasicResponseBase implementation for ResponseBase.
  1185  func (rb ResponseBase) AsAnswer() (*Answer, bool) {
  1186  	return nil, false
  1187  }
  1188  
  1189  // AsBasicAnswer is the BasicResponseBase implementation for ResponseBase.
  1190  func (rb ResponseBase) AsBasicAnswer() (BasicAnswer, bool) {
  1191  	return nil, false
  1192  }
  1193  
  1194  // AsThing is the BasicResponseBase implementation for ResponseBase.
  1195  func (rb ResponseBase) AsThing() (*Thing, bool) {
  1196  	return nil, false
  1197  }
  1198  
  1199  // AsBasicThing is the BasicResponseBase implementation for ResponseBase.
  1200  func (rb ResponseBase) AsBasicThing() (BasicThing, bool) {
  1201  	return nil, false
  1202  }
  1203  
  1204  // AsCreativeWork is the BasicResponseBase implementation for ResponseBase.
  1205  func (rb ResponseBase) AsCreativeWork() (*CreativeWork, bool) {
  1206  	return nil, false
  1207  }
  1208  
  1209  // AsBasicCreativeWork is the BasicResponseBase implementation for ResponseBase.
  1210  func (rb ResponseBase) AsBasicCreativeWork() (BasicCreativeWork, bool) {
  1211  	return nil, false
  1212  }
  1213  
  1214  // AsResponseBase is the BasicResponseBase implementation for ResponseBase.
  1215  func (rb ResponseBase) AsResponseBase() (*ResponseBase, bool) {
  1216  	return &rb, true
  1217  }
  1218  
  1219  // AsBasicResponseBase is the BasicResponseBase implementation for ResponseBase.
  1220  func (rb ResponseBase) AsBasicResponseBase() (BasicResponseBase, bool) {
  1221  	return &rb, true
  1222  }
  1223  
  1224  // SearchResponse defines the top-level object that the response includes when the request succeeds.
  1225  type SearchResponse struct {
  1226  	autorest.Response `json:"-"`
  1227  	// QueryContext - READ-ONLY; An object that contains the query string that Bing used for the request. This object contains the query string as entered by the user. It may also contain an altered query string that Bing used for the query if the query string contained a spelling mistake.
  1228  	QueryContext *QueryContext `json:"queryContext,omitempty"`
  1229  	// WebPages - READ-ONLY; A list of webpages that are relevant to the search query.
  1230  	WebPages *WebWebAnswer `json:"webPages,omitempty"`
  1231  	// WebSearchURL - READ-ONLY; The URL To Bing's search result for this item.
  1232  	WebSearchURL *string `json:"webSearchUrl,omitempty"`
  1233  	// ID - READ-ONLY; A String identifier.
  1234  	ID *string `json:"id,omitempty"`
  1235  	// Type - Possible values include: 'TypeResponseBase', 'TypeWebPage', 'TypeWebWebAnswer', 'TypeSearchResponse', 'TypeResponse', 'TypeSearchResultsAnswer', 'TypeIdentifiable', 'TypeErrorResponse', 'TypeAnswer', 'TypeThing', 'TypeCreativeWork'
  1236  	Type Type `json:"_type,omitempty"`
  1237  }
  1238  
  1239  // MarshalJSON is the custom marshaler for SearchResponse.
  1240  func (sr SearchResponse) MarshalJSON() ([]byte, error) {
  1241  	sr.Type = TypeSearchResponse
  1242  	objectMap := make(map[string]interface{})
  1243  	if sr.Type != "" {
  1244  		objectMap["_type"] = sr.Type
  1245  	}
  1246  	return json.Marshal(objectMap)
  1247  }
  1248  
  1249  // AsWebPage is the BasicResponseBase implementation for SearchResponse.
  1250  func (sr SearchResponse) AsWebPage() (*WebPage, bool) {
  1251  	return nil, false
  1252  }
  1253  
  1254  // AsWebWebAnswer is the BasicResponseBase implementation for SearchResponse.
  1255  func (sr SearchResponse) AsWebWebAnswer() (*WebWebAnswer, bool) {
  1256  	return nil, false
  1257  }
  1258  
  1259  // AsSearchResponse is the BasicResponseBase implementation for SearchResponse.
  1260  func (sr SearchResponse) AsSearchResponse() (*SearchResponse, bool) {
  1261  	return &sr, true
  1262  }
  1263  
  1264  // AsResponse is the BasicResponseBase implementation for SearchResponse.
  1265  func (sr SearchResponse) AsResponse() (*Response, bool) {
  1266  	return nil, false
  1267  }
  1268  
  1269  // AsBasicResponse is the BasicResponseBase implementation for SearchResponse.
  1270  func (sr SearchResponse) AsBasicResponse() (BasicResponse, bool) {
  1271  	return &sr, true
  1272  }
  1273  
  1274  // AsSearchResultsAnswer is the BasicResponseBase implementation for SearchResponse.
  1275  func (sr SearchResponse) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) {
  1276  	return nil, false
  1277  }
  1278  
  1279  // AsBasicSearchResultsAnswer is the BasicResponseBase implementation for SearchResponse.
  1280  func (sr SearchResponse) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) {
  1281  	return nil, false
  1282  }
  1283  
  1284  // AsIdentifiable is the BasicResponseBase implementation for SearchResponse.
  1285  func (sr SearchResponse) AsIdentifiable() (*Identifiable, bool) {
  1286  	return nil, false
  1287  }
  1288  
  1289  // AsBasicIdentifiable is the BasicResponseBase implementation for SearchResponse.
  1290  func (sr SearchResponse) AsBasicIdentifiable() (BasicIdentifiable, bool) {
  1291  	return &sr, true
  1292  }
  1293  
  1294  // AsErrorResponse is the BasicResponseBase implementation for SearchResponse.
  1295  func (sr SearchResponse) AsErrorResponse() (*ErrorResponse, bool) {
  1296  	return nil, false
  1297  }
  1298  
  1299  // AsAnswer is the BasicResponseBase implementation for SearchResponse.
  1300  func (sr SearchResponse) AsAnswer() (*Answer, bool) {
  1301  	return nil, false
  1302  }
  1303  
  1304  // AsBasicAnswer is the BasicResponseBase implementation for SearchResponse.
  1305  func (sr SearchResponse) AsBasicAnswer() (BasicAnswer, bool) {
  1306  	return nil, false
  1307  }
  1308  
  1309  // AsThing is the BasicResponseBase implementation for SearchResponse.
  1310  func (sr SearchResponse) AsThing() (*Thing, bool) {
  1311  	return nil, false
  1312  }
  1313  
  1314  // AsBasicThing is the BasicResponseBase implementation for SearchResponse.
  1315  func (sr SearchResponse) AsBasicThing() (BasicThing, bool) {
  1316  	return nil, false
  1317  }
  1318  
  1319  // AsCreativeWork is the BasicResponseBase implementation for SearchResponse.
  1320  func (sr SearchResponse) AsCreativeWork() (*CreativeWork, bool) {
  1321  	return nil, false
  1322  }
  1323  
  1324  // AsBasicCreativeWork is the BasicResponseBase implementation for SearchResponse.
  1325  func (sr SearchResponse) AsBasicCreativeWork() (BasicCreativeWork, bool) {
  1326  	return nil, false
  1327  }
  1328  
  1329  // AsResponseBase is the BasicResponseBase implementation for SearchResponse.
  1330  func (sr SearchResponse) AsResponseBase() (*ResponseBase, bool) {
  1331  	return nil, false
  1332  }
  1333  
  1334  // AsBasicResponseBase is the BasicResponseBase implementation for SearchResponse.
  1335  func (sr SearchResponse) AsBasicResponseBase() (BasicResponseBase, bool) {
  1336  	return &sr, true
  1337  }
  1338  
  1339  // BasicSearchResultsAnswer ...
  1340  type BasicSearchResultsAnswer interface {
  1341  	AsWebWebAnswer() (*WebWebAnswer, bool)
  1342  	AsSearchResultsAnswer() (*SearchResultsAnswer, bool)
  1343  }
  1344  
  1345  // SearchResultsAnswer ...
  1346  type SearchResultsAnswer struct {
  1347  	// QueryContext - READ-ONLY
  1348  	QueryContext *QueryContext `json:"queryContext,omitempty"`
  1349  	// 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.
  1350  	TotalEstimatedMatches *int64 `json:"totalEstimatedMatches,omitempty"`
  1351  	// IsFamilyFriendly - READ-ONLY
  1352  	IsFamilyFriendly *bool `json:"isFamilyFriendly,omitempty"`
  1353  	// FollowUpQueries - READ-ONLY
  1354  	FollowUpQueries *[]Query `json:"followUpQueries,omitempty"`
  1355  	// WebSearchURL - READ-ONLY; The URL To Bing's search result for this item.
  1356  	WebSearchURL *string `json:"webSearchUrl,omitempty"`
  1357  	// ID - READ-ONLY; A String identifier.
  1358  	ID *string `json:"id,omitempty"`
  1359  	// Type - Possible values include: 'TypeResponseBase', 'TypeWebPage', 'TypeWebWebAnswer', 'TypeSearchResponse', 'TypeResponse', 'TypeSearchResultsAnswer', 'TypeIdentifiable', 'TypeErrorResponse', 'TypeAnswer', 'TypeThing', 'TypeCreativeWork'
  1360  	Type Type `json:"_type,omitempty"`
  1361  }
  1362  
  1363  func unmarshalBasicSearchResultsAnswer(body []byte) (BasicSearchResultsAnswer, error) {
  1364  	var m map[string]interface{}
  1365  	err := json.Unmarshal(body, &m)
  1366  	if err != nil {
  1367  		return nil, err
  1368  	}
  1369  
  1370  	switch m["_type"] {
  1371  	case string(TypeWebWebAnswer):
  1372  		var wwa WebWebAnswer
  1373  		err := json.Unmarshal(body, &wwa)
  1374  		return wwa, err
  1375  	default:
  1376  		var sra SearchResultsAnswer
  1377  		err := json.Unmarshal(body, &sra)
  1378  		return sra, err
  1379  	}
  1380  }
  1381  func unmarshalBasicSearchResultsAnswerArray(body []byte) ([]BasicSearchResultsAnswer, error) {
  1382  	var rawMessages []*json.RawMessage
  1383  	err := json.Unmarshal(body, &rawMessages)
  1384  	if err != nil {
  1385  		return nil, err
  1386  	}
  1387  
  1388  	sraArray := make([]BasicSearchResultsAnswer, len(rawMessages))
  1389  
  1390  	for index, rawMessage := range rawMessages {
  1391  		sra, err := unmarshalBasicSearchResultsAnswer(*rawMessage)
  1392  		if err != nil {
  1393  			return nil, err
  1394  		}
  1395  		sraArray[index] = sra
  1396  	}
  1397  	return sraArray, nil
  1398  }
  1399  
  1400  // MarshalJSON is the custom marshaler for SearchResultsAnswer.
  1401  func (sra SearchResultsAnswer) MarshalJSON() ([]byte, error) {
  1402  	sra.Type = TypeSearchResultsAnswer
  1403  	objectMap := make(map[string]interface{})
  1404  	if sra.Type != "" {
  1405  		objectMap["_type"] = sra.Type
  1406  	}
  1407  	return json.Marshal(objectMap)
  1408  }
  1409  
  1410  // AsWebPage is the BasicResponseBase implementation for SearchResultsAnswer.
  1411  func (sra SearchResultsAnswer) AsWebPage() (*WebPage, bool) {
  1412  	return nil, false
  1413  }
  1414  
  1415  // AsWebWebAnswer is the BasicResponseBase implementation for SearchResultsAnswer.
  1416  func (sra SearchResultsAnswer) AsWebWebAnswer() (*WebWebAnswer, bool) {
  1417  	return nil, false
  1418  }
  1419  
  1420  // AsSearchResponse is the BasicResponseBase implementation for SearchResultsAnswer.
  1421  func (sra SearchResultsAnswer) AsSearchResponse() (*SearchResponse, bool) {
  1422  	return nil, false
  1423  }
  1424  
  1425  // AsResponse is the BasicResponseBase implementation for SearchResultsAnswer.
  1426  func (sra SearchResultsAnswer) AsResponse() (*Response, bool) {
  1427  	return nil, false
  1428  }
  1429  
  1430  // AsBasicResponse is the BasicResponseBase implementation for SearchResultsAnswer.
  1431  func (sra SearchResultsAnswer) AsBasicResponse() (BasicResponse, bool) {
  1432  	return &sra, true
  1433  }
  1434  
  1435  // AsSearchResultsAnswer is the BasicResponseBase implementation for SearchResultsAnswer.
  1436  func (sra SearchResultsAnswer) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) {
  1437  	return &sra, true
  1438  }
  1439  
  1440  // AsBasicSearchResultsAnswer is the BasicResponseBase implementation for SearchResultsAnswer.
  1441  func (sra SearchResultsAnswer) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) {
  1442  	return &sra, true
  1443  }
  1444  
  1445  // AsIdentifiable is the BasicResponseBase implementation for SearchResultsAnswer.
  1446  func (sra SearchResultsAnswer) AsIdentifiable() (*Identifiable, bool) {
  1447  	return nil, false
  1448  }
  1449  
  1450  // AsBasicIdentifiable is the BasicResponseBase implementation for SearchResultsAnswer.
  1451  func (sra SearchResultsAnswer) AsBasicIdentifiable() (BasicIdentifiable, bool) {
  1452  	return &sra, true
  1453  }
  1454  
  1455  // AsErrorResponse is the BasicResponseBase implementation for SearchResultsAnswer.
  1456  func (sra SearchResultsAnswer) AsErrorResponse() (*ErrorResponse, bool) {
  1457  	return nil, false
  1458  }
  1459  
  1460  // AsAnswer is the BasicResponseBase implementation for SearchResultsAnswer.
  1461  func (sra SearchResultsAnswer) AsAnswer() (*Answer, bool) {
  1462  	return nil, false
  1463  }
  1464  
  1465  // AsBasicAnswer is the BasicResponseBase implementation for SearchResultsAnswer.
  1466  func (sra SearchResultsAnswer) AsBasicAnswer() (BasicAnswer, bool) {
  1467  	return &sra, true
  1468  }
  1469  
  1470  // AsThing is the BasicResponseBase implementation for SearchResultsAnswer.
  1471  func (sra SearchResultsAnswer) AsThing() (*Thing, bool) {
  1472  	return nil, false
  1473  }
  1474  
  1475  // AsBasicThing is the BasicResponseBase implementation for SearchResultsAnswer.
  1476  func (sra SearchResultsAnswer) AsBasicThing() (BasicThing, bool) {
  1477  	return nil, false
  1478  }
  1479  
  1480  // AsCreativeWork is the BasicResponseBase implementation for SearchResultsAnswer.
  1481  func (sra SearchResultsAnswer) AsCreativeWork() (*CreativeWork, bool) {
  1482  	return nil, false
  1483  }
  1484  
  1485  // AsBasicCreativeWork is the BasicResponseBase implementation for SearchResultsAnswer.
  1486  func (sra SearchResultsAnswer) AsBasicCreativeWork() (BasicCreativeWork, bool) {
  1487  	return nil, false
  1488  }
  1489  
  1490  // AsResponseBase is the BasicResponseBase implementation for SearchResultsAnswer.
  1491  func (sra SearchResultsAnswer) AsResponseBase() (*ResponseBase, bool) {
  1492  	return nil, false
  1493  }
  1494  
  1495  // AsBasicResponseBase is the BasicResponseBase implementation for SearchResultsAnswer.
  1496  func (sra SearchResultsAnswer) AsBasicResponseBase() (BasicResponseBase, bool) {
  1497  	return &sra, true
  1498  }
  1499  
  1500  // BasicThing ...
  1501  type BasicThing interface {
  1502  	AsWebPage() (*WebPage, bool)
  1503  	AsCreativeWork() (*CreativeWork, bool)
  1504  	AsBasicCreativeWork() (BasicCreativeWork, bool)
  1505  	AsThing() (*Thing, bool)
  1506  }
  1507  
  1508  // Thing ...
  1509  type Thing struct {
  1510  	// Name - READ-ONLY; The name of the thing represented by this object.
  1511  	Name *string `json:"name,omitempty"`
  1512  	// URL - READ-ONLY; The URL to get more information about the thing represented by this object.
  1513  	URL *string `json:"url,omitempty"`
  1514  	// Description - READ-ONLY; A short description of the item.
  1515  	Description *string `json:"description,omitempty"`
  1516  	// BingID - READ-ONLY; An ID that uniquely identifies this item.
  1517  	BingID *string `json:"bingId,omitempty"`
  1518  	// WebSearchURL - READ-ONLY; The URL To Bing's search result for this item.
  1519  	WebSearchURL *string `json:"webSearchUrl,omitempty"`
  1520  	// ID - READ-ONLY; A String identifier.
  1521  	ID *string `json:"id,omitempty"`
  1522  	// Type - Possible values include: 'TypeResponseBase', 'TypeWebPage', 'TypeWebWebAnswer', 'TypeSearchResponse', 'TypeResponse', 'TypeSearchResultsAnswer', 'TypeIdentifiable', 'TypeErrorResponse', 'TypeAnswer', 'TypeThing', 'TypeCreativeWork'
  1523  	Type Type `json:"_type,omitempty"`
  1524  }
  1525  
  1526  func unmarshalBasicThing(body []byte) (BasicThing, error) {
  1527  	var m map[string]interface{}
  1528  	err := json.Unmarshal(body, &m)
  1529  	if err != nil {
  1530  		return nil, err
  1531  	}
  1532  
  1533  	switch m["_type"] {
  1534  	case string(TypeWebPage):
  1535  		var wp WebPage
  1536  		err := json.Unmarshal(body, &wp)
  1537  		return wp, err
  1538  	case string(TypeCreativeWork):
  1539  		var cw CreativeWork
  1540  		err := json.Unmarshal(body, &cw)
  1541  		return cw, err
  1542  	default:
  1543  		var t Thing
  1544  		err := json.Unmarshal(body, &t)
  1545  		return t, err
  1546  	}
  1547  }
  1548  func unmarshalBasicThingArray(body []byte) ([]BasicThing, error) {
  1549  	var rawMessages []*json.RawMessage
  1550  	err := json.Unmarshal(body, &rawMessages)
  1551  	if err != nil {
  1552  		return nil, err
  1553  	}
  1554  
  1555  	tArray := make([]BasicThing, len(rawMessages))
  1556  
  1557  	for index, rawMessage := range rawMessages {
  1558  		t, err := unmarshalBasicThing(*rawMessage)
  1559  		if err != nil {
  1560  			return nil, err
  1561  		}
  1562  		tArray[index] = t
  1563  	}
  1564  	return tArray, nil
  1565  }
  1566  
  1567  // MarshalJSON is the custom marshaler for Thing.
  1568  func (t Thing) MarshalJSON() ([]byte, error) {
  1569  	t.Type = TypeThing
  1570  	objectMap := make(map[string]interface{})
  1571  	if t.Type != "" {
  1572  		objectMap["_type"] = t.Type
  1573  	}
  1574  	return json.Marshal(objectMap)
  1575  }
  1576  
  1577  // AsWebPage is the BasicResponseBase implementation for Thing.
  1578  func (t Thing) AsWebPage() (*WebPage, bool) {
  1579  	return nil, false
  1580  }
  1581  
  1582  // AsWebWebAnswer is the BasicResponseBase implementation for Thing.
  1583  func (t Thing) AsWebWebAnswer() (*WebWebAnswer, bool) {
  1584  	return nil, false
  1585  }
  1586  
  1587  // AsSearchResponse is the BasicResponseBase implementation for Thing.
  1588  func (t Thing) AsSearchResponse() (*SearchResponse, bool) {
  1589  	return nil, false
  1590  }
  1591  
  1592  // AsResponse is the BasicResponseBase implementation for Thing.
  1593  func (t Thing) AsResponse() (*Response, bool) {
  1594  	return nil, false
  1595  }
  1596  
  1597  // AsBasicResponse is the BasicResponseBase implementation for Thing.
  1598  func (t Thing) AsBasicResponse() (BasicResponse, bool) {
  1599  	return &t, true
  1600  }
  1601  
  1602  // AsSearchResultsAnswer is the BasicResponseBase implementation for Thing.
  1603  func (t Thing) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) {
  1604  	return nil, false
  1605  }
  1606  
  1607  // AsBasicSearchResultsAnswer is the BasicResponseBase implementation for Thing.
  1608  func (t Thing) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) {
  1609  	return nil, false
  1610  }
  1611  
  1612  // AsIdentifiable is the BasicResponseBase implementation for Thing.
  1613  func (t Thing) AsIdentifiable() (*Identifiable, bool) {
  1614  	return nil, false
  1615  }
  1616  
  1617  // AsBasicIdentifiable is the BasicResponseBase implementation for Thing.
  1618  func (t Thing) AsBasicIdentifiable() (BasicIdentifiable, bool) {
  1619  	return &t, true
  1620  }
  1621  
  1622  // AsErrorResponse is the BasicResponseBase implementation for Thing.
  1623  func (t Thing) AsErrorResponse() (*ErrorResponse, bool) {
  1624  	return nil, false
  1625  }
  1626  
  1627  // AsAnswer is the BasicResponseBase implementation for Thing.
  1628  func (t Thing) AsAnswer() (*Answer, bool) {
  1629  	return nil, false
  1630  }
  1631  
  1632  // AsBasicAnswer is the BasicResponseBase implementation for Thing.
  1633  func (t Thing) AsBasicAnswer() (BasicAnswer, bool) {
  1634  	return nil, false
  1635  }
  1636  
  1637  // AsThing is the BasicResponseBase implementation for Thing.
  1638  func (t Thing) AsThing() (*Thing, bool) {
  1639  	return &t, true
  1640  }
  1641  
  1642  // AsBasicThing is the BasicResponseBase implementation for Thing.
  1643  func (t Thing) AsBasicThing() (BasicThing, bool) {
  1644  	return &t, true
  1645  }
  1646  
  1647  // AsCreativeWork is the BasicResponseBase implementation for Thing.
  1648  func (t Thing) AsCreativeWork() (*CreativeWork, bool) {
  1649  	return nil, false
  1650  }
  1651  
  1652  // AsBasicCreativeWork is the BasicResponseBase implementation for Thing.
  1653  func (t Thing) AsBasicCreativeWork() (BasicCreativeWork, bool) {
  1654  	return nil, false
  1655  }
  1656  
  1657  // AsResponseBase is the BasicResponseBase implementation for Thing.
  1658  func (t Thing) AsResponseBase() (*ResponseBase, bool) {
  1659  	return nil, false
  1660  }
  1661  
  1662  // AsBasicResponseBase is the BasicResponseBase implementation for Thing.
  1663  func (t Thing) AsBasicResponseBase() (BasicResponseBase, bool) {
  1664  	return &t, true
  1665  }
  1666  
  1667  // WebMetaTag defines a webpage's metadata.
  1668  type WebMetaTag struct {
  1669  	// Name - READ-ONLY; The metadata.
  1670  	Name *string `json:"name,omitempty"`
  1671  	// Content - READ-ONLY; The name of the metadata.
  1672  	Content *string `json:"content,omitempty"`
  1673  }
  1674  
  1675  // MarshalJSON is the custom marshaler for WebMetaTag.
  1676  func (wmt WebMetaTag) MarshalJSON() ([]byte, error) {
  1677  	objectMap := make(map[string]interface{})
  1678  	return json.Marshal(objectMap)
  1679  }
  1680  
  1681  // WebPage defines a webpage that is relevant to the query.
  1682  type WebPage struct {
  1683  	// DisplayURL - READ-ONLY; The display URL of the webpage. The URL is meant for display purposes only and is not well formed.
  1684  	DisplayURL *string `json:"displayUrl,omitempty"`
  1685  	// Snippet - READ-ONLY; A snippet of text from the webpage that describes its contents.
  1686  	Snippet *string `json:"snippet,omitempty"`
  1687  	// DeepLinks - READ-ONLY; A list of links to related content that Bing found in the website that contains this webpage. The Webpage object in this context includes only the name, url, urlPingSuffix, and snippet fields.
  1688  	DeepLinks *[]WebPage `json:"deepLinks,omitempty"`
  1689  	// DateLastCrawled - READ-ONLY; The last time that Bing crawled the webpage. The date is in the form, YYYY-MM-DDTHH:MM:SS. For example, 2015-04-13T05:23:39.
  1690  	DateLastCrawled *string `json:"dateLastCrawled,omitempty"`
  1691  	// SearchTags - READ-ONLY; A list of search tags that the webpage owner specified on the webpage. The API returns only indexed search tags. The name field of the MetaTag object contains the indexed search tag. Search tags begin with search.* (for example, search.assetId). The content field contains the tag's value.
  1692  	SearchTags *[]WebMetaTag `json:"searchTags,omitempty"`
  1693  	// ThumbnailURL - READ-ONLY; The URL to a thumbnail of the item.
  1694  	ThumbnailURL *string `json:"thumbnailUrl,omitempty"`
  1695  	// Provider - READ-ONLY; The source of the creative work.
  1696  	Provider *[]BasicThing `json:"provider,omitempty"`
  1697  	// Text - READ-ONLY
  1698  	Text *string `json:"text,omitempty"`
  1699  	// Name - READ-ONLY; The name of the thing represented by this object.
  1700  	Name *string `json:"name,omitempty"`
  1701  	// URL - READ-ONLY; The URL to get more information about the thing represented by this object.
  1702  	URL *string `json:"url,omitempty"`
  1703  	// Description - READ-ONLY; A short description of the item.
  1704  	Description *string `json:"description,omitempty"`
  1705  	// BingID - READ-ONLY; An ID that uniquely identifies this item.
  1706  	BingID *string `json:"bingId,omitempty"`
  1707  	// WebSearchURL - READ-ONLY; The URL To Bing's search result for this item.
  1708  	WebSearchURL *string `json:"webSearchUrl,omitempty"`
  1709  	// ID - READ-ONLY; A String identifier.
  1710  	ID *string `json:"id,omitempty"`
  1711  	// Type - Possible values include: 'TypeResponseBase', 'TypeWebPage', 'TypeWebWebAnswer', 'TypeSearchResponse', 'TypeResponse', 'TypeSearchResultsAnswer', 'TypeIdentifiable', 'TypeErrorResponse', 'TypeAnswer', 'TypeThing', 'TypeCreativeWork'
  1712  	Type Type `json:"_type,omitempty"`
  1713  }
  1714  
  1715  // MarshalJSON is the custom marshaler for WebPage.
  1716  func (wp WebPage) MarshalJSON() ([]byte, error) {
  1717  	wp.Type = TypeWebPage
  1718  	objectMap := make(map[string]interface{})
  1719  	if wp.Type != "" {
  1720  		objectMap["_type"] = wp.Type
  1721  	}
  1722  	return json.Marshal(objectMap)
  1723  }
  1724  
  1725  // AsWebPage is the BasicResponseBase implementation for WebPage.
  1726  func (wp WebPage) AsWebPage() (*WebPage, bool) {
  1727  	return &wp, true
  1728  }
  1729  
  1730  // AsWebWebAnswer is the BasicResponseBase implementation for WebPage.
  1731  func (wp WebPage) AsWebWebAnswer() (*WebWebAnswer, bool) {
  1732  	return nil, false
  1733  }
  1734  
  1735  // AsSearchResponse is the BasicResponseBase implementation for WebPage.
  1736  func (wp WebPage) AsSearchResponse() (*SearchResponse, bool) {
  1737  	return nil, false
  1738  }
  1739  
  1740  // AsResponse is the BasicResponseBase implementation for WebPage.
  1741  func (wp WebPage) AsResponse() (*Response, bool) {
  1742  	return nil, false
  1743  }
  1744  
  1745  // AsBasicResponse is the BasicResponseBase implementation for WebPage.
  1746  func (wp WebPage) AsBasicResponse() (BasicResponse, bool) {
  1747  	return &wp, true
  1748  }
  1749  
  1750  // AsSearchResultsAnswer is the BasicResponseBase implementation for WebPage.
  1751  func (wp WebPage) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) {
  1752  	return nil, false
  1753  }
  1754  
  1755  // AsBasicSearchResultsAnswer is the BasicResponseBase implementation for WebPage.
  1756  func (wp WebPage) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) {
  1757  	return nil, false
  1758  }
  1759  
  1760  // AsIdentifiable is the BasicResponseBase implementation for WebPage.
  1761  func (wp WebPage) AsIdentifiable() (*Identifiable, bool) {
  1762  	return nil, false
  1763  }
  1764  
  1765  // AsBasicIdentifiable is the BasicResponseBase implementation for WebPage.
  1766  func (wp WebPage) AsBasicIdentifiable() (BasicIdentifiable, bool) {
  1767  	return &wp, true
  1768  }
  1769  
  1770  // AsErrorResponse is the BasicResponseBase implementation for WebPage.
  1771  func (wp WebPage) AsErrorResponse() (*ErrorResponse, bool) {
  1772  	return nil, false
  1773  }
  1774  
  1775  // AsAnswer is the BasicResponseBase implementation for WebPage.
  1776  func (wp WebPage) AsAnswer() (*Answer, bool) {
  1777  	return nil, false
  1778  }
  1779  
  1780  // AsBasicAnswer is the BasicResponseBase implementation for WebPage.
  1781  func (wp WebPage) AsBasicAnswer() (BasicAnswer, bool) {
  1782  	return nil, false
  1783  }
  1784  
  1785  // AsThing is the BasicResponseBase implementation for WebPage.
  1786  func (wp WebPage) AsThing() (*Thing, bool) {
  1787  	return nil, false
  1788  }
  1789  
  1790  // AsBasicThing is the BasicResponseBase implementation for WebPage.
  1791  func (wp WebPage) AsBasicThing() (BasicThing, bool) {
  1792  	return &wp, true
  1793  }
  1794  
  1795  // AsCreativeWork is the BasicResponseBase implementation for WebPage.
  1796  func (wp WebPage) AsCreativeWork() (*CreativeWork, bool) {
  1797  	return nil, false
  1798  }
  1799  
  1800  // AsBasicCreativeWork is the BasicResponseBase implementation for WebPage.
  1801  func (wp WebPage) AsBasicCreativeWork() (BasicCreativeWork, bool) {
  1802  	return &wp, true
  1803  }
  1804  
  1805  // AsResponseBase is the BasicResponseBase implementation for WebPage.
  1806  func (wp WebPage) AsResponseBase() (*ResponseBase, bool) {
  1807  	return nil, false
  1808  }
  1809  
  1810  // AsBasicResponseBase is the BasicResponseBase implementation for WebPage.
  1811  func (wp WebPage) AsBasicResponseBase() (BasicResponseBase, bool) {
  1812  	return &wp, true
  1813  }
  1814  
  1815  // UnmarshalJSON is the custom unmarshaler for WebPage struct.
  1816  func (wp *WebPage) UnmarshalJSON(body []byte) error {
  1817  	var m map[string]*json.RawMessage
  1818  	err := json.Unmarshal(body, &m)
  1819  	if err != nil {
  1820  		return err
  1821  	}
  1822  	for k, v := range m {
  1823  		switch k {
  1824  		case "displayUrl":
  1825  			if v != nil {
  1826  				var displayURL string
  1827  				err = json.Unmarshal(*v, &displayURL)
  1828  				if err != nil {
  1829  					return err
  1830  				}
  1831  				wp.DisplayURL = &displayURL
  1832  			}
  1833  		case "snippet":
  1834  			if v != nil {
  1835  				var snippet string
  1836  				err = json.Unmarshal(*v, &snippet)
  1837  				if err != nil {
  1838  					return err
  1839  				}
  1840  				wp.Snippet = &snippet
  1841  			}
  1842  		case "deepLinks":
  1843  			if v != nil {
  1844  				var deepLinks []WebPage
  1845  				err = json.Unmarshal(*v, &deepLinks)
  1846  				if err != nil {
  1847  					return err
  1848  				}
  1849  				wp.DeepLinks = &deepLinks
  1850  			}
  1851  		case "dateLastCrawled":
  1852  			if v != nil {
  1853  				var dateLastCrawled string
  1854  				err = json.Unmarshal(*v, &dateLastCrawled)
  1855  				if err != nil {
  1856  					return err
  1857  				}
  1858  				wp.DateLastCrawled = &dateLastCrawled
  1859  			}
  1860  		case "searchTags":
  1861  			if v != nil {
  1862  				var searchTags []WebMetaTag
  1863  				err = json.Unmarshal(*v, &searchTags)
  1864  				if err != nil {
  1865  					return err
  1866  				}
  1867  				wp.SearchTags = &searchTags
  1868  			}
  1869  		case "thumbnailUrl":
  1870  			if v != nil {
  1871  				var thumbnailURL string
  1872  				err = json.Unmarshal(*v, &thumbnailURL)
  1873  				if err != nil {
  1874  					return err
  1875  				}
  1876  				wp.ThumbnailURL = &thumbnailURL
  1877  			}
  1878  		case "provider":
  1879  			if v != nil {
  1880  				provider, err := unmarshalBasicThingArray(*v)
  1881  				if err != nil {
  1882  					return err
  1883  				}
  1884  				wp.Provider = &provider
  1885  			}
  1886  		case "text":
  1887  			if v != nil {
  1888  				var textVar string
  1889  				err = json.Unmarshal(*v, &textVar)
  1890  				if err != nil {
  1891  					return err
  1892  				}
  1893  				wp.Text = &textVar
  1894  			}
  1895  		case "name":
  1896  			if v != nil {
  1897  				var name string
  1898  				err = json.Unmarshal(*v, &name)
  1899  				if err != nil {
  1900  					return err
  1901  				}
  1902  				wp.Name = &name
  1903  			}
  1904  		case "url":
  1905  			if v != nil {
  1906  				var URL string
  1907  				err = json.Unmarshal(*v, &URL)
  1908  				if err != nil {
  1909  					return err
  1910  				}
  1911  				wp.URL = &URL
  1912  			}
  1913  		case "description":
  1914  			if v != nil {
  1915  				var description string
  1916  				err = json.Unmarshal(*v, &description)
  1917  				if err != nil {
  1918  					return err
  1919  				}
  1920  				wp.Description = &description
  1921  			}
  1922  		case "bingId":
  1923  			if v != nil {
  1924  				var bingID string
  1925  				err = json.Unmarshal(*v, &bingID)
  1926  				if err != nil {
  1927  					return err
  1928  				}
  1929  				wp.BingID = &bingID
  1930  			}
  1931  		case "webSearchUrl":
  1932  			if v != nil {
  1933  				var webSearchURL string
  1934  				err = json.Unmarshal(*v, &webSearchURL)
  1935  				if err != nil {
  1936  					return err
  1937  				}
  1938  				wp.WebSearchURL = &webSearchURL
  1939  			}
  1940  		case "id":
  1941  			if v != nil {
  1942  				var ID string
  1943  				err = json.Unmarshal(*v, &ID)
  1944  				if err != nil {
  1945  					return err
  1946  				}
  1947  				wp.ID = &ID
  1948  			}
  1949  		case "_type":
  1950  			if v != nil {
  1951  				var typeVar Type
  1952  				err = json.Unmarshal(*v, &typeVar)
  1953  				if err != nil {
  1954  					return err
  1955  				}
  1956  				wp.Type = typeVar
  1957  			}
  1958  		}
  1959  	}
  1960  
  1961  	return nil
  1962  }
  1963  
  1964  // WebWebAnswer defines a list of relevant webpage links.
  1965  type WebWebAnswer struct {
  1966  	// Value - A list of webpages that are relevant to the query.
  1967  	Value *[]WebPage `json:"value,omitempty"`
  1968  	// SomeResultsRemoved - READ-ONLY; A Boolean value that indicates whether the response excluded some results from the answer. If Bing excluded some results, the value is true.
  1969  	SomeResultsRemoved *bool `json:"someResultsRemoved,omitempty"`
  1970  	// QueryContext - READ-ONLY
  1971  	QueryContext *QueryContext `json:"queryContext,omitempty"`
  1972  	// 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.
  1973  	TotalEstimatedMatches *int64 `json:"totalEstimatedMatches,omitempty"`
  1974  	// IsFamilyFriendly - READ-ONLY
  1975  	IsFamilyFriendly *bool `json:"isFamilyFriendly,omitempty"`
  1976  	// FollowUpQueries - READ-ONLY
  1977  	FollowUpQueries *[]Query `json:"followUpQueries,omitempty"`
  1978  	// WebSearchURL - READ-ONLY; The URL To Bing's search result for this item.
  1979  	WebSearchURL *string `json:"webSearchUrl,omitempty"`
  1980  	// ID - READ-ONLY; A String identifier.
  1981  	ID *string `json:"id,omitempty"`
  1982  	// Type - Possible values include: 'TypeResponseBase', 'TypeWebPage', 'TypeWebWebAnswer', 'TypeSearchResponse', 'TypeResponse', 'TypeSearchResultsAnswer', 'TypeIdentifiable', 'TypeErrorResponse', 'TypeAnswer', 'TypeThing', 'TypeCreativeWork'
  1983  	Type Type `json:"_type,omitempty"`
  1984  }
  1985  
  1986  // MarshalJSON is the custom marshaler for WebWebAnswer.
  1987  func (wwa WebWebAnswer) MarshalJSON() ([]byte, error) {
  1988  	wwa.Type = TypeWebWebAnswer
  1989  	objectMap := make(map[string]interface{})
  1990  	if wwa.Value != nil {
  1991  		objectMap["value"] = wwa.Value
  1992  	}
  1993  	if wwa.Type != "" {
  1994  		objectMap["_type"] = wwa.Type
  1995  	}
  1996  	return json.Marshal(objectMap)
  1997  }
  1998  
  1999  // AsWebPage is the BasicResponseBase implementation for WebWebAnswer.
  2000  func (wwa WebWebAnswer) AsWebPage() (*WebPage, bool) {
  2001  	return nil, false
  2002  }
  2003  
  2004  // AsWebWebAnswer is the BasicResponseBase implementation for WebWebAnswer.
  2005  func (wwa WebWebAnswer) AsWebWebAnswer() (*WebWebAnswer, bool) {
  2006  	return &wwa, true
  2007  }
  2008  
  2009  // AsSearchResponse is the BasicResponseBase implementation for WebWebAnswer.
  2010  func (wwa WebWebAnswer) AsSearchResponse() (*SearchResponse, bool) {
  2011  	return nil, false
  2012  }
  2013  
  2014  // AsResponse is the BasicResponseBase implementation for WebWebAnswer.
  2015  func (wwa WebWebAnswer) AsResponse() (*Response, bool) {
  2016  	return nil, false
  2017  }
  2018  
  2019  // AsBasicResponse is the BasicResponseBase implementation for WebWebAnswer.
  2020  func (wwa WebWebAnswer) AsBasicResponse() (BasicResponse, bool) {
  2021  	return &wwa, true
  2022  }
  2023  
  2024  // AsSearchResultsAnswer is the BasicResponseBase implementation for WebWebAnswer.
  2025  func (wwa WebWebAnswer) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) {
  2026  	return nil, false
  2027  }
  2028  
  2029  // AsBasicSearchResultsAnswer is the BasicResponseBase implementation for WebWebAnswer.
  2030  func (wwa WebWebAnswer) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) {
  2031  	return &wwa, true
  2032  }
  2033  
  2034  // AsIdentifiable is the BasicResponseBase implementation for WebWebAnswer.
  2035  func (wwa WebWebAnswer) AsIdentifiable() (*Identifiable, bool) {
  2036  	return nil, false
  2037  }
  2038  
  2039  // AsBasicIdentifiable is the BasicResponseBase implementation for WebWebAnswer.
  2040  func (wwa WebWebAnswer) AsBasicIdentifiable() (BasicIdentifiable, bool) {
  2041  	return &wwa, true
  2042  }
  2043  
  2044  // AsErrorResponse is the BasicResponseBase implementation for WebWebAnswer.
  2045  func (wwa WebWebAnswer) AsErrorResponse() (*ErrorResponse, bool) {
  2046  	return nil, false
  2047  }
  2048  
  2049  // AsAnswer is the BasicResponseBase implementation for WebWebAnswer.
  2050  func (wwa WebWebAnswer) AsAnswer() (*Answer, bool) {
  2051  	return nil, false
  2052  }
  2053  
  2054  // AsBasicAnswer is the BasicResponseBase implementation for WebWebAnswer.
  2055  func (wwa WebWebAnswer) AsBasicAnswer() (BasicAnswer, bool) {
  2056  	return &wwa, true
  2057  }
  2058  
  2059  // AsThing is the BasicResponseBase implementation for WebWebAnswer.
  2060  func (wwa WebWebAnswer) AsThing() (*Thing, bool) {
  2061  	return nil, false
  2062  }
  2063  
  2064  // AsBasicThing is the BasicResponseBase implementation for WebWebAnswer.
  2065  func (wwa WebWebAnswer) AsBasicThing() (BasicThing, bool) {
  2066  	return nil, false
  2067  }
  2068  
  2069  // AsCreativeWork is the BasicResponseBase implementation for WebWebAnswer.
  2070  func (wwa WebWebAnswer) AsCreativeWork() (*CreativeWork, bool) {
  2071  	return nil, false
  2072  }
  2073  
  2074  // AsBasicCreativeWork is the BasicResponseBase implementation for WebWebAnswer.
  2075  func (wwa WebWebAnswer) AsBasicCreativeWork() (BasicCreativeWork, bool) {
  2076  	return nil, false
  2077  }
  2078  
  2079  // AsResponseBase is the BasicResponseBase implementation for WebWebAnswer.
  2080  func (wwa WebWebAnswer) AsResponseBase() (*ResponseBase, bool) {
  2081  	return nil, false
  2082  }
  2083  
  2084  // AsBasicResponseBase is the BasicResponseBase implementation for WebWebAnswer.
  2085  func (wwa WebWebAnswer) AsBasicResponseBase() (BasicResponseBase, bool) {
  2086  	return &wwa, true
  2087  }
  2088  

View as plain text