Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ This tap:
- Pulls raw data from the [Intercom v1.4 API](https://developers.intercom.com/intercom-api-reference/reference#introduction)
- Extracts the following resources:
- [Admins](https://developers.intercom.com/intercom-api-reference/reference#list-admins)
- [Admins Activity Logs](https://developers.intercom.com/intercom-api-reference/reference#view-admin-activity-logs)
- [Companies](https://developers.intercom.com/intercom-api-reference/reference#list-companies)
- [Conversations](https://developers.intercom.com/intercom-api-reference/reference#list-conversations)
- [Conversation Parts](https://developers.intercom.com/intercom-api-reference/reference#get-a-single-conversation)
Expand All @@ -34,6 +35,15 @@ This tap:
- Replication strategy: FULL_TABLE
- Transformations: none

[admins_activity_logs](https://developers.intercom.com/intercom-api-reference/reference#view-admin-activity-logs)
- Endpoint: https://api.intercom.io/admins/activity_logs
- Primary key fields: id
- Foreign key fields: performed_by > id
- Replication strategy: INCREMENTAL
- Bookmark: created_at (date-time)
- Bookmark query field: created_at_after
- Transformations: none

[companies](https://developers.intercom.com/intercom-api-reference/reference#list-companies)
- Endpoint: https://api.intercom.io/companies
- Primary key fields: id
Expand Down
11 changes: 0 additions & 11 deletions state.json.example

This file was deleted.

41 changes: 41 additions & 0 deletions tap_intercom/schemas/admins_activity_logs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"type": "object",
"additionalProperties": false,
"properties": {
"id": {
"type": ["null", "string"]
},
"activity_type": {
"type": ["null", "string"]
},
"activity_description": {
"type": ["null", "string"]
},
"created_at": {
"type": ["null", "string"],
"format": "date-time"
},
"metadata": {
"type": ["null", "object"],
"additionalProperties": true
},
"performed_by": {
"type": ["null", "object"],
"additionalProperties": false,
"properties": {
"type" : {
"type": ["null", "string"]
},
"id" : {
"type": ["null", "string"]
},
"ip" : {
"type": ["null", "string"]
},
"email" : {
"type": ["null", "string"]
}
}
}
}
}
11 changes: 11 additions & 0 deletions tap_intercom/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# scroll_type: always, historical, or never; default never
# interpolate_page: True, False (to determine start page based on total pages and bookmark)
# default: False
# bookmark_query_field_to_epoch: True, False (convert datetime bookmark to epoch upon query)

def build_query(body, value, starting_after=None):
# Update both the > and the = queries with our bookmark
Expand Down Expand Up @@ -155,6 +156,16 @@ def build_query(body, value, starting_after=None):
'key_properties': ['id'],
'replication_method': 'FULL_TABLE'
},
'admins_activity_logs': {
'key_properties': ['id'],
'replication_method': 'INCREMENTAL',
'replication_keys': ['created_at'],
'bookmark_type': 'datetime',
'data_key': 'activity_logs',
'path': 'admins/activity_logs',
'bookmark_query_field': 'created_at_after',
'bookmark_query_field_to_epoch': True
},
}


Expand Down
8 changes: 7 additions & 1 deletion tap_intercom/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ def process_records(catalog, #pylint: disable=too-many-branches
LOGGER.error('Transformer Error: {}'.format(err))
LOGGER.error('Stream: {}, record: {}'.format(stream_name, record))
raise

# Reset max_bookmark_value to new value if higher
if transformed_record.get(bookmark_field):
if max_bookmark_value is None or \
Expand Down Expand Up @@ -284,14 +285,19 @@ def sync_endpoint(client, #pylint: disable=too-many-branches
search_query = endpoint_config.get('search_query')
request_body = build_query(search_query, max_bookmark_int)

bookmark_query_field_to_epoch = endpoint_config.get('bookmark_query_field_to_epoch', False)

i = 1
while next_url is not None:
# Need URL querystring for 1st page; subsequent pages provided by next_url
# querystring: Squash query params into string
if i == 1 and not is_scrolling:
if bookmark_query_field:
if bookmark_type == 'datetime':
params[bookmark_query_field] = updated_since_days
if bookmark_query_field_to_epoch:
params[bookmark_query_field] = max_bookmark_int
else:
params[bookmark_query_field] = updated_since_days
elif bookmark_type == 'integer':
params[bookmark_query_field] = last_integer
if params != {}:
Expand Down