Skip to content

Commit ef4c89f

Browse files
committed
Adding FindAll capability to event resources
- Added the ability to override the default CollectionProxy class in the FindAll mixin - Created a dedicated Proxy class for Events which handles paging differently, based on the current Event API
1 parent 9d6bc47 commit ef4c89f

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

intercom/api_operations/find_all.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
class FindAll(object):
99
"""A mixin that provides `find_all` functionality."""
1010

11+
proxy_class = CollectionProxy
12+
1113
def find_all(self, **params):
1214
"""Find all instances of the resource based on the supplied parameters."""
1315
collection = utils.resource_class_to_collection_name(
@@ -17,6 +19,6 @@ def find_all(self, **params):
1719
else:
1820
finder_url = "/%s" % (collection)
1921
finder_params = params
20-
return CollectionProxy(
22+
return self.proxy_class(
2123
self.client, self.collection_class, collection,
2224
finder_url, finder_params)

intercom/service/event.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,20 @@
33
from intercom import event
44
from intercom.api_operations.bulk import Submit
55
from intercom.api_operations.save import Save
6+
from intercom.api_operations.find_all import FindAll
67
from intercom.service.base_service import BaseService
8+
from intercom.collection_proxy import CollectionProxy
79

810

9-
class Event(BaseService, Save, Submit):
11+
class EventCollectionProxy(CollectionProxy):
12+
13+
def paging_info_present(self, response):
14+
return 'pages' in response and 'next' in response['pages']
15+
16+
17+
class Event(BaseService, Save, Submit, FindAll):
18+
19+
proxy_class = EventCollectionProxy
1020

1121
@property
1222
def collection_class(self):

0 commit comments

Comments
 (0)