@@ -86,19 +86,19 @@ export class XivapiService {
8686 * @param options Search options, see http://xivapi.com/docs/Search for more details.
8787 */
8888 public search ( options : XivapiSearchOptions ) : Observable < any > {
89- let queryParams : HttpParams = this . prepareQueryString ( options ) ;
9089 if ( options . filters ) {
9190 const filterChain : string = options . filters . reduce ( ( chain , filter ) => {
9291 const value : string = filter . value instanceof Array ? filter . value . join ( ';' ) : filter . value . toString ( ) ;
9392 return `${ chain } ${ filter . column } ${ filter . operator } ${ value } ,` ;
9493 } , '' ) . slice ( 0 , - 1 ) ;
95- queryParams = queryParams . set ( 'filters' , filterChain ) ;
96- }
97- const baseUrl : string = options . staging ? XivapiService . STAGING_API_BASE_URL : XivapiService . API_BASE_URL ;
98- if ( options . staging ) {
99- queryParams = queryParams . delete ( 'staging' ) ;
94+
95+ if ( ! options . extraQueryParams ) {
96+ options . extraQueryParams = { } ;
97+ }
98+ options . extraQueryParams . filters = filterChain ;
10099 }
101- return this . doGet < any > ( `${ baseUrl } /Search` , queryParams ) ;
100+
101+ return this . request < any > ( '/Search' , options ) ;
102102 }
103103
104104 /**
@@ -261,9 +261,14 @@ export class XivapiService {
261261 if ( options === null || options === undefined ) {
262262 return queryString ;
263263 }
264- Object . keys ( options )
265- . filter ( key => key !== 'extraQueryParams' )
264+
265+ const { extraQueryParams, ...rest } = options ;
266+ Object . keys ( rest )
266267 . forEach ( optionKey => {
268+ if ( extraQueryParams && Object . prototype . hasOwnProperty . call ( extraQueryParams , optionKey ) ) {
269+ return ;
270+ }
271+
267272 // @ts -ignore
268273 const value : any = options [ optionKey ] as any ;
269274 if ( value instanceof Array ) {
@@ -272,11 +277,11 @@ export class XivapiService {
272277 queryString = queryString . set ( optionKey , value . toString ( ) ) ;
273278 }
274279 } ) ;
275- if ( options . extraQueryParams !== undefined ) {
276- Object . keys ( options . extraQueryParams )
280+ if ( extraQueryParams ) {
281+ Object . keys ( extraQueryParams )
277282 . forEach ( key => {
278283 // @ts -ignore
279- queryString = queryString . set ( key , options . extraQueryParams [ key ] . toString ( ) ) ;
284+ queryString = queryString . set ( key , extraQueryParams [ key ] . toString ( ) ) ;
280285 } ) ;
281286 }
282287 return queryString ;
0 commit comments