@@ -4,7 +4,7 @@ import { Observable } from 'rxjs';
4
4
import { environment } from '../../../environments/environment' ;
5
5
import { PagingResponse } from '../models/paging-response' ;
6
6
import { ListingUploadHistoryRecord } from '../models/listing-upload-history-record' ;
7
- import { ListingTableRow } from '../models/listing-table-row' ;
7
+ import { AggregatedListingTableRow , ListingTableRow } from '../models/listing-table-row' ;
8
8
import { ListingSearchRequest } from '../models/listing-search-request' ;
9
9
import { ListingAddressCandidate , ListingDetails } from '../models/listing-details' ;
10
10
import { ExportJurisdiction } from '../models/export-listing' ;
@@ -140,6 +140,73 @@ export class ListingDataService {
140
140
return this . httpClient . get < PagingResponse < ListingTableRow > > ( endpointUrl ) ;
141
141
}
142
142
143
+ getAggregatedListings (
144
+ pageNumber : number = 1 ,
145
+ pageSize : number = 10 ,
146
+ orderBy : string = '' ,
147
+ direction : 'asc' | 'desc' = 'asc' ,
148
+ searchReq : ListingSearchRequest = { } ,
149
+ filter ?: ListingFilter
150
+ ) : Observable < PagingResponse < AggregatedListingTableRow > > {
151
+ let endpointUrl = `${ environment . API_HOST } /rentallistings/grouped?pageSize=${ pageSize } &pageNumber=${ pageNumber } ` ;
152
+
153
+ if ( orderBy ) {
154
+ endpointUrl += `&orderBy=${ orderBy } &direction=${ direction } ` ;
155
+ }
156
+
157
+ if ( searchReq . all ) {
158
+ endpointUrl += `&all=${ searchReq . all } ` ;
159
+ }
160
+ if ( searchReq . address ) {
161
+ endpointUrl += `&address=${ searchReq . address } ` ;
162
+ }
163
+ if ( searchReq . url ) {
164
+ endpointUrl += `&url=${ searchReq . url } ` ;
165
+ }
166
+ if ( searchReq . listingId ) {
167
+ endpointUrl += `&listingId=${ searchReq . listingId } ` ;
168
+ }
169
+ if ( searchReq . hostName ) {
170
+ endpointUrl += `&hostName=${ searchReq . hostName } ` ;
171
+ }
172
+ if ( searchReq . businessLicence ) {
173
+ endpointUrl += `&businessLicence=${ searchReq . businessLicence } ` ;
174
+ }
175
+
176
+ if ( filter ) {
177
+ if ( filter . byLocation ) {
178
+ if ( ! ! filter . byLocation ?. isPrincipalResidenceRequired ) {
179
+ endpointUrl += `&prRequirement=${ filter . byLocation . isPrincipalResidenceRequired == 'Yes' } ` ;
180
+ }
181
+ if ( ! ! filter . byLocation ?. isBusinessLicenceRequired ) {
182
+ endpointUrl += `&blRequirement=${ filter . byLocation . isBusinessLicenceRequired == 'Yes' } ` ;
183
+ }
184
+ }
185
+ if ( filter . byStatus ) {
186
+ if ( filter . byStatus . reassigned !== null && filter . byStatus . reassigned !== undefined ) {
187
+ endpointUrl += `&reassigned=${ ! ! filter . byStatus . reassigned } ` ;
188
+ }
189
+ if ( filter . byStatus . takedownComplete !== null && filter . byStatus . takedownComplete !== undefined ) {
190
+ endpointUrl += `&takedownComplete=${ ! ! filter . byStatus . takedownComplete } ` ;
191
+ }
192
+
193
+ const statuses = new Array ( ) ;
194
+ if ( filter . byStatus . active ) statuses . push ( 'A' )
195
+ if ( filter . byStatus . inactive ) statuses . push ( 'I' )
196
+ if ( filter . byStatus . new ) statuses . push ( 'N' )
197
+
198
+ if ( statuses . length ) {
199
+ endpointUrl += `&statuses=${ statuses . join ( ',' ) } ` ;
200
+ }
201
+ }
202
+ if ( ! ! filter . community ) {
203
+ endpointUrl += `&lgId=${ filter . community } ` ;
204
+ }
205
+ }
206
+
207
+ return this . httpClient . get < PagingResponse < AggregatedListingTableRow > > ( endpointUrl ) ;
208
+ }
209
+
143
210
getListingDetailsById ( id : number ) : Observable < ListingDetails > {
144
211
return this . httpClient . get < ListingDetails > ( `${ environment . API_HOST } /rentallistings/${ id } ` ) ;
145
212
}
0 commit comments