customerio 2.2__tar.gz → 2.3__tar.gz

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.
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: customerio
3
- Version: 2.2
3
+ Version: 2.3
4
4
  Summary: Customer.io Python bindings.
5
5
  Home-page: https://github.com/customerio/customerio-python
6
6
  Author: Peaberry Software Inc.
@@ -17,3 +17,11 @@ Classifier: Programming Language :: Python :: 3.8
17
17
  Classifier: Programming Language :: Python :: 3.9
18
18
  License-File: LICENSE
19
19
  License-File: AUTHORS
20
+ Requires-Dist: requests>=2.20.0
21
+ Dynamic: author
22
+ Dynamic: author-email
23
+ Dynamic: classifier
24
+ Dynamic: home-page
25
+ Dynamic: license
26
+ Dynamic: requires-dist
27
+ Dynamic: summary
@@ -2,5 +2,5 @@ import warnings
2
2
 
3
3
  from customerio.client_base import CustomerIOException
4
4
  from customerio.track import CustomerIO
5
- from customerio.api import APIClient, SendEmailRequest, SendPushRequest, SendSMSRequest
5
+ from customerio.api import APIClient, SendEmailRequest, SendPushRequest, SendSMSRequest, SendInboxMessageRequest
6
6
  from customerio.regions import Regions
@@ -1,4 +1,4 @@
1
- VERSION = (2, 2, 0, 'final', 0)
1
+ VERSION = (2, 3, 0, 'final', 0)
2
2
 
3
3
  def get_version():
4
4
  version = '%s.%s' % (VERSION[0], VERSION[1])
@@ -34,6 +34,12 @@ class APIClient(ClientBase):
34
34
  resp = self.send_request('POST', self.url + "/v1/send/sms", request)
35
35
  return json.loads(resp)
36
36
 
37
+ def send_inbox_message(self, request):
38
+ if isinstance(request, SendInboxMessageRequest):
39
+ request = request._to_dict()
40
+ resp = self.send_request('POST', self.url + "/v1/send/inbox_message", request)
41
+ return json.loads(resp)
42
+
37
43
  # builds the session.
38
44
  def _build_session(self):
39
45
  session = super()._build_session()
@@ -219,7 +225,7 @@ class SendPushRequest(object):
219
225
  return data
220
226
 
221
227
  class SendSMSRequest(object):
