File tree 2 files changed +21
-0
lines changed
2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change 13
13
class MailtrapClient :
14
14
DEFAULT_HOST = "send.api.mailtrap.io"
15
15
DEFAULT_PORT = 443
16
+ BULK_HOST = "bulk.api.mailtrap.io"
16
17
SANDBOX_HOST = "sandbox.api.mailtrap.io"
17
18
18
19
def __init__ (
19
20
self ,
20
21
token : str ,
21
22
api_host : Optional [str ] = None ,
22
23
api_port : int = DEFAULT_PORT ,
24
+ bulk : bool = False ,
23
25
sandbox : bool = False ,
24
26
inbox_id : Optional [str ] = None ,
25
27
) -> None :
26
28
self .token = token
27
29
self .api_host = api_host
28
30
self .api_port = api_port
31
+ self .bulk = bulk
29
32
self .sandbox = sandbox
30
33
self .inbox_id = inbox_id
31
34
@@ -70,6 +73,8 @@ def _host(self) -> str:
70
73
return self .api_host
71
74
if self .sandbox :
72
75
return self .SANDBOX_HOST
76
+ if self .bulk :
77
+ return self .BULK_HOST
73
78
return self .DEFAULT_HOST
74
79
75
80
@staticmethod
@@ -90,3 +95,6 @@ def _validate_itself(self) -> None:
90
95
raise ClientConfigurationError (
91
96
"`inbox_id` is not allowed in non-sandbox mode"
92
97
)
98
+
99
+ if self .bulk and self .sandbox :
100
+ raise ClientConfigurationError ("bulk mode is not allowed in sandbox mode" )
Original file line number Diff line number Diff line change @@ -35,6 +35,7 @@ def get_client(**kwargs: Any) -> mt.MailtrapClient:
35
35
[
36
36
{"sandbox" : True },
37
37
{"inbox_id" : "12345" },
38
+ {"bulk" : True , "sandbox" : True , "inbox_id" : "12345" },
38
39
],
39
40
)
40
41
def test_client_validation (self , arguments : dict [str , Any ]) -> None :
@@ -54,10 +55,22 @@ def test_base_url_should_truncate_slash_from_host(self) -> None:
54
55
{"api_host" : "example.send.com" , "api_port" : 543 },
55
56
"https://example.send.com:543/api/send" ,
56
57
),
58
+ (
59
+ {"api_host" : "example.send.com" , "sandbox" : True , "inbox_id" : "12345" },
60
+ "https://example.send.com:443/api/send/12345" ,
61
+ ),
62
+ (
63
+ {"api_host" : "example.send.com" , "bulk" : True },
64
+ "https://example.send.com:443/api/send" ,
65
+ ),
57
66
(
58
67
{"sandbox" : True , "inbox_id" : "12345" },
59
68
"https://sandbox.api.mailtrap.io:443/api/send/12345" ,
60
69
),
70
+ (
71
+ {"bulk" : True },
72
+ "https://bulk.api.mailtrap.io:443/api/send" ,
73
+ ),
61
74
],
62
75
)
63
76
def test_api_send_url_should_return_default_sending_url (
You can’t perform that action at this time.
0 commit comments