Pull request: beta client squashed
Merge in DNS/adguard-home from beta-client-2 to master
Squashed commit of the following:
commit b2640cc49a6c5484d730b534dcf5a8013d7fa478
Merge: 659def862 aef4659e9
Author: Eugene Burkov <e.burkov@adguard.com>
Date: Tue Dec 29 19:23:09 2020 +0300
Merge branch 'master' into beta-client-2
commit 659def8626467949c35b7a6a0c99ffafb07b4385
Author: Eugene Burkov <e.burkov@adguard.com>
Date: Tue Dec 29 17:25:14 2020 +0300
all: upgrade github actions node version
commit b4b8cf8dd75672e9155da5d111ac66e8f5ba1535
Author: Vladislav Abdulmyanov <v.abdulmyanov@adguard.com>
Date: Tue Dec 29 16:57:14 2020 +0300
all: beta client squashed
This commit is contained in:
69
client2/src/lib/entities/ResultRule.ts
Normal file
69
client2/src/lib/entities/ResultRule.ts
Normal file
@@ -0,0 +1,69 @@
|
||||
// This file was autogenerated. Please do not change.
|
||||
// All changes will be overwrited on commit.
|
||||
export interface IResultRule {
|
||||
filter_list_id?: number;
|
||||
text?: string;
|
||||
}
|
||||
|
||||
export default class ResultRule {
|
||||
readonly _filter_list_id: number | undefined;
|
||||
|
||||
/**
|
||||
* Description: In case if there's a rule applied to this DNS request, this is ID of the filter list that the rule belongs to.
|
||||
*
|
||||
* Example: 123123
|
||||
*/
|
||||
get filterListId(): number | undefined {
|
||||
return this._filter_list_id;
|
||||
}
|
||||
|
||||
readonly _text: string | undefined;
|
||||
|
||||
/**
|
||||
* Description: The text of the filtering rule applied to the request (if any).
|
||||
*
|
||||
* Example: ||example.org^
|
||||
*/
|
||||
get text(): string | undefined {
|
||||
return this._text;
|
||||
}
|
||||
|
||||
constructor(props: IResultRule) {
|
||||
if (typeof props.filter_list_id === 'number') {
|
||||
this._filter_list_id = props.filter_list_id;
|
||||
}
|
||||
if (typeof props.text === 'string') {
|
||||
this._text = props.text.trim();
|
||||
}
|
||||
}
|
||||
|
||||
serialize(): IResultRule {
|
||||
const data: IResultRule = {
|
||||
};
|
||||
if (typeof this._filter_list_id !== 'undefined') {
|
||||
data.filter_list_id = this._filter_list_id;
|
||||
}
|
||||
if (typeof this._text !== 'undefined') {
|
||||
data.text = this._text;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
validate(): string[] {
|
||||
const validate = {
|
||||
filter_list_id: !this._filter_list_id ? true : typeof this._filter_list_id === 'number',
|
||||
text: !this._text ? true : typeof this._text === 'string' && !this._text ? true : this._text,
|
||||
};
|
||||
const isError: string[] = [];
|
||||
Object.keys(validate).forEach((key) => {
|
||||
if (!(validate as any)[key]) {
|
||||
isError.push(key);
|
||||
}
|
||||
});
|
||||
return isError;
|
||||
}
|
||||
|
||||
update(props: Partial<IResultRule>): ResultRule {
|
||||
return new ResultRule({ ...this.serialize(), ...props });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user