222
- '''An object with all the options avaiable for triggering a transactional push message'''
228
+ '''An object with all the options avaiable for triggering a transactional SMS message'''
223
229
  def __init__(self,
224
230
  transactional_message_id=None,
225
231
  to=None,
@@ -264,3 +270,44 @@ class SendSMSRequest(object):
264
270
  data[name] = value
265
271
 
266
272
  return data
273
+
274
+ class SendInboxMessageRequest(object):
275
+ '''An object with all the options avaiable for triggering a transactional inbox message'''
276
+ def __init__(self,
277
+ transactional_message_id=None,
278
+ identifiers=None,
279
+ disable_message_retention=None,
280
+ queue_draft=None,
281
+ message_data=None,
282
+ send_at=None,
283
+ language=None,
284
+ ):
285
+
286
+ self.transactional_message_id = transactional_message_id
287
+ self.identifiers = identifiers
288
+ self.disable_message_retention = disable_message_retention
289
+ self.queue_draft = queue_draft
290
+ self.message_data = message_data
291
+ self.send_at = send_at
292
+ self.language = language
293
+
294
+ def _to_dict(self):
295
+ '''Build a request payload from the object'''
296
+ field_map = dict(
297
+ # field name is the same as the payload field name
298
+ transactional_message_id="transactional_message_id",
299
+ identifiers="identifiers",
300
+ disable_message_retention="disable_message_retention",
301
+ queue_draft="queue_draft",
302
+ message_data="message_data",
303
+ send_at="send_at",
304
+ language="language",
305
+ )
306
+
307
+ data = {}
308
+ for field, name in field_map.items():
309
+ value = getattr(self, field, None)
310
+ if value is not None:
311
+ data[name] = value
312
+
313
+ return data
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.2
2
2
  Name: customerio
3
- Version: 2.2
3
+ Version: 2.3
4
4
  Summary: Customer.io Python bindings.
5
5
  Home-page: https://github.com/customerio/customerio-python
6
6
  Author: Peaberry Software Inc.
@@ -17,3 +17,11 @@ Classifier: Programming Language :: Python :: 3.8
17
17
  Classifier: Programming Language :: Python :: 3.9
18
18
  License-File: LICENSE
19
19
  License-File: AUTHORS
20
+ Requires-Dist: requests>=2.20.0
21
+ Dynamic: author
22
+ Dynamic: author-email
23
+ Dynamic: classifier
24
+ Dynamic: home-page
25
+ Dynamic: license
26
+ Dynamic: requires-dist
27
+ Dynamic: summary
@@ -14,6 +14,15 @@ def create_ssl_context():
14
14
  """Create SSL context for Python 3.12+ compatibility"""
15
15
  context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
16
16
  context.minimum_version = ssl.TLSVersion.TLSv1_2
17
+ # Disable hostname and certificate verification for self-signed certs
18
+ context.check_hostname = False
19
+ context.verify_mode = ssl.CERT_NONE
20
+ # Allow weaker ciphers for test compatibility
21
+ try:
22
+ context.set_ciphers('DEFAULT@SECLEVEL=1')
23
+ except ssl.SSLError:
24
+ # Fall back if the cipher string is not supported
25
+ pass
17
26
  return context
18
27
 
19
28
  request_counts = dict()
@@ -28,12 +37,16 @@ class Handler(BaseHTTPRequestHandler):
28
37
  '''
29
38
  def do_DELETE(self):
30
39
  self.send_response(200)
40
+ self.send_header('Content-Length', '0')
31
41
  self.end_headers()
32
42
 
33
43
  def do_POST(self):
44
+ response_body = bytes("{}", "utf-8")
34
45
  self.send_response(200)
46
+ self.send_header('Content-Type', 'application/json')
47
+ self.send_header('Content-Length', str(len(response_body)))
35
48
  self.end_headers()
36
- self.wfile.write(bytes("{}", "utf-8"))
49
+ self.wfile.write(response_body)
37
50
 
38
51
  def do_PUT(self):
39
52
  global request_counts
@@ -49,6 +62,7 @@ class Handler(BaseHTTPRequestHandler):
49
62
  if processed > fail_count:
50
63
  # return a valid response
51
64
  self.send_response(200)
65
+ self.send_header('Content-Length', '0')
52
66
  self.end_headers()
53
67
  return
54
68
 
@@ -5,7 +5,7 @@ import json
5
5
  import sys
6
6
  import unittest
7
7
 
8
- from customerio import APIClient, SendEmailRequest, SendPushRequest, SendSMSRequest, Regions, CustomerIOException
8
+ from customerio import APIClient, SendEmailRequest, SendPushRequest, SendSMSRequest, SendInboxMessageRequest, Regions, CustomerIOException
9
9
  from customerio.__version__ import __version__ as ClientVersion
10
10
  from tests.server import HTTPSTestCase
11
11
 
@@ -111,5 +111,21 @@ class TestAPIClient(HTTPSTestCase):
111
111
 
112
112
  self.client.send_sms(sms)
113
113
 
114
+ def test_send_inbox_message(self):
115
+ self.client.http.hooks = dict(response=partial(self._check_request, rq={
116
+ 'method': 'POST',
117
+ 'authorization': "Bearer app_api_key",
118
+ 'content_type': 'application/json',
119
+ 'url_suffix': '/v1/send/inbox_message',
120
+ 'body': {"identifiers": {"id":"customer_1"}, "transactional_message_id": 100}
121
+ }))
122
+
123
+ inbox_message = SendInboxMessageRequest(
124
+ identifiers={"id":"customer_1"},
125
+ transactional_message_id=100,
126
+ )
127
+
128
+ self.client.send_inbox_message(inbox_message)
129
+
114
130
  if __name__ == '__main__':
115
131
  unittest.main()
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes