@@ -517,4 +517,79 @@ class RelationshipType(AddressableHALResource):
517517 def __init__ (self , api_resource ):
518518 super (RelationshipType , self ).__init__ (api_resource )
519519
520+ class SearchResult (HALResource ):
521+ """
522+ {
523+ "query":"my query",
524+ "scope":"9076bd16-e69a-48d6-9e41-0238cb40d863",
525+ "appliedFilters": [
526+ {
527+ "filter" : "title",
528+ "operator" : "notcontains",
529+ "value" : "abcd",
530+ "label" : "abcd"
531+ },
532+ {
533+ "filter" : "author",
534+ "operator" : "authority",
535+ "value" : "1234",
536+ "label" : "Smith, Donald"
537+ }
538+ ],
539+ "sort" : {
540+ "by" : "dc.date.issued",
541+ "order" : "asc"
542+ },
543+ "_embedded" : {
544+ "searchResults": {
545+ "_embedded": {
546+ "objects" : [...],
547+ },
548+
549+ "_links": {
550+ "first": {
551+ "href": "/api/discover/search/objects?query=my+query&scope=9076bd16-e69a-48d6-9e41-0238cb40d863&f.title=abcd,notcontains&f.author=1234,authority&page=0&size=5"
552+ },
553+ "self": {
554+ "href": "/api/discover/search/objects?query=my+query&scope=9076bd16-e69a-48d6-9e41-0238cb40d863&f.title=abcd,notcontains&f.author=1234,authority&page=0&size=5"
555+ },
556+ "next": {
557+ "href": "/api/discover/search/objects?query=my+query&scope=9076bd16-e69a-48d6-9e41-0238cb40d863&f.title=abcd,notcontains&f.author=1234,authority&page=1&size=5"
558+ },
559+ "last": {
560+ "href": "/api/discover/search/objects?query=my+query&scope=9076bd16-e69a-48d6-9e41-0238cb40d863&f.title=abcd,notcontains&f.author=1234,authority&page=2&size=5"
561+ }
562+ },
563+ "page": {
564+ "number": 0,
565+ "size": 20,
566+ "totalElements": 12,
567+ "totalPages": 3
568+ }
569+ }, "facets"... (TODO)
570+ """
571+ query = None
572+ scope = None
573+ appliedFilters = []
574+ type = None
520575
576+ def __init__ (self , api_resource ):
577+ super (SearchResult , self ).__init__ (api_resource )
578+ if 'lastModified' in api_resource :
579+ self .lastModified = api_resource ['lastModified' ]
580+ if 'step' in api_resource :
581+ self .step = api_resource ['step' ]
582+ if 'sections' in api_resource :
583+ self .sections = api_resource ['sections' ].copy ()
584+ if 'type' in api_resource and self .type is not None :
585+ self .type = api_resource ['type' ]
586+
587+ def as_dict (self ):
588+ parent_dict = super (SearchResult , self ).as_dict ()
589+ dict = {
590+ 'lastModified' : self .lastModified ,
591+ 'step' : self .step ,
592+ 'sections' : self .sections ,
593+ 'type' : self .type
594+ }
595+ return {** parent_dict , ** dict }
0 commit comments