1 package localsearch
2
3
4
5
6
7
8
9 import (
10 "encoding/json"
11 "github.com/Azure/go-autorest/autorest"
12 )
13
14
15 const fqdn = "github.com/Azure/azure-sdk-for-go/services/cognitiveservices/v1.0/localsearch"
16
17
18 type BasicAction interface {
19 AsSearchAction() (*SearchAction, bool)
20 AsAction() (*Action, bool)
21 }
22
23
24 type Action struct {
25
26 Location *[]Place `json:"location,omitempty"`
27
28 Result *[]BasicThing `json:"result,omitempty"`
29
30 DisplayName *string `json:"displayName,omitempty"`
31
32 IsTopAction *bool `json:"isTopAction,omitempty"`
33
34 ServiceURL *string `json:"serviceUrl,omitempty"`
35
36 ThumbnailURL *string `json:"thumbnailUrl,omitempty"`
37
38 About *[]BasicThing `json:"about,omitempty"`
39
40 Mentions *[]BasicThing `json:"mentions,omitempty"`
41
42 Provider *[]BasicThing `json:"provider,omitempty"`
43
44 Creator BasicThing `json:"creator,omitempty"`
45
46 Text *string `json:"text,omitempty"`
47
48 DiscussionURL *string `json:"discussionUrl,omitempty"`
49
50 CommentCount *int32 `json:"commentCount,omitempty"`
51
52 MainEntity BasicThing `json:"mainEntity,omitempty"`
53
54 HeadLine *string `json:"headLine,omitempty"`
55
56 CopyrightHolder BasicThing `json:"copyrightHolder,omitempty"`
57
58 CopyrightYear *int32 `json:"copyrightYear,omitempty"`
59
60 Disclaimer *string `json:"disclaimer,omitempty"`
61
62 IsAccessibleForFree *bool `json:"isAccessibleForFree,omitempty"`
63
64 Genre *[]string `json:"genre,omitempty"`
65
66 IsFamilyFriendly *bool `json:"isFamilyFriendly,omitempty"`
67
68 Name *string `json:"name,omitempty"`
69
70 URL *string `json:"url,omitempty"`
71
72 EntityPresentationInfo BasicEntitiesEntityPresentationInfo `json:"entityPresentationInfo,omitempty"`
73
74 ReadLink *string `json:"readLink,omitempty"`
75
76 WebSearchURL *string `json:"webSearchUrl,omitempty"`
77
78 PotentialAction *[]BasicAction `json:"potentialAction,omitempty"`
79
80 ImmediateAction *[]BasicAction `json:"immediateAction,omitempty"`
81
82 PreferredClickthroughURL *string `json:"preferredClickthroughUrl,omitempty"`
83
84 AdaptiveCard *string `json:"adaptiveCard,omitempty"`
85
86 ID *string `json:"id,omitempty"`
87
88 Type TypeBasicResponseBase `json:"_type,omitempty"`
89 }
90
91 func unmarshalBasicAction(body []byte) (BasicAction, error) {
92 var m map[string]interface{}
93 err := json.Unmarshal(body, &m)
94 if err != nil {
95 return nil, err
96 }
97
98 switch m["_type"] {
99 case string(TypeSearchAction):
100 var sa SearchAction
101 err := json.Unmarshal(body, &sa)
102 return sa, err
103 default:
104 var a Action
105 err := json.Unmarshal(body, &a)
106 return a, err
107 }
108 }
109 func unmarshalBasicActionArray(body []byte) ([]BasicAction, error) {
110 var rawMessages []*json.RawMessage
111 err := json.Unmarshal(body, &rawMessages)
112 if err != nil {
113 return nil, err
114 }
115
116 aArray := make([]BasicAction, len(rawMessages))
117
118 for index, rawMessage := range rawMessages {
119 a, err := unmarshalBasicAction(*rawMessage)
120 if err != nil {
121 return nil, err
122 }
123 aArray[index] = a
124 }
125 return aArray, nil
126 }
127
128
129 func (a Action) MarshalJSON() ([]byte, error) {
130 a.Type = TypeAction
131 objectMap := make(map[string]interface{})
132 if a.Type != "" {
133 objectMap["_type"] = a.Type
134 }
135 return json.Marshal(objectMap)
136 }
137
138
139 func (a Action) AsThing() (*Thing, bool) {
140 return nil, false
141 }
142
143
144 func (a Action) AsBasicThing() (BasicThing, bool) {
145 return &a, true
146 }
147
148
149 func (a Action) AsPlaces() (*Places, bool) {
150 return nil, false
151 }
152
153
154 func (a Action) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) {
155 return nil, false
156 }
157
158
159 func (a Action) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) {
160 return nil, false
161 }
162
163
164 func (a Action) AsSearchResponse() (*SearchResponse, bool) {
165 return nil, false
166 }
167
168
169 func (a Action) AsPostalAddress() (*PostalAddress, bool) {
170 return nil, false
171 }
172
173
174 func (a Action) AsPlace() (*Place, bool) {
175 return nil, false
176 }
177
178
179 func (a Action) AsAction() (*Action, bool) {
180 return &a, true
181 }
182
183
184 func (a Action) AsBasicAction() (BasicAction, bool) {
185 return &a, true
186 }
187
188
189 func (a Action) AsResponse() (*Response, bool) {
190 return nil, false
191 }
192
193
194 func (a Action) AsBasicResponse() (BasicResponse, bool) {
195 return &a, true
196 }
197
198
199 func (a Action) AsIdentifiable() (*Identifiable, bool) {
200 return nil, false
201 }
202
203
204 func (a Action) AsBasicIdentifiable() (BasicIdentifiable, bool) {
205 return &a, true
206 }
207
208
209 func (a Action) AsAnswer() (*Answer, bool) {
210 return nil, false
211 }
212
213
214 func (a Action) AsBasicAnswer() (BasicAnswer, bool) {
215 return nil, false
216 }
217
218
219 func (a Action) AsErrorResponse() (*ErrorResponse, bool) {
220 return nil, false
221 }
222
223
224 func (a Action) AsCreativeWork() (*CreativeWork, bool) {
225 return nil, false
226 }
227
228
229 func (a Action) AsBasicCreativeWork() (BasicCreativeWork, bool) {
230 return &a, true
231 }
232
233
234 func (a Action) AsIntangible() (*Intangible, bool) {
235 return nil, false
236 }
237
238
239 func (a Action) AsBasicIntangible() (BasicIntangible, bool) {
240 return nil, false
241 }
242
243
244 func (a Action) AsSearchAction() (*SearchAction, bool) {
245 return nil, false
246 }
247
248
249 func (a Action) AsStructuredValue() (*StructuredValue, bool) {
250 return nil, false
251 }
252
253
254 func (a Action) AsBasicStructuredValue() (BasicStructuredValue, bool) {
255 return nil, false
256 }
257
258
259 func (a Action) AsResponseBase() (*ResponseBase, bool) {
260 return nil, false
261 }
262
263
264 func (a Action) AsBasicResponseBase() (BasicResponseBase, bool) {
265 return &a, true
266 }
267
268
269 func (a *Action) UnmarshalJSON(body []byte) error {
270 var m map[string]*json.RawMessage
271 err := json.Unmarshal(body, &m)
272 if err != nil {
273 return err
274 }
275 for k, v := range m {
276 switch k {
277 case "location":
278 if v != nil {
279 var location []Place
280 err = json.Unmarshal(*v, &location)
281 if err != nil {
282 return err
283 }
284 a.Location = &location
285 }
286 case "result":
287 if v != nil {
288 resultVar, err := unmarshalBasicThingArray(*v)
289 if err != nil {
290 return err
291 }
292 a.Result = &resultVar
293 }
294 case "displayName":
295 if v != nil {
296 var displayName string
297 err = json.Unmarshal(*v, &displayName)
298 if err != nil {
299 return err
300 }
301 a.DisplayName = &displayName
302 }
303 case "isTopAction":
304 if v != nil {
305 var isTopAction bool
306 err = json.Unmarshal(*v, &isTopAction)
307 if err != nil {
308 return err
309 }
310 a.IsTopAction = &isTopAction
311 }
312 case "serviceUrl":
313 if v != nil {
314 var serviceURL string
315 err = json.Unmarshal(*v, &serviceURL)
316 if err != nil {
317 return err
318 }
319 a.ServiceURL = &serviceURL
320 }
321 case "thumbnailUrl":
322 if v != nil {
323 var thumbnailURL string
324 err = json.Unmarshal(*v, &thumbnailURL)
325 if err != nil {
326 return err
327 }
328 a.ThumbnailURL = &thumbnailURL
329 }
330 case "about":
331 if v != nil {
332 about, err := unmarshalBasicThingArray(*v)
333 if err != nil {
334 return err
335 }
336 a.About = &about
337 }
338 case "mentions":
339 if v != nil {
340 mentions, err := unmarshalBasicThingArray(*v)
341 if err != nil {
342 return err
343 }
344 a.Mentions = &mentions
345 }
346 case "provider":
347 if v != nil {
348 provider, err := unmarshalBasicThingArray(*v)
349 if err != nil {
350 return err
351 }
352 a.Provider = &provider
353 }
354 case "creator":
355 if v != nil {
356 creator, err := unmarshalBasicThing(*v)
357 if err != nil {
358 return err
359 }
360 a.Creator = creator
361 }
362 case "text":
363 if v != nil {
364 var textVar string
365 err = json.Unmarshal(*v, &textVar)
366 if err != nil {
367 return err
368 }
369 a.Text = &textVar
370 }
371 case "discussionUrl":
372 if v != nil {
373 var discussionURL string
374 err = json.Unmarshal(*v, &discussionURL)
375 if err != nil {
376 return err
377 }
378 a.DiscussionURL = &discussionURL
379 }
380 case "commentCount":
381 if v != nil {
382 var commentCount int32
383 err = json.Unmarshal(*v, &commentCount)
384 if err != nil {
385 return err
386 }
387 a.CommentCount = &commentCount
388 }
389 case "mainEntity":
390 if v != nil {
391 mainEntity, err := unmarshalBasicThing(*v)
392 if err != nil {
393 return err
394 }
395 a.MainEntity = mainEntity
396 }
397 case "headLine":
398 if v != nil {
399 var headLine string
400 err = json.Unmarshal(*v, &headLine)
401 if err != nil {
402 return err
403 }
404 a.HeadLine = &headLine
405 }
406 case "copyrightHolder":
407 if v != nil {
408 copyrightHolder, err := unmarshalBasicThing(*v)
409 if err != nil {
410 return err
411 }
412 a.CopyrightHolder = copyrightHolder
413 }
414 case "copyrightYear":
415 if v != nil {
416 var copyrightYear int32
417 err = json.Unmarshal(*v, ©rightYear)
418 if err != nil {
419 return err
420 }
421 a.CopyrightYear = ©rightYear
422 }
423 case "disclaimer":
424 if v != nil {
425 var disclaimer string
426 err = json.Unmarshal(*v, &disclaimer)
427 if err != nil {
428 return err
429 }
430 a.Disclaimer = &disclaimer
431 }
432 case "isAccessibleForFree":
433 if v != nil {
434 var isAccessibleForFree bool
435 err = json.Unmarshal(*v, &isAccessibleForFree)
436 if err != nil {
437 return err
438 }
439 a.IsAccessibleForFree = &isAccessibleForFree
440 }
441 case "genre":
442 if v != nil {
443 var genre []string
444 err = json.Unmarshal(*v, &genre)
445 if err != nil {
446 return err
447 }
448 a.Genre = &genre
449 }
450 case "isFamilyFriendly":
451 if v != nil {
452 var isFamilyFriendly bool
453 err = json.Unmarshal(*v, &isFamilyFriendly)
454 if err != nil {
455 return err
456 }
457 a.IsFamilyFriendly = &isFamilyFriendly
458 }
459 case "name":
460 if v != nil {
461 var name string
462 err = json.Unmarshal(*v, &name)
463 if err != nil {
464 return err
465 }
466 a.Name = &name
467 }
468 case "url":
469 if v != nil {
470 var URL string
471 err = json.Unmarshal(*v, &URL)
472 if err != nil {
473 return err
474 }
475 a.URL = &URL
476 }
477 case "entityPresentationInfo":
478 if v != nil {
479 entityPresentationInfo, err := unmarshalBasicEntitiesEntityPresentationInfo(*v)
480 if err != nil {
481 return err
482 }
483 a.EntityPresentationInfo = entityPresentationInfo
484 }
485 case "readLink":
486 if v != nil {
487 var readLink string
488 err = json.Unmarshal(*v, &readLink)
489 if err != nil {
490 return err
491 }
492 a.ReadLink = &readLink
493 }
494 case "webSearchUrl":
495 if v != nil {
496 var webSearchURL string
497 err = json.Unmarshal(*v, &webSearchURL)
498 if err != nil {
499 return err
500 }
501 a.WebSearchURL = &webSearchURL
502 }
503 case "potentialAction":
504 if v != nil {
505 potentialAction, err := unmarshalBasicActionArray(*v)
506 if err != nil {
507 return err
508 }
509 a.PotentialAction = &potentialAction
510 }
511 case "immediateAction":
512 if v != nil {
513 immediateAction, err := unmarshalBasicActionArray(*v)
514 if err != nil {
515 return err
516 }
517 a.ImmediateAction = &immediateAction
518 }
519 case "preferredClickthroughUrl":
520 if v != nil {
521 var preferredClickthroughURL string
522 err = json.Unmarshal(*v, &preferredClickthroughURL)
523 if err != nil {
524 return err
525 }
526 a.PreferredClickthroughURL = &preferredClickthroughURL
527 }
528 case "adaptiveCard":
529 if v != nil {
530 var adaptiveCard string
531 err = json.Unmarshal(*v, &adaptiveCard)
532 if err != nil {
533 return err
534 }
535 a.AdaptiveCard = &adaptiveCard
536 }
537 case "id":
538 if v != nil {
539 var ID string
540 err = json.Unmarshal(*v, &ID)
541 if err != nil {
542 return err
543 }
544 a.ID = &ID
545 }
546 case "_type":
547 if v != nil {
548 var typeVar TypeBasicResponseBase
549 err = json.Unmarshal(*v, &typeVar)
550 if err != nil {
551 return err
552 }
553 a.Type = typeVar
554 }
555 }
556 }
557
558 return nil
559 }
560
561
562 type BasicAnswer interface {
563 AsPlaces() (*Places, bool)
564 AsSearchResultsAnswer() (*SearchResultsAnswer, bool)
565 AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool)
566 AsAnswer() (*Answer, bool)
567 }
568
569
570 type Answer struct {
571
572 ReadLink *string `json:"readLink,omitempty"`
573
574 WebSearchURL *string `json:"webSearchUrl,omitempty"`
575
576 PotentialAction *[]BasicAction `json:"potentialAction,omitempty"`
577
578 ImmediateAction *[]BasicAction `json:"immediateAction,omitempty"`
579
580 PreferredClickthroughURL *string `json:"preferredClickthroughUrl,omitempty"`
581
582 AdaptiveCard *string `json:"adaptiveCard,omitempty"`
583
584 ID *string `json:"id,omitempty"`
585
586 Type TypeBasicResponseBase `json:"_type,omitempty"`
587 }
588
589 func unmarshalBasicAnswer(body []byte) (BasicAnswer, error) {
590 var m map[string]interface{}
591 err := json.Unmarshal(body, &m)
592 if err != nil {
593 return nil, err
594 }
595
596 switch m["_type"] {
597 case string(TypePlaces):
598 var p Places
599 err := json.Unmarshal(body, &p)
600 return p, err
601 case string(TypeSearchResultsAnswer):
602 var sra SearchResultsAnswer
603 err := json.Unmarshal(body, &sra)
604 return sra, err
605 default:
606 var a Answer
607 err := json.Unmarshal(body, &a)
608 return a, err
609 }
610 }
611 func unmarshalBasicAnswerArray(body []byte) ([]BasicAnswer, error) {
612 var rawMessages []*json.RawMessage
613 err := json.Unmarshal(body, &rawMessages)
614 if err != nil {
615 return nil, err
616 }
617
618 aArray := make([]BasicAnswer, len(rawMessages))
619
620 for index, rawMessage := range rawMessages {
621 a, err := unmarshalBasicAnswer(*rawMessage)
622 if err != nil {
623 return nil, err
624 }
625 aArray[index] = a
626 }
627 return aArray, nil
628 }
629
630
631 func (a Answer) MarshalJSON() ([]byte, error) {
632 a.Type = TypeAnswer
633 objectMap := make(map[string]interface{})
634 if a.Type != "" {
635 objectMap["_type"] = a.Type
636 }
637 return json.Marshal(objectMap)
638 }
639
640
641 func (a Answer) AsThing() (*Thing, bool) {
642 return nil, false
643 }
644
645
646 func (a Answer) AsBasicThing() (BasicThing, bool) {
647 return nil, false
648 }
649
650
651 func (a Answer) AsPlaces() (*Places, bool) {
652 return nil, false
653 }
654
655
656 func (a Answer) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) {
657 return nil, false
658 }
659
660
661 func (a Answer) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) {
662 return nil, false
663 }
664
665
666 func (a Answer) AsSearchResponse() (*SearchResponse, bool) {
667 return nil, false
668 }
669
670
671 func (a Answer) AsPostalAddress() (*PostalAddress, bool) {
672 return nil, false
673 }
674
675
676 func (a Answer) AsPlace() (*Place, bool) {
677 return nil, false
678 }
679
680
681 func (a Answer) AsAction() (*Action, bool) {
682 return nil, false
683 }
684
685
686 func (a Answer) AsBasicAction() (BasicAction, bool) {
687 return nil, false
688 }
689
690
691 func (a Answer) AsResponse() (*Response, bool) {
692 return nil, false
693 }
694
695
696 func (a Answer) AsBasicResponse() (BasicResponse, bool) {
697 return &a, true
698 }
699
700
701 func (a Answer) AsIdentifiable() (*Identifiable, bool) {
702 return nil, false
703 }
704
705
706 func (a Answer) AsBasicIdentifiable() (BasicIdentifiable, bool) {
707 return &a, true
708 }
709
710
711 func (a Answer) AsAnswer() (*Answer, bool) {
712 return &a, true
713 }
714
715
716 func (a Answer) AsBasicAnswer() (BasicAnswer, bool) {
717 return &a, true
718 }
719
720
721 func (a Answer) AsErrorResponse() (*ErrorResponse, bool) {
722 return nil, false
723 }
724
725
726 func (a Answer) AsCreativeWork() (*CreativeWork, bool) {
727 return nil, false
728 }
729
730
731 func (a Answer) AsBasicCreativeWork() (BasicCreativeWork, bool) {
732 return nil, false
733 }
734
735
736 func (a Answer) AsIntangible() (*Intangible, bool) {
737 return nil, false
738 }
739
740
741 func (a Answer) AsBasicIntangible() (BasicIntangible, bool) {
742 return nil, false
743 }
744
745
746 func (a Answer) AsSearchAction() (*SearchAction, bool) {
747 return nil, false
748 }
749
750
751 func (a Answer) AsStructuredValue() (*StructuredValue, bool) {
752 return nil, false
753 }
754
755
756 func (a Answer) AsBasicStructuredValue() (BasicStructuredValue, bool) {
757 return nil, false
758 }
759
760
761 func (a Answer) AsResponseBase() (*ResponseBase, bool) {
762 return nil, false
763 }
764
765
766 func (a Answer) AsBasicResponseBase() (BasicResponseBase, bool) {
767 return &a, true
768 }
769
770
771 func (a *Answer) UnmarshalJSON(body []byte) error {
772 var m map[string]*json.RawMessage
773 err := json.Unmarshal(body, &m)
774 if err != nil {
775 return err
776 }
777 for k, v := range m {
778 switch k {
779 case "readLink":
780 if v != nil {
781 var readLink string
782 err = json.Unmarshal(*v, &readLink)
783 if err != nil {
784 return err
785 }
786 a.ReadLink = &readLink
787 }
788 case "webSearchUrl":
789 if v != nil {
790 var webSearchURL string
791 err = json.Unmarshal(*v, &webSearchURL)
792 if err != nil {
793 return err
794 }
795 a.WebSearchURL = &webSearchURL
796 }
797 case "potentialAction":
798 if v != nil {
799 potentialAction, err := unmarshalBasicActionArray(*v)
800 if err != nil {
801 return err
802 }
803 a.PotentialAction = &potentialAction
804 }
805 case "immediateAction":
806 if v != nil {
807 immediateAction, err := unmarshalBasicActionArray(*v)
808 if err != nil {
809 return err
810 }
811 a.ImmediateAction = &immediateAction
812 }
813 case "preferredClickthroughUrl":
814 if v != nil {
815 var preferredClickthroughURL string
816 err = json.Unmarshal(*v, &preferredClickthroughURL)
817 if err != nil {
818 return err
819 }
820 a.PreferredClickthroughURL = &preferredClickthroughURL
821 }
822 case "adaptiveCard":
823 if v != nil {
824 var adaptiveCard string
825 err = json.Unmarshal(*v, &adaptiveCard)
826 if err != nil {
827 return err
828 }
829 a.AdaptiveCard = &adaptiveCard
830 }
831 case "id":
832 if v != nil {
833 var ID string
834 err = json.Unmarshal(*v, &ID)
835 if err != nil {
836 return err
837 }
838 a.ID = &ID
839 }
840 case "_type":
841 if v != nil {
842 var typeVar TypeBasicResponseBase
843 err = json.Unmarshal(*v, &typeVar)
844 if err != nil {
845 return err
846 }
847 a.Type = typeVar
848 }
849 }
850 }
851
852 return nil
853 }
854
855
856
857 type BasicCreativeWork interface {
858 AsAction() (*Action, bool)
859 AsBasicAction() (BasicAction, bool)
860 AsSearchAction() (*SearchAction, bool)
861 AsCreativeWork() (*CreativeWork, bool)
862 }
863
864
865
866 type CreativeWork struct {
867
868 ThumbnailURL *string `json:"thumbnailUrl,omitempty"`
869
870 About *[]BasicThing `json:"about,omitempty"`
871
872 Mentions *[]BasicThing `json:"mentions,omitempty"`
873
874 Provider *[]BasicThing `json:"provider,omitempty"`
875
876 Creator BasicThing `json:"creator,omitempty"`
877
878 Text *string `json:"text,omitempty"`
879
880 DiscussionURL *string `json:"discussionUrl,omitempty"`
881
882 CommentCount *int32 `json:"commentCount,omitempty"`
883
884 MainEntity BasicThing `json:"mainEntity,omitempty"`
885
886 HeadLine *string `json:"headLine,omitempty"`
887
888 CopyrightHolder BasicThing `json:"copyrightHolder,omitempty"`
889
890 CopyrightYear *int32 `json:"copyrightYear,omitempty"`
891
892 Disclaimer *string `json:"disclaimer,omitempty"`
893
894 IsAccessibleForFree *bool `json:"isAccessibleForFree,omitempty"`
895
896 Genre *[]string `json:"genre,omitempty"`
897
898 IsFamilyFriendly *bool `json:"isFamilyFriendly,omitempty"`
899
900 Name *string `json:"name,omitempty"`
901
902 URL *string `json:"url,omitempty"`
903
904 EntityPresentationInfo BasicEntitiesEntityPresentationInfo `json:"entityPresentationInfo,omitempty"`
905
906 ReadLink *string `json:"readLink,omitempty"`
907
908 WebSearchURL *string `json:"webSearchUrl,omitempty"`
909
910 PotentialAction *[]BasicAction `json:"potentialAction,omitempty"`
911
912 ImmediateAction *[]BasicAction `json:"immediateAction,omitempty"`
913
914 PreferredClickthroughURL *string `json:"preferredClickthroughUrl,omitempty"`
915
916 AdaptiveCard *string `json:"adaptiveCard,omitempty"`
917
918 ID *string `json:"id,omitempty"`
919
920 Type TypeBasicResponseBase `json:"_type,omitempty"`
921 }
922
923 func unmarshalBasicCreativeWork(body []byte) (BasicCreativeWork, error) {
924 var m map[string]interface{}
925 err := json.Unmarshal(body, &m)
926 if err != nil {
927 return nil, err
928 }
929
930 switch m["_type"] {
931 case string(TypeAction):
932 var a Action
933 err := json.Unmarshal(body, &a)
934 return a, err
935 case string(TypeSearchAction):
936 var sa SearchAction
937 err := json.Unmarshal(body, &sa)
938 return sa, err
939 default:
940 var cw CreativeWork
941 err := json.Unmarshal(body, &cw)
942 return cw, err
943 }
944 }
945 func unmarshalBasicCreativeWorkArray(body []byte) ([]BasicCreativeWork, error) {
946 var rawMessages []*json.RawMessage
947 err := json.Unmarshal(body, &rawMessages)
948 if err != nil {
949 return nil, err
950 }
951
952 cwArray := make([]BasicCreativeWork, len(rawMessages))
953
954 for index, rawMessage := range rawMessages {
955 cw, err := unmarshalBasicCreativeWork(*rawMessage)
956 if err != nil {
957 return nil, err
958 }
959 cwArray[index] = cw
960 }
961 return cwArray, nil
962 }
963
964
965 func (cw CreativeWork) MarshalJSON() ([]byte, error) {
966 cw.Type = TypeCreativeWork
967 objectMap := make(map[string]interface{})
968 if cw.Type != "" {
969 objectMap["_type"] = cw.Type
970 }
971 return json.Marshal(objectMap)
972 }
973
974
975 func (cw CreativeWork) AsThing() (*Thing, bool) {
976 return nil, false
977 }
978
979
980 func (cw CreativeWork) AsBasicThing() (BasicThing, bool) {
981 return &cw, true
982 }
983
984
985 func (cw CreativeWork) AsPlaces() (*Places, bool) {
986 return nil, false
987 }
988
989
990 func (cw CreativeWork) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) {
991 return nil, false
992 }
993
994
995 func (cw CreativeWork) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) {
996 return nil, false
997 }
998
999
1000 func (cw CreativeWork) AsSearchResponse() (*SearchResponse, bool) {
1001 return nil, false
1002 }
1003
1004
1005 func (cw CreativeWork) AsPostalAddress() (*PostalAddress, bool) {
1006 return nil, false
1007 }
1008
1009
1010 func (cw CreativeWork) AsPlace() (*Place, bool) {
1011 return nil, false
1012 }
1013
1014
1015 func (cw CreativeWork) AsAction() (*Action, bool) {
1016 return nil, false
1017 }
1018
1019
1020 func (cw CreativeWork) AsBasicAction() (BasicAction, bool) {
1021 return nil, false
1022 }
1023
1024
1025 func (cw CreativeWork) AsResponse() (*Response, bool) {
1026 return nil, false
1027 }
1028
1029
1030 func (cw CreativeWork) AsBasicResponse() (BasicResponse, bool) {
1031 return &cw, true
1032 }
1033
1034
1035 func (cw CreativeWork) AsIdentifiable() (*Identifiable, bool) {
1036 return nil, false
1037 }
1038
1039
1040 func (cw CreativeWork) AsBasicIdentifiable() (BasicIdentifiable, bool) {
1041 return &cw, true
1042 }
1043
1044
1045 func (cw CreativeWork) AsAnswer() (*Answer, bool) {
1046 return nil, false
1047 }
1048
1049
1050 func (cw CreativeWork) AsBasicAnswer() (BasicAnswer, bool) {
1051 return nil, false
1052 }
1053
1054
1055 func (cw CreativeWork) AsErrorResponse() (*ErrorResponse, bool) {
1056 return nil, false
1057 }
1058
1059
1060 func (cw CreativeWork) AsCreativeWork() (*CreativeWork, bool) {
1061 return &cw, true
1062 }
1063
1064
1065 func (cw CreativeWork) AsBasicCreativeWork() (BasicCreativeWork, bool) {
1066 return &cw, true
1067 }
1068
1069
1070 func (cw CreativeWork) AsIntangible() (*Intangible, bool) {
1071 return nil, false
1072 }
1073
1074
1075 func (cw CreativeWork) AsBasicIntangible() (BasicIntangible, bool) {
1076 return nil, false
1077 }
1078
1079
1080 func (cw CreativeWork) AsSearchAction() (*SearchAction, bool) {
1081 return nil, false
1082 }
1083
1084
1085 func (cw CreativeWork) AsStructuredValue() (*StructuredValue, bool) {
1086 return nil, false
1087 }
1088
1089
1090 func (cw CreativeWork) AsBasicStructuredValue() (BasicStructuredValue, bool) {
1091 return nil, false
1092 }
1093
1094
1095 func (cw CreativeWork) AsResponseBase() (*ResponseBase, bool) {
1096 return nil, false
1097 }
1098
1099
1100 func (cw CreativeWork) AsBasicResponseBase() (BasicResponseBase, bool) {
1101 return &cw, true
1102 }
1103
1104
1105 func (cw *CreativeWork) UnmarshalJSON(body []byte) error {
1106 var m map[string]*json.RawMessage
1107 err := json.Unmarshal(body, &m)
1108 if err != nil {
1109 return err
1110 }
1111 for k, v := range m {
1112 switch k {
1113 case "thumbnailUrl":
1114 if v != nil {
1115 var thumbnailURL string
1116 err = json.Unmarshal(*v, &thumbnailURL)
1117 if err != nil {
1118 return err
1119 }
1120 cw.ThumbnailURL = &thumbnailURL
1121 }
1122 case "about":
1123 if v != nil {
1124 about, err := unmarshalBasicThingArray(*v)
1125 if err != nil {
1126 return err
1127 }
1128 cw.About = &about
1129 }
1130 case "mentions":
1131 if v != nil {
1132 mentions, err := unmarshalBasicThingArray(*v)
1133 if err != nil {
1134 return err
1135 }
1136 cw.Mentions = &mentions
1137 }
1138 case "provider":
1139 if v != nil {
1140 provider, err := unmarshalBasicThingArray(*v)
1141 if err != nil {
1142 return err
1143 }
1144 cw.Provider = &provider
1145 }
1146 case "creator":
1147 if v != nil {
1148 creator, err := unmarshalBasicThing(*v)
1149 if err != nil {
1150 return err
1151 }
1152 cw.Creator = creator
1153 }
1154 case "text":
1155 if v != nil {
1156 var textVar string
1157 err = json.Unmarshal(*v, &textVar)
1158 if err != nil {
1159 return err
1160 }
1161 cw.Text = &textVar
1162 }
1163 case "discussionUrl":
1164 if v != nil {
1165 var discussionURL string
1166 err = json.Unmarshal(*v, &discussionURL)
1167 if err != nil {
1168 return err
1169 }
1170 cw.DiscussionURL = &discussionURL
1171 }
1172 case "commentCount":
1173 if v != nil {
1174 var commentCount int32
1175 err = json.Unmarshal(*v, &commentCount)
1176 if err != nil {
1177 return err
1178 }
1179 cw.CommentCount = &commentCount
1180 }
1181 case "mainEntity":
1182 if v != nil {
1183 mainEntity, err := unmarshalBasicThing(*v)
1184 if err != nil {
1185 return err
1186 }
1187 cw.MainEntity = mainEntity
1188 }
1189 case "headLine":
1190 if v != nil {
1191 var headLine string
1192 err = json.Unmarshal(*v, &headLine)
1193 if err != nil {
1194 return err
1195 }
1196 cw.HeadLine = &headLine
1197 }
1198 case "copyrightHolder":
1199 if v != nil {
1200 copyrightHolder, err := unmarshalBasicThing(*v)
1201 if err != nil {
1202 return err
1203 }
1204 cw.CopyrightHolder = copyrightHolder
1205 }
1206 case "copyrightYear":
1207 if v != nil {
1208 var copyrightYear int32
1209 err = json.Unmarshal(*v, ©rightYear)
1210 if err != nil {
1211 return err
1212 }
1213 cw.CopyrightYear = ©rightYear
1214 }
1215 case "disclaimer":
1216 if v != nil {
1217 var disclaimer string
1218 err = json.Unmarshal(*v, &disclaimer)
1219 if err != nil {
1220 return err
1221 }
1222 cw.Disclaimer = &disclaimer
1223 }
1224 case "isAccessibleForFree":
1225 if v != nil {
1226 var isAccessibleForFree bool
1227 err = json.Unmarshal(*v, &isAccessibleForFree)
1228 if err != nil {
1229 return err
1230 }
1231 cw.IsAccessibleForFree = &isAccessibleForFree
1232 }
1233 case "genre":
1234 if v != nil {
1235 var genre []string
1236 err = json.Unmarshal(*v, &genre)
1237 if err != nil {
1238 return err
1239 }
1240 cw.Genre = &genre
1241 }
1242 case "isFamilyFriendly":
1243 if v != nil {
1244 var isFamilyFriendly bool
1245 err = json.Unmarshal(*v, &isFamilyFriendly)
1246 if err != nil {
1247 return err
1248 }
1249 cw.IsFamilyFriendly = &isFamilyFriendly
1250 }
1251 case "name":
1252 if v != nil {
1253 var name string
1254 err = json.Unmarshal(*v, &name)
1255 if err != nil {
1256 return err
1257 }
1258 cw.Name = &name
1259 }
1260 case "url":
1261 if v != nil {
1262 var URL string
1263 err = json.Unmarshal(*v, &URL)
1264 if err != nil {
1265 return err
1266 }
1267 cw.URL = &URL
1268 }
1269 case "entityPresentationInfo":
1270 if v != nil {
1271 entityPresentationInfo, err := unmarshalBasicEntitiesEntityPresentationInfo(*v)
1272 if err != nil {
1273 return err
1274 }
1275 cw.EntityPresentationInfo = entityPresentationInfo
1276 }
1277 case "readLink":
1278 if v != nil {
1279 var readLink string
1280 err = json.Unmarshal(*v, &readLink)
1281 if err != nil {
1282 return err
1283 }
1284 cw.ReadLink = &readLink
1285 }
1286 case "webSearchUrl":
1287 if v != nil {
1288 var webSearchURL string
1289 err = json.Unmarshal(*v, &webSearchURL)
1290 if err != nil {
1291 return err
1292 }
1293 cw.WebSearchURL = &webSearchURL
1294 }
1295 case "potentialAction":
1296 if v != nil {
1297 potentialAction, err := unmarshalBasicActionArray(*v)
1298 if err != nil {
1299 return err
1300 }
1301 cw.PotentialAction = &potentialAction
1302 }
1303 case "immediateAction":
1304 if v != nil {
1305 immediateAction, err := unmarshalBasicActionArray(*v)
1306 if err != nil {
1307 return err
1308 }
1309 cw.ImmediateAction = &immediateAction
1310 }
1311 case "preferredClickthroughUrl":
1312 if v != nil {
1313 var preferredClickthroughURL string
1314 err = json.Unmarshal(*v, &preferredClickthroughURL)
1315 if err != nil {
1316 return err
1317 }
1318 cw.PreferredClickthroughURL = &preferredClickthroughURL
1319 }
1320 case "adaptiveCard":
1321 if v != nil {
1322 var adaptiveCard string
1323 err = json.Unmarshal(*v, &adaptiveCard)
1324 if err != nil {
1325 return err
1326 }
1327 cw.AdaptiveCard = &adaptiveCard
1328 }
1329 case "id":
1330 if v != nil {
1331 var ID string
1332 err = json.Unmarshal(*v, &ID)
1333 if err != nil {
1334 return err
1335 }
1336 cw.ID = &ID
1337 }
1338 case "_type":
1339 if v != nil {
1340 var typeVar TypeBasicResponseBase
1341 err = json.Unmarshal(*v, &typeVar)
1342 if err != nil {
1343 return err
1344 }
1345 cw.Type = typeVar
1346 }
1347 }
1348 }
1349
1350 return nil
1351 }
1352
1353
1354 type BasicEntitiesEntityPresentationInfo interface {
1355 AsEntitiesEntityPresentationInfo() (*EntitiesEntityPresentationInfo, bool)
1356 }
1357
1358
1359 type EntitiesEntityPresentationInfo struct {
1360
1361 EntityScenario EntityScenario `json:"entityScenario,omitempty"`
1362
1363 EntityTypeHints *[]EntityType `json:"entityTypeHints,omitempty"`
1364
1365 EntityTypeDisplayHint *string `json:"entityTypeDisplayHint,omitempty"`
1366
1367 Query *string `json:"query,omitempty"`
1368
1369 EntitySubTypeHints *[]string `json:"entitySubTypeHints,omitempty"`
1370
1371 Type TypeBasicEntitiesEntityPresentationInfo `json:"_type,omitempty"`
1372 }
1373
1374 func unmarshalBasicEntitiesEntityPresentationInfo(body []byte) (BasicEntitiesEntityPresentationInfo, error) {
1375 var m map[string]interface{}
1376 err := json.Unmarshal(body, &m)
1377 if err != nil {
1378 return nil, err
1379 }
1380
1381 switch m["_type"] {
1382 default:
1383 var eepi EntitiesEntityPresentationInfo
1384 err := json.Unmarshal(body, &eepi)
1385 return eepi, err
1386 }
1387 }
1388 func unmarshalBasicEntitiesEntityPresentationInfoArray(body []byte) ([]BasicEntitiesEntityPresentationInfo, error) {
1389 var rawMessages []*json.RawMessage
1390 err := json.Unmarshal(body, &rawMessages)
1391 if err != nil {
1392 return nil, err
1393 }
1394
1395 eepiArray := make([]BasicEntitiesEntityPresentationInfo, len(rawMessages))
1396
1397 for index, rawMessage := range rawMessages {
1398 eepi, err := unmarshalBasicEntitiesEntityPresentationInfo(*rawMessage)
1399 if err != nil {
1400 return nil, err
1401 }
1402 eepiArray[index] = eepi
1403 }
1404 return eepiArray, nil
1405 }
1406
1407
1408 func (eepi EntitiesEntityPresentationInfo) MarshalJSON() ([]byte, error) {
1409 eepi.Type = TypeEntitiesEntityPresentationInfo
1410 objectMap := make(map[string]interface{})
1411 if eepi.EntityScenario != "" {
1412 objectMap["entityScenario"] = eepi.EntityScenario
1413 }
1414 if eepi.Type != "" {
1415 objectMap["_type"] = eepi.Type
1416 }
1417 return json.Marshal(objectMap)
1418 }
1419
1420
1421 func (eepi EntitiesEntityPresentationInfo) AsEntitiesEntityPresentationInfo() (*EntitiesEntityPresentationInfo, bool) {
1422 return &eepi, true
1423 }
1424
1425
1426 func (eepi EntitiesEntityPresentationInfo) AsBasicEntitiesEntityPresentationInfo() (BasicEntitiesEntityPresentationInfo, bool) {
1427 return &eepi, true
1428 }
1429
1430
1431 type BasicError interface {
1432 AsError() (*Error, bool)
1433 }
1434
1435
1436 type Error struct {
1437
1438 Code ErrorCode `json:"code,omitempty"`
1439
1440 SubCode ErrorSubCode `json:"subCode,omitempty"`
1441
1442 Message *string `json:"message,omitempty"`
1443
1444 MoreDetails *string `json:"moreDetails,omitempty"`
1445
1446 Parameter *string `json:"parameter,omitempty"`
1447
1448 Value *string `json:"value,omitempty"`
1449
1450 Type TypeBasicError `json:"_type,omitempty"`
1451 }
1452
1453 func unmarshalBasicError(body []byte) (BasicError, error) {
1454 var m map[string]interface{}
1455 err := json.Unmarshal(body, &m)
1456 if err != nil {
1457 return nil, err
1458 }
1459
1460 switch m["_type"] {
1461 default:
1462 var e Error
1463 err := json.Unmarshal(body, &e)
1464 return e, err
1465 }
1466 }
1467 func unmarshalBasicErrorArray(body []byte) ([]BasicError, error) {
1468 var rawMessages []*json.RawMessage
1469 err := json.Unmarshal(body, &rawMessages)
1470 if err != nil {
1471 return nil, err
1472 }
1473
1474 eArray := make([]BasicError, len(rawMessages))
1475
1476 for index, rawMessage := range rawMessages {
1477 e, err := unmarshalBasicError(*rawMessage)
1478 if err != nil {
1479 return nil, err
1480 }
1481 eArray[index] = e
1482 }
1483 return eArray, nil
1484 }
1485
1486
1487 func (e Error) MarshalJSON() ([]byte, error) {
1488 e.Type = TypeError
1489 objectMap := make(map[string]interface{})
1490 if e.Code != "" {
1491 objectMap["code"] = e.Code
1492 }
1493 if e.Message != nil {
1494 objectMap["message"] = e.Message
1495 }
1496 if e.Type != "" {
1497 objectMap["_type"] = e.Type
1498 }
1499 return json.Marshal(objectMap)
1500 }
1501
1502
1503 func (e Error) AsError() (*Error, bool) {
1504 return &e, true
1505 }
1506
1507
1508 func (e Error) AsBasicError() (BasicError, bool) {
1509 return &e, true
1510 }
1511
1512
1513 type ErrorResponse struct {
1514
1515 Errors *[]BasicError `json:"errors,omitempty"`
1516
1517 ReadLink *string `json:"readLink,omitempty"`
1518
1519 WebSearchURL *string `json:"webSearchUrl,omitempty"`
1520
1521 PotentialAction *[]BasicAction `json:"potentialAction,omitempty"`
1522
1523 ImmediateAction *[]BasicAction `json:"immediateAction,omitempty"`
1524
1525 PreferredClickthroughURL *string `json:"preferredClickthroughUrl,omitempty"`
1526
1527 AdaptiveCard *string `json:"adaptiveCard,omitempty"`
1528
1529 ID *string `json:"id,omitempty"`
1530
1531 Type TypeBasicResponseBase `json:"_type,omitempty"`
1532 }
1533
1534
1535 func (er ErrorResponse) MarshalJSON() ([]byte, error) {
1536 er.Type = TypeErrorResponse
1537 objectMap := make(map[string]interface{})
1538 if er.Errors != nil {
1539 objectMap["errors"] = er.Errors
1540 }
1541 if er.Type != "" {
1542 objectMap["_type"] = er.Type
1543 }
1544 return json.Marshal(objectMap)
1545 }
1546
1547
1548 func (er ErrorResponse) AsThing() (*Thing, bool) {
1549 return nil, false
1550 }
1551
1552
1553 func (er ErrorResponse) AsBasicThing() (BasicThing, bool) {
1554 return nil, false
1555 }
1556
1557
1558 func (er ErrorResponse) AsPlaces() (*Places, bool) {
1559 return nil, false
1560 }
1561
1562
1563 func (er ErrorResponse) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) {
1564 return nil, false
1565 }
1566
1567
1568 func (er ErrorResponse) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) {
1569 return nil, false
1570 }
1571
1572
1573 func (er ErrorResponse) AsSearchResponse() (*SearchResponse, bool) {
1574 return nil, false
1575 }
1576
1577
1578 func (er ErrorResponse) AsPostalAddress() (*PostalAddress, bool) {
1579 return nil, false
1580 }
1581
1582
1583 func (er ErrorResponse) AsPlace() (*Place, bool) {
1584 return nil, false
1585 }
1586
1587
1588 func (er ErrorResponse) AsAction() (*Action, bool) {
1589 return nil, false
1590 }
1591
1592
1593 func (er ErrorResponse) AsBasicAction() (BasicAction, bool) {
1594 return nil, false
1595 }
1596
1597
1598 func (er ErrorResponse) AsResponse() (*Response, bool) {
1599 return nil, false
1600 }
1601
1602
1603 func (er ErrorResponse) AsBasicResponse() (BasicResponse, bool) {
1604 return &er, true
1605 }
1606
1607
1608 func (er ErrorResponse) AsIdentifiable() (*Identifiable, bool) {
1609 return nil, false
1610 }
1611
1612
1613 func (er ErrorResponse) AsBasicIdentifiable() (BasicIdentifiable, bool) {
1614 return &er, true
1615 }
1616
1617
1618 func (er ErrorResponse) AsAnswer() (*Answer, bool) {
1619 return nil, false
1620 }
1621
1622
1623 func (er ErrorResponse) AsBasicAnswer() (BasicAnswer, bool) {
1624 return nil, false
1625 }
1626
1627
1628 func (er ErrorResponse) AsErrorResponse() (*ErrorResponse, bool) {
1629 return &er, true
1630 }
1631
1632
1633 func (er ErrorResponse) AsCreativeWork() (*CreativeWork, bool) {
1634 return nil, false
1635 }
1636
1637
1638 func (er ErrorResponse) AsBasicCreativeWork() (BasicCreativeWork, bool) {
1639 return nil, false
1640 }
1641
1642
1643 func (er ErrorResponse) AsIntangible() (*Intangible, bool) {
1644 return nil, false
1645 }
1646
1647
1648 func (er ErrorResponse) AsBasicIntangible() (BasicIntangible, bool) {
1649 return nil, false
1650 }
1651
1652
1653 func (er ErrorResponse) AsSearchAction() (*SearchAction, bool) {
1654 return nil, false
1655 }
1656
1657
1658 func (er ErrorResponse) AsStructuredValue() (*StructuredValue, bool) {
1659 return nil, false
1660 }
1661
1662
1663 func (er ErrorResponse) AsBasicStructuredValue() (BasicStructuredValue, bool) {
1664 return nil, false
1665 }
1666
1667
1668 func (er ErrorResponse) AsResponseBase() (*ResponseBase, bool) {
1669 return nil, false
1670 }
1671
1672
1673 func (er ErrorResponse) AsBasicResponseBase() (BasicResponseBase, bool) {
1674 return &er, true
1675 }
1676
1677
1678 func (er *ErrorResponse) UnmarshalJSON(body []byte) error {
1679 var m map[string]*json.RawMessage
1680 err := json.Unmarshal(body, &m)
1681 if err != nil {
1682 return err
1683 }
1684 for k, v := range m {
1685 switch k {
1686 case "errors":
1687 if v != nil {
1688 errorsVar, err := unmarshalBasicErrorArray(*v)
1689 if err != nil {
1690 return err
1691 }
1692 er.Errors = &errorsVar
1693 }
1694 case "readLink":
1695 if v != nil {
1696 var readLink string
1697 err = json.Unmarshal(*v, &readLink)
1698 if err != nil {
1699 return err
1700 }
1701 er.ReadLink = &readLink
1702 }
1703 case "webSearchUrl":
1704 if v != nil {
1705 var webSearchURL string
1706 err = json.Unmarshal(*v, &webSearchURL)
1707 if err != nil {
1708 return err
1709 }
1710 er.WebSearchURL = &webSearchURL
1711 }
1712 case "potentialAction":
1713 if v != nil {
1714 potentialAction, err := unmarshalBasicActionArray(*v)
1715 if err != nil {
1716 return err
1717 }
1718 er.PotentialAction = &potentialAction
1719 }
1720 case "immediateAction":
1721 if v != nil {
1722 immediateAction, err := unmarshalBasicActionArray(*v)
1723 if err != nil {
1724 return err
1725 }
1726 er.ImmediateAction = &immediateAction
1727 }
1728 case "preferredClickthroughUrl":
1729 if v != nil {
1730 var preferredClickthroughURL string
1731 err = json.Unmarshal(*v, &preferredClickthroughURL)
1732 if err != nil {
1733 return err
1734 }
1735 er.PreferredClickthroughURL = &preferredClickthroughURL
1736 }
1737 case "adaptiveCard":
1738 if v != nil {
1739 var adaptiveCard string
1740 err = json.Unmarshal(*v, &adaptiveCard)
1741 if err != nil {
1742 return err
1743 }
1744 er.AdaptiveCard = &adaptiveCard
1745 }
1746 case "id":
1747 if v != nil {
1748 var ID string
1749 err = json.Unmarshal(*v, &ID)
1750 if err != nil {
1751 return err
1752 }
1753 er.ID = &ID
1754 }
1755 case "_type":
1756 if v != nil {
1757 var typeVar TypeBasicResponseBase
1758 err = json.Unmarshal(*v, &typeVar)
1759 if err != nil {
1760 return err
1761 }
1762 er.Type = typeVar
1763 }
1764 }
1765 }
1766
1767 return nil
1768 }
1769
1770
1771 type BasicGeoCoordinates interface {
1772 AsGeoCoordinates() (*GeoCoordinates, bool)
1773 }
1774
1775
1776 type GeoCoordinates struct {
1777 Latitude *float64 `json:"latitude,omitempty"`
1778 Longitude *float64 `json:"longitude,omitempty"`
1779
1780 Elevation *float64 `json:"elevation,omitempty"`
1781
1782 Type TypeBasicGeoCoordinates `json:"_type,omitempty"`
1783 }
1784
1785 func unmarshalBasicGeoCoordinates(body []byte) (BasicGeoCoordinates, error) {
1786 var m map[string]interface{}
1787 err := json.Unmarshal(body, &m)
1788 if err != nil {
1789 return nil, err
1790 }
1791
1792 switch m["_type"] {
1793 default:
1794 var gc GeoCoordinates
1795 err := json.Unmarshal(body, &gc)
1796 return gc, err
1797 }
1798 }
1799 func unmarshalBasicGeoCoordinatesArray(body []byte) ([]BasicGeoCoordinates, error) {
1800 var rawMessages []*json.RawMessage
1801 err := json.Unmarshal(body, &rawMessages)
1802 if err != nil {
1803 return nil, err
1804 }
1805
1806 gcArray := make([]BasicGeoCoordinates, len(rawMessages))
1807
1808 for index, rawMessage := range rawMessages {
1809 gc, err := unmarshalBasicGeoCoordinates(*rawMessage)
1810 if err != nil {
1811 return nil, err
1812 }
1813 gcArray[index] = gc
1814 }
1815 return gcArray, nil
1816 }
1817
1818
1819 func (gc GeoCoordinates) MarshalJSON() ([]byte, error) {
1820 gc.Type = TypeGeoCoordinates
1821 objectMap := make(map[string]interface{})
1822 if gc.Latitude != nil {
1823 objectMap["latitude"] = gc.Latitude
1824 }
1825 if gc.Longitude != nil {
1826 objectMap["longitude"] = gc.Longitude
1827 }
1828 if gc.Type != "" {
1829 objectMap["_type"] = gc.Type
1830 }
1831 return json.Marshal(objectMap)
1832 }
1833
1834
1835 func (gc GeoCoordinates) AsGeoCoordinates() (*GeoCoordinates, bool) {
1836 return &gc, true
1837 }
1838
1839
1840 func (gc GeoCoordinates) AsBasicGeoCoordinates() (BasicGeoCoordinates, bool) {
1841 return &gc, true
1842 }
1843
1844
1845 type BasicIdentifiable interface {
1846 AsThing() (*Thing, bool)
1847 AsBasicThing() (BasicThing, bool)
1848 AsPlaces() (*Places, bool)
1849 AsSearchResultsAnswer() (*SearchResultsAnswer, bool)
1850 AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool)
1851 AsSearchResponse() (*SearchResponse, bool)
1852 AsPostalAddress() (*PostalAddress, bool)
1853 AsPlace() (*Place, bool)
1854 AsAction() (*Action, bool)
1855 AsBasicAction() (BasicAction, bool)
1856 AsResponse() (*Response, bool)
1857 AsBasicResponse() (BasicResponse, bool)
1858 AsAnswer() (*Answer, bool)
1859 AsBasicAnswer() (BasicAnswer, bool)
1860 AsErrorResponse() (*ErrorResponse, bool)
1861 AsCreativeWork() (*CreativeWork, bool)
1862 AsBasicCreativeWork() (BasicCreativeWork, bool)
1863 AsIntangible() (*Intangible, bool)
1864 AsBasicIntangible() (BasicIntangible, bool)
1865 AsSearchAction() (*SearchAction, bool)
1866 AsStructuredValue() (*StructuredValue, bool)
1867 AsBasicStructuredValue() (BasicStructuredValue, bool)
1868 AsIdentifiable() (*Identifiable, bool)
1869 }
1870
1871
1872 type Identifiable struct {
1873
1874 ID *string `json:"id,omitempty"`
1875
1876 Type TypeBasicResponseBase `json:"_type,omitempty"`
1877 }
1878
1879 func unmarshalBasicIdentifiable(body []byte) (BasicIdentifiable, error) {
1880 var m map[string]interface{}
1881 err := json.Unmarshal(body, &m)
1882 if err != nil {
1883 return nil, err
1884 }
1885
1886 switch m["_type"] {
1887 case string(TypeThing):
1888 var t Thing
1889 err := json.Unmarshal(body, &t)
1890 return t, err
1891 case string(TypePlaces):
1892 var p Places
1893 err := json.Unmarshal(body, &p)
1894 return p, err
1895 case string(TypeSearchResultsAnswer):
1896 var sra SearchResultsAnswer
1897 err := json.Unmarshal(body, &sra)
1898 return sra, err
1899 case string(TypeSearchResponse):
1900 var sr SearchResponse
1901 err := json.Unmarshal(body, &sr)
1902 return sr, err
1903 case string(TypePostalAddress):
1904 var pa PostalAddress
1905 err := json.Unmarshal(body, &pa)
1906 return pa, err
1907 case string(TypePlace):
1908 var p Place
1909 err := json.Unmarshal(body, &p)
1910 return p, err
1911 case string(TypeAction):
1912 var a Action
1913 err := json.Unmarshal(body, &a)
1914 return a, err
1915 case string(TypeResponse):
1916 var r Response
1917 err := json.Unmarshal(body, &r)
1918 return r, err
1919 case string(TypeAnswer):
1920 var a Answer
1921 err := json.Unmarshal(body, &a)
1922 return a, err
1923 case string(TypeErrorResponse):
1924 var er ErrorResponse
1925 err := json.Unmarshal(body, &er)
1926 return er, err
1927 case string(TypeCreativeWork):
1928 var cw CreativeWork
1929 err := json.Unmarshal(body, &cw)
1930 return cw, err
1931 case string(TypeIntangible):
1932 var i Intangible
1933 err := json.Unmarshal(body, &i)
1934 return i, err
1935 case string(TypeSearchAction):
1936 var sa SearchAction
1937 err := json.Unmarshal(body, &sa)
1938 return sa, err
1939 case string(TypeStructuredValue):
1940 var sv StructuredValue
1941 err := json.Unmarshal(body, &sv)
1942 return sv, err
1943 default:
1944 var i Identifiable
1945 err := json.Unmarshal(body, &i)
1946 return i, err
1947 }
1948 }
1949 func unmarshalBasicIdentifiableArray(body []byte) ([]BasicIdentifiable, error) {
1950 var rawMessages []*json.RawMessage
1951 err := json.Unmarshal(body, &rawMessages)
1952 if err != nil {
1953 return nil, err
1954 }
1955
1956 iArray := make([]BasicIdentifiable, len(rawMessages))
1957
1958 for index, rawMessage := range rawMessages {
1959 i, err := unmarshalBasicIdentifiable(*rawMessage)
1960 if err != nil {
1961 return nil, err
1962 }
1963 iArray[index] = i
1964 }
1965 return iArray, nil
1966 }
1967
1968
1969 func (i Identifiable) MarshalJSON() ([]byte, error) {
1970 i.Type = TypeIdentifiable
1971 objectMap := make(map[string]interface{})
1972 if i.Type != "" {
1973 objectMap["_type"] = i.Type
1974 }
1975 return json.Marshal(objectMap)
1976 }
1977
1978
1979 func (i Identifiable) AsThing() (*Thing, bool) {
1980 return nil, false
1981 }
1982
1983
1984 func (i Identifiable) AsBasicThing() (BasicThing, bool) {
1985 return nil, false
1986 }
1987
1988
1989 func (i Identifiable) AsPlaces() (*Places, bool) {
1990 return nil, false
1991 }
1992
1993
1994 func (i Identifiable) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) {
1995 return nil, false
1996 }
1997
1998
1999 func (i Identifiable) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) {
2000 return nil, false
2001 }
2002
2003
2004 func (i Identifiable) AsSearchResponse() (*SearchResponse, bool) {
2005 return nil, false
2006 }
2007
2008
2009 func (i Identifiable) AsPostalAddress() (*PostalAddress, bool) {
2010 return nil, false
2011 }
2012
2013
2014 func (i Identifiable) AsPlace() (*Place, bool) {
2015 return nil, false
2016 }
2017
2018
2019 func (i Identifiable) AsAction() (*Action, bool) {
2020 return nil, false
2021 }
2022
2023
2024 func (i Identifiable) AsBasicAction() (BasicAction, bool) {
2025 return nil, false
2026 }
2027
2028
2029 func (i Identifiable) AsResponse() (*Response, bool) {
2030 return nil, false
2031 }
2032
2033
2034 func (i Identifiable) AsBasicResponse() (BasicResponse, bool) {
2035 return nil, false
2036 }
2037
2038
2039 func (i Identifiable) AsIdentifiable() (*Identifiable, bool) {
2040 return &i, true
2041 }
2042
2043
2044 func (i Identifiable) AsBasicIdentifiable() (BasicIdentifiable, bool) {
2045 return &i, true
2046 }
2047
2048
2049 func (i Identifiable) AsAnswer() (*Answer, bool) {
2050 return nil, false
2051 }
2052
2053
2054 func (i Identifiable) AsBasicAnswer() (BasicAnswer, bool) {
2055 return nil, false
2056 }
2057
2058
2059 func (i Identifiable) AsErrorResponse() (*ErrorResponse, bool) {
2060 return nil, false
2061 }
2062
2063
2064 func (i Identifiable) AsCreativeWork() (*CreativeWork, bool) {
2065 return nil, false
2066 }
2067
2068
2069 func (i Identifiable) AsBasicCreativeWork() (BasicCreativeWork, bool) {
2070 return nil, false
2071 }
2072
2073
2074 func (i Identifiable) AsIntangible() (*Intangible, bool) {
2075 return nil, false
2076 }
2077
2078
2079 func (i Identifiable) AsBasicIntangible() (BasicIntangible, bool) {
2080 return nil, false
2081 }
2082
2083
2084 func (i Identifiable) AsSearchAction() (*SearchAction, bool) {
2085 return nil, false
2086 }
2087
2088
2089 func (i Identifiable) AsStructuredValue() (*StructuredValue, bool) {
2090 return nil, false
2091 }
2092
2093
2094 func (i Identifiable) AsBasicStructuredValue() (BasicStructuredValue, bool) {
2095 return nil, false
2096 }
2097
2098
2099 func (i Identifiable) AsResponseBase() (*ResponseBase, bool) {
2100 return nil, false
2101 }
2102
2103
2104 func (i Identifiable) AsBasicResponseBase() (BasicResponseBase, bool) {
2105 return &i, true
2106 }
2107
2108
2109
2110 type BasicIntangible interface {
2111 AsPostalAddress() (*PostalAddress, bool)
2112 AsStructuredValue() (*StructuredValue, bool)
2113 AsBasicStructuredValue() (BasicStructuredValue, bool)
2114 AsIntangible() (*Intangible, bool)
2115 }
2116
2117
2118
2119 type Intangible struct {
2120
2121 Name *string `json:"name,omitempty"`
2122
2123 URL *string `json:"url,omitempty"`
2124
2125 EntityPresentationInfo BasicEntitiesEntityPresentationInfo `json:"entityPresentationInfo,omitempty"`
2126
2127 ReadLink *string `json:"readLink,omitempty"`
2128
2129 WebSearchURL *string `json:"webSearchUrl,omitempty"`
2130
2131 PotentialAction *[]BasicAction `json:"potentialAction,omitempty"`
2132
2133 ImmediateAction *[]BasicAction `json:"immediateAction,omitempty"`
2134
2135 PreferredClickthroughURL *string `json:"preferredClickthroughUrl,omitempty"`
2136
2137 AdaptiveCard *string `json:"adaptiveCard,omitempty"`
2138
2139 ID *string `json:"id,omitempty"`
2140
2141 Type TypeBasicResponseBase `json:"_type,omitempty"`
2142 }
2143
2144 func unmarshalBasicIntangible(body []byte) (BasicIntangible, error) {
2145 var m map[string]interface{}
2146 err := json.Unmarshal(body, &m)
2147 if err != nil {
2148 return nil, err
2149 }
2150
2151 switch m["_type"] {
2152 case string(TypePostalAddress):
2153 var pa PostalAddress
2154 err := json.Unmarshal(body, &pa)
2155 return pa, err
2156 case string(TypeStructuredValue):
2157 var sv StructuredValue
2158 err := json.Unmarshal(body, &sv)
2159 return sv, err
2160 default:
2161 var i Intangible
2162 err := json.Unmarshal(body, &i)
2163 return i, err
2164 }
2165 }
2166 func unmarshalBasicIntangibleArray(body []byte) ([]BasicIntangible, error) {
2167 var rawMessages []*json.RawMessage
2168 err := json.Unmarshal(body, &rawMessages)
2169 if err != nil {
2170 return nil, err
2171 }
2172
2173 iArray := make([]BasicIntangible, len(rawMessages))
2174
2175 for index, rawMessage := range rawMessages {
2176 i, err := unmarshalBasicIntangible(*rawMessage)
2177 if err != nil {
2178 return nil, err
2179 }
2180 iArray[index] = i
2181 }
2182 return iArray, nil
2183 }
2184
2185
2186 func (i Intangible) MarshalJSON() ([]byte, error) {
2187 i.Type = TypeIntangible
2188 objectMap := make(map[string]interface{})
2189 if i.Type != "" {
2190 objectMap["_type"] = i.Type
2191 }
2192 return json.Marshal(objectMap)
2193 }
2194
2195
2196 func (i Intangible) AsThing() (*Thing, bool) {
2197 return nil, false
2198 }
2199
2200
2201 func (i Intangible) AsBasicThing() (BasicThing, bool) {
2202 return &i, true
2203 }
2204
2205
2206 func (i Intangible) AsPlaces() (*Places, bool) {
2207 return nil, false
2208 }
2209
2210
2211 func (i Intangible) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) {
2212 return nil, false
2213 }
2214
2215
2216 func (i Intangible) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) {
2217 return nil, false
2218 }
2219
2220
2221 func (i Intangible) AsSearchResponse() (*SearchResponse, bool) {
2222 return nil, false
2223 }
2224
2225
2226 func (i Intangible) AsPostalAddress() (*PostalAddress, bool) {
2227 return nil, false
2228 }
2229
2230
2231 func (i Intangible) AsPlace() (*Place, bool) {
2232 return nil, false
2233 }
2234
2235
2236 func (i Intangible) AsAction() (*Action, bool) {
2237 return nil, false
2238 }
2239
2240
2241 func (i Intangible) AsBasicAction() (BasicAction, bool) {
2242 return nil, false
2243 }
2244
2245
2246 func (i Intangible) AsResponse() (*Response, bool) {
2247 return nil, false
2248 }
2249
2250
2251 func (i Intangible) AsBasicResponse() (BasicResponse, bool) {
2252 return &i, true
2253 }
2254
2255
2256 func (i Intangible) AsIdentifiable() (*Identifiable, bool) {
2257 return nil, false
2258 }
2259
2260
2261 func (i Intangible) AsBasicIdentifiable() (BasicIdentifiable, bool) {
2262 return &i, true
2263 }
2264
2265
2266 func (i Intangible) AsAnswer() (*Answer, bool) {
2267 return nil, false
2268 }
2269
2270
2271 func (i Intangible) AsBasicAnswer() (BasicAnswer, bool) {
2272 return nil, false
2273 }
2274
2275
2276 func (i Intangible) AsErrorResponse() (*ErrorResponse, bool) {
2277 return nil, false
2278 }
2279
2280
2281 func (i Intangible) AsCreativeWork() (*CreativeWork, bool) {
2282 return nil, false
2283 }
2284
2285
2286 func (i Intangible) AsBasicCreativeWork() (BasicCreativeWork, bool) {
2287 return nil, false
2288 }
2289
2290
2291 func (i Intangible) AsIntangible() (*Intangible, bool) {
2292 return &i, true
2293 }
2294
2295
2296 func (i Intangible) AsBasicIntangible() (BasicIntangible, bool) {
2297 return &i, true
2298 }
2299
2300
2301 func (i Intangible) AsSearchAction() (*SearchAction, bool) {
2302 return nil, false
2303 }
2304
2305
2306 func (i Intangible) AsStructuredValue() (*StructuredValue, bool) {
2307 return nil, false
2308 }
2309
2310
2311 func (i Intangible) AsBasicStructuredValue() (BasicStructuredValue, bool) {
2312 return nil, false
2313 }
2314
2315
2316 func (i Intangible) AsResponseBase() (*ResponseBase, bool) {
2317 return nil, false
2318 }
2319
2320
2321 func (i Intangible) AsBasicResponseBase() (BasicResponseBase, bool) {
2322 return &i, true
2323 }
2324
2325
2326 func (i *Intangible) UnmarshalJSON(body []byte) error {
2327 var m map[string]*json.RawMessage
2328 err := json.Unmarshal(body, &m)
2329 if err != nil {
2330 return err
2331 }
2332 for k, v := range m {
2333 switch k {
2334 case "name":
2335 if v != nil {
2336 var name string
2337 err = json.Unmarshal(*v, &name)
2338 if err != nil {
2339 return err
2340 }
2341 i.Name = &name
2342 }
2343 case "url":
2344 if v != nil {
2345 var URL string
2346 err = json.Unmarshal(*v, &URL)
2347 if err != nil {
2348 return err
2349 }
2350 i.URL = &URL
2351 }
2352 case "entityPresentationInfo":
2353 if v != nil {
2354 entityPresentationInfo, err := unmarshalBasicEntitiesEntityPresentationInfo(*v)
2355 if err != nil {
2356 return err
2357 }
2358 i.EntityPresentationInfo = entityPresentationInfo
2359 }
2360 case "readLink":
2361 if v != nil {
2362 var readLink string
2363 err = json.Unmarshal(*v, &readLink)
2364 if err != nil {
2365 return err
2366 }
2367 i.ReadLink = &readLink
2368 }
2369 case "webSearchUrl":
2370 if v != nil {
2371 var webSearchURL string
2372 err = json.Unmarshal(*v, &webSearchURL)
2373 if err != nil {
2374 return err
2375 }
2376 i.WebSearchURL = &webSearchURL
2377 }
2378 case "potentialAction":
2379 if v != nil {
2380 potentialAction, err := unmarshalBasicActionArray(*v)
2381 if err != nil {
2382 return err
2383 }
2384 i.PotentialAction = &potentialAction
2385 }
2386 case "immediateAction":
2387 if v != nil {
2388 immediateAction, err := unmarshalBasicActionArray(*v)
2389 if err != nil {
2390 return err
2391 }
2392 i.ImmediateAction = &immediateAction
2393 }
2394 case "preferredClickthroughUrl":
2395 if v != nil {
2396 var preferredClickthroughURL string
2397 err = json.Unmarshal(*v, &preferredClickthroughURL)
2398 if err != nil {
2399 return err
2400 }
2401 i.PreferredClickthroughURL = &preferredClickthroughURL
2402 }
2403 case "adaptiveCard":
2404 if v != nil {
2405 var adaptiveCard string
2406 err = json.Unmarshal(*v, &adaptiveCard)
2407 if err != nil {
2408 return err
2409 }
2410 i.AdaptiveCard = &adaptiveCard
2411 }
2412 case "id":
2413 if v != nil {
2414 var ID string
2415 err = json.Unmarshal(*v, &ID)
2416 if err != nil {
2417 return err
2418 }
2419 i.ID = &ID
2420 }
2421 case "_type":
2422 if v != nil {
2423 var typeVar TypeBasicResponseBase
2424 err = json.Unmarshal(*v, &typeVar)
2425 if err != nil {
2426 return err
2427 }
2428 i.Type = typeVar
2429 }
2430 }
2431 }
2432
2433 return nil
2434 }
2435
2436
2437 type Place struct {
2438
2439 Geo BasicGeoCoordinates `json:"geo,omitempty"`
2440
2441 RoutablePoint BasicGeoCoordinates `json:"routablePoint,omitempty"`
2442
2443 Address *PostalAddress `json:"address,omitempty"`
2444
2445 Telephone *string `json:"telephone,omitempty"`
2446
2447 Name *string `json:"name,omitempty"`
2448
2449 URL *string `json:"url,omitempty"`
2450
2451 EntityPresentationInfo BasicEntitiesEntityPresentationInfo `json:"entityPresentationInfo,omitempty"`
2452
2453 ReadLink *string `json:"readLink,omitempty"`
2454
2455 WebSearchURL *string `json:"webSearchUrl,omitempty"`
2456
2457 PotentialAction *[]BasicAction `json:"potentialAction,omitempty"`
2458
2459 ImmediateAction *[]BasicAction `json:"immediateAction,omitempty"`
2460
2461 PreferredClickthroughURL *string `json:"preferredClickthroughUrl,omitempty"`
2462
2463 AdaptiveCard *string `json:"adaptiveCard,omitempty"`
2464
2465 ID *string `json:"id,omitempty"`
2466
2467 Type TypeBasicResponseBase `json:"_type,omitempty"`
2468 }
2469
2470
2471 func (p Place) MarshalJSON() ([]byte, error) {
2472 p.Type = TypePlace
2473 objectMap := make(map[string]interface{})
2474 if p.Type != "" {
2475 objectMap["_type"] = p.Type
2476 }
2477 return json.Marshal(objectMap)
2478 }
2479
2480
2481 func (p Place) AsThing() (*Thing, bool) {
2482 return nil, false
2483 }
2484
2485
2486 func (p Place) AsBasicThing() (BasicThing, bool) {
2487 return &p, true
2488 }
2489
2490
2491 func (p Place) AsPlaces() (*Places, bool) {
2492 return nil, false
2493 }
2494
2495
2496 func (p Place) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) {
2497 return nil, false
2498 }
2499
2500
2501 func (p Place) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) {
2502 return nil, false
2503 }
2504
2505
2506 func (p Place) AsSearchResponse() (*SearchResponse, bool) {
2507 return nil, false
2508 }
2509
2510
2511 func (p Place) AsPostalAddress() (*PostalAddress, bool) {
2512 return nil, false
2513 }
2514
2515
2516 func (p Place) AsPlace() (*Place, bool) {
2517 return &p, true
2518 }
2519
2520
2521 func (p Place) AsAction() (*Action, bool) {
2522 return nil, false
2523 }
2524
2525
2526 func (p Place) AsBasicAction() (BasicAction, bool) {
2527 return nil, false
2528 }
2529
2530
2531 func (p Place) AsResponse() (*Response, bool) {
2532 return nil, false
2533 }
2534
2535
2536 func (p Place) AsBasicResponse() (BasicResponse, bool) {
2537 return &p, true
2538 }
2539
2540
2541 func (p Place) AsIdentifiable() (*Identifiable, bool) {
2542 return nil, false
2543 }
2544
2545
2546 func (p Place) AsBasicIdentifiable() (BasicIdentifiable, bool) {
2547 return &p, true
2548 }
2549
2550
2551 func (p Place) AsAnswer() (*Answer, bool) {
2552 return nil, false
2553 }
2554
2555
2556 func (p Place) AsBasicAnswer() (BasicAnswer, bool) {
2557 return nil, false
2558 }
2559
2560
2561 func (p Place) AsErrorResponse() (*ErrorResponse, bool) {
2562 return nil, false
2563 }
2564
2565
2566 func (p Place) AsCreativeWork() (*CreativeWork, bool) {
2567 return nil, false
2568 }
2569
2570
2571 func (p Place) AsBasicCreativeWork() (BasicCreativeWork, bool) {
2572 return nil, false
2573 }
2574
2575
2576 func (p Place) AsIntangible() (*Intangible, bool) {
2577 return nil, false
2578 }
2579
2580
2581 func (p Place) AsBasicIntangible() (BasicIntangible, bool) {
2582 return nil, false
2583 }
2584
2585
2586 func (p Place) AsSearchAction() (*SearchAction, bool) {
2587 return nil, false
2588 }
2589
2590
2591 func (p Place) AsStructuredValue() (*StructuredValue, bool) {
2592 return nil, false
2593 }
2594
2595
2596 func (p Place) AsBasicStructuredValue() (BasicStructuredValue, bool) {
2597 return nil, false
2598 }
2599
2600
2601 func (p Place) AsResponseBase() (*ResponseBase, bool) {
2602 return nil, false
2603 }
2604
2605
2606 func (p Place) AsBasicResponseBase() (BasicResponseBase, bool) {
2607 return &p, true
2608 }
2609
2610
2611 func (p *Place) UnmarshalJSON(body []byte) error {
2612 var m map[string]*json.RawMessage
2613 err := json.Unmarshal(body, &m)
2614 if err != nil {
2615 return err
2616 }
2617 for k, v := range m {
2618 switch k {
2619 case "geo":
2620 if v != nil {
2621 geo, err := unmarshalBasicGeoCoordinates(*v)
2622 if err != nil {
2623 return err
2624 }
2625 p.Geo = geo
2626 }
2627 case "routablePoint":
2628 if v != nil {
2629 routablePoint, err := unmarshalBasicGeoCoordinates(*v)
2630 if err != nil {
2631 return err
2632 }
2633 p.RoutablePoint = routablePoint
2634 }
2635 case "address":
2636 if v != nil {
2637 var address PostalAddress
2638 err = json.Unmarshal(*v, &address)
2639 if err != nil {
2640 return err
2641 }
2642 p.Address = &address
2643 }
2644 case "telephone":
2645 if v != nil {
2646 var telephone string
2647 err = json.Unmarshal(*v, &telephone)
2648 if err != nil {
2649 return err
2650 }
2651 p.Telephone = &telephone
2652 }
2653 case "name":
2654 if v != nil {
2655 var name string
2656 err = json.Unmarshal(*v, &name)
2657 if err != nil {
2658 return err
2659 }
2660 p.Name = &name
2661 }
2662 case "url":
2663 if v != nil {
2664 var URL string
2665 err = json.Unmarshal(*v, &URL)
2666 if err != nil {
2667 return err
2668 }
2669 p.URL = &URL
2670 }
2671 case "entityPresentationInfo":
2672 if v != nil {
2673 entityPresentationInfo, err := unmarshalBasicEntitiesEntityPresentationInfo(*v)
2674 if err != nil {
2675 return err
2676 }
2677 p.EntityPresentationInfo = entityPresentationInfo
2678 }
2679 case "readLink":
2680 if v != nil {
2681 var readLink string
2682 err = json.Unmarshal(*v, &readLink)
2683 if err != nil {
2684 return err
2685 }
2686 p.ReadLink = &readLink
2687 }
2688 case "webSearchUrl":
2689 if v != nil {
2690 var webSearchURL string
2691 err = json.Unmarshal(*v, &webSearchURL)
2692 if err != nil {
2693 return err
2694 }
2695 p.WebSearchURL = &webSearchURL
2696 }
2697 case "potentialAction":
2698 if v != nil {
2699 potentialAction, err := unmarshalBasicActionArray(*v)
2700 if err != nil {
2701 return err
2702 }
2703 p.PotentialAction = &potentialAction
2704 }
2705 case "immediateAction":
2706 if v != nil {
2707 immediateAction, err := unmarshalBasicActionArray(*v)
2708 if err != nil {
2709 return err
2710 }
2711 p.ImmediateAction = &immediateAction
2712 }
2713 case "preferredClickthroughUrl":
2714 if v != nil {
2715 var preferredClickthroughURL string
2716 err = json.Unmarshal(*v, &preferredClickthroughURL)
2717 if err != nil {
2718 return err
2719 }
2720 p.PreferredClickthroughURL = &preferredClickthroughURL
2721 }
2722 case "adaptiveCard":
2723 if v != nil {
2724 var adaptiveCard string
2725 err = json.Unmarshal(*v, &adaptiveCard)
2726 if err != nil {
2727 return err
2728 }
2729 p.AdaptiveCard = &adaptiveCard
2730 }
2731 case "id":
2732 if v != nil {
2733 var ID string
2734 err = json.Unmarshal(*v, &ID)
2735 if err != nil {
2736 return err
2737 }
2738 p.ID = &ID
2739 }
2740 case "_type":
2741 if v != nil {
2742 var typeVar TypeBasicResponseBase
2743 err = json.Unmarshal(*v, &typeVar)
2744 if err != nil {
2745 return err
2746 }
2747 p.Type = typeVar
2748 }
2749 }
2750 }
2751
2752 return nil
2753 }
2754
2755
2756 type Places struct {
2757
2758 Value *[]BasicThing `json:"value,omitempty"`
2759
2760 QueryContext BasicQueryContext `json:"queryContext,omitempty"`
2761
2762 TotalEstimatedMatches *int64 `json:"totalEstimatedMatches,omitempty"`
2763
2764 IsFamilyFriendly *bool `json:"isFamilyFriendly,omitempty"`
2765
2766 ReadLink *string `json:"readLink,omitempty"`
2767
2768 WebSearchURL *string `json:"webSearchUrl,omitempty"`
2769
2770 PotentialAction *[]BasicAction `json:"potentialAction,omitempty"`
2771
2772 ImmediateAction *[]BasicAction `json:"immediateAction,omitempty"`
2773
2774 PreferredClickthroughURL *string `json:"preferredClickthroughUrl,omitempty"`
2775
2776 AdaptiveCard *string `json:"adaptiveCard,omitempty"`
2777
2778 ID *string `json:"id,omitempty"`
2779
2780 Type TypeBasicResponseBase `json:"_type,omitempty"`
2781 }
2782
2783
2784 func (p Places) MarshalJSON() ([]byte, error) {
2785 p.Type = TypePlaces
2786 objectMap := make(map[string]interface{})
2787 if p.Value != nil {
2788 objectMap["value"] = p.Value
2789 }
2790 if p.Type != "" {
2791 objectMap["_type"] = p.Type
2792 }
2793 return json.Marshal(objectMap)
2794 }
2795
2796
2797 func (p Places) AsThing() (*Thing, bool) {
2798 return nil, false
2799 }
2800
2801
2802 func (p Places) AsBasicThing() (BasicThing, bool) {
2803 return nil, false
2804 }
2805
2806
2807 func (p Places) AsPlaces() (*Places, bool) {
2808 return &p, true
2809 }
2810
2811
2812 func (p Places) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) {
2813 return nil, false
2814 }
2815
2816
2817 func (p Places) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) {
2818 return &p, true
2819 }
2820
2821
2822 func (p Places) AsSearchResponse() (*SearchResponse, bool) {
2823 return nil, false
2824 }
2825
2826
2827 func (p Places) AsPostalAddress() (*PostalAddress, bool) {
2828 return nil, false
2829 }
2830
2831
2832 func (p Places) AsPlace() (*Place, bool) {
2833 return nil, false
2834 }
2835
2836
2837 func (p Places) AsAction() (*Action, bool) {
2838 return nil, false
2839 }
2840
2841
2842 func (p Places) AsBasicAction() (BasicAction, bool) {
2843 return nil, false
2844 }
2845
2846
2847 func (p Places) AsResponse() (*Response, bool) {
2848 return nil, false
2849 }
2850
2851
2852 func (p Places) AsBasicResponse() (BasicResponse, bool) {
2853 return &p, true
2854 }
2855
2856
2857 func (p Places) AsIdentifiable() (*Identifiable, bool) {
2858 return nil, false
2859 }
2860
2861
2862 func (p Places) AsBasicIdentifiable() (BasicIdentifiable, bool) {
2863 return &p, true
2864 }
2865
2866
2867 func (p Places) AsAnswer() (*Answer, bool) {
2868 return nil, false
2869 }
2870
2871
2872 func (p Places) AsBasicAnswer() (BasicAnswer, bool) {
2873 return &p, true
2874 }
2875
2876
2877 func (p Places) AsErrorResponse() (*ErrorResponse, bool) {
2878 return nil, false
2879 }
2880
2881
2882 func (p Places) AsCreativeWork() (*CreativeWork, bool) {
2883 return nil, false
2884 }
2885
2886
2887 func (p Places) AsBasicCreativeWork() (BasicCreativeWork, bool) {
2888 return nil, false
2889 }
2890
2891
2892 func (p Places) AsIntangible() (*Intangible, bool) {
2893 return nil, false
2894 }
2895
2896
2897 func (p Places) AsBasicIntangible() (BasicIntangible, bool) {
2898 return nil, false
2899 }
2900
2901
2902 func (p Places) AsSearchAction() (*SearchAction, bool) {
2903 return nil, false
2904 }
2905
2906
2907 func (p Places) AsStructuredValue() (*StructuredValue, bool) {
2908 return nil, false
2909 }
2910
2911
2912 func (p Places) AsBasicStructuredValue() (BasicStructuredValue, bool) {
2913 return nil, false
2914 }
2915
2916
2917 func (p Places) AsResponseBase() (*ResponseBase, bool) {
2918 return nil, false
2919 }
2920
2921
2922 func (p Places) AsBasicResponseBase() (BasicResponseBase, bool) {
2923 return &p, true
2924 }
2925
2926
2927 func (p *Places) UnmarshalJSON(body []byte) error {
2928 var m map[string]*json.RawMessage
2929 err := json.Unmarshal(body, &m)
2930 if err != nil {
2931 return err
2932 }
2933 for k, v := range m {
2934 switch k {
2935 case "value":
2936 if v != nil {
2937 value, err := unmarshalBasicThingArray(*v)
2938 if err != nil {
2939 return err
2940 }
2941 p.Value = &value
2942 }
2943 case "queryContext":
2944 if v != nil {
2945 queryContext, err := unmarshalBasicQueryContext(*v)
2946 if err != nil {
2947 return err
2948 }
2949 p.QueryContext = queryContext
2950 }
2951 case "totalEstimatedMatches":
2952 if v != nil {
2953 var totalEstimatedMatches int64
2954 err = json.Unmarshal(*v, &totalEstimatedMatches)
2955 if err != nil {
2956 return err
2957 }
2958 p.TotalEstimatedMatches = &totalEstimatedMatches
2959 }
2960 case "isFamilyFriendly":
2961 if v != nil {
2962 var isFamilyFriendly bool
2963 err = json.Unmarshal(*v, &isFamilyFriendly)
2964 if err != nil {
2965 return err
2966 }
2967 p.IsFamilyFriendly = &isFamilyFriendly
2968 }
2969 case "readLink":
2970 if v != nil {
2971 var readLink string
2972 err = json.Unmarshal(*v, &readLink)
2973 if err != nil {
2974 return err
2975 }
2976 p.ReadLink = &readLink
2977 }
2978 case "webSearchUrl":
2979 if v != nil {
2980 var webSearchURL string
2981 err = json.Unmarshal(*v, &webSearchURL)
2982 if err != nil {
2983 return err
2984 }
2985 p.WebSearchURL = &webSearchURL
2986 }
2987 case "potentialAction":
2988 if v != nil {
2989 potentialAction, err := unmarshalBasicActionArray(*v)
2990 if err != nil {
2991 return err
2992 }
2993 p.PotentialAction = &potentialAction
2994 }
2995 case "immediateAction":
2996 if v != nil {
2997 immediateAction, err := unmarshalBasicActionArray(*v)
2998 if err != nil {
2999 return err
3000 }
3001 p.ImmediateAction = &immediateAction
3002 }
3003 case "preferredClickthroughUrl":
3004 if v != nil {
3005 var preferredClickthroughURL string
3006 err = json.Unmarshal(*v, &preferredClickthroughURL)
3007 if err != nil {
3008 return err
3009 }
3010 p.PreferredClickthroughURL = &preferredClickthroughURL
3011 }
3012 case "adaptiveCard":
3013 if v != nil {
3014 var adaptiveCard string
3015 err = json.Unmarshal(*v, &adaptiveCard)
3016 if err != nil {
3017 return err
3018 }
3019 p.AdaptiveCard = &adaptiveCard
3020 }
3021 case "id":
3022 if v != nil {
3023 var ID string
3024 err = json.Unmarshal(*v, &ID)
3025 if err != nil {
3026 return err
3027 }
3028 p.ID = &ID
3029 }
3030 case "_type":
3031 if v != nil {
3032 var typeVar TypeBasicResponseBase
3033 err = json.Unmarshal(*v, &typeVar)
3034 if err != nil {
3035 return err
3036 }
3037 p.Type = typeVar
3038 }
3039 }
3040 }
3041
3042 return nil
3043 }
3044
3045
3046 type PostalAddress struct {
3047
3048 StreetAddress *string `json:"streetAddress,omitempty"`
3049
3050 AddressLocality *string `json:"addressLocality,omitempty"`
3051
3052 AddressSubregion *string `json:"addressSubregion,omitempty"`
3053
3054 AddressRegion *string `json:"addressRegion,omitempty"`
3055
3056 PostalCode *string `json:"postalCode,omitempty"`
3057
3058 PostOfficeBoxNumber *string `json:"postOfficeBoxNumber,omitempty"`
3059
3060 AddressCountry *string `json:"addressCountry,omitempty"`
3061
3062 CountryIso *string `json:"countryIso,omitempty"`
3063
3064 Neighborhood *string `json:"neighborhood,omitempty"`
3065
3066 AddressRegionAbbreviation *string `json:"addressRegionAbbreviation,omitempty"`
3067
3068 Text *string `json:"text,omitempty"`
3069
3070 HouseNumber *string `json:"houseNumber,omitempty"`
3071
3072 StreetName *string `json:"streetName,omitempty"`
3073
3074 FormattingRuleID *string `json:"formattingRuleId,omitempty"`
3075
3076 Name *string `json:"name,omitempty"`
3077
3078 URL *string `json:"url,omitempty"`
3079
3080 EntityPresentationInfo BasicEntitiesEntityPresentationInfo `json:"entityPresentationInfo,omitempty"`
3081
3082 ReadLink *string `json:"readLink,omitempty"`
3083
3084 WebSearchURL *string `json:"webSearchUrl,omitempty"`
3085
3086 PotentialAction *[]BasicAction `json:"potentialAction,omitempty"`
3087
3088 ImmediateAction *[]BasicAction `json:"immediateAction,omitempty"`
3089
3090 PreferredClickthroughURL *string `json:"preferredClickthroughUrl,omitempty"`
3091
3092 AdaptiveCard *string `json:"adaptiveCard,omitempty"`
3093
3094 ID *string `json:"id,omitempty"`
3095
3096 Type TypeBasicResponseBase `json:"_type,omitempty"`
3097 }
3098
3099
3100 func (pa PostalAddress) MarshalJSON() ([]byte, error) {
3101 pa.Type = TypePostalAddress
3102 objectMap := make(map[string]interface{})
3103 if pa.Type != "" {
3104 objectMap["_type"] = pa.Type
3105 }
3106 return json.Marshal(objectMap)
3107 }
3108
3109
3110 func (pa PostalAddress) AsThing() (*Thing, bool) {
3111 return nil, false
3112 }
3113
3114
3115 func (pa PostalAddress) AsBasicThing() (BasicThing, bool) {
3116 return &pa, true
3117 }
3118
3119
3120 func (pa PostalAddress) AsPlaces() (*Places, bool) {
3121 return nil, false
3122 }
3123
3124
3125 func (pa PostalAddress) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) {
3126 return nil, false
3127 }
3128
3129
3130 func (pa PostalAddress) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) {
3131 return nil, false
3132 }
3133
3134
3135 func (pa PostalAddress) AsSearchResponse() (*SearchResponse, bool) {
3136 return nil, false
3137 }
3138
3139
3140 func (pa PostalAddress) AsPostalAddress() (*PostalAddress, bool) {
3141 return &pa, true
3142 }
3143
3144
3145 func (pa PostalAddress) AsPlace() (*Place, bool) {
3146 return nil, false
3147 }
3148
3149
3150 func (pa PostalAddress) AsAction() (*Action, bool) {
3151 return nil, false
3152 }
3153
3154
3155 func (pa PostalAddress) AsBasicAction() (BasicAction, bool) {
3156 return nil, false
3157 }
3158
3159
3160 func (pa PostalAddress) AsResponse() (*Response, bool) {
3161 return nil, false
3162 }
3163
3164
3165 func (pa PostalAddress) AsBasicResponse() (BasicResponse, bool) {
3166 return &pa, true
3167 }
3168
3169
3170 func (pa PostalAddress) AsIdentifiable() (*Identifiable, bool) {
3171 return nil, false
3172 }
3173
3174
3175 func (pa PostalAddress) AsBasicIdentifiable() (BasicIdentifiable, bool) {
3176 return &pa, true
3177 }
3178
3179
3180 func (pa PostalAddress) AsAnswer() (*Answer, bool) {
3181 return nil, false
3182 }
3183
3184
3185 func (pa PostalAddress) AsBasicAnswer() (BasicAnswer, bool) {
3186 return nil, false
3187 }
3188
3189
3190 func (pa PostalAddress) AsErrorResponse() (*ErrorResponse, bool) {
3191 return nil, false
3192 }
3193
3194
3195 func (pa PostalAddress) AsCreativeWork() (*CreativeWork, bool) {
3196 return nil, false
3197 }
3198
3199
3200 func (pa PostalAddress) AsBasicCreativeWork() (BasicCreativeWork, bool) {
3201 return nil, false
3202 }
3203
3204
3205 func (pa PostalAddress) AsIntangible() (*Intangible, bool) {
3206 return nil, false
3207 }
3208
3209
3210 func (pa PostalAddress) AsBasicIntangible() (BasicIntangible, bool) {
3211 return &pa, true
3212 }
3213
3214
3215 func (pa PostalAddress) AsSearchAction() (*SearchAction, bool) {
3216 return nil, false
3217 }
3218
3219
3220 func (pa PostalAddress) AsStructuredValue() (*StructuredValue, bool) {
3221 return nil, false
3222 }
3223
3224
3225 func (pa PostalAddress) AsBasicStructuredValue() (BasicStructuredValue, bool) {
3226 return &pa, true
3227 }
3228
3229
3230 func (pa PostalAddress) AsResponseBase() (*ResponseBase, bool) {
3231 return nil, false
3232 }
3233
3234
3235 func (pa PostalAddress) AsBasicResponseBase() (BasicResponseBase, bool) {
3236 return &pa, true
3237 }
3238
3239
3240 func (pa *PostalAddress) UnmarshalJSON(body []byte) error {
3241 var m map[string]*json.RawMessage
3242 err := json.Unmarshal(body, &m)
3243 if err != nil {
3244 return err
3245 }
3246 for k, v := range m {
3247 switch k {
3248 case "streetAddress":
3249 if v != nil {
3250 var streetAddress string
3251 err = json.Unmarshal(*v, &streetAddress)
3252 if err != nil {
3253 return err
3254 }
3255 pa.StreetAddress = &streetAddress
3256 }
3257 case "addressLocality":
3258 if v != nil {
3259 var addressLocality string
3260 err = json.Unmarshal(*v, &addressLocality)
3261 if err != nil {
3262 return err
3263 }
3264 pa.AddressLocality = &addressLocality
3265 }
3266 case "addressSubregion":
3267 if v != nil {
3268 var addressSubregion string
3269 err = json.Unmarshal(*v, &addressSubregion)
3270 if err != nil {
3271 return err
3272 }
3273 pa.AddressSubregion = &addressSubregion
3274 }
3275 case "addressRegion":
3276 if v != nil {
3277 var addressRegion string
3278 err = json.Unmarshal(*v, &addressRegion)
3279 if err != nil {
3280 return err
3281 }
3282 pa.AddressRegion = &addressRegion
3283 }
3284 case "postalCode":
3285 if v != nil {
3286 var postalCode string
3287 err = json.Unmarshal(*v, &postalCode)
3288 if err != nil {
3289 return err
3290 }
3291 pa.PostalCode = &postalCode
3292 }
3293 case "postOfficeBoxNumber":
3294 if v != nil {
3295 var postOfficeBoxNumber string
3296 err = json.Unmarshal(*v, &postOfficeBoxNumber)
3297 if err != nil {
3298 return err
3299 }
3300 pa.PostOfficeBoxNumber = &postOfficeBoxNumber
3301 }
3302 case "addressCountry":
3303 if v != nil {
3304 var addressCountry string
3305 err = json.Unmarshal(*v, &addressCountry)
3306 if err != nil {
3307 return err
3308 }
3309 pa.AddressCountry = &addressCountry
3310 }
3311 case "countryIso":
3312 if v != nil {
3313 var countryIso string
3314 err = json.Unmarshal(*v, &countryIso)
3315 if err != nil {
3316 return err
3317 }
3318 pa.CountryIso = &countryIso
3319 }
3320 case "neighborhood":
3321 if v != nil {
3322 var neighborhood string
3323 err = json.Unmarshal(*v, &neighborhood)
3324 if err != nil {
3325 return err
3326 }
3327 pa.Neighborhood = &neighborhood
3328 }
3329 case "addressRegionAbbreviation":
3330 if v != nil {
3331 var addressRegionAbbreviation string
3332 err = json.Unmarshal(*v, &addressRegionAbbreviation)
3333 if err != nil {
3334 return err
3335 }
3336 pa.AddressRegionAbbreviation = &addressRegionAbbreviation
3337 }
3338 case "text":
3339 if v != nil {
3340 var textVar string
3341 err = json.Unmarshal(*v, &textVar)
3342 if err != nil {
3343 return err
3344 }
3345 pa.Text = &textVar
3346 }
3347 case "houseNumber":
3348 if v != nil {
3349 var houseNumber string
3350 err = json.Unmarshal(*v, &houseNumber)
3351 if err != nil {
3352 return err
3353 }
3354 pa.HouseNumber = &houseNumber
3355 }
3356 case "streetName":
3357 if v != nil {
3358 var streetName string
3359 err = json.Unmarshal(*v, &streetName)
3360 if err != nil {
3361 return err
3362 }
3363 pa.StreetName = &streetName
3364 }
3365 case "formattingRuleId":
3366 if v != nil {
3367 var formattingRuleID string
3368 err = json.Unmarshal(*v, &formattingRuleID)
3369 if err != nil {
3370 return err
3371 }
3372 pa.FormattingRuleID = &formattingRuleID
3373 }
3374 case "name":
3375 if v != nil {
3376 var name string
3377 err = json.Unmarshal(*v, &name)
3378 if err != nil {
3379 return err
3380 }
3381 pa.Name = &name
3382 }
3383 case "url":
3384 if v != nil {
3385 var URL string
3386 err = json.Unmarshal(*v, &URL)
3387 if err != nil {
3388 return err
3389 }
3390 pa.URL = &URL
3391 }
3392 case "entityPresentationInfo":
3393 if v != nil {
3394 entityPresentationInfo, err := unmarshalBasicEntitiesEntityPresentationInfo(*v)
3395 if err != nil {
3396 return err
3397 }
3398 pa.EntityPresentationInfo = entityPresentationInfo
3399 }
3400 case "readLink":
3401 if v != nil {
3402 var readLink string
3403 err = json.Unmarshal(*v, &readLink)
3404 if err != nil {
3405 return err
3406 }
3407 pa.ReadLink = &readLink
3408 }
3409 case "webSearchUrl":
3410 if v != nil {
3411 var webSearchURL string
3412 err = json.Unmarshal(*v, &webSearchURL)
3413 if err != nil {
3414 return err
3415 }
3416 pa.WebSearchURL = &webSearchURL
3417 }
3418 case "potentialAction":
3419 if v != nil {
3420 potentialAction, err := unmarshalBasicActionArray(*v)
3421 if err != nil {
3422 return err
3423 }
3424 pa.PotentialAction = &potentialAction
3425 }
3426 case "immediateAction":
3427 if v != nil {
3428 immediateAction, err := unmarshalBasicActionArray(*v)
3429 if err != nil {
3430 return err
3431 }
3432 pa.ImmediateAction = &immediateAction
3433 }
3434 case "preferredClickthroughUrl":
3435 if v != nil {
3436 var preferredClickthroughURL string
3437 err = json.Unmarshal(*v, &preferredClickthroughURL)
3438 if err != nil {
3439 return err
3440 }
3441 pa.PreferredClickthroughURL = &preferredClickthroughURL
3442 }
3443 case "adaptiveCard":
3444 if v != nil {
3445 var adaptiveCard string
3446 err = json.Unmarshal(*v, &adaptiveCard)
3447 if err != nil {
3448 return err
3449 }
3450 pa.AdaptiveCard = &adaptiveCard
3451 }
3452 case "id":
3453 if v != nil {
3454 var ID string
3455 err = json.Unmarshal(*v, &ID)
3456 if err != nil {
3457 return err
3458 }
3459 pa.ID = &ID
3460 }
3461 case "_type":
3462 if v != nil {
3463 var typeVar TypeBasicResponseBase
3464 err = json.Unmarshal(*v, &typeVar)
3465 if err != nil {
3466 return err
3467 }
3468 pa.Type = typeVar
3469 }
3470 }
3471 }
3472
3473 return nil
3474 }
3475
3476
3477 type BasicQueryContext interface {
3478 AsQueryContext() (*QueryContext, bool)
3479 }
3480
3481
3482 type QueryContext struct {
3483
3484 OriginalQuery *string `json:"originalQuery,omitempty"`
3485
3486 AlteredQuery *string `json:"alteredQuery,omitempty"`
3487
3488 AlterationDisplayQuery *string `json:"alterationDisplayQuery,omitempty"`
3489
3490 AlterationOverrideQuery *string `json:"alterationOverrideQuery,omitempty"`
3491
3492 AdultIntent *bool `json:"adultIntent,omitempty"`
3493
3494 AskUserForLocation *bool `json:"askUserForLocation,omitempty"`
3495
3496 IsTransactional *bool `json:"isTransactional,omitempty"`
3497
3498 Type Type `json:"_type,omitempty"`
3499 }
3500
3501 func unmarshalBasicQueryContext(body []byte) (BasicQueryContext, error) {
3502 var m map[string]interface{}
3503 err := json.Unmarshal(body, &m)
3504 if err != nil {
3505 return nil, err
3506 }
3507
3508 switch m["_type"] {
3509 default:
3510 var qc QueryContext
3511 err := json.Unmarshal(body, &qc)
3512 return qc, err
3513 }
3514 }
3515 func unmarshalBasicQueryContextArray(body []byte) ([]BasicQueryContext, error) {
3516 var rawMessages []*json.RawMessage
3517 err := json.Unmarshal(body, &rawMessages)
3518 if err != nil {
3519 return nil, err
3520 }
3521
3522 qcArray := make([]BasicQueryContext, len(rawMessages))
3523
3524 for index, rawMessage := range rawMessages {
3525 qc, err := unmarshalBasicQueryContext(*rawMessage)
3526 if err != nil {
3527 return nil, err
3528 }
3529 qcArray[index] = qc
3530 }
3531 return qcArray, nil
3532 }
3533
3534
3535 func (qc QueryContext) MarshalJSON() ([]byte, error) {
3536 qc.Type = TypeQueryContext
3537 objectMap := make(map[string]interface{})
3538 if qc.OriginalQuery != nil {
3539 objectMap["originalQuery"] = qc.OriginalQuery
3540 }
3541 if qc.Type != "" {
3542 objectMap["_type"] = qc.Type
3543 }
3544 return json.Marshal(objectMap)
3545 }
3546
3547
3548 func (qc QueryContext) AsQueryContext() (*QueryContext, bool) {
3549 return &qc, true
3550 }
3551
3552
3553 func (qc QueryContext) AsBasicQueryContext() (BasicQueryContext, bool) {
3554 return &qc, true
3555 }
3556
3557
3558 type BasicResponse interface {
3559 AsThing() (*Thing, bool)
3560 AsBasicThing() (BasicThing, bool)
3561 AsPlaces() (*Places, bool)
3562 AsSearchResultsAnswer() (*SearchResultsAnswer, bool)
3563 AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool)
3564 AsSearchResponse() (*SearchResponse, bool)
3565 AsPostalAddress() (*PostalAddress, bool)
3566 AsPlace() (*Place, bool)
3567 AsAction() (*Action, bool)
3568 AsBasicAction() (BasicAction, bool)
3569 AsAnswer() (*Answer, bool)
3570 AsBasicAnswer() (BasicAnswer, bool)
3571 AsErrorResponse() (*ErrorResponse, bool)
3572 AsCreativeWork() (*CreativeWork, bool)
3573 AsBasicCreativeWork() (BasicCreativeWork, bool)
3574 AsIntangible() (*Intangible, bool)
3575 AsBasicIntangible() (BasicIntangible, bool)
3576 AsSearchAction() (*SearchAction, bool)
3577 AsStructuredValue() (*StructuredValue, bool)
3578 AsBasicStructuredValue() (BasicStructuredValue, bool)
3579 AsResponse() (*Response, bool)
3580 }
3581
3582
3583
3584 type Response struct {
3585
3586 ReadLink *string `json:"readLink,omitempty"`
3587
3588 WebSearchURL *string `json:"webSearchUrl,omitempty"`
3589
3590 PotentialAction *[]BasicAction `json:"potentialAction,omitempty"`
3591
3592 ImmediateAction *[]BasicAction `json:"immediateAction,omitempty"`
3593
3594 PreferredClickthroughURL *string `json:"preferredClickthroughUrl,omitempty"`
3595
3596 AdaptiveCard *string `json:"adaptiveCard,omitempty"`
3597
3598 ID *string `json:"id,omitempty"`
3599
3600 Type TypeBasicResponseBase `json:"_type,omitempty"`
3601 }
3602
3603 func unmarshalBasicResponse(body []byte) (BasicResponse, error) {
3604 var m map[string]interface{}
3605 err := json.Unmarshal(body, &m)
3606 if err != nil {
3607 return nil, err
3608 }
3609
3610 switch m["_type"] {
3611 case string(TypeThing):
3612 var t Thing
3613 err := json.Unmarshal(body, &t)
3614 return t, err
3615 case string(TypePlaces):
3616 var p Places
3617 err := json.Unmarshal(body, &p)
3618 return p, err
3619 case string(TypeSearchResultsAnswer):
3620 var sra SearchResultsAnswer
3621 err := json.Unmarshal(body, &sra)
3622 return sra, err
3623 case string(TypeSearchResponse):
3624 var sr SearchResponse
3625 err := json.Unmarshal(body, &sr)
3626 return sr, err
3627 case string(TypePostalAddress):
3628 var pa PostalAddress
3629 err := json.Unmarshal(body, &pa)
3630 return pa, err
3631 case string(TypePlace):
3632 var p Place
3633 err := json.Unmarshal(body, &p)
3634 return p, err
3635 case string(TypeAction):
3636 var a Action
3637 err := json.Unmarshal(body, &a)
3638 return a, err
3639 case string(TypeAnswer):
3640 var a Answer
3641 err := json.Unmarshal(body, &a)
3642 return a, err
3643 case string(TypeErrorResponse):
3644 var er ErrorResponse
3645 err := json.Unmarshal(body, &er)
3646 return er, err
3647 case string(TypeCreativeWork):
3648 var cw CreativeWork
3649 err := json.Unmarshal(body, &cw)
3650 return cw, err
3651 case string(TypeIntangible):
3652 var i Intangible
3653 err := json.Unmarshal(body, &i)
3654 return i, err
3655 case string(TypeSearchAction):
3656 var sa SearchAction
3657 err := json.Unmarshal(body, &sa)
3658 return sa, err
3659 case string(TypeStructuredValue):
3660 var sv StructuredValue
3661 err := json.Unmarshal(body, &sv)
3662 return sv, err
3663 default:
3664 var r Response
3665 err := json.Unmarshal(body, &r)
3666 return r, err
3667 }
3668 }
3669 func unmarshalBasicResponseArray(body []byte) ([]BasicResponse, error) {
3670 var rawMessages []*json.RawMessage
3671 err := json.Unmarshal(body, &rawMessages)
3672 if err != nil {
3673 return nil, err
3674 }
3675
3676 rArray := make([]BasicResponse, len(rawMessages))
3677
3678 for index, rawMessage := range rawMessages {
3679 r, err := unmarshalBasicResponse(*rawMessage)
3680 if err != nil {
3681 return nil, err
3682 }
3683 rArray[index] = r
3684 }
3685 return rArray, nil
3686 }
3687
3688
3689 func (r Response) MarshalJSON() ([]byte, error) {
3690 r.Type = TypeResponse
3691 objectMap := make(map[string]interface{})
3692 if r.Type != "" {
3693 objectMap["_type"] = r.Type
3694 }
3695 return json.Marshal(objectMap)
3696 }
3697
3698
3699 func (r Response) AsThing() (*Thing, bool) {
3700 return nil, false
3701 }
3702
3703
3704 func (r Response) AsBasicThing() (BasicThing, bool) {
3705 return nil, false
3706 }
3707
3708
3709 func (r Response) AsPlaces() (*Places, bool) {
3710 return nil, false
3711 }
3712
3713
3714 func (r Response) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) {
3715 return nil, false
3716 }
3717
3718
3719 func (r Response) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) {
3720 return nil, false
3721 }
3722
3723
3724 func (r Response) AsSearchResponse() (*SearchResponse, bool) {
3725 return nil, false
3726 }
3727
3728
3729 func (r Response) AsPostalAddress() (*PostalAddress, bool) {
3730 return nil, false
3731 }
3732
3733
3734 func (r Response) AsPlace() (*Place, bool) {
3735 return nil, false
3736 }
3737
3738
3739 func (r Response) AsAction() (*Action, bool) {
3740 return nil, false
3741 }
3742
3743
3744 func (r Response) AsBasicAction() (BasicAction, bool) {
3745 return nil, false
3746 }
3747
3748
3749 func (r Response) AsResponse() (*Response, bool) {
3750 return &r, true
3751 }
3752
3753
3754 func (r Response) AsBasicResponse() (BasicResponse, bool) {
3755 return &r, true
3756 }
3757
3758
3759 func (r Response) AsIdentifiable() (*Identifiable, bool) {
3760 return nil, false
3761 }
3762
3763
3764 func (r Response) AsBasicIdentifiable() (BasicIdentifiable, bool) {
3765 return &r, true
3766 }
3767
3768
3769 func (r Response) AsAnswer() (*Answer, bool) {
3770 return nil, false
3771 }
3772
3773
3774 func (r Response) AsBasicAnswer() (BasicAnswer, bool) {
3775 return nil, false
3776 }
3777
3778
3779 func (r Response) AsErrorResponse() (*ErrorResponse, bool) {
3780 return nil, false
3781 }
3782
3783
3784 func (r Response) AsCreativeWork() (*CreativeWork, bool) {
3785 return nil, false
3786 }
3787
3788
3789 func (r Response) AsBasicCreativeWork() (BasicCreativeWork, bool) {
3790 return nil, false
3791 }
3792
3793
3794 func (r Response) AsIntangible() (*Intangible, bool) {
3795 return nil, false
3796 }
3797
3798
3799 func (r Response) AsBasicIntangible() (BasicIntangible, bool) {
3800 return nil, false
3801 }
3802
3803
3804 func (r Response) AsSearchAction() (*SearchAction, bool) {
3805 return nil, false
3806 }
3807
3808
3809 func (r Response) AsStructuredValue() (*StructuredValue, bool) {
3810 return nil, false
3811 }
3812
3813
3814 func (r Response) AsBasicStructuredValue() (BasicStructuredValue, bool) {
3815 return nil, false
3816 }
3817
3818
3819 func (r Response) AsResponseBase() (*ResponseBase, bool) {
3820 return nil, false
3821 }
3822
3823
3824 func (r Response) AsBasicResponseBase() (BasicResponseBase, bool) {
3825 return &r, true
3826 }
3827
3828
3829 func (r *Response) UnmarshalJSON(body []byte) error {
3830 var m map[string]*json.RawMessage
3831 err := json.Unmarshal(body, &m)
3832 if err != nil {
3833 return err
3834 }
3835 for k, v := range m {
3836 switch k {
3837 case "readLink":
3838 if v != nil {
3839 var readLink string
3840 err = json.Unmarshal(*v, &readLink)
3841 if err != nil {
3842 return err
3843 }
3844 r.ReadLink = &readLink
3845 }
3846 case "webSearchUrl":
3847 if v != nil {
3848 var webSearchURL string
3849 err = json.Unmarshal(*v, &webSearchURL)
3850 if err != nil {
3851 return err
3852 }
3853 r.WebSearchURL = &webSearchURL
3854 }
3855 case "potentialAction":
3856 if v != nil {
3857 potentialAction, err := unmarshalBasicActionArray(*v)
3858 if err != nil {
3859 return err
3860 }
3861 r.PotentialAction = &potentialAction
3862 }
3863 case "immediateAction":
3864 if v != nil {
3865 immediateAction, err := unmarshalBasicActionArray(*v)
3866 if err != nil {
3867 return err
3868 }
3869 r.ImmediateAction = &immediateAction
3870 }
3871 case "preferredClickthroughUrl":
3872 if v != nil {
3873 var preferredClickthroughURL string
3874 err = json.Unmarshal(*v, &preferredClickthroughURL)
3875 if err != nil {
3876 return err
3877 }
3878 r.PreferredClickthroughURL = &preferredClickthroughURL
3879 }
3880 case "adaptiveCard":
3881 if v != nil {
3882 var adaptiveCard string
3883 err = json.Unmarshal(*v, &adaptiveCard)
3884 if err != nil {
3885 return err
3886 }
3887 r.AdaptiveCard = &adaptiveCard
3888 }
3889 case "id":
3890 if v != nil {
3891 var ID string
3892 err = json.Unmarshal(*v, &ID)
3893 if err != nil {
3894 return err
3895 }
3896 r.ID = &ID
3897 }
3898 case "_type":
3899 if v != nil {
3900 var typeVar TypeBasicResponseBase
3901 err = json.Unmarshal(*v, &typeVar)
3902 if err != nil {
3903 return err
3904 }
3905 r.Type = typeVar
3906 }
3907 }
3908 }
3909
3910 return nil
3911 }
3912
3913
3914 type BasicResponseBase interface {
3915 AsThing() (*Thing, bool)
3916 AsBasicThing() (BasicThing, bool)
3917 AsPlaces() (*Places, bool)
3918 AsSearchResultsAnswer() (*SearchResultsAnswer, bool)
3919 AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool)
3920 AsSearchResponse() (*SearchResponse, bool)
3921 AsPostalAddress() (*PostalAddress, bool)
3922 AsPlace() (*Place, bool)
3923 AsAction() (*Action, bool)
3924 AsBasicAction() (BasicAction, bool)
3925 AsResponse() (*Response, bool)
3926 AsBasicResponse() (BasicResponse, bool)
3927 AsIdentifiable() (*Identifiable, bool)
3928 AsBasicIdentifiable() (BasicIdentifiable, bool)
3929 AsAnswer() (*Answer, bool)
3930 AsBasicAnswer() (BasicAnswer, bool)
3931 AsErrorResponse() (*ErrorResponse, bool)
3932 AsCreativeWork() (*CreativeWork, bool)
3933 AsBasicCreativeWork() (BasicCreativeWork, bool)
3934 AsIntangible() (*Intangible, bool)
3935 AsBasicIntangible() (BasicIntangible, bool)
3936 AsSearchAction() (*SearchAction, bool)
3937 AsStructuredValue() (*StructuredValue, bool)
3938 AsBasicStructuredValue() (BasicStructuredValue, bool)
3939 AsResponseBase() (*ResponseBase, bool)
3940 }
3941
3942
3943 type ResponseBase struct {
3944
3945 Type TypeBasicResponseBase `json:"_type,omitempty"`
3946 }
3947
3948 func unmarshalBasicResponseBase(body []byte) (BasicResponseBase, error) {
3949 var m map[string]interface{}
3950 err := json.Unmarshal(body, &m)
3951 if err != nil {
3952 return nil, err
3953 }
3954
3955 switch m["_type"] {
3956 case string(TypeThing):
3957 var t Thing
3958 err := json.Unmarshal(body, &t)
3959 return t, err
3960 case string(TypePlaces):
3961 var p Places
3962 err := json.Unmarshal(body, &p)
3963 return p, err
3964 case string(TypeSearchResultsAnswer):
3965 var sra SearchResultsAnswer
3966 err := json.Unmarshal(body, &sra)
3967 return sra, err
3968 case string(TypeSearchResponse):
3969 var sr SearchResponse
3970 err := json.Unmarshal(body, &sr)
3971 return sr, err
3972 case string(TypePostalAddress):
3973 var pa PostalAddress
3974 err := json.Unmarshal(body, &pa)
3975 return pa, err
3976 case string(TypePlace):
3977 var p Place
3978 err := json.Unmarshal(body, &p)
3979 return p, err
3980 case string(TypeAction):
3981 var a Action
3982 err := json.Unmarshal(body, &a)
3983 return a, err
3984 case string(TypeResponse):
3985 var r Response
3986 err := json.Unmarshal(body, &r)
3987 return r, err
3988 case string(TypeIdentifiable):
3989 var i Identifiable
3990 err := json.Unmarshal(body, &i)
3991 return i, err
3992 case string(TypeAnswer):
3993 var a Answer
3994 err := json.Unmarshal(body, &a)
3995 return a, err
3996 case string(TypeErrorResponse):
3997 var er ErrorResponse
3998 err := json.Unmarshal(body, &er)
3999 return er, err
4000 case string(TypeCreativeWork):
4001 var cw CreativeWork
4002 err := json.Unmarshal(body, &cw)
4003 return cw, err
4004 case string(TypeIntangible):
4005 var i Intangible
4006 err := json.Unmarshal(body, &i)
4007 return i, err
4008 case string(TypeSearchAction):
4009 var sa SearchAction
4010 err := json.Unmarshal(body, &sa)
4011 return sa, err
4012 case string(TypeStructuredValue):
4013 var sv StructuredValue
4014 err := json.Unmarshal(body, &sv)
4015 return sv, err
4016 default:
4017 var rb ResponseBase
4018 err := json.Unmarshal(body, &rb)
4019 return rb, err
4020 }
4021 }
4022 func unmarshalBasicResponseBaseArray(body []byte) ([]BasicResponseBase, error) {
4023 var rawMessages []*json.RawMessage
4024 err := json.Unmarshal(body, &rawMessages)
4025 if err != nil {
4026 return nil, err
4027 }
4028
4029 rbArray := make([]BasicResponseBase, len(rawMessages))
4030
4031 for index, rawMessage := range rawMessages {
4032 rb, err := unmarshalBasicResponseBase(*rawMessage)
4033 if err != nil {
4034 return nil, err
4035 }
4036 rbArray[index] = rb
4037 }
4038 return rbArray, nil
4039 }
4040
4041
4042 func (rb ResponseBase) MarshalJSON() ([]byte, error) {
4043 rb.Type = TypeResponseBase
4044 objectMap := make(map[string]interface{})
4045 if rb.Type != "" {
4046 objectMap["_type"] = rb.Type
4047 }
4048 return json.Marshal(objectMap)
4049 }
4050
4051
4052 func (rb ResponseBase) AsThing() (*Thing, bool) {
4053 return nil, false
4054 }
4055
4056
4057 func (rb ResponseBase) AsBasicThing() (BasicThing, bool) {
4058 return nil, false
4059 }
4060
4061
4062 func (rb ResponseBase) AsPlaces() (*Places, bool) {
4063 return nil, false
4064 }
4065
4066
4067 func (rb ResponseBase) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) {
4068 return nil, false
4069 }
4070
4071
4072 func (rb ResponseBase) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) {
4073 return nil, false
4074 }
4075
4076
4077 func (rb ResponseBase) AsSearchResponse() (*SearchResponse, bool) {
4078 return nil, false
4079 }
4080
4081
4082 func (rb ResponseBase) AsPostalAddress() (*PostalAddress, bool) {
4083 return nil, false
4084 }
4085
4086
4087 func (rb ResponseBase) AsPlace() (*Place, bool) {
4088 return nil, false
4089 }
4090
4091
4092 func (rb ResponseBase) AsAction() (*Action, bool) {
4093 return nil, false
4094 }
4095
4096
4097 func (rb ResponseBase) AsBasicAction() (BasicAction, bool) {
4098 return nil, false
4099 }
4100
4101
4102 func (rb ResponseBase) AsResponse() (*Response, bool) {
4103 return nil, false
4104 }
4105
4106
4107 func (rb ResponseBase) AsBasicResponse() (BasicResponse, bool) {
4108 return nil, false
4109 }
4110
4111
4112 func (rb ResponseBase) AsIdentifiable() (*Identifiable, bool) {
4113 return nil, false
4114 }
4115
4116
4117 func (rb ResponseBase) AsBasicIdentifiable() (BasicIdentifiable, bool) {
4118 return nil, false
4119 }
4120
4121
4122 func (rb ResponseBase) AsAnswer() (*Answer, bool) {
4123 return nil, false
4124 }
4125
4126
4127 func (rb ResponseBase) AsBasicAnswer() (BasicAnswer, bool) {
4128 return nil, false
4129 }
4130
4131
4132 func (rb ResponseBase) AsErrorResponse() (*ErrorResponse, bool) {
4133 return nil, false
4134 }
4135
4136
4137 func (rb ResponseBase) AsCreativeWork() (*CreativeWork, bool) {
4138 return nil, false
4139 }
4140
4141
4142 func (rb ResponseBase) AsBasicCreativeWork() (BasicCreativeWork, bool) {
4143 return nil, false
4144 }
4145
4146
4147 func (rb ResponseBase) AsIntangible() (*Intangible, bool) {
4148 return nil, false
4149 }
4150
4151
4152 func (rb ResponseBase) AsBasicIntangible() (BasicIntangible, bool) {
4153 return nil, false
4154 }
4155
4156
4157 func (rb ResponseBase) AsSearchAction() (*SearchAction, bool) {
4158 return nil, false
4159 }
4160
4161
4162 func (rb ResponseBase) AsStructuredValue() (*StructuredValue, bool) {
4163 return nil, false
4164 }
4165
4166
4167 func (rb ResponseBase) AsBasicStructuredValue() (BasicStructuredValue, bool) {
4168 return nil, false
4169 }
4170
4171
4172 func (rb ResponseBase) AsResponseBase() (*ResponseBase, bool) {
4173 return &rb, true
4174 }
4175
4176
4177 func (rb ResponseBase) AsBasicResponseBase() (BasicResponseBase, bool) {
4178 return &rb, true
4179 }
4180
4181
4182 type SearchAction struct {
4183
4184 DisplayText *string `json:"displayText,omitempty"`
4185
4186 Query *string `json:"query,omitempty"`
4187
4188 RichContent *[]BasicAnswer `json:"richContent,omitempty"`
4189
4190 FormattingRuleID *string `json:"formattingRuleId,omitempty"`
4191
4192 Location *[]Place `json:"location,omitempty"`
4193
4194 Result *[]BasicThing `json:"result,omitempty"`
4195
4196 DisplayName *string `json:"displayName,omitempty"`
4197
4198 IsTopAction *bool `json:"isTopAction,omitempty"`
4199
4200 ServiceURL *string `json:"serviceUrl,omitempty"`
4201
4202 ThumbnailURL *string `json:"thumbnailUrl,omitempty"`
4203
4204 About *[]BasicThing `json:"about,omitempty"`
4205
4206 Mentions *[]BasicThing `json:"mentions,omitempty"`
4207
4208 Provider *[]BasicThing `json:"provider,omitempty"`
4209
4210 Creator BasicThing `json:"creator,omitempty"`
4211
4212 Text *string `json:"text,omitempty"`
4213
4214 DiscussionURL *string `json:"discussionUrl,omitempty"`
4215
4216 CommentCount *int32 `json:"commentCount,omitempty"`
4217
4218 MainEntity BasicThing `json:"mainEntity,omitempty"`
4219
4220 HeadLine *string `json:"headLine,omitempty"`
4221
4222 CopyrightHolder BasicThing `json:"copyrightHolder,omitempty"`
4223
4224 CopyrightYear *int32 `json:"copyrightYear,omitempty"`
4225
4226 Disclaimer *string `json:"disclaimer,omitempty"`
4227
4228 IsAccessibleForFree *bool `json:"isAccessibleForFree,omitempty"`
4229
4230 Genre *[]string `json:"genre,omitempty"`
4231
4232 IsFamilyFriendly *bool `json:"isFamilyFriendly,omitempty"`
4233
4234 Name *string `json:"name,omitempty"`
4235
4236 URL *string `json:"url,omitempty"`
4237
4238 EntityPresentationInfo BasicEntitiesEntityPresentationInfo `json:"entityPresentationInfo,omitempty"`
4239
4240 ReadLink *string `json:"readLink,omitempty"`
4241
4242 WebSearchURL *string `json:"webSearchUrl,omitempty"`
4243
4244 PotentialAction *[]BasicAction `json:"potentialAction,omitempty"`
4245
4246 ImmediateAction *[]BasicAction `json:"immediateAction,omitempty"`
4247
4248 PreferredClickthroughURL *string `json:"preferredClickthroughUrl,omitempty"`
4249
4250 AdaptiveCard *string `json:"adaptiveCard,omitempty"`
4251
4252 ID *string `json:"id,omitempty"`
4253
4254 Type TypeBasicResponseBase `json:"_type,omitempty"`
4255 }
4256
4257
4258 func (sa SearchAction) MarshalJSON() ([]byte, error) {
4259 sa.Type = TypeSearchAction
4260 objectMap := make(map[string]interface{})
4261 if sa.Type != "" {
4262 objectMap["_type"] = sa.Type
4263 }
4264 return json.Marshal(objectMap)
4265 }
4266
4267
4268 func (sa SearchAction) AsThing() (*Thing, bool) {
4269 return nil, false
4270 }
4271
4272
4273 func (sa SearchAction) AsBasicThing() (BasicThing, bool) {
4274 return &sa, true
4275 }
4276
4277
4278 func (sa SearchAction) AsPlaces() (*Places, bool) {
4279 return nil, false
4280 }
4281
4282
4283 func (sa SearchAction) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) {
4284 return nil, false
4285 }
4286
4287
4288 func (sa SearchAction) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) {
4289 return nil, false
4290 }
4291
4292
4293 func (sa SearchAction) AsSearchResponse() (*SearchResponse, bool) {
4294 return nil, false
4295 }
4296
4297
4298 func (sa SearchAction) AsPostalAddress() (*PostalAddress, bool) {
4299 return nil, false
4300 }
4301
4302
4303 func (sa SearchAction) AsPlace() (*Place, bool) {
4304 return nil, false
4305 }
4306
4307
4308 func (sa SearchAction) AsAction() (*Action, bool) {
4309 return nil, false
4310 }
4311
4312
4313 func (sa SearchAction) AsBasicAction() (BasicAction, bool) {
4314 return &sa, true
4315 }
4316
4317
4318 func (sa SearchAction) AsResponse() (*Response, bool) {
4319 return nil, false
4320 }
4321
4322
4323 func (sa SearchAction) AsBasicResponse() (BasicResponse, bool) {
4324 return &sa, true
4325 }
4326
4327
4328 func (sa SearchAction) AsIdentifiable() (*Identifiable, bool) {
4329 return nil, false
4330 }
4331
4332
4333 func (sa SearchAction) AsBasicIdentifiable() (BasicIdentifiable, bool) {
4334 return &sa, true
4335 }
4336
4337
4338 func (sa SearchAction) AsAnswer() (*Answer, bool) {
4339 return nil, false
4340 }
4341
4342
4343 func (sa SearchAction) AsBasicAnswer() (BasicAnswer, bool) {
4344 return nil, false
4345 }
4346
4347
4348 func (sa SearchAction) AsErrorResponse() (*ErrorResponse, bool) {
4349 return nil, false
4350 }
4351
4352
4353 func (sa SearchAction) AsCreativeWork() (*CreativeWork, bool) {
4354 return nil, false
4355 }
4356
4357
4358 func (sa SearchAction) AsBasicCreativeWork() (BasicCreativeWork, bool) {
4359 return &sa, true
4360 }
4361
4362
4363 func (sa SearchAction) AsIntangible() (*Intangible, bool) {
4364 return nil, false
4365 }
4366
4367
4368 func (sa SearchAction) AsBasicIntangible() (BasicIntangible, bool) {
4369 return nil, false
4370 }
4371
4372
4373 func (sa SearchAction) AsSearchAction() (*SearchAction, bool) {
4374 return &sa, true
4375 }
4376
4377
4378 func (sa SearchAction) AsStructuredValue() (*StructuredValue, bool) {
4379 return nil, false
4380 }
4381
4382
4383 func (sa SearchAction) AsBasicStructuredValue() (BasicStructuredValue, bool) {
4384 return nil, false
4385 }
4386
4387
4388 func (sa SearchAction) AsResponseBase() (*ResponseBase, bool) {
4389 return nil, false
4390 }
4391
4392
4393 func (sa SearchAction) AsBasicResponseBase() (BasicResponseBase, bool) {
4394 return &sa, true
4395 }
4396
4397
4398 func (sa *SearchAction) UnmarshalJSON(body []byte) error {
4399 var m map[string]*json.RawMessage
4400 err := json.Unmarshal(body, &m)
4401 if err != nil {
4402 return err
4403 }
4404 for k, v := range m {
4405 switch k {
4406 case "displayText":
4407 if v != nil {
4408 var displayText string
4409 err = json.Unmarshal(*v, &displayText)
4410 if err != nil {
4411 return err
4412 }
4413 sa.DisplayText = &displayText
4414 }
4415 case "query":
4416 if v != nil {
4417 var query string
4418 err = json.Unmarshal(*v, &query)
4419 if err != nil {
4420 return err
4421 }
4422 sa.Query = &query
4423 }
4424 case "richContent":
4425 if v != nil {
4426 richContent, err := unmarshalBasicAnswerArray(*v)
4427 if err != nil {
4428 return err
4429 }
4430 sa.RichContent = &richContent
4431 }
4432 case "formattingRuleId":
4433 if v != nil {
4434 var formattingRuleID string
4435 err = json.Unmarshal(*v, &formattingRuleID)
4436 if err != nil {
4437 return err
4438 }
4439 sa.FormattingRuleID = &formattingRuleID
4440 }
4441 case "location":
4442 if v != nil {
4443 var location []Place
4444 err = json.Unmarshal(*v, &location)
4445 if err != nil {
4446 return err
4447 }
4448 sa.Location = &location
4449 }
4450 case "result":
4451 if v != nil {
4452 resultVar, err := unmarshalBasicThingArray(*v)
4453 if err != nil {
4454 return err
4455 }
4456 sa.Result = &resultVar
4457 }
4458 case "displayName":
4459 if v != nil {
4460 var displayName string
4461 err = json.Unmarshal(*v, &displayName)
4462 if err != nil {
4463 return err
4464 }
4465 sa.DisplayName = &displayName
4466 }
4467 case "isTopAction":
4468 if v != nil {
4469 var isTopAction bool
4470 err = json.Unmarshal(*v, &isTopAction)
4471 if err != nil {
4472 return err
4473 }
4474 sa.IsTopAction = &isTopAction
4475 }
4476 case "serviceUrl":
4477 if v != nil {
4478 var serviceURL string
4479 err = json.Unmarshal(*v, &serviceURL)
4480 if err != nil {
4481 return err
4482 }
4483 sa.ServiceURL = &serviceURL
4484 }
4485 case "thumbnailUrl":
4486 if v != nil {
4487 var thumbnailURL string
4488 err = json.Unmarshal(*v, &thumbnailURL)
4489 if err != nil {
4490 return err
4491 }
4492 sa.ThumbnailURL = &thumbnailURL
4493 }
4494 case "about":
4495 if v != nil {
4496 about, err := unmarshalBasicThingArray(*v)
4497 if err != nil {
4498 return err
4499 }
4500 sa.About = &about
4501 }
4502 case "mentions":
4503 if v != nil {
4504 mentions, err := unmarshalBasicThingArray(*v)
4505 if err != nil {
4506 return err
4507 }
4508 sa.Mentions = &mentions
4509 }
4510 case "provider":
4511 if v != nil {
4512 provider, err := unmarshalBasicThingArray(*v)
4513 if err != nil {
4514 return err
4515 }
4516 sa.Provider = &provider
4517 }
4518 case "creator":
4519 if v != nil {
4520 creator, err := unmarshalBasicThing(*v)
4521 if err != nil {
4522 return err
4523 }
4524 sa.Creator = creator
4525 }
4526 case "text":
4527 if v != nil {
4528 var textVar string
4529 err = json.Unmarshal(*v, &textVar)
4530 if err != nil {
4531 return err
4532 }
4533 sa.Text = &textVar
4534 }
4535 case "discussionUrl":
4536 if v != nil {
4537 var discussionURL string
4538 err = json.Unmarshal(*v, &discussionURL)
4539 if err != nil {
4540 return err
4541 }
4542 sa.DiscussionURL = &discussionURL
4543 }
4544 case "commentCount":
4545 if v != nil {
4546 var commentCount int32
4547 err = json.Unmarshal(*v, &commentCount)
4548 if err != nil {
4549 return err
4550 }
4551 sa.CommentCount = &commentCount
4552 }
4553 case "mainEntity":
4554 if v != nil {
4555 mainEntity, err := unmarshalBasicThing(*v)
4556 if err != nil {
4557 return err
4558 }
4559 sa.MainEntity = mainEntity
4560 }
4561 case "headLine":
4562 if v != nil {
4563 var headLine string
4564 err = json.Unmarshal(*v, &headLine)
4565 if err != nil {
4566 return err
4567 }
4568 sa.HeadLine = &headLine
4569 }
4570 case "copyrightHolder":
4571 if v != nil {
4572 copyrightHolder, err := unmarshalBasicThing(*v)
4573 if err != nil {
4574 return err
4575 }
4576 sa.CopyrightHolder = copyrightHolder
4577 }
4578 case "copyrightYear":
4579 if v != nil {
4580 var copyrightYear int32
4581 err = json.Unmarshal(*v, ©rightYear)
4582 if err != nil {
4583 return err
4584 }
4585 sa.CopyrightYear = ©rightYear
4586 }
4587 case "disclaimer":
4588 if v != nil {
4589 var disclaimer string
4590 err = json.Unmarshal(*v, &disclaimer)
4591 if err != nil {
4592 return err
4593 }
4594 sa.Disclaimer = &disclaimer
4595 }
4596 case "isAccessibleForFree":
4597 if v != nil {
4598 var isAccessibleForFree bool
4599 err = json.Unmarshal(*v, &isAccessibleForFree)
4600 if err != nil {
4601 return err
4602 }
4603 sa.IsAccessibleForFree = &isAccessibleForFree
4604 }
4605 case "genre":
4606 if v != nil {
4607 var genre []string
4608 err = json.Unmarshal(*v, &genre)
4609 if err != nil {
4610 return err
4611 }
4612 sa.Genre = &genre
4613 }
4614 case "isFamilyFriendly":
4615 if v != nil {
4616 var isFamilyFriendly bool
4617 err = json.Unmarshal(*v, &isFamilyFriendly)
4618 if err != nil {
4619 return err
4620 }
4621 sa.IsFamilyFriendly = &isFamilyFriendly
4622 }
4623 case "name":
4624 if v != nil {
4625 var name string
4626 err = json.Unmarshal(*v, &name)
4627 if err != nil {
4628 return err
4629 }
4630 sa.Name = &name
4631 }
4632 case "url":
4633 if v != nil {
4634 var URL string
4635 err = json.Unmarshal(*v, &URL)
4636 if err != nil {
4637 return err
4638 }
4639 sa.URL = &URL
4640 }
4641 case "entityPresentationInfo":
4642 if v != nil {
4643 entityPresentationInfo, err := unmarshalBasicEntitiesEntityPresentationInfo(*v)
4644 if err != nil {
4645 return err
4646 }
4647 sa.EntityPresentationInfo = entityPresentationInfo
4648 }
4649 case "readLink":
4650 if v != nil {
4651 var readLink string
4652 err = json.Unmarshal(*v, &readLink)
4653 if err != nil {
4654 return err
4655 }
4656 sa.ReadLink = &readLink
4657 }
4658 case "webSearchUrl":
4659 if v != nil {
4660 var webSearchURL string
4661 err = json.Unmarshal(*v, &webSearchURL)
4662 if err != nil {
4663 return err
4664 }
4665 sa.WebSearchURL = &webSearchURL
4666 }
4667 case "potentialAction":
4668 if v != nil {
4669 potentialAction, err := unmarshalBasicActionArray(*v)
4670 if err != nil {
4671 return err
4672 }
4673 sa.PotentialAction = &potentialAction
4674 }
4675 case "immediateAction":
4676 if v != nil {
4677 immediateAction, err := unmarshalBasicActionArray(*v)
4678 if err != nil {
4679 return err
4680 }
4681 sa.ImmediateAction = &immediateAction
4682 }
4683 case "preferredClickthroughUrl":
4684 if v != nil {
4685 var preferredClickthroughURL string
4686 err = json.Unmarshal(*v, &preferredClickthroughURL)
4687 if err != nil {
4688 return err
4689 }
4690 sa.PreferredClickthroughURL = &preferredClickthroughURL
4691 }
4692 case "adaptiveCard":
4693 if v != nil {
4694 var adaptiveCard string
4695 err = json.Unmarshal(*v, &adaptiveCard)
4696 if err != nil {
4697 return err
4698 }
4699 sa.AdaptiveCard = &adaptiveCard
4700 }
4701 case "id":
4702 if v != nil {
4703 var ID string
4704 err = json.Unmarshal(*v, &ID)
4705 if err != nil {
4706 return err
4707 }
4708 sa.ID = &ID
4709 }
4710 case "_type":
4711 if v != nil {
4712 var typeVar TypeBasicResponseBase
4713 err = json.Unmarshal(*v, &typeVar)
4714 if err != nil {
4715 return err
4716 }
4717 sa.Type = typeVar
4718 }
4719 }
4720 }
4721
4722 return nil
4723 }
4724
4725
4726 type SearchResponse struct {
4727 autorest.Response `json:"-"`
4728
4729 QueryContext BasicQueryContext `json:"queryContext,omitempty"`
4730
4731 Places *Places `json:"places,omitempty"`
4732
4733 Lottery BasicSearchResultsAnswer `json:"lottery,omitempty"`
4734
4735 SearchResultsConfidenceScore *float64 `json:"searchResultsConfidenceScore,omitempty"`
4736
4737 ReadLink *string `json:"readLink,omitempty"`
4738
4739 WebSearchURL *string `json:"webSearchUrl,omitempty"`
4740
4741 PotentialAction *[]BasicAction `json:"potentialAction,omitempty"`
4742
4743 ImmediateAction *[]BasicAction `json:"immediateAction,omitempty"`
4744
4745 PreferredClickthroughURL *string `json:"preferredClickthroughUrl,omitempty"`
4746
4747 AdaptiveCard *string `json:"adaptiveCard,omitempty"`
4748
4749 ID *string `json:"id,omitempty"`
4750
4751 Type TypeBasicResponseBase `json:"_type,omitempty"`
4752 }
4753
4754
4755 func (sr SearchResponse) MarshalJSON() ([]byte, error) {
4756 sr.Type = TypeSearchResponse
4757 objectMap := make(map[string]interface{})
4758 if sr.Type != "" {
4759 objectMap["_type"] = sr.Type
4760 }
4761 return json.Marshal(objectMap)
4762 }
4763
4764
4765 func (sr SearchResponse) AsThing() (*Thing, bool) {
4766 return nil, false
4767 }
4768
4769
4770 func (sr SearchResponse) AsBasicThing() (BasicThing, bool) {
4771 return nil, false
4772 }
4773
4774
4775 func (sr SearchResponse) AsPlaces() (*Places, bool) {
4776 return nil, false
4777 }
4778
4779
4780 func (sr SearchResponse) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) {
4781 return nil, false
4782 }
4783
4784
4785 func (sr SearchResponse) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) {
4786 return nil, false
4787 }
4788
4789
4790 func (sr SearchResponse) AsSearchResponse() (*SearchResponse, bool) {
4791 return &sr, true
4792 }
4793
4794
4795 func (sr SearchResponse) AsPostalAddress() (*PostalAddress, bool) {
4796 return nil, false
4797 }
4798
4799
4800 func (sr SearchResponse) AsPlace() (*Place, bool) {
4801 return nil, false
4802 }
4803
4804
4805 func (sr SearchResponse) AsAction() (*Action, bool) {
4806 return nil, false
4807 }
4808
4809
4810 func (sr SearchResponse) AsBasicAction() (BasicAction, bool) {
4811 return nil, false
4812 }
4813
4814
4815 func (sr SearchResponse) AsResponse() (*Response, bool) {
4816 return nil, false
4817 }
4818
4819
4820 func (sr SearchResponse) AsBasicResponse() (BasicResponse, bool) {
4821 return &sr, true
4822 }
4823
4824
4825 func (sr SearchResponse) AsIdentifiable() (*Identifiable, bool) {
4826 return nil, false
4827 }
4828
4829
4830 func (sr SearchResponse) AsBasicIdentifiable() (BasicIdentifiable, bool) {
4831 return &sr, true
4832 }
4833
4834
4835 func (sr SearchResponse) AsAnswer() (*Answer, bool) {
4836 return nil, false
4837 }
4838
4839
4840 func (sr SearchResponse) AsBasicAnswer() (BasicAnswer, bool) {
4841 return nil, false
4842 }
4843
4844
4845 func (sr SearchResponse) AsErrorResponse() (*ErrorResponse, bool) {
4846 return nil, false
4847 }
4848
4849
4850 func (sr SearchResponse) AsCreativeWork() (*CreativeWork, bool) {
4851 return nil, false
4852 }
4853
4854
4855 func (sr SearchResponse) AsBasicCreativeWork() (BasicCreativeWork, bool) {
4856 return nil, false
4857 }
4858
4859
4860 func (sr SearchResponse) AsIntangible() (*Intangible, bool) {
4861 return nil, false
4862 }
4863
4864
4865 func (sr SearchResponse) AsBasicIntangible() (BasicIntangible, bool) {
4866 return nil, false
4867 }
4868
4869
4870 func (sr SearchResponse) AsSearchAction() (*SearchAction, bool) {
4871 return nil, false
4872 }
4873
4874
4875 func (sr SearchResponse) AsStructuredValue() (*StructuredValue, bool) {
4876 return nil, false
4877 }
4878
4879
4880 func (sr SearchResponse) AsBasicStructuredValue() (BasicStructuredValue, bool) {
4881 return nil, false
4882 }
4883
4884
4885 func (sr SearchResponse) AsResponseBase() (*ResponseBase, bool) {
4886 return nil, false
4887 }
4888
4889
4890 func (sr SearchResponse) AsBasicResponseBase() (BasicResponseBase, bool) {
4891 return &sr, true
4892 }
4893
4894
4895 func (sr *SearchResponse) UnmarshalJSON(body []byte) error {
4896 var m map[string]*json.RawMessage
4897 err := json.Unmarshal(body, &m)
4898 if err != nil {
4899 return err
4900 }
4901 for k, v := range m {
4902 switch k {
4903 case "queryContext":
4904 if v != nil {
4905 queryContext, err := unmarshalBasicQueryContext(*v)
4906 if err != nil {
4907 return err
4908 }
4909 sr.QueryContext = queryContext
4910 }
4911 case "places":
4912 if v != nil {
4913 var places Places
4914 err = json.Unmarshal(*v, &places)
4915 if err != nil {
4916 return err
4917 }
4918 sr.Places = &places
4919 }
4920 case "lottery":
4921 if v != nil {
4922 lottery, err := unmarshalBasicSearchResultsAnswer(*v)
4923 if err != nil {
4924 return err
4925 }
4926 sr.Lottery = lottery
4927 }
4928 case "searchResultsConfidenceScore":
4929 if v != nil {
4930 var searchResultsConfidenceScore float64
4931 err = json.Unmarshal(*v, &searchResultsConfidenceScore)
4932 if err != nil {
4933 return err
4934 }
4935 sr.SearchResultsConfidenceScore = &searchResultsConfidenceScore
4936 }
4937 case "readLink":
4938 if v != nil {
4939 var readLink string
4940 err = json.Unmarshal(*v, &readLink)
4941 if err != nil {
4942 return err
4943 }
4944 sr.ReadLink = &readLink
4945 }
4946 case "webSearchUrl":
4947 if v != nil {
4948 var webSearchURL string
4949 err = json.Unmarshal(*v, &webSearchURL)
4950 if err != nil {
4951 return err
4952 }
4953 sr.WebSearchURL = &webSearchURL
4954 }
4955 case "potentialAction":
4956 if v != nil {
4957 potentialAction, err := unmarshalBasicActionArray(*v)
4958 if err != nil {
4959 return err
4960 }
4961 sr.PotentialAction = &potentialAction
4962 }
4963 case "immediateAction":
4964 if v != nil {
4965 immediateAction, err := unmarshalBasicActionArray(*v)
4966 if err != nil {
4967 return err
4968 }
4969 sr.ImmediateAction = &immediateAction
4970 }
4971 case "preferredClickthroughUrl":
4972 if v != nil {
4973 var preferredClickthroughURL string
4974 err = json.Unmarshal(*v, &preferredClickthroughURL)
4975 if err != nil {
4976 return err
4977 }
4978 sr.PreferredClickthroughURL = &preferredClickthroughURL
4979 }
4980 case "adaptiveCard":
4981 if v != nil {
4982 var adaptiveCard string
4983 err = json.Unmarshal(*v, &adaptiveCard)
4984 if err != nil {
4985 return err
4986 }
4987 sr.AdaptiveCard = &adaptiveCard
4988 }
4989 case "id":
4990 if v != nil {
4991 var ID string
4992 err = json.Unmarshal(*v, &ID)
4993 if err != nil {
4994 return err
4995 }
4996 sr.ID = &ID
4997 }
4998 case "_type":
4999 if v != nil {
5000 var typeVar TypeBasicResponseBase
5001 err = json.Unmarshal(*v, &typeVar)
5002 if err != nil {
5003 return err
5004 }
5005 sr.Type = typeVar
5006 }
5007 }
5008 }
5009
5010 return nil
5011 }
5012
5013
5014 type BasicSearchResultsAnswer interface {
5015 AsPlaces() (*Places, bool)
5016 AsSearchResultsAnswer() (*SearchResultsAnswer, bool)
5017 }
5018
5019
5020 type SearchResultsAnswer struct {
5021
5022 QueryContext BasicQueryContext `json:"queryContext,omitempty"`
5023
5024 TotalEstimatedMatches *int64 `json:"totalEstimatedMatches,omitempty"`
5025
5026 IsFamilyFriendly *bool `json:"isFamilyFriendly,omitempty"`
5027
5028 ReadLink *string `json:"readLink,omitempty"`
5029
5030 WebSearchURL *string `json:"webSearchUrl,omitempty"`
5031
5032 PotentialAction *[]BasicAction `json:"potentialAction,omitempty"`
5033
5034 ImmediateAction *[]BasicAction `json:"immediateAction,omitempty"`
5035
5036 PreferredClickthroughURL *string `json:"preferredClickthroughUrl,omitempty"`
5037
5038 AdaptiveCard *string `json:"adaptiveCard,omitempty"`
5039
5040 ID *string `json:"id,omitempty"`
5041
5042 Type TypeBasicResponseBase `json:"_type,omitempty"`
5043 }
5044
5045 func unmarshalBasicSearchResultsAnswer(body []byte) (BasicSearchResultsAnswer, error) {
5046 var m map[string]interface{}
5047 err := json.Unmarshal(body, &m)
5048 if err != nil {
5049 return nil, err
5050 }
5051
5052 switch m["_type"] {
5053 case string(TypePlaces):
5054 var p Places
5055 err := json.Unmarshal(body, &p)
5056 return p, err
5057 default:
5058 var sra SearchResultsAnswer
5059 err := json.Unmarshal(body, &sra)
5060 return sra, err
5061 }
5062 }
5063 func unmarshalBasicSearchResultsAnswerArray(body []byte) ([]BasicSearchResultsAnswer, error) {
5064 var rawMessages []*json.RawMessage
5065 err := json.Unmarshal(body, &rawMessages)
5066 if err != nil {
5067 return nil, err
5068 }
5069
5070 sraArray := make([]BasicSearchResultsAnswer, len(rawMessages))
5071
5072 for index, rawMessage := range rawMessages {
5073 sra, err := unmarshalBasicSearchResultsAnswer(*rawMessage)
5074 if err != nil {
5075 return nil, err
5076 }
5077 sraArray[index] = sra
5078 }
5079 return sraArray, nil
5080 }
5081
5082
5083 func (sra SearchResultsAnswer) MarshalJSON() ([]byte, error) {
5084 sra.Type = TypeSearchResultsAnswer
5085 objectMap := make(map[string]interface{})
5086 if sra.Type != "" {
5087 objectMap["_type"] = sra.Type
5088 }
5089 return json.Marshal(objectMap)
5090 }
5091
5092
5093 func (sra SearchResultsAnswer) AsThing() (*Thing, bool) {
5094 return nil, false
5095 }
5096
5097
5098 func (sra SearchResultsAnswer) AsBasicThing() (BasicThing, bool) {
5099 return nil, false
5100 }
5101
5102
5103 func (sra SearchResultsAnswer) AsPlaces() (*Places, bool) {
5104 return nil, false
5105 }
5106
5107
5108 func (sra SearchResultsAnswer) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) {
5109 return &sra, true
5110 }
5111
5112
5113 func (sra SearchResultsAnswer) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) {
5114 return &sra, true
5115 }
5116
5117
5118 func (sra SearchResultsAnswer) AsSearchResponse() (*SearchResponse, bool) {
5119 return nil, false
5120 }
5121
5122
5123 func (sra SearchResultsAnswer) AsPostalAddress() (*PostalAddress, bool) {
5124 return nil, false
5125 }
5126
5127
5128 func (sra SearchResultsAnswer) AsPlace() (*Place, bool) {
5129 return nil, false
5130 }
5131
5132
5133 func (sra SearchResultsAnswer) AsAction() (*Action, bool) {
5134 return nil, false
5135 }
5136
5137
5138 func (sra SearchResultsAnswer) AsBasicAction() (BasicAction, bool) {
5139 return nil, false
5140 }
5141
5142
5143 func (sra SearchResultsAnswer) AsResponse() (*Response, bool) {
5144 return nil, false
5145 }
5146
5147
5148 func (sra SearchResultsAnswer) AsBasicResponse() (BasicResponse, bool) {
5149 return &sra, true
5150 }
5151
5152
5153 func (sra SearchResultsAnswer) AsIdentifiable() (*Identifiable, bool) {
5154 return nil, false
5155 }
5156
5157
5158 func (sra SearchResultsAnswer) AsBasicIdentifiable() (BasicIdentifiable, bool) {
5159 return &sra, true
5160 }
5161
5162
5163 func (sra SearchResultsAnswer) AsAnswer() (*Answer, bool) {
5164 return nil, false
5165 }
5166
5167
5168 func (sra SearchResultsAnswer) AsBasicAnswer() (BasicAnswer, bool) {
5169 return &sra, true
5170 }
5171
5172
5173 func (sra SearchResultsAnswer) AsErrorResponse() (*ErrorResponse, bool) {
5174 return nil, false
5175 }
5176
5177
5178 func (sra SearchResultsAnswer) AsCreativeWork() (*CreativeWork, bool) {
5179 return nil, false
5180 }
5181
5182
5183 func (sra SearchResultsAnswer) AsBasicCreativeWork() (BasicCreativeWork, bool) {
5184 return nil, false
5185 }
5186
5187
5188 func (sra SearchResultsAnswer) AsIntangible() (*Intangible, bool) {
5189 return nil, false
5190 }
5191
5192
5193 func (sra SearchResultsAnswer) AsBasicIntangible() (BasicIntangible, bool) {
5194 return nil, false
5195 }
5196
5197
5198 func (sra SearchResultsAnswer) AsSearchAction() (*SearchAction, bool) {
5199 return nil, false
5200 }
5201
5202
5203 func (sra SearchResultsAnswer) AsStructuredValue() (*StructuredValue, bool) {
5204 return nil, false
5205 }
5206
5207
5208 func (sra SearchResultsAnswer) AsBasicStructuredValue() (BasicStructuredValue, bool) {
5209 return nil, false
5210 }
5211
5212
5213 func (sra SearchResultsAnswer) AsResponseBase() (*ResponseBase, bool) {
5214 return nil, false
5215 }
5216
5217
5218 func (sra SearchResultsAnswer) AsBasicResponseBase() (BasicResponseBase, bool) {
5219 return &sra, true
5220 }
5221
5222
5223 func (sra *SearchResultsAnswer) UnmarshalJSON(body []byte) error {
5224 var m map[string]*json.RawMessage
5225 err := json.Unmarshal(body, &m)
5226 if err != nil {
5227 return err
5228 }
5229 for k, v := range m {
5230 switch k {
5231 case "queryContext":
5232 if v != nil {
5233 queryContext, err := unmarshalBasicQueryContext(*v)
5234 if err != nil {
5235 return err
5236 }
5237 sra.QueryContext = queryContext
5238 }
5239 case "totalEstimatedMatches":
5240 if v != nil {
5241 var totalEstimatedMatches int64
5242 err = json.Unmarshal(*v, &totalEstimatedMatches)
5243 if err != nil {
5244 return err
5245 }
5246 sra.TotalEstimatedMatches = &totalEstimatedMatches
5247 }
5248 case "isFamilyFriendly":
5249 if v != nil {
5250 var isFamilyFriendly bool
5251 err = json.Unmarshal(*v, &isFamilyFriendly)
5252 if err != nil {
5253 return err
5254 }
5255 sra.IsFamilyFriendly = &isFamilyFriendly
5256 }
5257 case "readLink":
5258 if v != nil {
5259 var readLink string
5260 err = json.Unmarshal(*v, &readLink)
5261 if err != nil {
5262 return err
5263 }
5264 sra.ReadLink = &readLink
5265 }
5266 case "webSearchUrl":
5267 if v != nil {
5268 var webSearchURL string
5269 err = json.Unmarshal(*v, &webSearchURL)
5270 if err != nil {
5271 return err
5272 }
5273 sra.WebSearchURL = &webSearchURL
5274 }
5275 case "potentialAction":
5276 if v != nil {
5277 potentialAction, err := unmarshalBasicActionArray(*v)
5278 if err != nil {
5279 return err
5280 }
5281 sra.PotentialAction = &potentialAction
5282 }
5283 case "immediateAction":
5284 if v != nil {
5285 immediateAction, err := unmarshalBasicActionArray(*v)
5286 if err != nil {
5287 return err
5288 }
5289 sra.ImmediateAction = &immediateAction
5290 }
5291 case "preferredClickthroughUrl":
5292 if v != nil {
5293 var preferredClickthroughURL string
5294 err = json.Unmarshal(*v, &preferredClickthroughURL)
5295 if err != nil {
5296 return err
5297 }
5298 sra.PreferredClickthroughURL = &preferredClickthroughURL
5299 }
5300 case "adaptiveCard":
5301 if v != nil {
5302 var adaptiveCard string
5303 err = json.Unmarshal(*v, &adaptiveCard)
5304 if err != nil {
5305 return err
5306 }
5307 sra.AdaptiveCard = &adaptiveCard
5308 }
5309 case "id":
5310 if v != nil {
5311 var ID string
5312 err = json.Unmarshal(*v, &ID)
5313 if err != nil {
5314 return err
5315 }
5316 sra.ID = &ID
5317 }
5318 case "_type":
5319 if v != nil {
5320 var typeVar TypeBasicResponseBase
5321 err = json.Unmarshal(*v, &typeVar)
5322 if err != nil {
5323 return err
5324 }
5325 sra.Type = typeVar
5326 }
5327 }
5328 }
5329
5330 return nil
5331 }
5332
5333
5334 type BasicStructuredValue interface {
5335 AsPostalAddress() (*PostalAddress, bool)
5336 AsStructuredValue() (*StructuredValue, bool)
5337 }
5338
5339
5340 type StructuredValue struct {
5341
5342 Name *string `json:"name,omitempty"`
5343
5344 URL *string `json:"url,omitempty"`
5345
5346 EntityPresentationInfo BasicEntitiesEntityPresentationInfo `json:"entityPresentationInfo,omitempty"`
5347
5348 ReadLink *string `json:"readLink,omitempty"`
5349
5350 WebSearchURL *string `json:"webSearchUrl,omitempty"`
5351
5352 PotentialAction *[]BasicAction `json:"potentialAction,omitempty"`
5353
5354 ImmediateAction *[]BasicAction `json:"immediateAction,omitempty"`
5355
5356 PreferredClickthroughURL *string `json:"preferredClickthroughUrl,omitempty"`
5357
5358 AdaptiveCard *string `json:"adaptiveCard,omitempty"`
5359
5360 ID *string `json:"id,omitempty"`
5361
5362 Type TypeBasicResponseBase `json:"_type,omitempty"`
5363 }
5364
5365 func unmarshalBasicStructuredValue(body []byte) (BasicStructuredValue, error) {
5366 var m map[string]interface{}
5367 err := json.Unmarshal(body, &m)
5368 if err != nil {
5369 return nil, err
5370 }
5371
5372 switch m["_type"] {
5373 case string(TypePostalAddress):
5374 var pa PostalAddress
5375 err := json.Unmarshal(body, &pa)
5376 return pa, err
5377 default:
5378 var sv StructuredValue
5379 err := json.Unmarshal(body, &sv)
5380 return sv, err
5381 }
5382 }
5383 func unmarshalBasicStructuredValueArray(body []byte) ([]BasicStructuredValue, error) {
5384 var rawMessages []*json.RawMessage
5385 err := json.Unmarshal(body, &rawMessages)
5386 if err != nil {
5387 return nil, err
5388 }
5389
5390 svArray := make([]BasicStructuredValue, len(rawMessages))
5391
5392 for index, rawMessage := range rawMessages {
5393 sv, err := unmarshalBasicStructuredValue(*rawMessage)
5394 if err != nil {
5395 return nil, err
5396 }
5397 svArray[index] = sv
5398 }
5399 return svArray, nil
5400 }
5401
5402
5403 func (sv StructuredValue) MarshalJSON() ([]byte, error) {
5404 sv.Type = TypeStructuredValue
5405 objectMap := make(map[string]interface{})
5406 if sv.Type != "" {
5407 objectMap["_type"] = sv.Type
5408 }
5409 return json.Marshal(objectMap)
5410 }
5411
5412
5413 func (sv StructuredValue) AsThing() (*Thing, bool) {
5414 return nil, false
5415 }
5416
5417
5418 func (sv StructuredValue) AsBasicThing() (BasicThing, bool) {
5419 return &sv, true
5420 }
5421
5422
5423 func (sv StructuredValue) AsPlaces() (*Places, bool) {
5424 return nil, false
5425 }
5426
5427
5428 func (sv StructuredValue) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) {
5429 return nil, false
5430 }
5431
5432
5433 func (sv StructuredValue) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) {
5434 return nil, false
5435 }
5436
5437
5438 func (sv StructuredValue) AsSearchResponse() (*SearchResponse, bool) {
5439 return nil, false
5440 }
5441
5442
5443 func (sv StructuredValue) AsPostalAddress() (*PostalAddress, bool) {
5444 return nil, false
5445 }
5446
5447
5448 func (sv StructuredValue) AsPlace() (*Place, bool) {
5449 return nil, false
5450 }
5451
5452
5453 func (sv StructuredValue) AsAction() (*Action, bool) {
5454 return nil, false
5455 }
5456
5457
5458 func (sv StructuredValue) AsBasicAction() (BasicAction, bool) {
5459 return nil, false
5460 }
5461
5462
5463 func (sv StructuredValue) AsResponse() (*Response, bool) {
5464 return nil, false
5465 }
5466
5467
5468 func (sv StructuredValue) AsBasicResponse() (BasicResponse, bool) {
5469 return &sv, true
5470 }
5471
5472
5473 func (sv StructuredValue) AsIdentifiable() (*Identifiable, bool) {
5474 return nil, false
5475 }
5476
5477
5478 func (sv StructuredValue) AsBasicIdentifiable() (BasicIdentifiable, bool) {
5479 return &sv, true
5480 }
5481
5482
5483 func (sv StructuredValue) AsAnswer() (*Answer, bool) {
5484 return nil, false
5485 }
5486
5487
5488 func (sv StructuredValue) AsBasicAnswer() (BasicAnswer, bool) {
5489 return nil, false
5490 }
5491
5492
5493 func (sv StructuredValue) AsErrorResponse() (*ErrorResponse, bool) {
5494 return nil, false
5495 }
5496
5497
5498 func (sv StructuredValue) AsCreativeWork() (*CreativeWork, bool) {
5499 return nil, false
5500 }
5501
5502
5503 func (sv StructuredValue) AsBasicCreativeWork() (BasicCreativeWork, bool) {
5504 return nil, false
5505 }
5506
5507
5508 func (sv StructuredValue) AsIntangible() (*Intangible, bool) {
5509 return nil, false
5510 }
5511
5512
5513 func (sv StructuredValue) AsBasicIntangible() (BasicIntangible, bool) {
5514 return &sv, true
5515 }
5516
5517
5518 func (sv StructuredValue) AsSearchAction() (*SearchAction, bool) {
5519 return nil, false
5520 }
5521
5522
5523 func (sv StructuredValue) AsStructuredValue() (*StructuredValue, bool) {
5524 return &sv, true
5525 }
5526
5527
5528 func (sv StructuredValue) AsBasicStructuredValue() (BasicStructuredValue, bool) {
5529 return &sv, true
5530 }
5531
5532
5533 func (sv StructuredValue) AsResponseBase() (*ResponseBase, bool) {
5534 return nil, false
5535 }
5536
5537
5538 func (sv StructuredValue) AsBasicResponseBase() (BasicResponseBase, bool) {
5539 return &sv, true
5540 }
5541
5542
5543 func (sv *StructuredValue) UnmarshalJSON(body []byte) error {
5544 var m map[string]*json.RawMessage
5545 err := json.Unmarshal(body, &m)
5546 if err != nil {
5547 return err
5548 }
5549 for k, v := range m {
5550 switch k {
5551 case "name":
5552 if v != nil {
5553 var name string
5554 err = json.Unmarshal(*v, &name)
5555 if err != nil {
5556 return err
5557 }
5558 sv.Name = &name
5559 }
5560 case "url":
5561 if v != nil {
5562 var URL string
5563 err = json.Unmarshal(*v, &URL)
5564 if err != nil {
5565 return err
5566 }
5567 sv.URL = &URL
5568 }
5569 case "entityPresentationInfo":
5570 if v != nil {
5571 entityPresentationInfo, err := unmarshalBasicEntitiesEntityPresentationInfo(*v)
5572 if err != nil {
5573 return err
5574 }
5575 sv.EntityPresentationInfo = entityPresentationInfo
5576 }
5577 case "readLink":
5578 if v != nil {
5579 var readLink string
5580 err = json.Unmarshal(*v, &readLink)
5581 if err != nil {
5582 return err
5583 }
5584 sv.ReadLink = &readLink
5585 }
5586 case "webSearchUrl":
5587 if v != nil {
5588 var webSearchURL string
5589 err = json.Unmarshal(*v, &webSearchURL)
5590 if err != nil {
5591 return err
5592 }
5593 sv.WebSearchURL = &webSearchURL
5594 }
5595 case "potentialAction":
5596 if v != nil {
5597 potentialAction, err := unmarshalBasicActionArray(*v)
5598 if err != nil {
5599 return err
5600 }
5601 sv.PotentialAction = &potentialAction
5602 }
5603 case "immediateAction":
5604 if v != nil {
5605 immediateAction, err := unmarshalBasicActionArray(*v)
5606 if err != nil {
5607 return err
5608 }
5609 sv.ImmediateAction = &immediateAction
5610 }
5611 case "preferredClickthroughUrl":
5612 if v != nil {
5613 var preferredClickthroughURL string
5614 err = json.Unmarshal(*v, &preferredClickthroughURL)
5615 if err != nil {
5616 return err
5617 }
5618 sv.PreferredClickthroughURL = &preferredClickthroughURL
5619 }
5620 case "adaptiveCard":
5621 if v != nil {
5622 var adaptiveCard string
5623 err = json.Unmarshal(*v, &adaptiveCard)
5624 if err != nil {
5625 return err
5626 }
5627 sv.AdaptiveCard = &adaptiveCard
5628 }
5629 case "id":
5630 if v != nil {
5631 var ID string
5632 err = json.Unmarshal(*v, &ID)
5633 if err != nil {
5634 return err
5635 }
5636 sv.ID = &ID
5637 }
5638 case "_type":
5639 if v != nil {
5640 var typeVar TypeBasicResponseBase
5641 err = json.Unmarshal(*v, &typeVar)
5642 if err != nil {
5643 return err
5644 }
5645 sv.Type = typeVar
5646 }
5647 }
5648 }
5649
5650 return nil
5651 }
5652
5653
5654 type BasicThing interface {
5655 AsPostalAddress() (*PostalAddress, bool)
5656 AsPlace() (*Place, bool)
5657 AsAction() (*Action, bool)
5658 AsBasicAction() (BasicAction, bool)
5659 AsCreativeWork() (*CreativeWork, bool)
5660 AsBasicCreativeWork() (BasicCreativeWork, bool)
5661 AsIntangible() (*Intangible, bool)
5662 AsBasicIntangible() (BasicIntangible, bool)
5663 AsSearchAction() (*SearchAction, bool)
5664 AsStructuredValue() (*StructuredValue, bool)
5665 AsBasicStructuredValue() (BasicStructuredValue, bool)
5666 AsThing() (*Thing, bool)
5667 }
5668
5669
5670 type Thing struct {
5671
5672 Name *string `json:"name,omitempty"`
5673
5674 URL *string `json:"url,omitempty"`
5675
5676 EntityPresentationInfo BasicEntitiesEntityPresentationInfo `json:"entityPresentationInfo,omitempty"`
5677
5678 ReadLink *string `json:"readLink,omitempty"`
5679
5680 WebSearchURL *string `json:"webSearchUrl,omitempty"`
5681
5682 PotentialAction *[]BasicAction `json:"potentialAction,omitempty"`
5683
5684 ImmediateAction *[]BasicAction `json:"immediateAction,omitempty"`
5685
5686 PreferredClickthroughURL *string `json:"preferredClickthroughUrl,omitempty"`
5687
5688 AdaptiveCard *string `json:"adaptiveCard,omitempty"`
5689
5690 ID *string `json:"id,omitempty"`
5691
5692 Type TypeBasicResponseBase `json:"_type,omitempty"`
5693 }
5694
5695 func unmarshalBasicThing(body []byte) (BasicThing, error) {
5696 var m map[string]interface{}
5697 err := json.Unmarshal(body, &m)
5698 if err != nil {
5699 return nil, err
5700 }
5701
5702 switch m["_type"] {
5703 case string(TypePostalAddress):
5704 var pa PostalAddress
5705 err := json.Unmarshal(body, &pa)
5706 return pa, err
5707 case string(TypePlace):
5708 var p Place
5709 err := json.Unmarshal(body, &p)
5710 return p, err
5711 case string(TypeAction):
5712 var a Action
5713 err := json.Unmarshal(body, &a)
5714 return a, err
5715 case string(TypeCreativeWork):
5716 var cw CreativeWork
5717 err := json.Unmarshal(body, &cw)
5718 return cw, err
5719 case string(TypeIntangible):
5720 var i Intangible
5721 err := json.Unmarshal(body, &i)
5722 return i, err
5723 case string(TypeSearchAction):
5724 var sa SearchAction
5725 err := json.Unmarshal(body, &sa)
5726 return sa, err
5727 case string(TypeStructuredValue):
5728 var sv StructuredValue
5729 err := json.Unmarshal(body, &sv)
5730 return sv, err
5731 default:
5732 var t Thing
5733 err := json.Unmarshal(body, &t)
5734 return t, err
5735 }
5736 }
5737 func unmarshalBasicThingArray(body []byte) ([]BasicThing, error) {
5738 var rawMessages []*json.RawMessage
5739 err := json.Unmarshal(body, &rawMessages)
5740 if err != nil {
5741 return nil, err
5742 }
5743
5744 tArray := make([]BasicThing, len(rawMessages))
5745
5746 for index, rawMessage := range rawMessages {
5747 t, err := unmarshalBasicThing(*rawMessage)
5748 if err != nil {
5749 return nil, err
5750 }
5751 tArray[index] = t
5752 }
5753 return tArray, nil
5754 }
5755
5756
5757 func (t Thing) MarshalJSON() ([]byte, error) {
5758 t.Type = TypeThing
5759 objectMap := make(map[string]interface{})
5760 if t.Type != "" {
5761 objectMap["_type"] = t.Type
5762 }
5763 return json.Marshal(objectMap)
5764 }
5765
5766
5767 func (t Thing) AsThing() (*Thing, bool) {
5768 return &t, true
5769 }
5770
5771
5772 func (t Thing) AsBasicThing() (BasicThing, bool) {
5773 return &t, true
5774 }
5775
5776
5777 func (t Thing) AsPlaces() (*Places, bool) {
5778 return nil, false
5779 }
5780
5781
5782 func (t Thing) AsSearchResultsAnswer() (*SearchResultsAnswer, bool) {
5783 return nil, false
5784 }
5785
5786
5787 func (t Thing) AsBasicSearchResultsAnswer() (BasicSearchResultsAnswer, bool) {
5788 return nil, false
5789 }
5790
5791
5792 func (t Thing) AsSearchResponse() (*SearchResponse, bool) {
5793 return nil, false
5794 }
5795
5796
5797 func (t Thing) AsPostalAddress() (*PostalAddress, bool) {
5798 return nil, false
5799 }
5800
5801
5802 func (t Thing) AsPlace() (*Place, bool) {
5803 return nil, false
5804 }
5805
5806
5807 func (t Thing) AsAction() (*Action, bool) {
5808 return nil, false
5809 }
5810
5811
5812 func (t Thing) AsBasicAction() (BasicAction, bool) {
5813 return nil, false
5814 }
5815
5816
5817 func (t Thing) AsResponse() (*Response, bool) {
5818 return nil, false
5819 }
5820
5821
5822 func (t Thing) AsBasicResponse() (BasicResponse, bool) {
5823 return &t, true
5824 }
5825
5826
5827 func (t Thing) AsIdentifiable() (*Identifiable, bool) {
5828 return nil, false
5829 }
5830
5831
5832 func (t Thing) AsBasicIdentifiable() (BasicIdentifiable, bool) {
5833 return &t, true
5834 }
5835
5836
5837 func (t Thing) AsAnswer() (*Answer, bool) {
5838 return nil, false
5839 }
5840
5841
5842 func (t Thing) AsBasicAnswer() (BasicAnswer, bool) {
5843 return nil, false
5844 }
5845
5846
5847 func (t Thing) AsErrorResponse() (*ErrorResponse, bool) {
5848 return nil, false
5849 }
5850
5851
5852 func (t Thing) AsCreativeWork() (*CreativeWork, bool) {
5853 return nil, false
5854 }
5855
5856
5857 func (t Thing) AsBasicCreativeWork() (BasicCreativeWork, bool) {
5858 return nil, false
5859 }
5860
5861
5862 func (t Thing) AsIntangible() (*Intangible, bool) {
5863 return nil, false
5864 }
5865
5866
5867 func (t Thing) AsBasicIntangible() (BasicIntangible, bool) {
5868 return nil, false
5869 }
5870
5871
5872 func (t Thing) AsSearchAction() (*SearchAction, bool) {
5873 return nil, false
5874 }
5875
5876
5877 func (t Thing) AsStructuredValue() (*StructuredValue, bool) {
5878 return nil, false
5879 }
5880
5881
5882 func (t Thing) AsBasicStructuredValue() (BasicStructuredValue, bool) {
5883 return nil, false
5884 }
5885
5886
5887 func (t Thing) AsResponseBase() (*ResponseBase, bool) {
5888 return nil, false
5889 }
5890
5891
5892 func (t Thing) AsBasicResponseBase() (BasicResponseBase, bool) {
5893 return &t, true
5894 }
5895
5896
5897 func (t *Thing) UnmarshalJSON(body []byte) error {
5898 var m map[string]*json.RawMessage
5899 err := json.Unmarshal(body, &m)
5900 if err != nil {
5901 return err
5902 }
5903 for k, v := range m {
5904 switch k {
5905 case "name":
5906 if v != nil {
5907 var name string
5908 err = json.Unmarshal(*v, &name)
5909 if err != nil {
5910 return err
5911 }
5912 t.Name = &name
5913 }
5914 case "url":
5915 if v != nil {
5916 var URL string
5917 err = json.Unmarshal(*v, &URL)
5918 if err != nil {
5919 return err
5920 }
5921 t.URL = &URL
5922 }
5923 case "entityPresentationInfo":
5924 if v != nil {
5925 entityPresentationInfo, err := unmarshalBasicEntitiesEntityPresentationInfo(*v)
5926 if err != nil {
5927 return err
5928 }
5929 t.EntityPresentationInfo = entityPresentationInfo
5930 }
5931 case "readLink":
5932 if v != nil {
5933 var readLink string
5934 err = json.Unmarshal(*v, &readLink)
5935 if err != nil {
5936 return err
5937 }
5938 t.ReadLink = &readLink
5939 }
5940 case "webSearchUrl":
5941 if v != nil {
5942 var webSearchURL string
5943 err = json.Unmarshal(*v, &webSearchURL)
5944 if err != nil {
5945 return err
5946 }
5947 t.WebSearchURL = &webSearchURL
5948 }
5949 case "potentialAction":
5950 if v != nil {
5951 potentialAction, err := unmarshalBasicActionArray(*v)
5952 if err != nil {
5953 return err
5954 }
5955 t.PotentialAction = &potentialAction
5956 }
5957 case "immediateAction":
5958 if v != nil {
5959 immediateAction, err := unmarshalBasicActionArray(*v)
5960 if err != nil {
5961 return err
5962 }
5963 t.ImmediateAction = &immediateAction
5964 }
5965 case "preferredClickthroughUrl":
5966 if v != nil {
5967 var preferredClickthroughURL string
5968 err = json.Unmarshal(*v, &preferredClickthroughURL)
5969 if err != nil {
5970 return err
5971 }
5972 t.PreferredClickthroughURL = &preferredClickthroughURL
5973 }
5974 case "adaptiveCard":
5975 if v != nil {
5976 var adaptiveCard string
5977 err = json.Unmarshal(*v, &adaptiveCard)
5978 if err != nil {
5979 return err
5980 }
5981 t.AdaptiveCard = &adaptiveCard
5982 }
5983 case "id":
5984 if v != nil {
5985 var ID string
5986 err = json.Unmarshal(*v, &ID)
5987 if err != nil {
5988 return err
5989 }
5990 t.ID = &ID
5991 }
5992 case "_type":
5993 if v != nil {
5994 var typeVar TypeBasicResponseBase
5995 err = json.Unmarshal(*v, &typeVar)
5996 if err != nil {
5997 return err
5998 }
5999 t.Type = typeVar
6000 }
6001 }
6002 }
6003
6004 return nil
6005 }
6006
View as plain text