-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from Relewise/feat/objectpath-and-scopes
feat: implement objectpath and scopes for filters
- Loading branch information
Showing
6 changed files
with
124 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { ApplyFilterSettings, FilterScopes } from '../models/data-contracts'; | ||
|
||
export class FilterScopesBuilder { | ||
|
||
private fillScope: ApplyFilterSettings | undefined = undefined; | ||
private defaultScope: ApplyFilterSettings | undefined = undefined; | ||
|
||
public fill({ apply }: { apply: boolean; }): this { | ||
this.fillScope = { | ||
$type: 'Relewise.Client.Requests.Filters.Settings.ApplyFilterSettings, Relewise.Client', | ||
apply, | ||
}; | ||
|
||
return this; | ||
} | ||
|
||
public default({ apply }: { apply: boolean; }): this { | ||
this.defaultScope = { | ||
$type: 'Relewise.Client.Requests.Filters.Settings.ApplyFilterSettings, Relewise.Client', | ||
apply, | ||
}; | ||
|
||
return this; | ||
} | ||
|
||
public build(): FilterScopes | null { | ||
return this.fillScope || this.defaultScope | ||
? { | ||
fill: this.fillScope, | ||
default: this.defaultScope, | ||
} | ||
: null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { FilterSettings } from '../models/data-contracts'; | ||
import { FilterScopesBuilder } from './filterScopesBuilder'; | ||
|
||
export class FilterSettingsBuilder { | ||
private scopesBuilder: FilterScopesBuilder = new FilterScopesBuilder(); | ||
|
||
public scopes(builder: (builder: FilterScopesBuilder) => void): this { | ||
builder(this.scopesBuilder); | ||
|
||
return this; | ||
} | ||
|
||
public build(): FilterSettings | null { | ||
const scopes = this.scopesBuilder.build(); | ||
return scopes | ||
? { scopes: scopes } | ||
: null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters