|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +from __future__ import unicode_literals |
| 3 | + |
| 4 | +from yoti_python_sdk.doc_scan import constants |
| 5 | +from yoti_python_sdk.utils import YotiSerializable, remove_null_values |
| 6 | +from .requested_check import RequestedCheck |
| 7 | + |
| 8 | + |
| 9 | +class WatchlistAdvancedCaProfilesCheckConfig(YotiSerializable): |
| 10 | + """ |
| 11 | + The configuration applied when creating a Watchlist Advanced CA Profiles check. |
| 12 | + """ |
| 13 | + |
| 14 | + def __init__(self, remove_deceased=None, share_url=None, sources=None): |
| 15 | + """ |
| 16 | + :param remove_deceased: whether to remove deceased individuals from results |
| 17 | + :type remove_deceased: bool or None |
| 18 | + :param share_url: whether to share the URL in results |
| 19 | + :type share_url: bool or None |
| 20 | + :param sources: the sources configuration |
| 21 | + :type sources: WatchlistAdvancedCaSourcesConfig or None |
| 22 | + """ |
| 23 | + self.__remove_deceased = remove_deceased |
| 24 | + self.__share_url = share_url |
| 25 | + self.__sources = sources |
| 26 | + |
| 27 | + @property |
| 28 | + def remove_deceased(self): |
| 29 | + """ |
| 30 | + Whether deceased individuals are removed from results |
| 31 | +
|
| 32 | + :return: remove deceased flag |
| 33 | + :rtype: bool or None |
| 34 | + """ |
| 35 | + return self.__remove_deceased |
| 36 | + |
| 37 | + @property |
| 38 | + def share_url(self): |
| 39 | + """ |
| 40 | + Whether the URL is shared in results |
| 41 | +
|
| 42 | + :return: share URL flag |
| 43 | + :rtype: bool or None |
| 44 | + """ |
| 45 | + return self.__share_url |
| 46 | + |
| 47 | + @property |
| 48 | + def sources(self): |
| 49 | + """ |
| 50 | + The sources configuration for the advanced CA profiles check |
| 51 | +
|
| 52 | + :return: the sources configuration |
| 53 | + :rtype: WatchlistAdvancedCaSourcesConfig or None |
| 54 | + """ |
| 55 | + return self.__sources |
| 56 | + |
| 57 | + def to_json(self): |
| 58 | + return remove_null_values( |
| 59 | + { |
| 60 | + "remove_deceased": self.__remove_deceased, |
| 61 | + "share_url": self.__share_url, |
| 62 | + "sources": self.__sources, |
| 63 | + } |
| 64 | + ) |
| 65 | + |
| 66 | + |
| 67 | +class WatchlistAdvancedCaSourcesConfig(YotiSerializable): |
| 68 | + """ |
| 69 | + Configures the sources for a Watchlist Advanced CA Profiles check. |
| 70 | + """ |
| 71 | + |
| 72 | + def __init__(self, types=None): |
| 73 | + """ |
| 74 | + :param types: the list of source types to check against |
| 75 | + :type types: list[str] or None |
| 76 | + """ |
| 77 | + self.__types = types or [] |
| 78 | + |
| 79 | + @property |
| 80 | + def types(self): |
| 81 | + """ |
| 82 | + The list of source types |
| 83 | +
|
| 84 | + :return: the source types |
| 85 | + :rtype: list[str] |
| 86 | + """ |
| 87 | + return self.__types |
| 88 | + |
| 89 | + def to_json(self): |
| 90 | + return remove_null_values({"types": self.__types}) |
| 91 | + |
| 92 | + |
| 93 | +class WatchlistAdvancedCaProfilesCheck(RequestedCheck): |
| 94 | + """ |
| 95 | + Requests creation of a Watchlist Advanced CA Profiles check |
| 96 | + """ |
| 97 | + |
| 98 | + def __init__(self, config): |
| 99 | + """ |
| 100 | + :param config: the Watchlist Advanced CA Profiles check configuration |
| 101 | + :type config: WatchlistAdvancedCaProfilesCheckConfig |
| 102 | + """ |
| 103 | + self.__config = config |
| 104 | + |
| 105 | + @property |
| 106 | + def type(self): |
| 107 | + return constants.WATCHLIST_ADVANCED_CA_CHECK_TYPE |
| 108 | + |
| 109 | + @property |
| 110 | + def config(self): |
| 111 | + return self.__config |
| 112 | + |
| 113 | + |
| 114 | +class WatchlistAdvancedCaProfilesCheckBuilder(object): |
| 115 | + """ |
| 116 | + Builder to assist creation of :class:`WatchlistAdvancedCaProfilesCheck` |
| 117 | + """ |
| 118 | + |
| 119 | + def __init__(self): |
| 120 | + self.__remove_deceased = None |
| 121 | + self.__share_url = None |
| 122 | + self.__sources = None |
| 123 | + |
| 124 | + def with_remove_deceased(self, remove_deceased): |
| 125 | + """ |
| 126 | + Sets whether deceased individuals should be removed from results |
| 127 | +
|
| 128 | + :param remove_deceased: the remove deceased flag |
| 129 | + :type remove_deceased: bool |
| 130 | + :return: the builder |
| 131 | + :rtype: WatchlistAdvancedCaProfilesCheckBuilder |
| 132 | + """ |
| 133 | + self.__remove_deceased = remove_deceased |
| 134 | + return self |
| 135 | + |
| 136 | + def with_share_url(self, share_url): |
| 137 | + """ |
| 138 | + Sets whether the URL should be shared in results |
| 139 | +
|
| 140 | + :param share_url: the share URL flag |
| 141 | + :type share_url: bool |
| 142 | + :return: the builder |
| 143 | + :rtype: WatchlistAdvancedCaProfilesCheckBuilder |
| 144 | + """ |
| 145 | + self.__share_url = share_url |
| 146 | + return self |
| 147 | + |
| 148 | + def with_sources(self, sources): |
| 149 | + """ |
| 150 | + Sets the sources configuration for the check |
| 151 | +
|
| 152 | + :param sources: the sources configuration |
| 153 | + :type sources: WatchlistAdvancedCaSourcesConfig |
| 154 | + :return: the builder |
| 155 | + :rtype: WatchlistAdvancedCaProfilesCheckBuilder |
| 156 | + """ |
| 157 | + self.__sources = sources |
| 158 | + return self |
| 159 | + |
| 160 | + def build(self): |
| 161 | + config = WatchlistAdvancedCaProfilesCheckConfig( |
| 162 | + self.__remove_deceased, self.__share_url, self.__sources |
| 163 | + ) |
| 164 | + return WatchlistAdvancedCaProfilesCheck(config) |
0 commit comments