customerio 2.2__tar.gz → 2.4__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.4
2
2
  Name: customerio
3
- Version: 2.2
3
+ Version: 2.4
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,12 @@ 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: license-file
27
+ Dynamic: requires-dist
28
+ 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, SendInAppRequest
6
6
  from customerio.regions import Regions
@@ -1,4 +1,4 @@
1
- VERSION = (2, 2, 0, 'final', 0)
1
+ VERSION = (2, 4, 0, 'final', 0)
2
2
 
3
3
  def get_version():
4
4
  version = '%s.%s' % (VERSION[0], VERSION[1])
@@ -34,6 +34,18 @@ 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
+
43
+ def send_in_app(self, request):
44
+ if isinstance(request, SendInAppRequest):
45
+ request = request._to_dict()
46
+ resp = self.send_request('POST', self.url + "/v1/send/in_app", request)
47
+ return json.loads(resp)
48
+
37
49
  # builds the session.
38
50
  def _build_session(self):
39
51
  session = super()._build_session()
@@ -219,7 +231,7 @@ class SendPushRequest(object):
219
231
  return data
220
232
 
221
233
  class SendSMSRequest(object):
222
- '''An object with all the options avaiable for triggering a transactional push message'''
234
+ '''An object with all the options avaiable for triggering a transactional SMS message'''
223
235
  def __init__(self,
224
236
  transactional_message_id=None,
225
237
  to=None,
@@ -264,3 +276,85 @@ class SendSMSRequest(object):
264
276
  data[name] = value
265
277
 
266
278
  return data
279
+
280
+ class SendInboxMessageRequest(object):
281
+ '''An object with all the options avaiable for triggering a transactional inbox message'''
282
+ def __init__(self,
283
+ transactional_message_id=None,
284
+ identifiers=None,
285
+ disable_message_retention=None,
286
+ queue_draft=None,
287
+ message_data=None,
288
+ send_at=None,
289
+ language=None,
290
+ ):
291
+
292
+ self.transactional_message_id = transactional_message_id
293
+ self.identifiers = identifiers
294
+ self.disable_message_retention = disable_message_retention
295
+ self.queue_draft = queue_draft
296
+ self.message_data = message_data
297
+ self.send_at = send_at
298
+ self.language = language
299
+
300
+ def _to_dict(self):
301
+ '''Build a request payload from the object'''
302
+ field_map = dict(
303
+ # field name is the same as the payload field name
304
+ transactional_message_id="transactional_message_id",
305
+ identifiers="identifiers",
306
+ disable_message_retention="disable_message_retention",
307
+ queue_draft="queue_draft",
308
+ message_data="message_data",
309
+ send_at="send_at",
310
+ language="language",
311
+ )
312
+
313
+ data = {}
314
+ for field, name in field_map.items():
315
+ value = getattr(self, field, None)
316
+ if value is not None:
317
+ data[name] = value
318
+
319
+ return data
320
+
321
+ class SendInAppRequest(object):
322
+ '''An object with all the options available for triggering a transactional in-app message'''
323
+ def __init__(self,
324
+ transactional_message_id=None,
325
+ identifiers=None,
326
+ disable_message_retention=None,
327
+ queue_draft=None,
328
+ message_data=None,
329
+ send_at=None,
330
+ language=None,
331
+ ):
332
+
333
+ self.transactional_message_id = transactional_message_id
334
+ self.identifiers = identifiers
335
+ self.disable_message_retention = disable_message_retention
336
+ self.queue_draft = queue_draft
337
+ self.message_data = message_data
338
+ self.send_at = send_at
339
+ self.language = language
340
+
341
+ def _to_dict(self):
342
+ '''Build a request payload from the object'''
343
+ field_map = dict(
344
+ # field name is the same as the payload field name
345
+ transactional_message_id="transactional_message_id",
346
+ identifiers="identifiers",
347
+ disable_message_retention="disable_message_retention",
348
+ queue_draft="queue_draft",
349
+ message_data="message_data",
350
+ send_at="send_at",
351
+ language="language",
352
+ )
353
+
354
+ data = {}
355
+ for field, name in field_map.items():
356
+ value = getattr(self, field, None)
357
+ if value is not None:
358
+ data[name] = value
359
+
360
+ return data
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: customerio
3
- Version: 2.2
3
+ Version: 2.4
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,12 @@ 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: license-file
27
+ Dynamic: requires-dist
28
+ 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, SendInAppRequest, Regions, CustomerIOException
9
9
  from customerio.__version__ import __version__ as ClientVersion
10
10
  from tests.server import HTTPSTestCase
11
11
 
@@ -111,5 +111,37 @@ 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
+
130
+ def test_send_in_app(self):
131
+ self.client.http.hooks = dict(response=partial(self._check_request, rq={
132
+ 'method': 'POST',
133
+ 'authorization': "Bearer app_api_key",
134
+ 'content_type': 'application/json',
135
+ 'url_suffix': '/v1/send/in_app',
136
+ 'body': {"identifiers": {"id":"customer_1"}, "transactional_message_id": 100}
137
+ }))
138
+
139
+ in_app = SendInAppRequest(
140
+ identifiers={"id":"customer_1"},
141
+ transactional_message_id=100,
142
+ )
143
+
144
+ self.client.send_in_app(in_app)
145
+
114
146
  if __name__ == '__main__':
115
147
  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