...

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

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

     1  package spellcheck
     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/spellcheck"
    16  
    17  // BasicAnswer ...
    18  type BasicAnswer interface {
    19  	AsSpellCheck() (*SpellCheck, bool)
    20  	AsAnswer() (*Answer, bool)
    21  }
    22  
    23  // Answer ...
    24  type Answer struct {
    25  	// ID - READ-ONLY; A String identifier.
    26  	ID *string `json:"id,omitempty"`
    27  	// Type - Possible values include: 'TypeResponseBase', 'TypeSpellCheck', 'TypeAnswer', 'TypeResponse', 'TypeIdentifiable', 'TypeErrorResponse'
    28  	Type Type `json:"_type,omitempty"`
    29  }
    30  
    31  func unmarshalBasicAnswer(body []byte) (BasicAnswer, error) {
    32  	var m map[string]interface{}
    33  	err := json.Unmarshal(body, &m)
    34  	if err != nil {
    35  		return nil, err
    36  	}
    37  
    38  	switch m["_type"] {
    39  	case string(TypeSpellCheck):
    40  		var sc SpellCheck
    41  		err := json.Unmarshal(body, &sc)
    42  		return sc, err
    43  	default:
    44  		var a Answer
    45  		err := json.Unmarshal(body, &a)
    46  		return a, err
    47  	}
    48  }
    49  func unmarshalBasicAnswerArray(body []byte) ([]BasicAnswer, error) {
    50  	var rawMessages []*json.RawMessage
    51  	err := json.Unmarshal(body, &rawMessages)
    52  	if err != nil {
    53  		return nil, err
    54  	}
    55  
    56  	aArray := make([]BasicAnswer, len(rawMessages))
    57  
    58  	for index, rawMessage := range rawMessages {
    59  		a, err := unmarshalBasicAnswer(*rawMessage)
    60  		if err != nil {
    61  			return nil, err
    62  		}
    63  		aArray[index] = a
    64  	}
    65  	return aArray, nil
    66  }
    67  
    68  // MarshalJSON is the custom marshaler for Answer.
    69  func (a Answer) MarshalJSON() ([]byte, error) {
    70  	a.Type = TypeAnswer
    71  	objectMap := make(map[string]interface{})
    72  	if a.Type != "" {
    73  		objectMap["_type"] = a.Type
    74  	}
    75  	return json.Marshal(objectMap)
    76  }
    77  
    78  // AsSpellCheck is the BasicResponseBase implementation for Answer.
    79  func (a Answer) AsSpellCheck() (*SpellCheck, bool) {
    80  	return nil, false
    81  }
    82  
    83  // AsAnswer is the BasicResponseBase implementation for Answer.
    84  func (a Answer) AsAnswer() (*Answer, bool) {
    85  	return &a, true
    86  }
    87  
    88  // AsBasicAnswer is the BasicResponseBase implementation for Answer.
    89  func (a Answer) AsBasicAnswer() (BasicAnswer, bool) {
    90  	return &a, true
    91  }
    92  
    93  // AsResponse is the BasicResponseBase implementation for Answer.
    94  func (a Answer) AsResponse() (*Response, bool) {
    95  	return nil, false
    96  }
    97  
    98  // AsBasicResponse is the BasicResponseBase implementation for Answer.
    99  func (a Answer) AsBasicResponse() (BasicResponse, bool) {
   100  	return &a, true
   101  }
   102  
   103  // AsIdentifiable is the BasicResponseBase implementation for Answer.
   104  func (a Answer) AsIdentifiable() (*Identifiable, bool) {
   105  	return nil, false
   106  }
   107  
   108  // AsBasicIdentifiable is the BasicResponseBase implementation for Answer.
   109  func (a Answer) AsBasicIdentifiable() (BasicIdentifiable, bool) {
   110  	return &a, true
   111  }
   112  
   113  // AsErrorResponse is the BasicResponseBase implementation for Answer.
   114  func (a Answer) AsErrorResponse() (*ErrorResponse, bool) {
   115  	return nil, false
   116  }
   117  
   118  // AsResponseBase is the BasicResponseBase implementation for Answer.
   119  func (a Answer) AsResponseBase() (*ResponseBase, bool) {
   120  	return nil, false
   121  }
   122  
   123  // AsBasicResponseBase is the BasicResponseBase implementation for Answer.
   124  func (a Answer) AsBasicResponseBase() (BasicResponseBase, bool) {
   125  	return &a, true
   126  }
   127  
   128  // Error defines the error that occurred.
   129  type Error struct {
   130  	// Code - The error code that identifies the category of error. Possible values include: 'None', 'ServerError', 'InvalidRequest', 'RateLimitExceeded', 'InvalidAuthorization', 'InsufficientAuthorization'
   131  	Code ErrorCode `json:"code,omitempty"`
   132  	// 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'
   133  	SubCode ErrorSubCode `json:"subCode,omitempty"`
   134  	// Message - A description of the error.
   135  	Message *string `json:"message,omitempty"`
   136  	// MoreDetails - READ-ONLY; A description that provides additional information about the error.
   137  	MoreDetails *string `json:"moreDetails,omitempty"`
   138  	// Parameter - READ-ONLY; The parameter in the request that caused the error.
   139  	Parameter *string `json:"parameter,omitempty"`
   140  	// Value - READ-ONLY; The parameter's value in the request that was not valid.
   141  	Value *string `json:"value,omitempty"`
   142  }
   143  
   144  // MarshalJSON is the custom marshaler for Error.
   145  func (e Error) MarshalJSON() ([]byte, error) {
   146  	objectMap := make(map[string]interface{})
   147  	if e.Code != "" {
   148  		objectMap["code"] = e.Code
   149  	}
   150  	if e.Message != nil {
   151  		objectMap["message"] = e.Message
   152  	}
   153  	return json.Marshal(objectMap)
   154  }
   155  
   156  // ErrorResponse the top-level response that represents a failed request.
   157  type ErrorResponse struct {
   158  	// Errors - A list of errors that describe the reasons why the request failed.
   159  	Errors *[]Error `json:"errors,omitempty"`
   160  	// ID - READ-ONLY; A String identifier.
   161  	ID *string `json:"id,omitempty"`
   162  	// Type - Possible values include: 'TypeResponseBase', 'TypeSpellCheck', 'TypeAnswer', 'TypeResponse', 'TypeIdentifiable', 'TypeErrorResponse'
   163  	Type Type `json:"_type,omitempty"`
   164  }
   165  
   166  // MarshalJSON is the custom marshaler for ErrorResponse.
   167  func (er ErrorResponse) MarshalJSON() ([]byte, error) {
   168  	er.Type = TypeErrorResponse
   169  	objectMap := make(map[string]interface{})
   170  	if er.Errors != nil {
   171  		objectMap["errors"] = er.Errors
   172  	}
   173  	if er.Type != "" {
   174  		objectMap["_type"] = er.Type
   175  	}
   176  	return json.Marshal(objectMap)
   177  }
   178  
   179  // AsSpellCheck is the BasicResponseBase implementation for ErrorResponse.
   180  func (er ErrorResponse) AsSpellCheck() (*SpellCheck, bool) {
   181  	return nil, false
   182  }
   183  
   184  // AsAnswer is the BasicResponseBase implementation for ErrorResponse.
   185  func (er ErrorResponse) AsAnswer() (*Answer, bool) {
   186  	return nil, false
   187  }
   188  
   189  // AsBasicAnswer is the BasicResponseBase implementation for ErrorResponse.
   190  func (er ErrorResponse) AsBasicAnswer() (BasicAnswer, bool) {
   191  	return nil, false
   192  }
   193  
   194  // AsResponse is the BasicResponseBase implementation for ErrorResponse.
   195  func (er ErrorResponse) AsResponse() (*Response, bool) {
   196  	return nil, false
   197  }
   198  
   199  // AsBasicResponse is the BasicResponseBase implementation for ErrorResponse.
   200  func (er ErrorResponse) AsBasicResponse() (BasicResponse, bool) {
   201  	return &er, true
   202  }
   203  
   204  // AsIdentifiable is the BasicResponseBase implementation for ErrorResponse.
   205  func (er ErrorResponse) AsIdentifiable() (*Identifiable, bool) {
   206  	return nil, false
   207  }
   208  
   209  // AsBasicIdentifiable is the BasicResponseBase implementation for ErrorResponse.
   210  func (er ErrorResponse) AsBasicIdentifiable() (BasicIdentifiable, bool) {
   211  	return &er, true
   212  }
   213  
   214  // AsErrorResponse is the BasicResponseBase implementation for ErrorResponse.
   215  func (er ErrorResponse) AsErrorResponse() (*ErrorResponse, bool) {
   216  	return &er, true
   217  }
   218  
   219  // AsResponseBase is the BasicResponseBase implementation for ErrorResponse.
   220  func (er ErrorResponse) AsResponseBase() (*ResponseBase, bool) {
   221  	return nil, false
   222  }
   223  
   224  // AsBasicResponseBase is the BasicResponseBase implementation for ErrorResponse.
   225  func (er ErrorResponse) AsBasicResponseBase() (BasicResponseBase, bool) {
   226  	return &er, true
   227  }
   228  
   229  // BasicIdentifiable defines the identity of a resource.
   230  type BasicIdentifiable interface {
   231  	AsSpellCheck() (*SpellCheck, bool)
   232  	AsAnswer() (*Answer, bool)
   233  	AsBasicAnswer() (BasicAnswer, bool)
   234  	AsResponse() (*Response, bool)
   235  	AsBasicResponse() (BasicResponse, bool)
   236  	AsErrorResponse() (*ErrorResponse, bool)
   237  	AsIdentifiable() (*Identifiable, bool)
   238  }
   239  
   240  // Identifiable defines the identity of a resource.
   241  type Identifiable struct {
   242  	// ID - READ-ONLY; A String identifier.
   243  	ID *string `json:"id,omitempty"`
   244  	// Type - Possible values include: 'TypeResponseBase', 'TypeSpellCheck', 'TypeAnswer', 'TypeResponse', 'TypeIdentifiable', 'TypeErrorResponse'
   245  	Type Type `json:"_type,omitempty"`
   246  }
   247  
   248  func unmarshalBasicIdentifiable(body []byte) (BasicIdentifiable, error) {
   249  	var m map[string]interface{}
   250  	err := json.Unmarshal(body, &m)
   251  	if err != nil {
   252  		return nil, err
   253  	}
   254  
   255  	switch m["_type"] {
   256  	case string(TypeSpellCheck):
   257  		var sc SpellCheck
   258  		err := json.Unmarshal(body, &sc)
   259  		return sc, err
   260  	case string(TypeAnswer):
   261  		var a Answer
   262  		err := json.Unmarshal(body, &a)
   263  		return a, err
   264  	case string(TypeResponse):
   265  		var r Response
   266  		err := json.Unmarshal(body, &r)
   267  		return r, err
   268  	case string(TypeErrorResponse):
   269  		var er ErrorResponse
   270  		err := json.Unmarshal(body, &er)
   271  		return er, err
   272  	default:
   273  		var i Identifiable
   274  		err := json.Unmarshal(body, &i)
   275  		return i, err
   276  	}
   277  }
   278  func unmarshalBasicIdentifiableArray(body []byte) ([]BasicIdentifiable, error) {
   279  	var rawMessages []*json.RawMessage
   280  	err := json.Unmarshal(body, &rawMessages)
   281  	if err != nil {
   282  		return nil, err
   283  	}
   284  
   285  	iArray := make([]BasicIdentifiable, len(rawMessages))
   286  
   287  	for index, rawMessage := range rawMessages {
   288  		i, err := unmarshalBasicIdentifiable(*rawMessage)
   289  		if err != nil {
   290  			return nil, err
   291  		}
   292  		iArray[index] = i
   293  	}
   294  	return iArray, nil
   295  }
   296  
   297  // MarshalJSON is the custom marshaler for Identifiable.
   298  func (i Identifiable) MarshalJSON() ([]byte, error) {
   299  	i.Type = TypeIdentifiable
   300  	objectMap := make(map[string]interface{})
   301  	if i.Type != "" {
   302  		objectMap["_type"] = i.Type
   303  	}
   304  	return json.Marshal(objectMap)
   305  }
   306  
   307  // AsSpellCheck is the BasicResponseBase implementation for Identifiable.
   308  func (i Identifiable) AsSpellCheck() (*SpellCheck, bool) {
   309  	return nil, false
   310  }
   311  
   312  // AsAnswer is the BasicResponseBase implementation for Identifiable.
   313  func (i Identifiable) AsAnswer() (*Answer, bool) {
   314  	return nil, false
   315  }
   316  
   317  // AsBasicAnswer is the BasicResponseBase implementation for Identifiable.
   318  func (i Identifiable) AsBasicAnswer() (BasicAnswer, bool) {
   319  	return nil, false
   320  }
   321  
   322  // AsResponse is the BasicResponseBase implementation for Identifiable.
   323  func (i Identifiable) AsResponse() (*Response, bool) {
   324  	return nil, false
   325  }
   326  
   327  // AsBasicResponse is the BasicResponseBase implementation for Identifiable.
   328  func (i Identifiable) AsBasicResponse() (BasicResponse, bool) {
   329  	return nil, false
   330  }
   331  
   332  // AsIdentifiable is the BasicResponseBase implementation for Identifiable.
   333  func (i Identifiable) AsIdentifiable() (*Identifiable, bool) {
   334  	return &i, true
   335  }
   336  
   337  // AsBasicIdentifiable is the BasicResponseBase implementation for Identifiable.
   338  func (i Identifiable) AsBasicIdentifiable() (BasicIdentifiable, bool) {
   339  	return &i, true
   340  }
   341  
   342  // AsErrorResponse is the BasicResponseBase implementation for Identifiable.
   343  func (i Identifiable) AsErrorResponse() (*ErrorResponse, bool) {
   344  	return nil, false
   345  }
   346  
   347  // AsResponseBase is the BasicResponseBase implementation for Identifiable.
   348  func (i Identifiable) AsResponseBase() (*ResponseBase, bool) {
   349  	return nil, false
   350  }
   351  
   352  // AsBasicResponseBase is the BasicResponseBase implementation for Identifiable.
   353  func (i Identifiable) AsBasicResponseBase() (BasicResponseBase, bool) {
   354  	return &i, true
   355  }
   356  
   357  // BasicResponse defines a response. All schemas that could be returned at the root of a response should inherit from
   358  // this
   359  type BasicResponse interface {
   360  	AsSpellCheck() (*SpellCheck, bool)
   361  	AsAnswer() (*Answer, bool)
   362  	AsBasicAnswer() (BasicAnswer, bool)
   363  	AsErrorResponse() (*ErrorResponse, bool)
   364  	AsResponse() (*Response, bool)
   365  }
   366  
   367  // Response defines a response. All schemas that could be returned at the root of a response should inherit
   368  // from this
   369  type Response struct {
   370  	// ID - READ-ONLY; A String identifier.
   371  	ID *string `json:"id,omitempty"`
   372  	// Type - Possible values include: 'TypeResponseBase', 'TypeSpellCheck', 'TypeAnswer', 'TypeResponse', 'TypeIdentifiable', 'TypeErrorResponse'
   373  	Type Type `json:"_type,omitempty"`
   374  }
   375  
   376  func unmarshalBasicResponse(body []byte) (BasicResponse, error) {
   377  	var m map[string]interface{}
   378  	err := json.Unmarshal(body, &m)
   379  	if err != nil {
   380  		return nil, err
   381  	}
   382  
   383  	switch m["_type"] {
   384  	case string(TypeSpellCheck):
   385  		var sc SpellCheck
   386  		err := json.Unmarshal(body, &sc)
   387  		return sc, err
   388  	case string(TypeAnswer):
   389  		var a Answer
   390  		err := json.Unmarshal(body, &a)
   391  		return a, err
   392  	case string(TypeErrorResponse):
   393  		var er ErrorResponse
   394  		err := json.Unmarshal(body, &er)
   395  		return er, err
   396  	default:
   397  		var r Response
   398  		err := json.Unmarshal(body, &r)
   399  		return r, err
   400  	}
   401  }
   402  func unmarshalBasicResponseArray(body []byte) ([]BasicResponse, error) {
   403  	var rawMessages []*json.RawMessage
   404  	err := json.Unmarshal(body, &rawMessages)
   405  	if err != nil {
   406  		return nil, err
   407  	}
   408  
   409  	rArray := make([]BasicResponse, len(rawMessages))
   410  
   411  	for index, rawMessage := range rawMessages {
   412  		r, err := unmarshalBasicResponse(*rawMessage)
   413  		if err != nil {
   414  			return nil, err
   415  		}
   416  		rArray[index] = r
   417  	}
   418  	return rArray, nil
   419  }
   420  
   421  // MarshalJSON is the custom marshaler for Response.
   422  func (r Response) MarshalJSON() ([]byte, error) {
   423  	r.Type = TypeResponse
   424  	objectMap := make(map[string]interface{})
   425  	if r.Type != "" {
   426  		objectMap["_type"] = r.Type
   427  	}
   428  	return json.Marshal(objectMap)
   429  }
   430  
   431  // AsSpellCheck is the BasicResponseBase implementation for Response.
   432  func (r Response) AsSpellCheck() (*SpellCheck, bool) {
   433  	return nil, false
   434  }
   435  
   436  // AsAnswer is the BasicResponseBase implementation for Response.
   437  func (r Response) AsAnswer() (*Answer, bool) {
   438  	return nil, false
   439  }
   440  
   441  // AsBasicAnswer is the BasicResponseBase implementation for Response.
   442  func (r Response) AsBasicAnswer() (BasicAnswer, bool) {
   443  	return nil, false
   444  }
   445  
   446  // AsResponse is the BasicResponseBase implementation for Response.
   447  func (r Response) AsResponse() (*Response, bool) {
   448  	return &r, true
   449  }
   450  
   451  // AsBasicResponse is the BasicResponseBase implementation for Response.
   452  func (r Response) AsBasicResponse() (BasicResponse, bool) {
   453  	return &r, true
   454  }
   455  
   456  // AsIdentifiable is the BasicResponseBase implementation for Response.
   457  func (r Response) AsIdentifiable() (*Identifiable, bool) {
   458  	return nil, false
   459  }
   460  
   461  // AsBasicIdentifiable is the BasicResponseBase implementation for Response.
   462  func (r Response) AsBasicIdentifiable() (BasicIdentifiable, bool) {
   463  	return &r, true
   464  }
   465  
   466  // AsErrorResponse is the BasicResponseBase implementation for Response.
   467  func (r Response) AsErrorResponse() (*ErrorResponse, bool) {
   468  	return nil, false
   469  }
   470  
   471  // AsResponseBase is the BasicResponseBase implementation for Response.
   472  func (r Response) AsResponseBase() (*ResponseBase, bool) {
   473  	return nil, false
   474  }
   475  
   476  // AsBasicResponseBase is the BasicResponseBase implementation for Response.
   477  func (r Response) AsBasicResponseBase() (BasicResponseBase, bool) {
   478  	return &r, true
   479  }
   480  
   481  // BasicResponseBase ...
   482  type BasicResponseBase interface {
   483  	AsSpellCheck() (*SpellCheck, bool)
   484  	AsAnswer() (*Answer, bool)
   485  	AsBasicAnswer() (BasicAnswer, bool)
   486  	AsResponse() (*Response, bool)
   487  	AsBasicResponse() (BasicResponse, bool)
   488  	AsIdentifiable() (*Identifiable, bool)
   489  	AsBasicIdentifiable() (BasicIdentifiable, bool)
   490  	AsErrorResponse() (*ErrorResponse, bool)
   491  	AsResponseBase() (*ResponseBase, bool)
   492  }
   493  
   494  // ResponseBase ...
   495  type ResponseBase struct {
   496  	// Type - Possible values include: 'TypeResponseBase', 'TypeSpellCheck', 'TypeAnswer', 'TypeResponse', 'TypeIdentifiable', 'TypeErrorResponse'
   497  	Type Type `json:"_type,omitempty"`
   498  }
   499  
   500  func unmarshalBasicResponseBase(body []byte) (BasicResponseBase, error) {
   501  	var m map[string]interface{}
   502  	err := json.Unmarshal(body, &m)
   503  	if err != nil {
   504  		return nil, err
   505  	}
   506  
   507  	switch m["_type"] {
   508  	case string(TypeSpellCheck):
   509  		var sc SpellCheck
   510  		err := json.Unmarshal(body, &sc)
   511  		return sc, err
   512  	case string(TypeAnswer):
   513  		var a Answer
   514  		err := json.Unmarshal(body, &a)
   515  		return a, err
   516  	case string(TypeResponse):
   517  		var r Response
   518  		err := json.Unmarshal(body, &r)
   519  		return r, err
   520  	case string(TypeIdentifiable):
   521  		var i Identifiable
   522  		err := json.Unmarshal(body, &i)
   523  		return i, err
   524  	case string(TypeErrorResponse):
   525  		var er ErrorResponse
   526  		err := json.Unmarshal(body, &er)
   527  		return er, err
   528  	default:
   529  		var rb ResponseBase
   530  		err := json.Unmarshal(body, &rb)
   531  		return rb, err
   532  	}
   533  }
   534  func unmarshalBasicResponseBaseArray(body []byte) ([]BasicResponseBase, error) {
   535  	var rawMessages []*json.RawMessage
   536  	err := json.Unmarshal(body, &rawMessages)
   537  	if err != nil {
   538  		return nil, err
   539  	}
   540  
   541  	rbArray := make([]BasicResponseBase, len(rawMessages))
   542  
   543  	for index, rawMessage := range rawMessages {
   544  		rb, err := unmarshalBasicResponseBase(*rawMessage)
   545  		if err != nil {
   546  			return nil, err
   547  		}
   548  		rbArray[index] = rb
   549  	}
   550  	return rbArray, nil
   551  }
   552  
   553  // MarshalJSON is the custom marshaler for ResponseBase.
   554  func (rb ResponseBase) MarshalJSON() ([]byte, error) {
   555  	rb.Type = TypeResponseBase
   556  	objectMap := make(map[string]interface{})
   557  	if rb.Type != "" {
   558  		objectMap["_type"] = rb.Type
   559  	}
   560  	return json.Marshal(objectMap)
   561  }
   562  
   563  // AsSpellCheck is the BasicResponseBase implementation for ResponseBase.
   564  func (rb ResponseBase) AsSpellCheck() (*SpellCheck, bool) {
   565  	return nil, false
   566  }
   567  
   568  // AsAnswer is the BasicResponseBase implementation for ResponseBase.
   569  func (rb ResponseBase) AsAnswer() (*Answer, bool) {
   570  	return nil, false
   571  }
   572  
   573  // AsBasicAnswer is the BasicResponseBase implementation for ResponseBase.
   574  func (rb ResponseBase) AsBasicAnswer() (BasicAnswer, bool) {
   575  	return nil, false
   576  }
   577  
   578  // AsResponse is the BasicResponseBase implementation for ResponseBase.
   579  func (rb ResponseBase) AsResponse() (*Response, bool) {
   580  	return nil, false
   581  }
   582  
   583  // AsBasicResponse is the BasicResponseBase implementation for ResponseBase.
   584  func (rb ResponseBase) AsBasicResponse() (BasicResponse, bool) {
   585  	return nil, false
   586  }
   587  
   588  // AsIdentifiable is the BasicResponseBase implementation for ResponseBase.
   589  func (rb ResponseBase) AsIdentifiable() (*Identifiable, bool) {
   590  	return nil, false
   591  }
   592  
   593  // AsBasicIdentifiable is the BasicResponseBase implementation for ResponseBase.
   594  func (rb ResponseBase) AsBasicIdentifiable() (BasicIdentifiable, bool) {
   595  	return nil, false
   596  }
   597  
   598  // AsErrorResponse is the BasicResponseBase implementation for ResponseBase.
   599  func (rb ResponseBase) AsErrorResponse() (*ErrorResponse, bool) {
   600  	return nil, false
   601  }
   602  
   603  // AsResponseBase is the BasicResponseBase implementation for ResponseBase.
   604  func (rb ResponseBase) AsResponseBase() (*ResponseBase, bool) {
   605  	return &rb, true
   606  }
   607  
   608  // AsBasicResponseBase is the BasicResponseBase implementation for ResponseBase.
   609  func (rb ResponseBase) AsBasicResponseBase() (BasicResponseBase, bool) {
   610  	return &rb, true
   611  }
   612  
   613  // SpellCheck ...
   614  type SpellCheck struct {
   615  	autorest.Response `json:"-"`
   616  	FlaggedTokens     *[]SpellingFlaggedToken `json:"flaggedTokens,omitempty"`
   617  	// ID - READ-ONLY; A String identifier.
   618  	ID *string `json:"id,omitempty"`
   619  	// Type - Possible values include: 'TypeResponseBase', 'TypeSpellCheck', 'TypeAnswer', 'TypeResponse', 'TypeIdentifiable', 'TypeErrorResponse'
   620  	Type Type `json:"_type,omitempty"`
   621  }
   622  
   623  // MarshalJSON is the custom marshaler for SpellCheck.
   624  func (sc SpellCheck) MarshalJSON() ([]byte, error) {
   625  	sc.Type = TypeSpellCheck
   626  	objectMap := make(map[string]interface{})
   627  	if sc.FlaggedTokens != nil {
   628  		objectMap["flaggedTokens"] = sc.FlaggedTokens
   629  	}
   630  	if sc.Type != "" {
   631  		objectMap["_type"] = sc.Type
   632  	}
   633  	return json.Marshal(objectMap)
   634  }
   635  
   636  // AsSpellCheck is the BasicResponseBase implementation for SpellCheck.
   637  func (sc SpellCheck) AsSpellCheck() (*SpellCheck, bool) {
   638  	return &sc, true
   639  }
   640  
   641  // AsAnswer is the BasicResponseBase implementation for SpellCheck.
   642  func (sc SpellCheck) AsAnswer() (*Answer, bool) {
   643  	return nil, false
   644  }
   645  
   646  // AsBasicAnswer is the BasicResponseBase implementation for SpellCheck.
   647  func (sc SpellCheck) AsBasicAnswer() (BasicAnswer, bool) {
   648  	return &sc, true
   649  }
   650  
   651  // AsResponse is the BasicResponseBase implementation for SpellCheck.
   652  func (sc SpellCheck) AsResponse() (*Response, bool) {
   653  	return nil, false
   654  }
   655  
   656  // AsBasicResponse is the BasicResponseBase implementation for SpellCheck.
   657  func (sc SpellCheck) AsBasicResponse() (BasicResponse, bool) {
   658  	return &sc, true
   659  }
   660  
   661  // AsIdentifiable is the BasicResponseBase implementation for SpellCheck.
   662  func (sc SpellCheck) AsIdentifiable() (*Identifiable, bool) {
   663  	return nil, false
   664  }
   665  
   666  // AsBasicIdentifiable is the BasicResponseBase implementation for SpellCheck.
   667  func (sc SpellCheck) AsBasicIdentifiable() (BasicIdentifiable, bool) {
   668  	return &sc, true
   669  }
   670  
   671  // AsErrorResponse is the BasicResponseBase implementation for SpellCheck.
   672  func (sc SpellCheck) AsErrorResponse() (*ErrorResponse, bool) {
   673  	return nil, false
   674  }
   675  
   676  // AsResponseBase is the BasicResponseBase implementation for SpellCheck.
   677  func (sc SpellCheck) AsResponseBase() (*ResponseBase, bool) {
   678  	return nil, false
   679  }
   680  
   681  // AsBasicResponseBase is the BasicResponseBase implementation for SpellCheck.
   682  func (sc SpellCheck) AsBasicResponseBase() (BasicResponseBase, bool) {
   683  	return &sc, true
   684  }
   685  
   686  // SpellingFlaggedToken ...
   687  type SpellingFlaggedToken struct {
   688  	Offset *int32  `json:"offset,omitempty"`
   689  	Token  *string `json:"token,omitempty"`
   690  	// Type - Possible values include: 'UnknownToken', 'RepeatedToken'
   691  	Type ErrorType `json:"type,omitempty"`
   692  	// Suggestions - READ-ONLY
   693  	Suggestions *[]SpellingTokenSuggestion `json:"suggestions,omitempty"`
   694  	// PingURLSuffix - READ-ONLY
   695  	PingURLSuffix *string `json:"pingUrlSuffix,omitempty"`
   696  }
   697  
   698  // MarshalJSON is the custom marshaler for SpellingFlaggedToken.
   699  func (sft SpellingFlaggedToken) MarshalJSON() ([]byte, error) {
   700  	objectMap := make(map[string]interface{})
   701  	if sft.Offset != nil {
   702  		objectMap["offset"] = sft.Offset
   703  	}
   704  	if sft.Token != nil {
   705  		objectMap["token"] = sft.Token
   706  	}
   707  	if sft.Type != "" {
   708  		objectMap["type"] = sft.Type
   709  	}
   710  	return json.Marshal(objectMap)
   711  }
   712  
   713  // SpellingTokenSuggestion ...
   714  type SpellingTokenSuggestion struct {
   715  	Suggestion *string `json:"suggestion,omitempty"`
   716  	// Score - READ-ONLY
   717  	Score *float64 `json:"score,omitempty"`
   718  	// PingURLSuffix - READ-ONLY
   719  	PingURLSuffix *string `json:"pingUrlSuffix,omitempty"`
   720  }
   721  
   722  // MarshalJSON is the custom marshaler for SpellingTokenSuggestion.
   723  func (sts SpellingTokenSuggestion) MarshalJSON() ([]byte, error) {
   724  	objectMap := make(map[string]interface{})
   725  	if sts.Suggestion != nil {
   726  		objectMap["suggestion"] = sts.Suggestion
   727  	}
   728  	return json.Marshal(objectMap)
   729  }
   730  

View as plain text