customerio 2.3__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.2
1
+ Metadata-Version: 2.4
2
2
  Name: customerio
3
- Version: 2.3
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.
@@ -23,5 +23,6 @@ Dynamic: author-email
23
23
  Dynamic: classifier
24
24
  Dynamic: home-page
25
25
  Dynamic: license
26
+ Dynamic: license-file
26
27
  Dynamic: requires-dist
27
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, SendInboxMessageRequest
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, 3, 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])
@@ -40,6 +40,12 @@ class APIClient(ClientBase):
40
40
  resp = self.send_request('POST', self.url + "/v1/send/inbox_message", request)
41
41
  return json.loads(resp)
42
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
+
43
49
  # builds the session.
44
50
  def _build_session(self):
45
51
  session = super()._build_session()
@@ -311,3 +317,44 @@ class SendInboxMessageRequest(object):
311
317
  data[name] = value
312
318
 
313
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.2
1
+ Metadata-Version: 2.4
2
2
  Name: customerio
3
- Version: 2.3
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.
@@ -23,5 +23,6 @@ Dynamic: author-email
23
23
  Dynamic: classifier
24
24
  Dynamic: home-page
25
25
  Dynamic: license
26
+ Dynamic: license-file
26
27
  Dynamic: requires-dist
27
28
  Dynamic: summary
@@ -5,7 +5,7 @@ import json
5
5
  import sys
6
6
  import unittest
7
7
 
8
- from customerio import APIClient, SendEmailRequest, SendPushRequest, SendSMSRequest, SendInboxMessageRequest, 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
 
@@ -126,6 +126,22 @@ class TestAPIClient(HTTPSTestCase):
126
126
  )
127
127
 
128
128
  self.client.send_inbox_message(inbox_message)
129
-
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
+
130
146
  if __name__ == '__main__':
131
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
File without changes