opportify-sdk 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- lib/__init__.py +0 -0
- lib/v1/__init__.py +0 -0
- lib/v1/openapi_client/__init__.py +63 -0
- lib/v1/openapi_client/api/__init__.py +6 -0
- lib/v1/openapi_client/api/email_insights_api.py +317 -0
- lib/v1/openapi_client/api/ip_insights_api.py +322 -0
- lib/v1/openapi_client/api_client.py +797 -0
- lib/v1/openapi_client/api_response.py +21 -0
- lib/v1/openapi_client/configuration.py +595 -0
- lib/v1/openapi_client/exceptions.py +199 -0
- lib/v1/openapi_client/models/__init__.py +45 -0
- lib/v1/openapi_client/models/abuse_contact.py +99 -0
- lib/v1/openapi_client/models/admin_contact.py +99 -0
- lib/v1/openapi_client/models/analyze_email200_response.py +113 -0
- lib/v1/openapi_client/models/analyze_email400_response.py +91 -0
- lib/v1/openapi_client/models/analyze_email400_response_error.py +137 -0
- lib/v1/openapi_client/models/analyze_email500_response.py +91 -0
- lib/v1/openapi_client/models/analyze_email500_response_error.py +89 -0
- lib/v1/openapi_client/models/analyze_email_request.py +92 -0
- lib/v1/openapi_client/models/analyze_ip200_response.py +127 -0
- lib/v1/openapi_client/models/analyze_ip400_response.py +91 -0
- lib/v1/openapi_client/models/analyze_ip400_response_error.py +137 -0
- lib/v1/openapi_client/models/analyze_ip404_response.py +91 -0
- lib/v1/openapi_client/models/analyze_ip500_response.py +91 -0
- lib/v1/openapi_client/models/analyze_ip_request.py +89 -0
- lib/v1/openapi_client/models/asn.py +93 -0
- lib/v1/openapi_client/models/block_listed.py +94 -0
- lib/v1/openapi_client/models/email_dns.py +87 -0
- lib/v1/openapi_client/models/geo.py +113 -0
- lib/v1/openapi_client/models/internalerror.py +89 -0
- lib/v1/openapi_client/models/invalidemail.py +89 -0
- lib/v1/openapi_client/models/ipvalidationfailed.py +89 -0
- lib/v1/openapi_client/models/malformedrequest.py +89 -0
- lib/v1/openapi_client/models/malformedrequest1.py +89 -0
- lib/v1/openapi_client/models/notfound.py +89 -0
- lib/v1/openapi_client/models/organization.py +103 -0
- lib/v1/openapi_client/models/risk_report.py +89 -0
- lib/v1/openapi_client/models/tech_contact.py +99 -0
- lib/v1/openapi_client/models/trusted_provider.py +93 -0
- lib/v1/openapi_client/models/whois.py +117 -0
- lib/v1/openapi_client/py.typed +0 -0
- lib/v1/openapi_client/rest.py +257 -0
- opportify_sdk-0.1.0.dist-info/METADATA +16 -0
- opportify_sdk-0.1.0.dist-info/RECORD +49 -0
- opportify_sdk-0.1.0.dist-info/WHEEL +5 -0
- opportify_sdk-0.1.0.dist-info/top_level.txt +2 -0
- src/__init__.py +6 -0
- src/email_insights.py +97 -0
- src/ip_insights.py +93 -0
src/email_insights.py
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# src/email_insights.py
|
|
2
|
+
import openapi_client
|
|
3
|
+
from openapi_client.configuration import Configuration as ApiConfiguration
|
|
4
|
+
from openapi_client.api_client import ApiClient
|
|
5
|
+
from openapi_client.api.email_insights_api import EmailInsightsApi
|
|
6
|
+
from openapi_client.models.analyze_email_request import AnalyzeEmailRequest
|
|
7
|
+
from openapi_client.exceptions import ApiException
|
|
8
|
+
|
|
9
|
+
class EmailInsights:
|
|
10
|
+
def __init__(self, api_key: str):
|
|
11
|
+
"""
|
|
12
|
+
Initialize the EmailInsights class with the provided API key.
|
|
13
|
+
|
|
14
|
+
:param api_key: The API key for authentication.
|
|
15
|
+
"""
|
|
16
|
+
self.config = ApiConfiguration()
|
|
17
|
+
self.config.api_key = {"opportifyToken": api_key}
|
|
18
|
+
self.host = "https://api.opportify.ai"
|
|
19
|
+
self.version = "v1"
|
|
20
|
+
self.debug_mode = False
|
|
21
|
+
self.api_instance = None
|
|
22
|
+
|
|
23
|
+
def analyze(self, params: dict) -> dict:
|
|
24
|
+
"""
|
|
25
|
+
Analyze the email with the given parameters.
|
|
26
|
+
|
|
27
|
+
:param params: Dictionary containing parameters for email analysis.
|
|
28
|
+
:return: The analysis result as a dictionary.
|
|
29
|
+
:raises Exception: If an API exception occurs.
|
|
30
|
+
"""
|
|
31
|
+
params = self._normalize_request(params)
|
|
32
|
+
|
|
33
|
+
# Configure the host and create the API client instance
|
|
34
|
+
self.config.host = f"{self.host}/insights/{self.version}"
|
|
35
|
+
api_client = ApiClient(configuration=self.config)
|
|
36
|
+
api_client.configuration.debug = self.debug_mode
|
|
37
|
+
self.api_instance = EmailInsightsApi(api_client)
|
|
38
|
+
|
|
39
|
+
# Prepare the AnalyzeEmailRequest object
|
|
40
|
+
analyze_email_request = AnalyzeEmailRequest(**params)
|
|
41
|
+
|
|
42
|
+
try:
|
|
43
|
+
result = self.api_instance.analyze_email(analyze_email_request)
|
|
44
|
+
return result.to_dict()
|
|
45
|
+
except ApiException as e:
|
|
46
|
+
raise Exception(f"API exception: {e.reason}")
|
|
47
|
+
|
|
48
|
+
def set_host(self, host: str) -> "EmailInsights":
|
|
49
|
+
"""
|
|
50
|
+
Set the host.
|
|
51
|
+
|
|
52
|
+
:param host: The host URL.
|
|
53
|
+
:return: The current instance for chaining.
|
|
54
|
+
"""
|
|
55
|
+
self.host = host
|
|
56
|
+
return self
|
|
57
|
+
|
|
58
|
+
def set_version(self, version: str) -> "EmailInsights":
|
|
59
|
+
"""
|
|
60
|
+
Set the version.
|
|
61
|
+
|
|
62
|
+
:param version: The API version.
|
|
63
|
+
:return: The current instance for chaining.
|
|
64
|
+
"""
|
|
65
|
+
self.version = version
|
|
66
|
+
return self
|
|
67
|
+
|
|
68
|
+
def set_debug_mode(self, debug_mode: bool) -> "EmailInsights":
|
|
69
|
+
"""
|
|
70
|
+
Set the debug mode.
|
|
71
|
+
|
|
72
|
+
:param debug_mode: Enable or disable debug mode.
|
|
73
|
+
:return: The current instance for chaining.
|
|
74
|
+
"""
|
|
75
|
+
self.debug_mode = debug_mode
|
|
76
|
+
return self
|
|
77
|
+
|
|
78
|
+
def _normalize_request(self, params: dict) -> dict:
|
|
79
|
+
"""
|
|
80
|
+
Normalize the request parameters.
|
|
81
|
+
|
|
82
|
+
:param params: The raw parameters.
|
|
83
|
+
:return: Normalized parameters.
|
|
84
|
+
"""
|
|
85
|
+
normalized = {}
|
|
86
|
+
normalized["email"] = str(params["email"])
|
|
87
|
+
|
|
88
|
+
if "enableAi" in params:
|
|
89
|
+
params["enable_ai"] = params.pop("enableAi")
|
|
90
|
+
|
|
91
|
+
if "enableAutoCorrection" in params:
|
|
92
|
+
params["enable_auto_correction"] = bool(params.pop("enableAutoCorrection"))
|
|
93
|
+
|
|
94
|
+
normalized["enable_ai"] = bool(params.get("enable_ai", False))
|
|
95
|
+
normalized["enable_auto_correction"] = bool(params.get("enable_auto_correction", False))
|
|
96
|
+
|
|
97
|
+
return normalized
|
src/ip_insights.py
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# src/ip_insights.py
|
|
2
|
+
import openapi_client
|
|
3
|
+
from openapi_client.configuration import Configuration as ApiConfiguration
|
|
4
|
+
from openapi_client.api_client import ApiClient
|
|
5
|
+
from openapi_client.api.ip_insights_api import IPInsightsApi
|
|
6
|
+
from openapi_client.models.analyze_ip_request import AnalyzeIpRequest
|
|
7
|
+
from openapi_client.exceptions import ApiException
|
|
8
|
+
|
|
9
|
+
class IpInsights:
|
|
10
|
+
def __init__(self, api_key: str):
|
|
11
|
+
"""
|
|
12
|
+
Initialize the IpInsights class with the provided API key.
|
|
13
|
+
|
|
14
|
+
:param api_key: The API key for authentication.
|
|
15
|
+
"""
|
|
16
|
+
self.config = ApiConfiguration()
|
|
17
|
+
self.config.api_key = {"opportifyToken": api_key}
|
|
18
|
+
self.host = "https://api.opportify.com"
|
|
19
|
+
self.version = "v1"
|
|
20
|
+
self.debug_mode = False
|
|
21
|
+
self.api_instance = None
|
|
22
|
+
|
|
23
|
+
def analyze(self, params: dict) -> dict:
|
|
24
|
+
"""
|
|
25
|
+
Analyze the IP address based on the provided parameters.
|
|
26
|
+
|
|
27
|
+
:param params: Dictionary containing parameters for IP analysis.
|
|
28
|
+
:return: The analysis result as a dictionary.
|
|
29
|
+
:raises Exception: If an API exception occurs.
|
|
30
|
+
"""
|
|
31
|
+
params = self._normalize_request(params)
|
|
32
|
+
|
|
33
|
+
# Configure the host and create the API client instance
|
|
34
|
+
self.config.host = f"{self.host}/insights/{self.version}"
|
|
35
|
+
api_client = ApiClient(configuration=self.config)
|
|
36
|
+
api_client.configuration.debug = self.debug_mode
|
|
37
|
+
self.api_instance = IPInsightsApi(api_client)
|
|
38
|
+
|
|
39
|
+
# Prepare the AnalyzeIpRequest object
|
|
40
|
+
analyze_ip_request = AnalyzeIpRequest(**params)
|
|
41
|
+
|
|
42
|
+
try:
|
|
43
|
+
result = self.api_instance.analyze_ip(analyze_ip_request)
|
|
44
|
+
return result.to_dict()
|
|
45
|
+
except ApiException as e:
|
|
46
|
+
raise Exception(f"API exception: {e.reason}")
|
|
47
|
+
|
|
48
|
+
def set_host(self, host: str) -> "IpInsights":
|
|
49
|
+
"""
|
|
50
|
+
Set the host.
|
|
51
|
+
|
|
52
|
+
:param host: The host URL.
|
|
53
|
+
:return: The current instance for chaining.
|
|
54
|
+
"""
|
|
55
|
+
self.host = host
|
|
56
|
+
return self
|
|
57
|
+
|
|
58
|
+
def set_version(self, version: str) -> "IpInsights":
|
|
59
|
+
"""
|
|
60
|
+
Set the version.
|
|
61
|
+
|
|
62
|
+
:param version: The API version.
|
|
63
|
+
:return: The current instance for chaining.
|
|
64
|
+
"""
|
|
65
|
+
self.version = version
|
|
66
|
+
return self
|
|
67
|
+
|
|
68
|
+
def set_debug_mode(self, debug_mode: bool) -> "IpInsights":
|
|
69
|
+
"""
|
|
70
|
+
Set the debug mode.
|
|
71
|
+
|
|
72
|
+
:param debug_mode: Enable or disable debug mode.
|
|
73
|
+
:return: The current instance for chaining.
|
|
74
|
+
"""
|
|
75
|
+
self.debug_mode = debug_mode
|
|
76
|
+
return self
|
|
77
|
+
|
|
78
|
+
def _normalize_request(self, params: dict) -> dict:
|
|
79
|
+
"""
|
|
80
|
+
Normalize the request parameters.
|
|
81
|
+
|
|
82
|
+
:param params: The raw parameters.
|
|
83
|
+
:return: Normalized parameters.
|
|
84
|
+
"""
|
|
85
|
+
normalized = {}
|
|
86
|
+
normalized["ip"] = str(params["ip"])
|
|
87
|
+
|
|
88
|
+
if "enableAi" in params:
|
|
89
|
+
params["enable_ai"] = params.pop("enableAi")
|
|
90
|
+
|
|
91
|
+
normalized["enable_ai"] = bool(params.get("enable_ai", False))
|
|
92
|
+
|
|
93
|
+
return normalized
|