1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
"""
Handles /sms-recipients endpoint
"""
import requests
from mailersend.base import base
class NewSmsRecipients(base.NewAPIClient):
"""
Instantiates the /sms-recipients endpoint object
"""
pass
def get_recipients(self, status="active", sms_number_id=None, page=None, limit=25):
"""
Get information about SMS recipients.
@params:
status (string) - Possible values are `active` and `opt_out`
sms_number_id (string)
page (int)
limit (int): Min: `10`, Max: `100`, default is 25
"""
passed_arguments = locals()
query_params = {}
for key, value in passed_arguments.items():
if key != "self":
query_params[key] = value
request = requests.get(
f"{self.api_base}/sms-recipients",
headers=self.headers_default,
params=query_params,
)
return f"{request.status_code}\n{request.text}"
def get_recipient(self, sms_recipient_id):
"""
Get information about a specific SMS recipient.
@params:
sms_recipient_id (string) - Possible values are `active` and `opt_out`
"""
request = requests.get(
f"{self.api_base}/sms-recipients/{sms_recipient_id}",
headers=self.headers_default,
)
return f"{request.status_code}\n{request.text}"
def update_recipient(self, sms_recipient_id, status):
"""
Update a specific SMS recipient
@params:
sms_recipient_id (string)
status (string)
"""
query_params = {"status": status}
data = {"sms_recipient_id": sms_recipient_id}
request = requests.put(
f"{self.api_base}/sms-recipients/{sms_recipient_id}",
headers=self.headers_default,
params=query_params,
json=data,
)
return f"{request.status_code}\n{request.text}"
|